Files
Wallos/scripts/dashboard.js
Miguel Ribeiro 27ac805141 feat: make container shutdown instant & graceful
feat: make container shutdown instant & graceful  (#916)
feat: add pushplus notification service  (#911)
feat: option to delete ai recommendations
fix: parsing ai recommendations from gemini (#909)
2025-09-14 16:46:42 +02:00

33 lines
1.1 KiB
JavaScript

document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll(".ai-recommendation-item").forEach(function (item) {
item.addEventListener("click", function () {
item.classList.toggle("expanded");
});
});
document.querySelectorAll(".delete-ai-recommendation").forEach(function (el) {
el.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
const item = el.closest(".ai-recommendation-item");
const id = item.getAttribute("data-id");
fetch("endpoints/ai/delete_recommendation.php", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: id })
})
.then(res => res.json())
.then(data => {
if (data.success) {
item.remove();
showSuccessMessage(translate('success'));
} else {
showErrorMessage(data.message || "Delete failed.");
}
})
.catch(() => showErrorMessage(translate('unknown_error')));
});
});
});