CxWebApp/static/js/app 2.js
CxAI Agent d057e09fa2
Some checks are pending
build-and-push / image (push) Waiting to run
feat: add new panes for demand, diffusion, inbox, items, lang, mac, slack, system, tools, and websocket
- Implemented demand pane for managing trend-driven design jobs.
- Created diffusion pane for generating images via Stable Diffusion.
- Added inbox pane for sweeping and routing artifacts through the CxAI inbox classifier.
- Developed items pane for CRUD operations against /api/items.
- Introduced lang pane for running language pipelines.
- Established mac pane for macOS app distribution information.
- Integrated slack pane for sending messages and displaying diagnostics.
- Built system pane for process introspection and version information.
- Launched tools pane for browsing and invoking MCP tools.
- Set up websocket pane for connecting to the /ws/echo service.
2026-05-16 19:23:30 -05:00

70 lines
2.1 KiB
JavaScript

document.addEventListener("DOMContentLoaded", () => {
loadItems();
loadHealth();
document.getElementById("add-form").addEventListener("submit", async (e) => {
e.preventDefault();
const name = document.getElementById("item-name").value.trim();
const desc = document.getElementById("item-desc").value.trim();
if (!name) return;
await fetch("/api/items", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name, description: desc }),
});
document.getElementById("item-name").value = "";
document.getElementById("item-desc").value = "";
loadItems();
});
});
async function loadItems() {
const el = document.getElementById("items-list");
try {
const res = await fetch("/api/items");
const data = await res.json();
if (!data.items || data.items.length === 0) {
el.innerHTML = "<p style='color:var(--muted)'>No items yet.</p>";
return;
}
el.innerHTML = data.items
.map(
(item) => `
<div class="item-row">
<div class="item-info">
<strong>${escapeHtml(item.name)}</strong>
<span>${escapeHtml(item.description)}</span>
</div>
<button class="delete-btn" onclick="deleteItem(${item.id})">Delete</button>
</div>`
)
.join("");
} catch {
el.innerHTML = "<p style='color:var(--danger)'>Failed to load items.</p>";
}
}
async function deleteItem(id) {
await fetch(`/api/items/${id}`, { method: "DELETE" });
loadItems();
}
async function loadHealth() {
const el = document.getElementById("health");
try {
const res = await fetch("/api/health");
const data = await res.json();
el.textContent = JSON.stringify(data, null, 2);
} catch {
el.textContent = "Health check failed";
}
}
function escapeHtml(text) {
const div = document.createElement("div");
div.appendChild(document.createTextNode(text));
return div.innerHTML;
}