From ab977666e04879b082b5256a1316b95cbc52d30a Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 4 Jun 2021 23:01:26 +0300 Subject: [PATCH] + apache restart monitor --- src/components/ApacheRestartMonitor.vue | 65 +++++++++++++++++++++++++ src/store/index.js | 2 + src/store/modules/apache_restart.js | 19 ++++++-- src/store/modules/infobases.js | 2 +- src/views/Home.vue | 5 +- 5 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 src/components/ApacheRestartMonitor.vue diff --git a/src/components/ApacheRestartMonitor.vue b/src/components/ApacheRestartMonitor.vue new file mode 100644 index 0000000..82dd3fd --- /dev/null +++ b/src/components/ApacheRestartMonitor.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/store/index.js b/src/store/index.js index b7dee6a..e970f2f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,9 +1,11 @@ import { createStore } from "vuex"; import infobases from "@/store/modules/infobases.js"; +import apache_restart from "@/store/modules/apache_restart.js"; export default createStore({ modules: { infobases, + apache_restart, }, }); diff --git a/src/store/modules/apache_restart.js b/src/store/modules/apache_restart.js index 2c4f7ea..70a8317 100644 --- a/src/store/modules/apache_restart.js +++ b/src/store/modules/apache_restart.js @@ -4,19 +4,24 @@ import config from "@/config.js"; const api_base = config.api; +const pass = (some) => some + export default { state: { apache_need_restart: false, restart_flag: false, + flag_sent: false, }, mutations: { setApacheNeedRestart(state) { state.apache_need_restart = true; - console.log("restart need"); }, setApacheRestartFlag(state, flag) { state.restart_flag = flag; }, + setApacheRestartFlagSent(state, flag) { + state.flag_sent = flag; + }, }, actions: { async fetchApacheRestartFlag(ctx) { @@ -25,6 +30,10 @@ export default { ctx.commit("setApacheRestartFlag", true); } catch (err) { ctx.commit("setApacheRestartFlag", false); + if (ctx.getters.isApacheRestartFlagSent) { + ctx.commit("setApacheNeedRestart", false); + ctx.commit("setApacheRestartFlagSent", false); + } } }, async updateApacheRestartFlag(ctx) { @@ -37,8 +46,9 @@ export default { try { await axios.put(`${api_base}/apache-restart`); ctx.commit("setApacheRestartFlag", true); - } catch (err) { - ctx.commit("setApacheRestartFlag", false); + ctx.commit("setApacheRestartFlagSent", true); + } catch(err) { + pass() } }, }, @@ -49,5 +59,8 @@ export default { isApacheRestartPending(state) { return state.restart_flag; }, + isApacheRestartFlagSent(state) { + return state.flag_sent; + }, }, }; diff --git a/src/store/modules/infobases.js b/src/store/modules/infobases.js index 8abd31c..8d6c13f 100644 --- a/src/store/modules/infobases.js +++ b/src/store/modules/infobases.js @@ -63,7 +63,7 @@ export default { state.infobases.splice(idx, 1); setInfobaseLock(state, { name, lock: false }); } else { - infobase.publicated = true; + //infobase.publicated = true; // debug state.infobases[idx] = infobase; } } diff --git a/src/views/Home.vue b/src/views/Home.vue index 293e4b2..599c283 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,6 +1,7 @@ @@ -8,11 +9,13 @@ // @ is an alias to /src //import HelloWorld from "@/components/HelloWorld.vue"; import InfobaseList from "@/components/InfobaseList.vue"; +import ApacheRestartMonitor from "@/components/ApacheRestartMonitor.vue"; export default { name: "Home", components: { InfobaseList, + ApacheRestartMonitor, }, };