feat: Enhance file deletion UX with custom confirmation dialogs

- Add FileMetadataDialog component for consistent delete confirmation
- Implement custom JavaScript handlers for file deletion events
- Add Notyf notifications for successful and failed deletions
- Improve delete button behavior in file list, details, and search views
- Enhance error handling and user feedback during file metadata deletion
This commit is contained in:
StarFleetCPTN
2025-03-09 18:54:23 -07:00
parent dfbcb021f5
commit 6545d26a93
2 changed files with 547 additions and 18 deletions
@@ -1,6 +1,7 @@
package handlers
import (
"fmt"
"net/http"
"strconv"
@@ -344,6 +345,8 @@ func (h *FileMetadataHandler) SearchFileMetadata(c *gin.Context) {
func (h *FileMetadataHandler) DeleteFileMetadata(c *gin.Context) {
userID := c.GetUint("userID")
fmt.Println("Deleting file metadata")
// Get file ID from URL parameter
fileID, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
@@ -373,6 +376,16 @@ func (h *FileMetadataHandler) DeleteFileMetadata(c *gin.Context) {
return
}
// Redirect to the file list
c.Redirect(http.StatusFound, "/files")
fmt.Println("File deleted successfully")
// Check if this is an HTMX request
isHtmxRequest := c.GetHeader("HX-Request") == "true"
if isHtmxRequest {
// For HTMX requests, just return a 200 status - client will handle UI updates
c.Status(http.StatusOK)
} else {
// For regular browser requests, redirect to the file list
c.Redirect(http.StatusFound, "/files")
}
}