This commit is contained in:
		@@ -24,24 +24,34 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    performPostAndEverything(url) {
 | 
					    performPostAndEverything(url) {
 | 
				
			||||||
      this.actionPending = true
 | 
					      return new Promise((resolve, reject) => {
 | 
				
			||||||
      this.$api.post(url).then(() => this.actionPending = false).catch((error) => {
 | 
					        this.actionPending = true
 | 
				
			||||||
        if (!error.response) {
 | 
					        this.$api.post(url).then(() => {
 | 
				
			||||||
          // network error happened
 | 
					          this.actionPending = false
 | 
				
			||||||
          this.$showToast("Some network error happened.\nCheck logs!")
 | 
					          resolve()
 | 
				
			||||||
        } else {
 | 
					        }).catch((error) => {
 | 
				
			||||||
          // server returned bruh moment
 | 
					          if (!error.response) {
 | 
				
			||||||
          this.$showToast(`The server returned error: ${error.response.status} ${error.response.statusText}\n${error.response.data}`)
 | 
					            // network error happened
 | 
				
			||||||
        }
 | 
					            this.$showToast("Some network error happened.\nCheck logs!")
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            // server returned bruh moment
 | 
				
			||||||
 | 
					            this.$showToast(`The server returned error: ${error.response.status} ${error.response.statusText}\n${error.response.data}`)
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.actionPending = false
 | 
					          this.actionPending = false
 | 
				
			||||||
      });
 | 
					          reject()
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    allOnline() {
 | 
					    allOnline() {
 | 
				
			||||||
      this.performPostAndEverything("/devices/online")
 | 
					      this.performPostAndEverything("/devices/online").then(() => {
 | 
				
			||||||
 | 
					        this.$showToast("Global online command issued", "success")
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    allOffline() {
 | 
					    allOffline() {
 | 
				
			||||||
      this.performPostAndEverything("/devices/offline")
 | 
					      this.performPostAndEverything("/devices/offline").then(() => {
 | 
				
			||||||
 | 
					        this.$showToast("Global offline command issued", "success")
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,24 +35,35 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    performPostAndEverything(url) {
 | 
					    performPostAndEverything(url) {
 | 
				
			||||||
      this.actionPending = true
 | 
					      return new Promise((resolve, reject) => {
 | 
				
			||||||
      this.$api.post(url).then(() => this.actionPending = false).catch((error) => {
 | 
					        this.actionPending = true
 | 
				
			||||||
        if (!error.response) {
 | 
					        this.$api.post(url).then(() => {
 | 
				
			||||||
          // network error happened
 | 
					          this.actionPending = false
 | 
				
			||||||
          this.$showToast("Some network error happened.\nCheck logs!")
 | 
					          resolve()
 | 
				
			||||||
        } else {
 | 
					        }).catch((error) => {
 | 
				
			||||||
          // server returned bruh moment
 | 
					 | 
				
			||||||
          this.$showToast(`The server returned error: ${error.response.status} ${error.response.statusText}\n${error.response.data}`)
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.actionPending = false
 | 
					          if (!error.response) {
 | 
				
			||||||
      });
 | 
					            // network error happened
 | 
				
			||||||
 | 
					            this.$showToast("Some network error happened.\nCheck logs!")
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            // server returned bruh moment
 | 
				
			||||||
 | 
					            this.$showToast(`The server returned error: ${error.response.status} ${error.response.statusText}\n${error.response.data}`)
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          this.actionPending = false
 | 
				
			||||||
 | 
					          reject()
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    bringOffline() {
 | 
					    bringOffline() {
 | 
				
			||||||
      this.performPostAndEverything(`/devices/${this.device_id}/offline`)
 | 
					      this.performPostAndEverything(`/devices/${this.device_id}/offline`).then(()=> {
 | 
				
			||||||
 | 
					        this.$showToast("Offline command issued!", "success")
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    bringOnline() {
 | 
					    bringOnline() {
 | 
				
			||||||
      this.performPostAndEverything(`/devices/${this.device_id}/online`)
 | 
					      this.performPostAndEverything(`/devices/${this.device_id}/online`).then(() => {
 | 
				
			||||||
 | 
					        this.$showToast("Online command issued!", "success")
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    doManualAlert() {
 | 
					    doManualAlert() {
 | 
				
			||||||
      this.performPostAndEverything(`/devices/${this.device_id}/alert`)
 | 
					      this.performPostAndEverything(`/devices/${this.device_id}/alert`)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user