ui: Can enable federation on alarms

This commit is contained in:
nemunaire 2024-07-25 19:03:21 +02:00
parent 3a6187d791
commit 435d1d8f98
5 changed files with 19 additions and 2 deletions

View File

@ -152,6 +152,7 @@ type AlarmRepeated struct {
Disabled bool `json:"disabled,omitempty"`
Excepts Exceptions `json:"excepts,omitempty"`
NextTime *time.Time `json:"next_time,omitempty"`
EnableFederation bool `json:"enable_federation,omitempty"`
}
func (a *AlarmRepeated) FillExcepts(cfg *config.Config, db *LevelDBStorage) error {
@ -273,6 +274,7 @@ type AlarmSingle struct {
Time time.Time `json:"time"`
FollowingRoutines []Identifier `json:"routines"`
Comment string `json:"comment,omitempty"`
EnableFederation bool `json:"enable_federation,omitempty"`
}
func GetAlarmSingle(db *LevelDBStorage, id Identifier) (alarm *AlarmSingle, err error) {

View File

@ -5,7 +5,7 @@ export class AlarmRepeated {
}
}
update({ id, weekday, time, routines, disabled, ignore_exceptions, comment, excepts, next_time }) {
update({ id, weekday, time, routines, disabled, ignore_exceptions, comment, excepts, next_time, enable_federation }) {
this.id = id;
this.weekday = weekday;
this.time = time;
@ -13,6 +13,7 @@ export class AlarmRepeated {
this.ignore_exceptions = ignore_exceptions;
this.comment = comment;
this.disabled = disabled == true;
this.enable_federation = enable_federation == true;
if (excepts !== undefined)
this.excepts = excepts;
if (next_time !== undefined)

View File

@ -5,11 +5,12 @@ export class AlarmSingle {
}
}
update({ id, time, routines, comment }) {
update({ id, time, routines, comment, enable_federation }) {
this.id = id;
this.time = new Date(time);
this.routines = routines == null ? [] : routines;
this.comment = comment;
this.enable_federation = enable_federation == true;
if (this.routines.length < 1) {
this.routines.push("");

View File

@ -95,6 +95,10 @@
<ListGroupItem>
<strong>Heure du réveil</strong> <DateFormat date={alarm.time} timeStyle="long" />
</ListGroupItem>
<ListGroupItem class="d-flex">
<strong>Fédération activée&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"}
</ListGroupItem>
</ListGroup>
{/await}
{:else if $page.params["kind"] == "repeated"}
@ -126,6 +130,10 @@
<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"}
</ListGroupItem>
<ListGroupItem class="d-flex">
<strong>Fédération activée&nbsp;?</strong>
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"}
</ListGroupItem>
{#if alarm.next_time}
<ListGroupItem>
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(obj.next_time)} dateStyle="long" />

View File

@ -154,6 +154,11 @@
<Input id="exceptionEnd" type="date" required bind:value={obj.end} />
</FormGroup>
{/if}
{#if $page.params["kind"] != "exceptions"}
<FormGroup>
<Input id="enable_federation" type="checkbox" label="Activer la fédération" bind:checked={obj.enable_federation} />
</FormGroup>
{/if}
<FormGroup>
<Label for="comment">Commentaire</Label>