Working on next alarm retrieval
This commit is contained in:
parent
6e54ad1a87
commit
9a06d04ce0
8 changed files with 261 additions and 40 deletions
|
|
@ -5,13 +5,15 @@ export class AlarmRepeated {
|
|||
}
|
||||
}
|
||||
|
||||
update({ id, weekday, time, routines, ignore_exceptions, comment }) {
|
||||
update({ id, weekday, time, routines, ignore_exceptions, comment, excepts, next_time }) {
|
||||
this.id = id;
|
||||
this.weekday = weekday;
|
||||
this.time = time;
|
||||
this.routines = routines;
|
||||
this.ignore_exceptions = ignore_exceptions;
|
||||
this.comment = comment;
|
||||
this.excepts = excepts;
|
||||
this.next_time = next_time;
|
||||
}
|
||||
|
||||
async delete() {
|
||||
|
|
|
|||
|
|
@ -61,3 +61,28 @@ export async function getAlarmSingle(aid) {
|
|||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getNextAlarm() {
|
||||
const res = await fetch(`api/alarms/next`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return new Date(await res.json());
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function newNCyclesAlarm(nCycles) {
|
||||
const res = await fetch('api/alarms/single', {
|
||||
method: 'POST',
|
||||
headers: {'Accept': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
time: new Date(Date.now() + 600000 + 5400000 * nCycles)
|
||||
}),
|
||||
});
|
||||
if (res.status == 200) {
|
||||
const data = await res.json();
|
||||
return new AlarmSingle(data);
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue