added admin page and audit log viewing
This commit is contained in:
35
internal/embedfs/web/js/admin.js
Normal file
35
internal/embedfs/web/js/admin.js
Normal file
@@ -0,0 +1,35 @@
|
||||
// Admin dashboard utilities
|
||||
|
||||
// Format JSON for display in modals
|
||||
function formatJSON(json) {
|
||||
try {
|
||||
const parsed = typeof json === "string" ? JSON.parse(json) : json;
|
||||
return JSON.stringify(parsed, null, 2);
|
||||
} catch (e) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle HTMX navigation for admin sections
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Update active nav item after HTMX navigation
|
||||
document.body.addEventListener("htmx:afterSwap", function (event) {
|
||||
if (event.detail.target.id === "admin-content") {
|
||||
// Get the current URL path
|
||||
const path = window.location.pathname;
|
||||
const section = path.split("/").pop() || "users";
|
||||
|
||||
// Update active state on nav items
|
||||
document.querySelectorAll("nav a").forEach(function (link) {
|
||||
const href = link.getAttribute("href");
|
||||
if (href && href.includes("/" + section)) {
|
||||
link.classList.remove("text-subtext0", "hover:bg-surface1", "hover:text-text");
|
||||
link.classList.add("bg-blue", "text-mantle", "font-semibold");
|
||||
} else {
|
||||
link.classList.remove("bg-blue", "text-mantle", "font-semibold");
|
||||
link.classList.add("text-subtext0", "hover:bg-surface1", "hover:text-text");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user