Skip to content

Commit

Permalink
Removed some comments; Remaining time shows just minutes and seconds …
Browse files Browse the repository at this point in the history
…if less than one hour is remaining
  • Loading branch information
Jan-Matthis committed Jun 28, 2024
1 parent 6bd45ca commit 7040cb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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){
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) + "&timestamp=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)
Expand Down Expand Up @@ -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, "")
}
})
Expand Down

0 comments on commit 7040cb2

Please sign in to comment.