Implement alarm sound
This commit is contained in:
parent
b24df8b0d8
commit
8faa21ccab
15 changed files with 531 additions and 50 deletions
46
ui/src/lib/alarm.js
Normal file
46
ui/src/lib/alarm.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
export async function isAlarmActive() {
|
||||
const res = await fetch('api/alarm', {
|
||||
headers: {'Accept': 'application/json'},
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runAlarm() {
|
||||
const res = await fetch('api/alarm/run', {
|
||||
method: 'POST',
|
||||
headers: {'Accept': 'application/json'},
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function alarmNextTrack() {
|
||||
const res = await fetch('api/alarm/next', {
|
||||
method: 'POST',
|
||||
headers: {'Accept': 'application/json'},
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function alarmStop() {
|
||||
const res = await fetch('api/alarm', {
|
||||
method: 'DELETE',
|
||||
headers: {'Accept': 'application/json'},
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue