From 5ece6028d57ecf5b970d249e8ed35b70f32b23fb Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Mon, 6 Jul 2020 18:01:10 -0400 Subject: [PATCH] improve net stop --- src/_store/networks.module.js | 7 +++++-- src/account/NetworkPage.vue | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/_store/networks.module.js b/src/_store/networks.module.js index dc83766..c8c76e1 100644 --- a/src/_store/networks.module.js +++ b/src/_store/networks.module.js @@ -90,7 +90,7 @@ const actions = { commit('stopNetworkRequest', networkId); networkService.stopNetwork(userId, networkId, messages, errors) .then( - network => commit('stopNetworkSuccess', network), + ok => commit('stopNetworkSuccess', {networkId, ok}), error => commit('stopNetworkFailure', { networkId, error: error.toString() }) ); }, @@ -204,8 +204,11 @@ const mutations = { stopNetworkRequest(state, id) { state.loading.stopping = true; }, - stopNetworkSuccess(state, id) { + stopNetworkSuccess(state, { networkId, ok }) { state.loading.stopping = false; + if (state.network && state.network.uuid && state.network.uuid === networkId) { + state.network.state = 'stopping'; + } }, stopNetworkFailure(state, { id, error }) { state.loading.stopping = false; diff --git a/src/account/NetworkPage.vue b/src/account/NetworkPage.vue index d463c51..34cc75c 100644 --- a/src/account/NetworkPage.vue +++ b/src/account/NetworkPage.vue @@ -168,20 +168,22 @@ this.refresher = setInterval(() => this.refreshStatus(user.uuid), 5000); }, stopNet () { - const vue = this; - if (confirm(vue.messages.confirmation_network_action_stop)) { - this.errors.clear(); - this.stopNetwork({ - userId: this.user.uuid, - networkId: this.networkId, - messages: this.messages, - errors: this.errors - }); + if (this.networkUuid === null) { + alert(this.messages.network_action_stop_not_ready); + } else { + if (confirm(this.messages.confirmation_network_action_stop)) { + this.errors.clear(); + this.stopNetwork({ + userId: this.user.uuid, + networkId: this.networkUuid, + messages: this.messages, + errors: this.errors + }); + } } }, deleteNet () { - const vue = this; - if (confirm(vue.messages.confirmation_network_action_delete)) { + if (confirm(this.messages.confirmation_network_action_delete)) { this.errors.clear(); this.deleteNetwork({ userId: this.user.uuid,