This commit is contained in:
parent
f8cf26eee3
commit
e10e00f222
@ -24,8 +24,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
performPostAndEverything(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.actionPending = true
|
||||
this.$api.post(url).then(() => this.actionPending = false).catch((error) => {
|
||||
this.$api.post(url).then(() => {
|
||||
this.actionPending = false
|
||||
resolve()
|
||||
}).catch((error) => {
|
||||
if (!error.response) {
|
||||
// network error happened
|
||||
this.$showToast("Some network error happened.\nCheck logs!")
|
||||
@ -35,13 +39,19 @@ export default {
|
||||
}
|
||||
|
||||
this.actionPending = false
|
||||
});
|
||||
reject()
|
||||
})
|
||||
})
|
||||
},
|
||||
allOnline() {
|
||||
this.performPostAndEverything("/devices/online")
|
||||
this.performPostAndEverything("/devices/online").then(() => {
|
||||
this.$showToast("Global online command issued", "success")
|
||||
})
|
||||
},
|
||||
allOffline() {
|
||||
this.performPostAndEverything("/devices/offline")
|
||||
this.performPostAndEverything("/devices/offline").then(() => {
|
||||
this.$showToast("Global offline command issued", "success")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,13 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
performPostAndEverything(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.actionPending = true
|
||||
this.$api.post(url).then(() => this.actionPending = false).catch((error) => {
|
||||
this.$api.post(url).then(() => {
|
||||
this.actionPending = false
|
||||
resolve()
|
||||
}).catch((error) => {
|
||||
|
||||
if (!error.response) {
|
||||
// network error happened
|
||||
this.$showToast("Some network error happened.\nCheck logs!")
|
||||
@ -46,13 +51,19 @@ export default {
|
||||
}
|
||||
|
||||
this.actionPending = false
|
||||
});
|
||||
reject()
|
||||
})
|
||||
})
|
||||
},
|
||||
bringOffline() {
|
||||
this.performPostAndEverything(`/devices/${this.device_id}/offline`)
|
||||
this.performPostAndEverything(`/devices/${this.device_id}/offline`).then(()=> {
|
||||
this.$showToast("Offline command issued!", "success")
|
||||
})
|
||||
},
|
||||
bringOnline() {
|
||||
this.performPostAndEverything(`/devices/${this.device_id}/online`)
|
||||
this.performPostAndEverything(`/devices/${this.device_id}/online`).then(() => {
|
||||
this.$showToast("Online command issued!", "success")
|
||||
})
|
||||
},
|
||||
doManualAlert() {
|
||||
this.performPostAndEverything(`/devices/${this.device_id}/alert`)
|
||||
|
Loading…
Reference in New Issue
Block a user