Skip to content

Commit

Permalink
Update Homescript data on automation edit
Browse files Browse the repository at this point in the history
  • Loading branch information
MikMuellerDev committed May 15, 2022
1 parent 15cebf7 commit 24fdfc6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions web/src/pages/automations/Automation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
}
interface timeDataType {
interface timeDataType {
hours: number
minutes: number
days: number[]
Expand All @@ -47,7 +47,7 @@
async function modifyAutomation(id: number, payload: addAutomation) {
$loading = true
try {
payload["id"] = id
payload['id'] = id
const res = await (
await fetch('/api/automation/modify', {
method: 'PUT',
Expand All @@ -56,7 +56,16 @@
})
).json()
if (!res.success) throw Error(res.error)
data.cronExpression = generateCronExpression(payload.hour, payload.minute, payload.days)
data.cronExpression = generateCronExpression(
payload.hour,
payload.minute,
payload.days
)
const homescriptDataTemp = $homescripts.find(
(s) => s.data.id === data.homescriptId
)
if (homescriptDataTemp !== undefined)
homescriptData = homescriptDataTemp
} catch (err) {
$createSnackbar(`Could not modify automation: ${err}`)
}
Expand Down Expand Up @@ -100,7 +109,7 @@
<div class="top">
<span class="automation__name">{data.name}</span>
<span class="automation__time">
At
At
{timeString}
<!-- {timeData.hours.toString().padStart(2, "0")}:{timeData.minutes.toString().padStart(2, "0")} -->
{#if timeData.days.length === 7}
Expand Down

0 comments on commit 24fdfc6

Please sign in to comment.