From a38a96f8a4acd12b0b25c2afac6c2c05d5969501 Mon Sep 17 00:00:00 2001 From: Wessie Date: Sun, 4 Feb 2024 02:22:28 +0000 Subject: [PATCH] website: add queue data --- templates/default/queue.tmpl | 3 ++- website/public/queue.go | 26 +++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/templates/default/queue.tmpl b/templates/default/queue.tmpl index 84412def..e899cd8e 100644 --- a/templates/default/queue.tmpl +++ b/templates/default/queue.tmpl @@ -1,3 +1,4 @@ {{define "content"}} -Queue {{printjson .}} +Queue +{{printjson .}} {{end}} \ No newline at end of file diff --git a/website/public/queue.go b/website/public/queue.go index 506c4808..d1a8311a 100644 --- a/website/public/queue.go +++ b/website/public/queue.go @@ -1,20 +1,36 @@ package public import ( - "log" "net/http" + + radio "github.com/R-a-dio/valkyrie" ) -func (s State) GetQueue(w http.ResponseWriter, r *http.Request) { - queueInput := struct { +func (s State) getQueue(w http.ResponseWriter, r *http.Request) error { + input := struct { shared + Queue []radio.QueueEntry }{ shared: s.shared(r), } - err := s.TemplateExecutor.ExecuteFull(theme, "queue", w, queueInput) + queue, err := s.Streamer.Queue(r.Context()) + if err != nil { + return err + } + input.Queue = queue + + err = s.TemplateExecutor.ExecuteFull(theme, "queue", w, input) + if err != nil { + return err + } + return nil +} + +func (s State) GetQueue(w http.ResponseWriter, r *http.Request) { + err := s.getQueue(w, r) if err != nil { - log.Println(err) + s.errorHandler(w, r, err) return } }