Update Bsb
Browse files
Bsb
CHANGED
|
@@ -773,4 +773,72 @@ No feedback collection for passive/idle sessions.
|
|
| 773 |
|
| 774 |
Summary
|
| 775 |
|
| 776 |
-
This design guarantees that feedback is solicited only after meaningful user interaction in the correct context, prevents duplicate feedback, and provides seamless update flows. All actions are secured, API-driven, and fail-safe against common errors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 773 |
|
| 774 |
Summary
|
| 775 |
|
| 776 |
+
This design guarantees that feedback is solicited only after meaningful user interaction in the correct context, prevents duplicate feedback, and provides seamless update flows. All actions are secured, API-driven, and fail-safe against common errors.
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
=======================
|
| 781 |
+
|
| 782 |
+
window.addEventListener('DOMContentLoaded', function () {
|
| 783 |
+
loadFiles();
|
| 784 |
+
loadZones();
|
| 785 |
+
|
| 786 |
+
// Modal initialization after DOM is loaded
|
| 787 |
+
const feedbackModalEl = document.getElementById("feedbackModal");
|
| 788 |
+
bootstrapFeedbackModal = new bootstrap.Modal(feedbackModalEl);
|
| 789 |
+
|
| 790 |
+
let historyFilename = "";
|
| 791 |
+
|
| 792 |
+
if (chatHistory && chatHistory.length > 0) {
|
| 793 |
+
chatHistory.forEach(entry => {
|
| 794 |
+
if (entry.filename && (entry.filename !== historyFilename || historyFilename === "")) {
|
| 795 |
+
historyFilename = entry.filename;
|
| 796 |
+
appendMessage("System", `Selected file: ${historyFilename}`, "bg-purple-600");
|
| 797 |
+
}
|
| 798 |
+
const userMessage = entry.question;
|
| 799 |
+
appendMessage("You", userMessage, "bg-blue-500", true);
|
| 800 |
+
const personaMessage = entry.persona;
|
| 801 |
+
appendMessage("Persona", personaMessage, "bg-blue-500", true);
|
| 802 |
+
const botMessage = entry.response;
|
| 803 |
+
appendMessage("Assistant", botMessage, "bg-gray-700", false);
|
| 804 |
+
});
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
// ---- FEEDBACK BUTTON LOGIC ----
|
| 808 |
+
const feedbackBtn = document.getElementById("feedbackBtn");
|
| 809 |
+
if (feedbackBtn) {
|
| 810 |
+
feedbackBtn.addEventListener("click", async function () {
|
| 811 |
+
try {
|
| 812 |
+
const response = await fetch(`/chat_feature/get_latest_feedback?user_id=${userId}¬ebook_id=${notebookId}`);
|
| 813 |
+
const data = await response.json();
|
| 814 |
+
console.log("Feedback data:", data);
|
| 815 |
+
|
| 816 |
+
if (data && data.exists) {
|
| 817 |
+
const msg = `Your Previous Experience on Last Used Configuration:\nConfiguration: ${data.zone_name}\nRating: ${data.rating}\nComment: ${data.comment}`;
|
| 818 |
+
alert(msg);
|
| 819 |
+
} else {
|
| 820 |
+
alert("No feedback exists for your previous configuration.");
|
| 821 |
+
}
|
| 822 |
+
} catch (err) {
|
| 823 |
+
alert("Error fetching feedback.");
|
| 824 |
+
console.error(err);
|
| 825 |
+
}
|
| 826 |
+
});
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
// ---- AUTO POPUP ALERT LOGIC ----
|
| 830 |
+
fetch(`/chat_feature/get_latest_feedback?user_id=${userId}¬ebook_id=${notebookId}`)
|
| 831 |
+
.then(response => response.json())
|
| 832 |
+
.then(data => {
|
| 833 |
+
if (data && data.exists) {
|
| 834 |
+
setTimeout(function () {
|
| 835 |
+
const msg = `Your Previous Experience on Last Used Configuration:\nConfiguration: ${data.zone_name}\nRating: ${data.rating}\nComment: ${data.comment}`;
|
| 836 |
+
alert(msg);
|
| 837 |
+
}, 5000); // 5 seconds
|
| 838 |
+
}
|
| 839 |
+
})
|
| 840 |
+
.catch(err => {
|
| 841 |
+
console.error("Error fetching previous feedback:", err);
|
| 842 |
+
});
|
| 843 |
+
|
| 844 |
+
});
|