New field to disable a repeated alarm
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2022-12-15 18:45:20 +01:00
parent 45efc3601e
commit 5526940e61
4 changed files with 13 additions and 1 deletions

View File

@ -149,6 +149,7 @@ type AlarmRepeated struct {
FollowingRoutines []Identifier `json:"routines"`
IgnoreExceptions bool `json:"ignore_exceptions"`
Comment string `json:"comment,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Excepts Exceptions `json:"excepts,omitempty"`
NextTime *time.Time `json:"next_time,omitempty"`
}
@ -185,6 +186,10 @@ func (a *AlarmRepeated) FillExcepts(cfg *config.Config, db *LevelDBStorage) erro
}
func (a *AlarmRepeated) GetNextOccurence(cfg *config.Config, db *LevelDBStorage) *time.Time {
if a.Disabled {
return nil
}
if len(a.Excepts) == 0 {
a.FillExcepts(cfg, db)
}

View File

@ -5,13 +5,14 @@ export class AlarmRepeated {
}
}
update({ id, weekday, time, routines, ignore_exceptions, comment, excepts, next_time }) {
update({ id, weekday, time, routines, disabled, ignore_exceptions, comment, excepts, next_time }) {
this.id = id;
this.weekday = weekday;
this.time = time;
this.routines = routines == null ? [] : routines;
this.ignore_exceptions = ignore_exceptions;
this.comment = comment;
this.disabled = disabled == true;
if (excepts !== undefined)
this.excepts = excepts;
if (next_time !== undefined)

View File

@ -35,6 +35,8 @@
href="alarms/repeated/{alarm.id}"
class="list-group-item list-group-item-action"
class:active={$page.params.kind === "repeated" && $page.params.aid === alarm.id}
class:text-muted={alarm.disabled}
style:text-decoration={alarm.disabled?"line-through":null}
>
Les {weekdayStr(alarm.weekday)}s à {alarm.time}
</a>

View File

@ -118,6 +118,10 @@
<ListGroupItem>
<strong>Heure du réveil</strong> {alarm.time}
</ListGroupItem>
<ListGroupItem class="d-flex">
<strong>Alarme active&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.disabled = !obj.disabled; obj.save().then(() => {obj.next_time = null; alarmsRepeated.refresh()});}} checked={!obj.disabled} /> {!obj.disabled?"oui":"non"}
</ListGroupItem>
<ListGroupItem class="d-flex">
<strong>Ignorer les exceptions&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.ignore_exceptions = !obj.ignore_exceptions; obj.save();}} checked={obj.ignore_exceptions} /> {obj.ignore_exceptions?"oui":"non"}