diff --git a/web/admin.html b/web/admin.html index 3c8fbda..907b25b 100644 --- a/web/admin.html +++ b/web/admin.html @@ -328,6 +328,30 @@ + +
+ @@ -1322,25 +1350,39 @@ } } - async addTag(promptId) { - const tag = prompt("Enter new tag:"); - if (!tag) return; + addTag(promptId) { + // Store the prompt ID for later use + this.currentTagPromptId = promptId; + // Clear the input and show the modal + document.getElementById("individualTagInput").value = ""; + this.showModal("individualTagModal"); + } + + async confirmIndividualTag() { + const tags = document.getElementById("individualTagInput").value.split(",") + .map((tag) => tag.trim()).filter((tag) => tag); + + if (tags.length === 0) return; try { - const response = await fetch(`/prompt_manager/prompts/${promptId}/tags`, { + const response = await fetch("/prompt_manager/prompts/tags", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ tag: tag.trim() }), + body: JSON.stringify({ + prompt_id: this.currentTagPromptId, + tags: tags, + }), }); if (response.ok) { - this.showNotification("Tag added", "success"); + this.showNotification(`Tags added to prompt`, "success"); + this.hideModal("individualTagModal"); // Refresh both stats and results await this.loadStatistics(); this.search(); } } catch (error) { - this.showNotification("Failed to add tag", "error"); + this.showNotification("Failed to add tags", "error"); } }