58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
import axios from "axios";
|
|
|
|
import config from "@/config.js";
|
|
|
|
const api_base = config.api;
|
|
|
|
const pass = () => {};
|
|
|
|
export default {
|
|
state: {
|
|
apache_need_restart: false,
|
|
restart_flag: false,
|
|
},
|
|
mutations: {
|
|
setApacheNeedRestart(state) {
|
|
state.apache_need_restart = true;
|
|
},
|
|
setApacheRestartFlag(state, flag) {
|
|
if (state.restart_flag && !flag) {
|
|
state.apache_need_restart = false;
|
|
}
|
|
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) {
|
|
pass();
|
|
}
|
|
},
|
|
},
|
|
getters: {
|
|
isApacheNeedRestart(state) {
|
|
return state.apache_need_restart;
|
|
},
|
|
isApacheRestartPending(state) {
|
|
return state.restart_flag;
|
|
},
|
|
},
|
|
};
|