diff --git a/templates/admin_library.templ b/templates/admin_library.templ
index c91d740..522a40e 100644
--- a/templates/admin_library.templ
+++ b/templates/admin_library.templ
@@ -8,7 +8,7 @@ templ AdminLibrary(user User, libraries []LibraryData, users []User) {
Library Management - Bookhoard
-
+
@Header(user, "/admin/library")
@AdminSidebar(user, "/admin/library")
diff --git a/templates/admin_library_templ.go b/templates/admin_library_templ.go
index 967d624..16ebb7f 100644
--- a/templates/admin_library_templ.go
+++ b/templates/admin_library_templ.go
@@ -29,7 +29,7 @@ func AdminLibrary(user User, libraries []LibraryData, users []User) templ.Compon
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
Library Management - Bookhoard")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Library Management - Bookhoard")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/templates/admin_templ.go b/templates/admin_templ.go
index 513ecd6..f75f8d5 100644
--- a/templates/admin_templ.go
+++ b/templates/admin_templ.go
@@ -29,7 +29,7 @@ func Admin(user User) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Admin Dashboard - Bookhoard")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Admin Dashboard - Bookhoard")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/templates/analytics_templ.go b/templates/analytics_templ.go
index bcc65af..5e507e3 100644
--- a/templates/analytics_templ.go
+++ b/templates/analytics_templ.go
@@ -29,7 +29,7 @@ func Analytics(user User) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Reading Analytics - Bookhoard")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Reading Analytics - Bookhoard")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/templates/collections.templ b/templates/collections.templ
index ae67fdb..503b6d8 100644
--- a/templates/collections.templ
+++ b/templates/collections.templ
@@ -18,69 +18,74 @@ templ Collection(user User, collections []CollectionData, errorMessage string) {
let libraryId = null;
function connectWebSocket() {
- const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+ const protocol =
+ window.location.protocol === "https:" ? "wss:" : "ws:";
const wsUrl = `${protocol}//${window.location.host}/ws/sync?token={ user.Token }`;
ws = new WebSocket(wsUrl);
- ws.onopen = function() {
- console.log('WebSocket connected');
+ ws.onopen = function () {
+ console.log("WebSocket connected");
};
- ws.onmessage = function(event) {
+ ws.onmessage = function (event) {
try {
const message = JSON.parse(event.data);
- if (message.type === 'collection_updated' && message.data.collection_id === collectionId) {
- const actionText = message.data.action === 'books_added'
- ? `Added ${message.data.count || 0} book(s)`
- : message.data.action === 'book_removed'
- ? 'Removed a book'
- : message.data.action === 'books_bulk_removed'
- ? `Removed ${message.data.count || 0} book(s)`
- : 'Collection updated';
+ if (
+ message.type === "collection_updated" &&
+ message.data.collection_id === collectionId
+ ) {
+ const actionText =
+ message.data.action === "books_added"
+ ? `Added ${message.data.count || 0} book(s)`
+ : message.data.action === "book_removed"
+ ? "Removed a book"
+ : message.data.action === "books_bulk_removed"
+ ? `Removed ${message.data.count || 0} book(s)`
+ : "Collection updated";
// Show toast notification
if (window.showToast) {
- window.showToast(actionText, 'info');
+ window.showToast(actionText, "info");
}
// Check if user is actively typing
const activeElement = document.activeElement;
- const isUserActive = activeElement && (
- activeElement.tagName === 'INPUT' ||
- activeElement.tagName === 'TEXTAREA' ||
- activeElement.tagName === 'SELECT' ||
- activeElement.getAttribute('contenteditable') === 'true'
- );
+ const isUserActive =
+ activeElement &&
+ (activeElement.tagName === "INPUT" ||
+ activeElement.tagName === "TEXTAREA" ||
+ activeElement.tagName === "SELECT" ||
+ activeElement.getAttribute("contenteditable") === "true");
if (!isUserActive) {
- setTimeout(function() {
+ setTimeout(function () {
location.reload();
}, 1000);
} else {
- console.log('User actively typing - skipping auto-reload');
+ console.log("User actively typing - skipping auto-reload");
}
}
} catch (error) {
- console.error('Failed to parse WebSocket message:', error);
+ console.error("Failed to parse WebSocket message:", error);
}
};
- ws.onclose = function() {
- console.log('WebSocket disconnected, reconnecting in 5s...');
+ ws.onclose = function () {
+ console.log("WebSocket disconnected, reconnecting in 5s...");
setTimeout(connectWebSocket, 5000);
};
- ws.onerror = function(error) {
- console.error('WebSocket error:', error);
+ ws.onerror = function (error) {
+ console.error("WebSocket error:", error);
};
}
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener("DOMContentLoaded", function () {
// Get collection and library IDs from data attributes
- const dataEl = document.getElementById('collection-data');
+ const dataEl = document.getElementById("collection-data");
if (dataEl) {
- collectionId = dataEl.dataset.id || '';
- libraryId = dataEl.dataset.libraryId || '';
+ collectionId = dataEl.dataset.id || "";
+ libraryId = dataEl.dataset.libraryId || "";
connectWebSocket();
}
});
@@ -220,13 +225,12 @@ templ CollectionDetail(user User, collection CollectionData, books []handlers.Bo
-