Merge branch 'master'

# Conflicts:
#	src/components/InfobaseURLEditor.vue
This commit is contained in:
Dmitry Belyaev 2021-06-07 13:49:37 +03:00
commit 12542a6d82
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
8 changed files with 118 additions and 13 deletions

View File

@ -0,0 +1,65 @@
<template>
<div
v-if="isApacheNeedRestart || isApacheRestartPending"
class="
container
d-flex
flex-row
rounded
bg-warning bg-gradient
shadow
p-3
mt-lg-5
w-50
"
>
<span class="fw-bold m-auto me-2">Apache: </span>
<span
v-if="isApacheNeedRestart && !isApacheRestartPending"
class="badge rounded-pill bg-danger m-auto"
>Нужен перезапуск</span
>
<span
v-if="isApacheRestartPending"
class="badge rounded-pill bg-success m-auto"
>Перезапуск</span
>
<span class="flex-fill"></span>
<button
v-if="isApacheRestartPending"
type="button"
class="btn btn-success btn-sm align-self-end shadow"
@click.prevent="fetchApacheRestartFlag"
title="Обновить статус"
v-tooltip:top
>
Обновить
</button>
<button
v-if="isApacheNeedRestart && !isApacheRestartPending"
type="button"
class="btn btn-danger btn-sm align-self-end shadow"
@click.prevent="updateApacheRestartFlag"
title="Перезапустить Apache"
v-tooltip:top
>
Перезапустить
</button>
</div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
export default {
computed: mapGetters([
"isApacheNeedRestart",
"isApacheRestartPending",
"isApacheRestartFlagSent",
]),
methods: mapActions(["updateApacheRestartFlag", "fetchApacheRestartFlag"]),
async updated() {
this.fetchApacheRestartFlag();
},
};
</script>

View File

@ -46,7 +46,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<InfobaseListItem <tr
v-is="'InfobaseListItem'"
v-for="(infobase, index) in allInfobases" v-for="(infobase, index) in allInfobases"
:key="infobase.name" :key="infobase.name"
:infobase="infobase" :infobase="infobase"

View File

@ -1,7 +1,14 @@
<template> <template>
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div class="input-group shadow" role="group"> <div class="input-group shadow" role="group">
<input type="text" v-model="url" class="form-control" ref="input" /> <input
type="text"
v-model.lazy="url"
@keyup.enter="submit"
@keyup.esc="cancel"
class="form-control"
ref="input"
/>
<button <button
type="submit" type="submit"
class="btn btn-sm btn-outline-primary" class="btn btn-sm btn-outline-primary"

View File

@ -11,18 +11,32 @@ window.jQuery = window.$ = require("jquery");
const app = createApp(App).use(store).use(router); const app = createApp(App).use(store).use(router);
const pass = () => {};
app.directive("tooltip", { app.directive("tooltip", {
mounted(el, binding) { mounted(el, binding) {
try {
window.$(el).tooltip({ window.$(el).tooltip({
placement: binding.arg, placement: binding.arg,
trigger: "hover", trigger: "hover",
}); });
} catch {
pass();
}
}, },
updated(el) { updated(el) {
try {
window.$(el).tooltip("update"); window.$(el).tooltip("update");
} catch {
pass();
}
}, },
unmounted(el) { unmounted(el) {
try {
window.$(el).tooltip("dispose"); window.$(el).tooltip("dispose");
} catch {
pass();
}
}, },
}); });

View File

@ -1,9 +1,11 @@
import { createStore } from "vuex"; import { createStore } from "vuex";
import infobases from "@/store/modules/infobases.js"; import infobases from "@/store/modules/infobases.js";
import apache_restart from "@/store/modules/apache_restart.js";
export default createStore({ export default createStore({
modules: { modules: {
infobases, infobases,
apache_restart,
}, },
}); });

View File

@ -4,19 +4,24 @@ import config from "@/config.js";
const api_base = config.api; const api_base = config.api;
const pass = (some) => some
export default { export default {
state: { state: {
apache_need_restart: false, apache_need_restart: false,
restart_flag: false, restart_flag: false,
flag_sent: false,
}, },
mutations: { mutations: {
setApacheNeedRestart(state) { setApacheNeedRestart(state) {
state.apache_need_restart = true; state.apache_need_restart = true;
console.log("restart need");
}, },
setApacheRestartFlag(state, flag) { setApacheRestartFlag(state, flag) {
state.restart_flag = flag; state.restart_flag = flag;
}, },
setApacheRestartFlagSent(state, flag) {
state.flag_sent = flag;
},
}, },
actions: { actions: {
async fetchApacheRestartFlag(ctx) { async fetchApacheRestartFlag(ctx) {
@ -25,6 +30,10 @@ export default {
ctx.commit("setApacheRestartFlag", true); ctx.commit("setApacheRestartFlag", true);
} catch (err) { } catch (err) {
ctx.commit("setApacheRestartFlag", false); ctx.commit("setApacheRestartFlag", false);
if (ctx.getters.isApacheRestartFlagSent) {
ctx.commit("setApacheNeedRestart", false);
ctx.commit("setApacheRestartFlagSent", false);
}
} }
}, },
async updateApacheRestartFlag(ctx) { async updateApacheRestartFlag(ctx) {
@ -37,8 +46,9 @@ export default {
try { try {
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);
} catch(err) { } catch(err) {
ctx.commit("setApacheRestartFlag", false); pass()
} }
}, },
}, },
@ -49,5 +59,8 @@ export default {
isApacheRestartPending(state) { isApacheRestartPending(state) {
return state.restart_flag; return state.restart_flag;
}, },
isApacheRestartFlagSent(state) {
return state.flag_sent;
},
}, },
}; };

View File

@ -63,7 +63,7 @@ export default {
state.infobases.splice(idx, 1); state.infobases.splice(idx, 1);
setInfobaseLock(state, { name, lock: false }); setInfobaseLock(state, { name, lock: false });
} else { } else {
infobase.publicated = true; //infobase.publicated = true; // debug
state.infobases[idx] = infobase; state.infobases[idx] = infobase;
} }
} }

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="home"> <div class="home">
<InfobaseList msg="Welcome to Your Vue.js App" /> <InfobaseList />
<ApacheRestartMonitor />
</div> </div>
</template> </template>
@ -8,11 +9,13 @@
// @ is an alias to /src // @ is an alias to /src
//import HelloWorld from "@/components/HelloWorld.vue"; //import HelloWorld from "@/components/HelloWorld.vue";
import InfobaseList from "@/components/InfobaseList.vue"; import InfobaseList from "@/components/InfobaseList.vue";
import ApacheRestartMonitor from "@/components/ApacheRestartMonitor.vue";
export default { export default {
name: "Home", name: "Home",
components: { components: {
InfobaseList, InfobaseList,
ApacheRestartMonitor,
}, },
}; };
</script> </script>