In-page addition of datapoints to triggers
This commit is contained in:
parent
68abb894a6
commit
adab2ab67d
2 changed files with 49 additions and 5 deletions
|
|
@ -66,7 +66,7 @@ export class UI {
|
|||
})
|
||||
.catch(err => alert(err))
|
||||
}//}}}
|
||||
chooseDatapoint() {//{{{
|
||||
async chooseDatapoint() {//{{{
|
||||
const dlg = document.getElementById('dlg-datapoints')
|
||||
const datapoint = document.getElementById('datapoint').value
|
||||
const dp = this.datapoints.find(dp => dp.Name == datapoint)
|
||||
|
|
@ -77,8 +77,10 @@ export class UI {
|
|||
}
|
||||
|
||||
this.trigger.addDatapoint(dp)
|
||||
dlg.close()
|
||||
this.render()
|
||||
.then(() => {
|
||||
dlg.close()
|
||||
this.render()
|
||||
})
|
||||
}//}}}
|
||||
deleteDatapoint(name) {//{{{
|
||||
if (!confirm(`Delete ${name}?`)) {
|
||||
|
|
@ -147,7 +149,15 @@ export class Trigger {
|
|||
})
|
||||
.catch(err => alert(err))
|
||||
}//}}}
|
||||
addDatapoint(dp) {//{{{
|
||||
this.datapoints[dp.Name] = dp
|
||||
async addDatapoint(dp) {//{{{
|
||||
return fetch(`/trigger/addDatapoint/${this.id}/${dp.Name}`)
|
||||
.then(data => data.json())
|
||||
.then(json => {
|
||||
if (!json.OK) {
|
||||
alert(json.Error)
|
||||
return
|
||||
}
|
||||
this.datapoints[dp.Name] = dp
|
||||
})
|
||||
}//}}}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue