From: Thomas Karpiniec Date: Wed, 30 Oct 2024 09:31:38 +0000 (+1100) Subject: More UI improvements X-Git-Tag: v1.0.0 X-Git-Url: https://code.octet-stream.net/broadcaster/commitdiff_plain/92da3eadf29c9e90cd67fd15dba3b8487ce4a918?ds=sidebyside;hp=25d02cf0c3462805176f4193d675c4904221dca1 More UI improvements --- diff --git a/server/main.go b/server/main.go index 9f6927e..d1d47d3 100644 --- a/server/main.go +++ b/server/main.go @@ -77,7 +77,7 @@ func main() { // Public routes http.HandleFunc("/login", logInPage) - http.Handle("/file-downloads/", http.StripPrefix("/file-downloads/", http.FileServer(http.Dir(config.AudioFilesPath)))) + http.Handle("/file-downloads/", applyDisposition(http.StripPrefix("/file-downloads/", http.FileServer(http.Dir(config.AudioFilesPath))))) // Authenticated routes @@ -106,6 +106,24 @@ func main() { } } +type DispositionMiddleware struct { + handler http.Handler +} + +func (m DispositionMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { + log.Println("path", r.URL.Path) + if r.URL.Path != "/file-downloads/" { + w.Header().Add("Content-Disposition", "attachment") + } + m.handler.ServeHTTP(w, r) +} + +func applyDisposition(handler http.Handler) DispositionMiddleware { + return DispositionMiddleware{ + handler: handler, + } +} + type authenticatedHandler func(http.ResponseWriter, *http.Request, User) type AuthMiddleware struct { @@ -139,6 +157,7 @@ func requireAdmin(handler authenticatedHandler) AuthMiddleware { type HeaderData struct { SelectedMenu string User User + Version string } func renderHeader(w http.ResponseWriter, selectedMenu string, user User) { @@ -146,6 +165,7 @@ func renderHeader(w http.ResponseWriter, selectedMenu string, user User) { data := HeaderData{ SelectedMenu: selectedMenu, User: user, + Version: version, } err := tmpl.Execute(w, data) if err != nil { @@ -456,6 +476,9 @@ func playlistsPage(w http.ResponseWriter, _ *http.Request, user User) { data := PlaylistsPageData{ Playlists: db.GetPlaylists(), } + for i := range data.Playlists { + data.Playlists[i].StartTime = strings.Replace(data.Playlists[i].StartTime, "T", " ", -1) + } tmpl := template.Must(template.ParseFS(content, "templates/playlists.html")) err := tmpl.Execute(w, data) if err != nil { @@ -506,7 +529,7 @@ func editPlaylistPage(w http.ResponseWriter, r *http.Request, id int, user User) data.Playlist = playlist data.Entries = db.GetEntriesForPlaylist(id) } - renderHeader(w, "radios", user) + renderHeader(w, "playlists", user) tmpl := template.Must(template.ParseFS(content, "templates/playlist.html")) tmpl.Execute(w, data) renderFooter(w) diff --git a/server/templates/files.html b/server/templates/files.html index e205472..a07ce2c 100644 --- a/server/templates/files.html +++ b/server/templates/files.html @@ -1,10 +1,11 @@

Audio File Management

All files can be downloaded from the public file listing.

- +
+ {{range .Files}} - - + + {{end}} diff --git a/server/templates/header.html b/server/templates/header.html index 3d4af19..64b3b4e 100644 --- a/server/templates/header.html +++ b/server/templates/header.html @@ -8,13 +8,39 @@ table.radio-status, td.outer { border: 1px solid; } + table.listing td, table.listing th { + padding: 0.35em; + } + td.enabled { + text-align: center; + } + td.token { + font-family: monospace; + font-size: 80%; + } table.inner { border-collapse: collapse; } - td.clear { + td.channel-state { text-align: center; + width: 5em; + height: 5em; + } + td.clear { background-color: #eeeeee; } + td.cos { + background-color: #aaeeaa; + } + td.ptt { + background-color: #eeaaaa; + } + th { + text-align: left; + } + input.seconds { + width: 3em; + } .time-table { font-size: 90%; } @@ -113,7 +139,7 @@ {{if .User.Username}}
Logged in as:
{{.User.Username}}
{{end}} - + {{end}}
diff --git a/server/templates/playlist.html b/server/templates/playlist.html index d778250..4493c60 100644 --- a/server/templates/playlist.html +++ b/server/templates/playlist.html @@ -39,11 +39,11 @@ {{range .Entries}}

Wait until - - seconds from + + seconds then play - (Delete Item) + (Delete)

{{end}}

@@ -73,11 +73,11 @@ {{end}} diff --git a/server/templates/playlists.html b/server/templates/playlists.html index e6b6a5a..ceb1ad7 100644 --- a/server/templates/playlists.html +++ b/server/templates/playlists.html @@ -1,9 +1,9 @@

Playlist Management

-
Name
{{.Name}}
{{.Name}}
- +
NameEnabled?Start Time
+ {{range .Playlists}} - + {{end}}
NameStart TimeEnabled?
{{.Name}}{{if .Enabled}}✅{{else}}❌{{end}}{{.StartTime}}(Edit)
{{.Name}}{{.StartTime}}{{if .Enabled}}✅{{else}}❌{{end}}(Edit)

Add New Playlist

diff --git a/server/templates/radios.html b/server/templates/radios.html index 0c1288f..a840c00 100644 --- a/server/templates/radios.html +++ b/server/templates/radios.html @@ -1,8 +1,9 @@

Radios

-