43 lines
1014 B
Go
43 lines
1014 B
Go
package web
|
|
|
|
import "net/http"
|
|
|
|
func (h *Web) handleAdminJukebox(w http.ResponseWriter, r *http.Request) {
|
|
data := struct {
|
|
Available bool
|
|
Status any
|
|
Error string
|
|
}{Available: h.Jukebox.Available}
|
|
|
|
if h.Jukebox.Available {
|
|
state, err := h.Jukebox.Status()
|
|
if err != nil {
|
|
data.Error = err.Error()
|
|
} else {
|
|
data.Status = state
|
|
}
|
|
}
|
|
h.page(w, r, "admin_jukebox", "admin_jukebox", "Jukebox", data)
|
|
}
|
|
|
|
func (h *Web) handleAdminJukeboxStop(w http.ResponseWriter, r *http.Request) {
|
|
if h.Jukebox.Available {
|
|
_, _ = h.Jukebox.Stop()
|
|
}
|
|
http.Redirect(w, r, "/admin/jukebox", http.StatusFound)
|
|
}
|
|
|
|
func (h *Web) handleAdminJukeboxStart(w http.ResponseWriter, r *http.Request) {
|
|
if h.Jukebox.Available {
|
|
_, _ = h.Jukebox.Start()
|
|
}
|
|
http.Redirect(w, r, "/admin/jukebox", http.StatusFound)
|
|
}
|
|
|
|
func (h *Web) handleAdminJukeboxClear(w http.ResponseWriter, r *http.Request) {
|
|
if h.Jukebox.Available {
|
|
_, _ = h.Jukebox.Clear()
|
|
}
|
|
http.Redirect(w, r, "/admin/jukebox", http.StatusFound)
|
|
}
|