Compare commits
3 Commits
f8be28744c
...
5526940e61
Author | SHA1 | Date | |
---|---|---|---|
5526940e61 | |||
45efc3601e | |||
51a52fcb8e |
@ -149,6 +149,7 @@ type AlarmRepeated struct {
|
|||||||
FollowingRoutines []Identifier `json:"routines"`
|
FollowingRoutines []Identifier `json:"routines"`
|
||||||
IgnoreExceptions bool `json:"ignore_exceptions"`
|
IgnoreExceptions bool `json:"ignore_exceptions"`
|
||||||
Comment string `json:"comment,omitempty"`
|
Comment string `json:"comment,omitempty"`
|
||||||
|
Disabled bool `json:"disabled,omitempty"`
|
||||||
Excepts Exceptions `json:"excepts,omitempty"`
|
Excepts Exceptions `json:"excepts,omitempty"`
|
||||||
NextTime *time.Time `json:"next_time,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 {
|
func (a *AlarmRepeated) GetNextOccurence(cfg *config.Config, db *LevelDBStorage) *time.Time {
|
||||||
|
if a.Disabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if len(a.Excepts) == 0 {
|
if len(a.Excepts) == 0 {
|
||||||
a.FillExcepts(cfg, db)
|
a.FillExcepts(cfg, db)
|
||||||
}
|
}
|
||||||
@ -239,16 +244,19 @@ func GetAlarmsRepeated(db *LevelDBStorage) (alarms []*AlarmRepeated, err error)
|
|||||||
|
|
||||||
func PutAlarmRepeated(db *LevelDBStorage, alarm *AlarmRepeated) (err error) {
|
func PutAlarmRepeated(db *LevelDBStorage, alarm *AlarmRepeated) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-repeated-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-repeated-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-repeated-%s", alarm.Id.ToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.Id = id
|
|
||||||
// Don't store this, this is autocalculated
|
// Don't store this, this is autocalculated
|
||||||
alarm.Excepts = nil
|
alarm.Excepts = nil
|
||||||
alarm.NextTime = nil
|
alarm.NextTime = nil
|
||||||
@ -293,17 +301,19 @@ func GetAlarmsSingle(db *LevelDBStorage) (alarms []*AlarmSingle, err error) {
|
|||||||
|
|
||||||
func PutAlarmSingle(db *LevelDBStorage, alarm *AlarmSingle) (err error) {
|
func PutAlarmSingle(db *LevelDBStorage, alarm *AlarmSingle) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-single-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-single-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-single-%s", alarm.Id.ToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.Id = id
|
|
||||||
|
|
||||||
return db.put(key, alarm)
|
return db.put(key, alarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,17 +373,19 @@ func GetAlarmExceptions(db *LevelDBStorage) (alarms []*AlarmException, err error
|
|||||||
|
|
||||||
func PutAlarmException(db *LevelDBStorage, alarm *AlarmException) (err error) {
|
func PutAlarmException(db *LevelDBStorage, alarm *AlarmException) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-exception-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-exception-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-exception-%s", alarm.Id.ToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.Id = id
|
|
||||||
|
|
||||||
return db.put(key, alarm)
|
return db.put(key, alarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,18 @@ 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.id = id;
|
||||||
this.weekday = weekday;
|
this.weekday = weekday;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.routines = routines == null ? [] : routines;
|
this.routines = routines == null ? [] : routines;
|
||||||
this.ignore_exceptions = ignore_exceptions;
|
this.ignore_exceptions = ignore_exceptions;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.excepts = excepts;
|
this.disabled = disabled == true;
|
||||||
this.next_time = next_time;
|
if (excepts !== undefined)
|
||||||
|
this.excepts = excepts;
|
||||||
|
if (next_time !== undefined)
|
||||||
|
this.next_time = next_time;
|
||||||
|
|
||||||
if (this.routines.length < 1) {
|
if (this.routines.length < 1) {
|
||||||
this.routines.push("");
|
this.routines.push("");
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
href="alarms/repeated/{alarm.id}"
|
href="alarms/repeated/{alarm.id}"
|
||||||
class="list-group-item list-group-item-action"
|
class="list-group-item list-group-item-action"
|
||||||
class:active={$page.params.kind === "repeated" && $page.params.aid === alarm.id}
|
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}
|
Les {weekdayStr(alarm.weekday)}s à {alarm.time}
|
||||||
</a>
|
</a>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
Col,
|
Col,
|
||||||
Container,
|
Container,
|
||||||
Icon,
|
Icon,
|
||||||
|
Input,
|
||||||
ListGroup,
|
ListGroup,
|
||||||
ListGroupItem,
|
ListGroupItem,
|
||||||
Row,
|
Row,
|
||||||
@ -117,12 +118,17 @@
|
|||||||
<ListGroupItem>
|
<ListGroupItem>
|
||||||
<strong>Heure du réveil</strong> {alarm.time}
|
<strong>Heure du réveil</strong> {alarm.time}
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
<ListGroupItem>
|
<ListGroupItem class="d-flex">
|
||||||
<strong>Ignorer les exceptions ?</strong> {alarm.ignore_exceptions?"oui":"non"}
|
<strong>Alarme active ?</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 ?</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>
|
||||||
{#if alarm.next_time}
|
{#if alarm.next_time}
|
||||||
<ListGroupItem>
|
<ListGroupItem>
|
||||||
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(alarm.next_time)} dateStyle="long" />
|
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(obj.next_time)} dateStyle="long" />
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
{/if}
|
{/if}
|
||||||
</ListGroup>
|
</ListGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user