MissSqui commited on
Commit
eecc94f
·
verified ·
1 Parent(s): 8bf2818

Update Bsb

Browse files
Files changed (1) hide show
  1. Bsb +62 -1
Bsb CHANGED
@@ -841,4 +841,65 @@ window.addEventListener('DOMContentLoaded', function () {
841
  console.error("Error fetching previous feedback:", err);
842
  });
843
 
844
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
  console.error("Error fetching previous feedback:", err);
842
  });
843
 
844
+ });
845
+
846
+
847
+ ====================================
848
+
849
+ window.addEventListener('DOMContentLoaded', function () {
850
+ loadFiles();
851
+ loadZones();
852
+
853
+ // Modal initialization after DOM is loaded
854
+ const feedbackModalEl = document.getElementById("feedbackModal");
855
+ bootstrapFeedbackModal = new bootstrap.Modal(feedbackModalEl);
856
+
857
+ let historyFilename = "";
858
+
859
+ if (chatHistory && chatHistory.length > 0) {
860
+ chatHistory.forEach(entry => {
861
+ if (entry.filename && (entry.filename !== historyFilename || historyFilename === "")) {
862
+ historyFilename = entry.filename;
863
+ appendMessage("System", `Selected file: ${historyFilename}`, "bg-purple-600");
864
+ }
865
+ const userMessage = entry.question;
866
+ appendMessage("You", userMessage, "bg-blue-500", true);
867
+ const personaMessage = entry.persona;
868
+ appendMessage("Persona", personaMessage, "bg-blue-500", true);
869
+ const botMessage = entry.response;
870
+ appendMessage("Assistant", botMessage, "bg-gray-700", false);
871
+ });
872
+ }
873
+
874
+ // ---- FEEDBACK BUTTON LOGIC ----
875
+ const feedbackBtn = document.getElementById("feedbackBtn");
876
+ if (feedbackBtn) {
877
+ feedbackBtn.addEventListener("click", async function () {
878
+ try {
879
+ //new change
880
+ let zoneParam = "";
881
+ if (currentZoneId) {
882
+ zoneParam = `&zone_id=${currentZoneId}`;
883
+ }
884
+ const userId = "{{ user_id }}";
885
+ const notebookId = "{{ notebook_id }}";
886
+ const response = await fetch(`/chat_feature/get_latest_feedback?user_id=${userId}&notebook_id=${notebookId}${zoneParam}`);
887
+ //const response = await fetch(`/chat_feature/get_latest_feedback?user_id=${userId}&notebook_id=${notebookId}`);
888
+ const data = await response.json();
889
+ console.log("Feedback data:", data);
890
+
891
+ if (data && data.exists) {
892
+ const msg = `Your Previous Experience on Last Used Configuration:\nConfiguration: ${data.zone_name}\nRating: ${data.rating}\nComment: ${data.comment}`;
893
+ alert(msg);
894
+ } else {
895
+ alert("No feedback exists for your previous configuration.");
896
+ }
897
+ } catch (err) {
898
+ alert("Error fetching feedback.");
899
+ console.error(err);
900
+ }
901
+ });
902
+ }
903
+
904
+
905
+ }); --> make me understand this in 3-4 lines