Skip to content

Commit

Permalink
website: add queue data
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Feb 4, 2024
1 parent 122dee7 commit a38a96f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion templates/default/queue.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{define "content"}}
Queue {{printjson .}}
Queue
{{printjson .}}
{{end}}
26 changes: 21 additions & 5 deletions website/public/queue.go
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit a38a96f

Please sign in to comment.