Add default library ID functionality to improve library targeting during media scans. Service changes in internal/services/media_scanner.go: - Add defaultLibraryID field to MediaScanner struct - Add SetLibraryID() method to set default library - Modify processMediaFile() to use defaultLibraryID when set - Prioritizes defaultLibraryID over folder-based library detection - Provides explicit library targeting for scans Service changes in internal/services/worker.go: - Add libraryUUID conversion from string to pgtype.UUID - Call scanner.SetLibraryID() before ScanFolders() - Ensures scanner respects the job's library ID These changes enable more precise library targeting during media scans, allowing scans to be directed to specific libraries rather than relying solely on folder-based detection.
78 lines
2.6 KiB
JavaScript
78 lines
2.6 KiB
JavaScript
"use strict";
|
|
// Header functionality
|
|
const toggleThemeDropdown = () => {
|
|
const dropdown = document.getElementById("theme-dropdown");
|
|
if (dropdown) {
|
|
dropdown.classList.toggle("hidden");
|
|
// Close user menu if open
|
|
const userMenu = document.getElementById("user-menu");
|
|
if (userMenu && !dropdown.classList.contains("hidden")) {
|
|
userMenu.classList.add("hidden");
|
|
}
|
|
}
|
|
};
|
|
const toggleUserMenu = () => {
|
|
const menu = document.getElementById("user-menu");
|
|
if (menu) {
|
|
menu.classList.toggle("hidden");
|
|
// Close theme dropdown if open
|
|
const themeDropdown = document.getElementById("theme-dropdown");
|
|
if (themeDropdown && !menu.classList.contains("hidden")) {
|
|
themeDropdown.classList.add("hidden");
|
|
}
|
|
}
|
|
};
|
|
const changeThemeTo = (theme) => {
|
|
// Apply the theme using the consolidated function from theme.ts
|
|
if (window.applyTheme) {
|
|
window.applyTheme(theme);
|
|
}
|
|
// Save to server if logged in
|
|
const token = localStorage.getItem("token");
|
|
if (token) {
|
|
fetch("/api/auth/theme", {
|
|
method: "PUT",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${token}`,
|
|
},
|
|
body: JSON.stringify({ theme }),
|
|
}).catch((err) => console.log("Theme save failed", err));
|
|
}
|
|
// Close dropdown
|
|
const dropdown = document.getElementById("theme-dropdown");
|
|
if (dropdown) {
|
|
dropdown.classList.add("hidden");
|
|
}
|
|
};
|
|
const logout = () => {
|
|
localStorage.removeItem("token");
|
|
localStorage.removeItem("user");
|
|
window.location.href = "/";
|
|
};
|
|
// Close dropdowns when clicking outside
|
|
document.addEventListener("click", (e) => {
|
|
const target = e.target;
|
|
const themeDropdown = document.getElementById("theme-dropdown");
|
|
const userMenu = document.getElementById("user-menu");
|
|
const themeButton = target?.closest('button[onclick="toggleThemeDropdown()"]');
|
|
const userButton = target?.closest('button[onclick="toggleUserMenu()"]');
|
|
if (!themeButton &&
|
|
themeDropdown &&
|
|
!themeDropdown.classList.contains("hidden")) {
|
|
if (!themeDropdown.contains(target)) {
|
|
themeDropdown.classList.add("hidden");
|
|
}
|
|
}
|
|
if (!userButton && userMenu && !userMenu.classList.contains("hidden")) {
|
|
if (!userMenu.contains(target)) {
|
|
userMenu.classList.add("hidden");
|
|
}
|
|
}
|
|
});
|
|
// Make functions available globally
|
|
window.toggleThemeDropdown = toggleThemeDropdown;
|
|
window.toggleUserMenu = toggleUserMenu;
|
|
window.changeThemeTo = changeThemeTo;
|
|
window.logout = logout;
|