refactor(alpine): migrate remaining pages to x-init declarative initialization
- Remove DOMContentLoaded event listeners from analytics.ts and docs.ts - Rely on x-init attribute in templates for page initialization - Clean up unused exports from collections.ts Alpine data - Add x-init calls to admin_library, analytics, and docs templates - Normalize quote style in collections WebSocket script (single to double) - Disable Add Books button in collection detail (pending implementation)
This commit is contained in:
@@ -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, "<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Admin Dashboard - Bookhoard</title><script src=\"/static/htmx.min.js\"></script><script src=\"/static/main.js\" defer></script><link href=\"/static/style.css\" rel=\"stylesheet\"><script>\n\t\t\t\tlet scanWs = null;\n\t\t\t\tfunction connectScanWebSocket() {\n\t\t\t\t\tconst protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n\t\t\t\t\tconst wsUrl = `${protocol}//${window.location.host}/ws/sync?token={ user.Token }`;\n\t\t\t\t\tscanWs = new WebSocket(wsUrl);\n\n\t\t\t\t\tscanWs.onmessage = function(event) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst message = JSON.parse(event.data);\n\t\t\t\t\t\t\tswitch (message.type) {\n\t\t\t\t\t\t\t\tcase 'scan_progress':\n\t\t\t\t\t\t\t\t\tupdateScanProgress(message.data);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 'scan_complete':\n\t\t\t\t\t\t\t\t\tshowScanComplete(message.data);\n\t\t\t\t\t\t\t\t\tstopScanStatusPolling();\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 'scan_error':\n\t\t\t\t\t\t\t\t\tshowScanError(message.data);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('Failed to parse WebSocket message:', error);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tscanWs.onerror = function(error) {\n\t\t\t\t\t\tconsole.error('WebSocket error:', error);\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tfunction updateScanProgress(data) {\n\t\t\t\t\tconst progressBar = document.getElementById('scan-progress-bar');\n\t\t\t\t\tif (progressBar) {\n\t\t\t\t\t\tprogressBar.style.width = (data.progress * 100) + '%';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst progressText = document.getElementById('scan-progress-text');\n\t\t\t\t\tif (progressText) {\n\t\t\t\t\t\tprogressText.textContent = `${data.files_scanned} files scanned (${data.new_items} new)`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfunction showScanComplete(data) {\n\t\t\t\t\tconsole.log('Scan complete:', data);\n\t\t\t\t}\n\n\t\t\t\tfunction showScanError(data) {\n\t\t\t\t\tconsole.error('Scan error:', data);\n\t\t\t\t}\n\n\t\t\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\t\t\tconnectScanWebSocket();\n\t\t\t\t});\n\t\t\t</script></head><body class=\"theme-tokyo-night\" x-data=\"admin\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Admin Dashboard - Bookhoard</title><script src=\"/static/htmx.min.js\"></script><script src=\"/static/main.js\" defer></script><link href=\"/static/style.css\" rel=\"stylesheet\"><script>\n\t\t\t\tlet scanWs = null;\n\t\t\t\tfunction connectScanWebSocket() {\n\t\t\t\t\tconst protocol =\n\t\t\t\t\t\twindow.location.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n\t\t\t\t\tconst wsUrl = `${protocol}//${window.location.host}/ws/sync?token={ user.Token }`;\n\t\t\t\t\tscanWs = new WebSocket(wsUrl);\n\n\t\t\t\t\tscanWs.onmessage = function (event) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst message = JSON.parse(event.data);\n\t\t\t\t\t\t\tswitch (message.type) {\n\t\t\t\t\t\t\t\tcase \"scan_progress\":\n\t\t\t\t\t\t\t\t\tupdateScanProgress(message.data);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"scan_complete\":\n\t\t\t\t\t\t\t\t\tshowScanComplete(message.data);\n\t\t\t\t\t\t\t\t\tstopScanStatusPolling();\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"scan_error\":\n\t\t\t\t\t\t\t\t\tshowScanError(message.data);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error(\"Failed to parse WebSocket message:\", error);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tscanWs.onerror = function (error) {\n\t\t\t\t\t\tconsole.error(\"WebSocket error:\", error);\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tfunction updateScanProgress(data) {\n\t\t\t\t\tconst progressBar = document.getElementById(\"scan-progress-bar\");\n\t\t\t\t\tif (progressBar) {\n\t\t\t\t\t\tprogressBar.style.width = data.progress * 100 + \"%\";\n\t\t\t\t\t}\n\n\t\t\t\t\tconst progressText = document.getElementById(\"scan-progress-text\");\n\t\t\t\t\tif (progressText) {\n\t\t\t\t\t\tprogressText.textContent = `${data.files_scanned} files scanned (${data.new_items} new)`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfunction showScanComplete(data) {\n\t\t\t\t\tconsole.log(\"Scan complete:\", data);\n\t\t\t\t}\n\n\t\t\t\tfunction showScanError(data) {\n\t\t\t\t\tconsole.error(\"Scan error:\", data);\n\t\t\t\t}\n\n\t\t\t\tdocument.addEventListener(\"DOMContentLoaded\", function () {\n\t\t\t\t\tconnectScanWebSocket();\n\t\t\t\t});\n\t\t\t</script></head><body x-data=\"admin\" x-init=\"loadWatchStatus()\" class=\"theme-tokyo-night\" x-data=\"admin\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user