Handle no alarm in nojs page
This commit is contained in:
parent
791b577c17
commit
425571d76e
@ -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(),
|
||||
|
@ -1,5 +1,8 @@
|
||||
<h1 style="margin-bottom: 0">
|
||||
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 }}
|
||||
</h1>
|
||||
{{ if not .noAlarm }}
|
||||
<h2 style="color: gray; margin-top: 0; margin-left: 5em">
|
||||
{{ if gt .nDays 2 }}(dans {{ .nDays }} jours){{ else }}(dans {{ .nCycles }} cycles + {{ .nMinutes }} min){{ end }}
|
||||
</h2>
|
||||
{{ end }}
|
||||
|
||||
<div style="display: flex; gap: 10px;">
|
||||
{{ if not .noAlarm }}
|
||||
<form method="post" action="/nojs.html">
|
||||
<input type="hidden" name="action" value="cancel">
|
||||
<button type="submit">
|
||||
Annuler la prochaine alarme
|
||||
</button>
|
||||
</form>
|
||||
{{ end }}
|
||||
|
||||
{{ if .isPlaying }}
|
||||
<form method="post" action="/nojs.html">
|
||||
|
Loading…
Reference in New Issue
Block a user