feat: Enhance file metadata and notification components

- Added sorting capabilities to file metadata lists, including SortBy and SortDir fields.
- Integrated a toast notification system for user feedback on actions.
- Updated templates and JavaScript for improved user interaction and responsiveness.
- Refactored file metadata handlers to utilize new sorting features and ensure proper data flow.
- Introduced new notification dialog components for better user confirmation on actions.
This commit is contained in:
StarFleetCPTN committed 2025-03-28 22:22:35 -07:00
1 parent c52edb75df
commit 28fa65df9d
49 files changed
+6153 -926

No files matched your search

@@ -0,0 +1,41 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.833
package list
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
// ListScripts contains JavaScript specific to the notification list page.
func ListScripts() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<script>\n\t\t// Notification system (showToast function is now in shared/toast/toast_js.templ)\n\n\t\t// Track all HTMX events for debugging\n\t\tdocument.addEventListener('htmx:beforeRequest', function(event) {\n\t\t\t// Check if this is a DELETE request for a notification service\n\t\t\tconst path = event.detail.path;\n\t\t\tconst method = event.detail.verb;\n\n\t\t\tconsole.log(`Request path: ${path}, method: ${method}`);\n\n\t\t\t// Pattern match for notification service deletions (e.g., /admin/settings/notifications/123)\n\t\t\tif (path && method === 'DELETE' && path.match(/^\\/admin\\/settings\\/notifications\\/\\d+$/)) {\n\t\t\t\tconsole.log(\"Detected notification service deletion request via URL pattern\");\n\n\t\t\t\t// This is definitely a delete request - store this information\n\t\t\t\twindow.isServiceDeleteRequest = true;\n\t\t\t}\n\t\t});\n\n\t\tdocument.addEventListener('htmx:afterRequest', function(event) {\n\t\t\t// Check for notification service deletion multiple ways\n\t\t\tconst isDeleteRequest =\n\t\t\t\t// Check global flag from the triggerServiceDelete function\n\t\t\t\twindow.currentlyDeletingService ||\n\t\t\t\t// Check flag from beforeRequest handler\n\t\t\t\twindow.isServiceDeleteRequest ||\n\t\t\t\t// Check URL pattern directly from this event\n\t\t\t\t(event.detail.pathInfo &&\n\t\t\t\t\tevent.detail.pathInfo.requestPath &&\n\t\t\t\t\tevent.detail.pathInfo.requestPath.match(/^\\/admin\\/settings\\/notifications\\/\\d+$/) &&\n\t\t\t\t\tevent.detail.verb === 'DELETE');\n\n\t\t\tconsole.log(`Is delete request: ${isDeleteRequest}`);\n\n\t\t\t// If this is a successful delete request, show notification\n\t\t\tif (isDeleteRequest && event.detail.successful) {\n\t\t\t\tconsole.log(\"Delete request was successful\");\n\n\t\t\t\tlet serviceName = \"Unknown\";\n\n\t\t\t\t// Try multiple sources for service name\n\t\t\t\tif (event.detail.elt && event.detail.elt.getAttribute) {\n\t\t\t\t\tserviceName = event.detail.elt.getAttribute('data-service-name') || serviceName;\n\t\t\t\t}\n\n\t\t\t\tif (serviceName === \"Unknown\" && window.lastDeletedService) {\n\t\t\t\t\t// Fallback to our stored service info\n\t\t\t\t\tserviceName = window.lastDeletedService.name;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(`Showing success notification for deleted service: ${serviceName}`);\n\t\t\t\t// Ensure showToast is globally available\n\t\t\t\tif (typeof showToast === 'function') {\n\t\t\t\t\tshowToast(`Notification service \"${serviceName}\" deleted successfully`, 'success');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(\"showToast function not found!\");\n\t\t\t\t}\n\n\n\t\t\t\t// Clear flags\n\t\t\t\twindow.currentlyDeletingService = false;\n\t\t\t\twindow.isServiceDeleteRequest = false;\n\t\t\t\twindow.lastDeletedService = null;\n\t\t\t}\n\t\t});\n\n\t\tdocument.addEventListener('htmx:responseError', function(event) {\n\t\t\tconsole.log(\"HTMX response error:\", event.detail);\n\n\t\t\t// Similar logic as success but for errors\n\t\t\tconst isDeleteRequest =\n\t\t\t\twindow.currentlyDeletingService ||\n\t\t\t\twindow.isServiceDeleteRequest ||\n\t\t\t\t(event.detail.pathInfo &&\n\t\t\t\t\tevent.detail.pathInfo.requestPath &&\n\t\t\t\t\tevent.detail.pathInfo.requestPath.match(/^\\/admin\\/settings\\/notifications\\/\\d+$/) &&\n\t\t\t\t\tevent.detail.verb === 'DELETE');\n\n\t\t\tlet errorMsg = 'An error occurred';\n\t\t\tif (event.detail.xhr && event.detail.xhr.responseText) {\n\t\t\t\terrorMsg = event.detail.xhr.responseText;\n\t\t\t}\n\n\t\t\tif (isDeleteRequest) {\n\t\t\t\tconsole.log(\"Delete request failed\");\n\n\t\t\t\tlet serviceName = \"Unknown\";\n\n\t\t\t\t// Try multiple sources for service name\n\t\t\t\tif (event.detail.elt && event.detail.elt.getAttribute) {\n\t\t\t\t\tserviceName = event.detail.elt.getAttribute('data-service-name') || serviceName;\n\t\t\t\t}\n\n\t\t\t\tif (serviceName === \"Unknown\" && window.lastDeletedService) {\n\t\t\t\t\t// Fallback to our stored service info\n\t\t\t\t\tserviceName = window.lastDeletedService.name;\n\t\t\t\t}\n\n\t\t\t\tlet specificErrorMsg = `Failed to delete notification service \"${serviceName}\"`;\n\n\t\t\t\tif (event.detail.xhr && event.detail.xhr.responseText) {\n\t\t\t\t\t// Try to provide a more specific error from the response\n\t\t\t\t\tspecificErrorMsg = `Error deleting \"${serviceName}\": ${event.detail.xhr.responseText}`;\n\t\t\t\t}\n\n\t\t\t\tconsole.log(`Showing error notification: ${specificErrorMsg}`);\n\t\t\t\tif (typeof showToast === 'function') {\n\t\t\t\t\tshowToast(specificErrorMsg, 'error');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(\"showToast function not found!\");\n\t\t\t\t}\n\n\n\t\t\t\t// Clear flags\n\t\t\t\twindow.currentlyDeletingService = false;\n\t\t\t\twindow.isServiceDeleteRequest = false;\n\t\t\t\twindow.lastDeletedService = null;\n\t\t\t} else {\n\t\t\t\t// General error toast\n\t\t\t\tif (typeof showToast === 'function') {\n\t\t\t\t\tshowToast(errorLine truncated
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate