apache_restart store

This commit is contained in:
Dmitry Belyaev 2021-06-04 16:54:20 +03:00
parent f789ac487b
commit b413cc312d
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
3 changed files with 56 additions and 1 deletions

View File

@ -84,7 +84,6 @@ export default {
}, },
computed: mapGetters([ computed: mapGetters([
"allInfobases", "allInfobases",
"getInfobaseByName",
"isLoading", "isLoading",
"isLoadingError", "isLoadingError",
"errorMessage", "errorMessage",

View File

@ -0,0 +1,53 @@
import axios from "axios";
import config from "@/config.js";
const api_base = config.api;
export default {
state: {
apache_need_restart: false,
restart_flag: false,
},
mutations: {
setApacheNeedRestart(state) {
state.apache_need_restart = true;
console.log("restart need");
},
setApacheRestartFlag(state, flag) {
state.restart_flag = flag;
},
},
actions: {
async fetchApacheRestartFlag(ctx) {
try {
await axios.get(`${api_base}/apache-restart`);
ctx.commit("setApacheRestartFlag", true);
} catch (err) {
ctx.commit("setApacheRestartFlag", false);
}
},
async updateApacheRestartFlag(ctx) {
if (
ctx.getters.isApacheRestartPending ||
!ctx.getters.isApacheNeedRestart
) {
return;
}
try {
await axios.put(`${api_base}/apache-restart`);
ctx.commit("setApacheRestartFlag", true);
} catch (err) {
ctx.commit("setApacheRestartFlag", false);
}
},
},
getters: {
isApacheNeedRestart(state) {
return state.apache_need_restart;
},
isApacheRestartPending(state) {
return state.restart_flag;
},
},
};

View File

@ -131,6 +131,7 @@ export default {
try { try {
await axios.post(`${api_base}/publications`, data); await axios.post(`${api_base}/publications`, data);
ctx.commit("setInfobaseURL", { name, url }); ctx.commit("setInfobaseURL", { name, url });
ctx.commit("setApacheNeedRestart", null, { root: true });
ctx.commit("setErrorMessage", ""); ctx.commit("setErrorMessage", "");
} catch (err) { } catch (err) {
ctx.commit("setErrorMessage", `Ошибка обновления URL для базы ${name}`); ctx.commit("setErrorMessage", `Ошибка обновления URL для базы ${name}`);
@ -146,6 +147,7 @@ export default {
try { try {
await axios.put(`${api_base}/publications`, { id: name, name }); await axios.put(`${api_base}/publications`, { id: name, name });
ctx.commit("setErrorMessage", ""); ctx.commit("setErrorMessage", "");
ctx.commit("setApacheNeedRestart", null, { root: true });
ctx.dispatch("fetchInfobase", name); ctx.dispatch("fetchInfobase", name);
} catch (err) { } catch (err) {
ctx.commit("setErrorMessage", `Ошибка публикации базы ${name}`); ctx.commit("setErrorMessage", `Ошибка публикации базы ${name}`);
@ -160,6 +162,7 @@ export default {
try { try {
await axios.delete(`${api_base}/publications/${name}`); await axios.delete(`${api_base}/publications/${name}`);
ctx.commit("setErrorMessage", ""); ctx.commit("setErrorMessage", "");
ctx.commit("setApacheNeedRestart", null, { root: true });
ctx.dispatch("fetchInfobase", name); ctx.dispatch("fetchInfobase", name);
} catch (err) { } catch (err) {
ctx.commit("setErrorMessage", `Ошибка отмены публикации базы ${name}`); ctx.commit("setErrorMessage", `Ошибка отмены публикации базы ${name}`);