diff --git a/ui/nojs.go b/ui/nojs.go index ddcb69f..6611b91 100644 --- a/ui/nojs.go +++ b/ui/nojs.go @@ -30,11 +30,20 @@ func DeclareNoJSRoutes(router *gin.Engine, cfg *config.Config, db *reveil.LevelD return } + if alarm == nil { + c.HTML(http.StatusOK, "index.tmpl", gin.H{ + "noAlarm": true, + "isPlaying": player.CommonPlayer != nil, + }) + return + } + nCycles := int(time.Until(*alarm) / (90 * time.Minute)) nDays := int(time.Until(*alarm) / (24 * time.Hour)) nMinutes := int((time.Until(*alarm) / time.Minute) % 90) c.HTML(http.StatusOK, "index.tmpl", gin.H{ + "noAlarm": false, "nextAlarmDate": alarm.Format("Mon 2"), "nextAlarmTime": alarm.Format("15:04"), "sameDay": time.Now().Day() == alarm.Day(), diff --git a/ui/nojs_templates/index.tmpl b/ui/nojs_templates/index.tmpl index 09334e9..4ad02f4 100644 --- a/ui/nojs_templates/index.tmpl +++ b/ui/nojs_templates/index.tmpl @@ -1,5 +1,8 @@

Prochain réveil le : + {{ if .noAlarm}} + aucun défini + {{ else }} {{ if .sameDay }} aujourd'hui {{ else if lt .nCycles 16 }} @@ -8,18 +11,23 @@ {{ .nextAlarmDate }} {{ end }} à {{ .nextAlarmTime }} + {{ end }}

+{{ if not .noAlarm }}

{{ if gt .nDays 2 }}(dans {{ .nDays }} jours){{ else }}(dans {{ .nCycles }} cycles + {{ .nMinutes }} min){{ end }}

+{{ end }}
+ {{ if not .noAlarm }}
+ {{ end }} {{ if .isPlaying }}