From 28fa65df9daebff471ba4da4bbbbbea82b1d3cbd Mon Sep 17 00:00:00 2001 From: StarFleetCPTN Date: Fri, 28 Mar 2025 22:22:35 -0700 Subject: [PATCH] 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. --- .../details/file_metadata_details.templ | 308 +++--- .../details/file_metadata_details_templ.go | 270 ++++-- .../dialog/file_metadata_dialog.templ | 23 +- .../dialog/file_metadata_dialog_templ.go | 35 +- .../list/file_metadata_list.templ | 56 +- .../list/file_metadata_list_partial.templ | 290 ++++-- .../list/file_metadata_list_partial_templ.go | 905 ++++++++++++++---- .../list/file_metadata_list_templ.go | 124 ++- .../search/file_metadata_search.templ | 96 +- .../search/file_metadata_search_content.templ | 70 +- .../file_metadata_search_content_templ.go | 132 +-- .../search/file_metadata_search_templ.go | 120 ++- components/file_metadata/types.go | 4 + .../utils/file_metadata_js.templ | 171 ++-- .../utils/file_metadata_js_templ.go | 7 +- components/layout.templ | 5 + components/notifications/dialog/dialog.templ | 43 + .../notifications/dialog/dialog_js.templ | 20 + .../notifications/dialog/dialog_js_templ.go | 41 + .../notifications/dialog/dialog_templ.go | 218 +++++ .../notifications/form/fields/email.templ | 32 + .../notifications/form/fields/email_templ.go | 45 + .../notifications/form/fields/gotify.templ | 116 +++ .../notifications/form/fields/gotify_templ.go | 238 +++++ .../notifications/form/fields/ntfy.templ | 133 +++ .../notifications/form/fields/ntfy_templ.go | 294 ++++++ .../form/fields/pushbullet.templ | 103 ++ .../form/fields/pushbullet_templ.go | 223 +++++ .../notifications/form/fields/pushover.templ | 154 +++ .../form/fields/pushover_templ.go | 266 +++++ .../notifications/form/fields/webhook.templ | 164 ++++ .../form/fields/webhook_templ.go | 292 ++++++ components/notifications/form/form.templ | 148 +++ components/notifications/form/form_js.templ | 45 + .../notifications/form/form_js_templ.go | 41 + components/notifications/form/form_templ.go | 344 +++++++ components/notifications/form/utils/utils.go | 28 + components/notifications/list/list.templ | 207 ++++ components/notifications/list/list_js.templ | 221 +++++ .../notifications/list/list_js_templ.go | 41 + components/notifications/list/list_templ.go | 403 ++++++++ components/notifications/types/types.go | 69 ++ components/shared/toast/toast.templ | 5 + components/shared/toast/toast_js.templ | 80 ++ components/shared/toast/toast_js_templ.go | 40 + components/shared/toast/toast_templ.go | 40 + .../web/handlers/file_metadata_handlers.go | 164 +++- internal/web/handlers/settings_handlers.go | 35 +- static/js/app.js | 170 +++- 49 files changed, 6153 insertions(+), 926 deletions(-) create mode 100644 components/notifications/dialog/dialog.templ create mode 100644 components/notifications/dialog/dialog_js.templ create mode 100644 components/notifications/dialog/dialog_js_templ.go create mode 100644 components/notifications/dialog/dialog_templ.go create mode 100644 components/notifications/form/fields/email.templ create mode 100644 components/notifications/form/fields/email_templ.go create mode 100644 components/notifications/form/fields/gotify.templ create mode 100644 components/notifications/form/fields/gotify_templ.go create mode 100644 components/notifications/form/fields/ntfy.templ create mode 100644 components/notifications/form/fields/ntfy_templ.go create mode 100644 components/notifications/form/fields/pushbullet.templ create mode 100644 components/notifications/form/fields/pushbullet_templ.go create mode 100644 components/notifications/form/fields/pushover.templ create mode 100644 components/notifications/form/fields/pushover_templ.go create mode 100644 components/notifications/form/fields/webhook.templ create mode 100644 components/notifications/form/fields/webhook_templ.go create mode 100644 components/notifications/form/form.templ create mode 100644 components/notifications/form/form_js.templ create mode 100644 components/notifications/form/form_js_templ.go create mode 100644 components/notifications/form/form_templ.go create mode 100644 components/notifications/form/utils/utils.go create mode 100644 components/notifications/list/list.templ create mode 100644 components/notifications/list/list_js.templ create mode 100644 components/notifications/list/list_js_templ.go create mode 100644 components/notifications/list/list_templ.go create mode 100644 components/notifications/types/types.go create mode 100644 components/shared/toast/toast.templ create mode 100644 components/shared/toast/toast_js.templ create mode 100644 components/shared/toast/toast_js_templ.go create mode 100644 components/shared/toast/toast_templ.go diff --git a/components/file_metadata/details/file_metadata_details.templ b/components/file_metadata/details/file_metadata_details.templ index 6a05496..5827770 100644 --- a/components/file_metadata/details/file_metadata_details.templ +++ b/components/file_metadata/details/file_metadata_details.templ @@ -4,128 +4,228 @@ import ( "context" "fmt" "strconv" + "github.com/starfleetcptn/gomft/components" "github.com/starfleetcptn/gomft/components/file_metadata" - "github.com/starfleetcptn/gomft/components/file_metadata/utils" - "github.com/starfleetcptn/gomft/components/layout" + "github.com/starfleetcptn/gomft/components/file_metadata/dialog" // Import dialog package + "github.com/starfleetcptn/gomft/components/file_metadata/utils" // Import utils package ) -// FileMetadataDetails renders the details view for a file metadata +// FileMetadataDetails renders the details view for a file metadata, matching original structure templ FileMetadataDetails(ctx context.Context, data file_metadata.FileMetadataDetailsData) { - @layout.LayoutWithContext("File Details", ctx) { + @components.LayoutWithContext("File Details", ctx) {
- - @utils.fileMetadataJS() - -
+ + @utils.FileMetadataJS() // Include JS for toasts, etc. + +

- File Details + File Details: { data.File.FileName }

- + + Back to Files +
- +
- File Information + { data.File.FileName }

- ID: { strconv.FormatInt(int64(data.File.ID), 10) } + File ID: { strconv.FormatUint(uint64(data.File.ID), 10) }

- +
-
File Information
-
-
-
Filename
-
{ data.File.FileName }
-
-
-
Size
-
{ strconv.FormatInt(data.File.FileSize, 10) } bytes
-
-
-
Hash
-
{ data.File.FileHash }
-
-
-
Status
-
- - { data.File.Status } - -
-
-
+
+ File Information +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Filename + + { data.File.FileName } +
+ Size + + { utils.FormatFileSize(data.File.FileSize) } +
+ Hash + + if data.File.FileHash != "" { + { data.File.FileHash } + } else { + Not available + } +
+ Status + + + { data.File.Status } + +
+ Original Path + +
+ + { data.File.OriginalPath } +
+
+ Destination Path + +
+ + { data.File.DestinationPath } +
+
+
- +
-
Processing Information
-
-
-
Original Path
-
{ data.File.OriginalPath }
-
-
-
Destination Path
-
{ data.File.DestinationPath }
-
-
-
Processed At
-
{ data.File.ProcessedTime.Format("2006-01-02 15:04:05") }
-
- if data.File.Status == "error" && data.File.ErrorMessage != "" { -
-
Error
-
{ data.File.ErrorMessage }
-
- } -
+
+ Processing Information +
+
+ + + + + + + + + + + + + + + + + + + if data.File.Status == "error" && data.File.ErrorMessage != "" { + + + + + } + + + + + + + + + +
+ Job + + + { data.File.Job.Name } + +
+ Processed Time + +
+ + { data.File.ProcessedTime.Format("2006-01-02 15:04:05") } +
+
+ Creation Time + +
+ + { data.File.CreationTime.Format("2006-01-02 15:04:05") } +
+
+ Modification Time + +
+ + { data.File.ModTime.Format("2006-01-02 15:04:05") } +
+
+ Error + +
+ + { data.File.ErrorMessage } +
+
+ Record Created + + { data.File.CreatedAt.Format("2006-01-02 15:04:05") } +
+ Record Updated + + { data.File.UpdatedAt.Format("2006-01-02 15:04:05") } +
+
- - -
- -
-
-
-
- -