package app import ( "fmt" "path/filepath" "strings" "github.com/seaweedfs/seaweedfs/weed/admin/dash" ) templ FileBrowser(data dash.FileBrowserData) {

if data.IsBucketPath && data.BucketName != "" { S3 Bucket: {data.BucketName} } else { File Browser }

if data.IsBucketPath && data.BucketName != "" { Back to Buckets }
Total Entries
{ fmt.Sprintf("%d", data.TotalEntries) }
Directories
{ fmt.Sprintf("%d", countDirectories(data.Entries)) }
Files
{ fmt.Sprintf("%d", countFiles(data.Entries)) }
Total Size
{ formatBytes(data.TotalSize) }
if data.CurrentPath == "/" { Root Directory } else if data.CurrentPath == "/buckets" { Object Store Buckets Directory Manage Buckets } else { { filepath.Base(data.CurrentPath) } }
if data.ParentPath != data.CurrentPath { Up }
if len(data.Entries) > 0 {
for _, entry := range data.Entries { }
Name Size Type Modified Permissions Actions
if entry.IsDirectory { { entry.Name } } else { { entry.Name } }
if entry.IsDirectory { } else { { formatBytes(entry.Size) } } if entry.IsDirectory { Directory } else { { getMimeDisplayName(entry.Mime) } } if !entry.ModTime.IsZero() { { entry.ModTime.Format("2006-01-02 15:04") } } else { } { entry.Mode }
if !entry.IsDirectory { }
} else {
Empty Directory

This directory contains no files or subdirectories.

}
Last updated: { data.LastUpdated.Format("2006-01-02 15:04:05") }
} func countDirectories(entries []dash.FileEntry) int { count := 0 for _, entry := range entries { if entry.IsDirectory { count++ } } return count } func countFiles(entries []dash.FileEntry) int { count := 0 for _, entry := range entries { if !entry.IsDirectory { count++ } } return count } func getFileIcon(mime string) string { switch { case strings.HasPrefix(mime, "image/"): return "fa-image" case strings.HasPrefix(mime, "video/"): return "fa-video" case strings.HasPrefix(mime, "audio/"): return "fa-music" case strings.HasPrefix(mime, "text/"): return "fa-file-text" case mime == "application/pdf": return "fa-file-pdf" case mime == "application/zip" || strings.Contains(mime, "archive"): return "fa-file-archive" case mime == "application/json": return "fa-file-code" case strings.Contains(mime, "script") || strings.Contains(mime, "javascript"): return "fa-file-code" default: return "fa-file" } } func getMimeDisplayName(mime string) string { switch mime { case "text/plain": return "Text" case "text/html": return "HTML" case "application/json": return "JSON" case "application/pdf": return "PDF" case "image/jpeg": return "JPEG" case "image/png": return "PNG" case "image/gif": return "GIF" case "video/mp4": return "MP4" case "audio/mpeg": return "MP3" case "application/zip": return "ZIP" default: if strings.HasPrefix(mime, "image/") { return "Image" } else if strings.HasPrefix(mime, "video/") { return "Video" } else if strings.HasPrefix(mime, "audio/") { return "Audio" } else if strings.HasPrefix(mime, "text/") { return "Text" } return "File" } }