diff --git a/assets/index.js b/assets/index.js index 6b48cac..fe1ecec 100644 --- a/assets/index.js +++ b/assets/index.js @@ -67,7 +67,6 @@ function updateTimer() { return response.json() }).then(capturing => { console.log('capturing', capturing); - // the second condition is not used for debugging if(is_active != capturing && !capturing){ updateCalendar() } @@ -80,8 +79,6 @@ function parseCalendar(active){ // Do we want 'Startet/Endet in' or 'Startet/Endet um'? let diff = 0; let t = 0; - - console.debug('Calendar ', calendar); now = Date.now(); if (calendar.length > 0){ @@ -102,14 +99,17 @@ function parseCalendar(active){ seconds = (seconds < 10) ? '0' + seconds : seconds; console.debug('Remaining ', diff/1000); - console.log(diff, calendar.length, is_active); - return (calendar.length == 0 && !is_active) ? 'Keine Aufzeichnung geplant' : active.info + ' ' + hours + ':' + minutes + ':' + seconds; + if (calendar.length == 0 && !is_active) { + return 'Keine Aufzeichnung geplant'; + } else { + return (hours > 0) ? active.info + ' ' + hours + ':' + minutes + ':' + seconds : active.info + ' ' + minutes + ':' + seconds; + } } function updateCalendar() { fetch("/calendar") .then(response => { - console.debug('Status ', response.status) + console.debug('Calednar fetched; Status ', response.status) return response.json()}) .then(json => { console.log('Calendar ', json); diff --git a/main.go b/main.go index c12e698..61567af 100644 --- a/main.go +++ b/main.go @@ -153,9 +153,9 @@ func setupRouter() *gin.Engine { r.GET("/calendar", func(c *gin.Context) { client := &http.Client{} + // Cutoff is set to 24 hours from now cutoff := time.Now().UnixMilli() + int64(86400000) url := config.Opencast.Url + "/recordings/calendar.json?agentid=" + config.Opencast.Agent + "&cutoff=" + fmt.Sprint(cutoff) + "×tamp=true" - fmt.Print("\n" + url + "\n") req, err := http.NewRequest("GET", url, nil) req.SetBasicAuth(config.Opencast.Username, config.Opencast.Password) resp, err := client.Do(req) @@ -196,10 +196,8 @@ func setupRouter() *gin.Engine { } if len(titles) > 0 { - fmt.Println(fmt.Sprint(len(titles)) + " Events planned.") c.JSON(http.StatusOK, events) } else { - fmt.Println("No Events") c.JSON(http.StatusOK, "") } })