Refactor UI to use JavaScript instead of HTMX

- Replace HTMX with plain JavaScript for tab management
- Consolidate tab UI into single button like profiles
- Add cookie-based current tab storage (client-side)
- Update profiles.js to work with new JSON response format
This commit is contained in:
2026-01-27 13:05:00 +13:00
parent fd52e40d17
commit c56739c5fa
4 changed files with 537 additions and 63 deletions

View File

@@ -26,7 +26,11 @@ document.addEventListener("DOMContentLoaded", () => {
if (Array.isArray(profiles)) {
entries = profiles.map((profileId) => [profileId, {}]);
} else if (profiles && typeof profiles === "object") {
entries = Object.entries(profiles);
// Make sure we're iterating over profile entries, not metadata
entries = Object.entries(profiles).filter(([key]) => {
// Skip metadata keys like 'current_profile_id' if they exist
return key !== 'current_profile_id' && key !== 'profiles';
});
}
if (entries.length === 0) {
@@ -113,19 +117,10 @@ document.addEventListener("DOMContentLoaded", () => {
if (!response.ok) {
throw new Error("Failed to load profiles");
}
const profiles = await response.json();
let currentProfileId = null;
try {
const currentResponse = await fetch("/profiles/current", {
headers: { Accept: "application/json" },
});
if (currentResponse.ok) {
const currentData = await currentResponse.json();
currentProfileId = currentData.id || null;
}
} catch (error) {
console.warn("Failed to load current profile:", error);
}
const data = await response.json();
// Handle both old format (just profiles object) and new format (with current_profile_id)
const profiles = data.profiles || data;
const currentProfileId = data.current_profile_id || null;
renderProfiles(profiles, currentProfileId);
} catch (error) {
console.error("Load profiles failed:", error);