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
|
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))
|
nCycles := int(time.Until(*alarm) / (90 * time.Minute))
|
||||||
nDays := int(time.Until(*alarm) / (24 * time.Hour))
|
nDays := int(time.Until(*alarm) / (24 * time.Hour))
|
||||||
nMinutes := int((time.Until(*alarm) / time.Minute) % 90)
|
nMinutes := int((time.Until(*alarm) / time.Minute) % 90)
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||||
|
"noAlarm": false,
|
||||||
"nextAlarmDate": alarm.Format("Mon 2"),
|
"nextAlarmDate": alarm.Format("Mon 2"),
|
||||||
"nextAlarmTime": alarm.Format("15:04"),
|
"nextAlarmTime": alarm.Format("15:04"),
|
||||||
"sameDay": time.Now().Day() == alarm.Day(),
|
"sameDay": time.Now().Day() == alarm.Day(),
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<h1 style="margin-bottom: 0">
|
<h1 style="margin-bottom: 0">
|
||||||
Prochain réveil le :
|
Prochain réveil le :
|
||||||
|
{{ if .noAlarm}}
|
||||||
|
aucun défini
|
||||||
|
{{ else }}
|
||||||
{{ if .sameDay }}
|
{{ if .sameDay }}
|
||||||
aujourd'hui
|
aujourd'hui
|
||||||
{{ else if lt .nCycles 16 }}
|
{{ else if lt .nCycles 16 }}
|
||||||
@ -8,18 +11,23 @@
|
|||||||
{{ .nextAlarmDate }}
|
{{ .nextAlarmDate }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
à {{ .nextAlarmTime }}
|
à {{ .nextAlarmTime }}
|
||||||
|
{{ end }}
|
||||||
</h1>
|
</h1>
|
||||||
|
{{ if not .noAlarm }}
|
||||||
<h2 style="color: gray; margin-top: 0; margin-left: 5em">
|
<h2 style="color: gray; margin-top: 0; margin-left: 5em">
|
||||||
{{ if gt .nDays 2 }}(dans {{ .nDays }} jours){{ else }}(dans {{ .nCycles }} cycles + {{ .nMinutes }} min){{ end }}
|
{{ if gt .nDays 2 }}(dans {{ .nDays }} jours){{ else }}(dans {{ .nCycles }} cycles + {{ .nMinutes }} min){{ end }}
|
||||||
</h2>
|
</h2>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div style="display: flex; gap: 10px;">
|
<div style="display: flex; gap: 10px;">
|
||||||
|
{{ if not .noAlarm }}
|
||||||
<form method="post" action="/nojs.html">
|
<form method="post" action="/nojs.html">
|
||||||
<input type="hidden" name="action" value="cancel">
|
<input type="hidden" name="action" value="cancel">
|
||||||
<button type="submit">
|
<button type="submit">
|
||||||
Annuler la prochaine alarme
|
Annuler la prochaine alarme
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if .isPlaying }}
|
{{ if .isPlaying }}
|
||||||
<form method="post" action="/nojs.html">
|
<form method="post" action="/nojs.html">
|
||||||
|
Loading…
Reference in New Issue
Block a user