monitor update in background
This commit is contained in:
parent
841e7bc68e
commit
47a594dda2
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="bounce">
|
<transition name="bounce">
|
||||||
<div
|
<div
|
||||||
v-if="isApacheNeedRestart || isApacheRestartPending"
|
v-if="isActive"
|
||||||
class="
|
class="
|
||||||
container
|
container
|
||||||
d-flex
|
d-flex
|
||||||
@ -54,14 +54,44 @@
|
|||||||
import { mapGetters, mapActions } from "vuex";
|
import { mapGetters, mapActions } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: mapGetters([
|
data: () => ({
|
||||||
|
is_locked: false,
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapGetters([
|
||||||
"isApacheNeedRestart",
|
"isApacheNeedRestart",
|
||||||
"isApacheRestartPending",
|
"isApacheRestartPending",
|
||||||
"isApacheRestartFlagSent",
|
"isApacheRestartFlagSent",
|
||||||
]),
|
]),
|
||||||
methods: mapActions(["updateApacheRestartFlag", "fetchApacheRestartFlag"]),
|
isActive() {
|
||||||
async updated() {
|
return this.isApacheNeedRestart || this.isApacheRestartPending;
|
||||||
this.fetchApacheRestartFlag();
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(["updateApacheRestartFlag", "fetchApacheRestartFlag"]),
|
||||||
|
async monitor_status() {
|
||||||
|
if (this.is_locked) return;
|
||||||
|
this.is_locked = true;
|
||||||
|
|
||||||
|
while (this.isActive) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
await this.fetchApacheRestartFlag();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.is_locked = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
"$store.getters.isApacheNeedRestart": function () {
|
||||||
|
this.monitor_status();
|
||||||
|
},
|
||||||
|
"$store.getters.isApacheRestartPending": function () {
|
||||||
|
this.monitor_status();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
if (this.isActive) await this.monitor_status();
|
||||||
|
else await this.fetchApacheRestartFlag();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,7 +4,7 @@ import config from "@/config.js";
|
|||||||
|
|
||||||
const api_base = config.api;
|
const api_base = config.api;
|
||||||
|
|
||||||
const pass = (some) => some
|
const pass = () => {};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
@ -47,8 +47,8 @@ export default {
|
|||||||
await axios.put(`${api_base}/apache-restart`);
|
await axios.put(`${api_base}/apache-restart`);
|
||||||
ctx.commit("setApacheRestartFlag", true);
|
ctx.commit("setApacheRestartFlag", true);
|
||||||
ctx.commit("setApacheRestartFlagSent", true);
|
ctx.commit("setApacheRestartFlagSent", true);
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
pass()
|
pass();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user