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>
</thead>
<tbody>
<InfobaseListItem
<tr
v-is="'InfobaseListItem'"
v-for="(infobase, index) in allInfobases"
:key="infobase.name"
:infobase="infobase"

View File

@ -1,7 +1,14 @@
<template>
<form @submit.prevent="submit">
<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
type="submit"
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 pass = () => {};
app.directive("tooltip", {
mounted(el, binding) {
try {
window.$(el).tooltip({
placement: binding.arg,
trigger: "hover",
});
} catch {
pass();
}
},
updated(el) {
try {
window.$(el).tooltip("update");
} catch {
pass();
}
},
unmounted(el) {
try {
window.$(el).tooltip("dispose");
} catch {
pass();
}
},
});

View File

@ -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,
},
});

View File

@ -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);
ctx.commit("setApacheRestartFlagSent", true);
} catch(err) {
ctx.commit("setApacheRestartFlag", false);
pass()
}
},
},
@ -49,5 +59,8 @@ export default {
isApacheRestartPending(state) {
return state.restart_flag;
},
isApacheRestartFlagSent(state) {
return state.flag_sent;
},
},
};

View File

@ -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;
}
}

View File

@ -1,6 +1,7 @@
<template>
<div class="home">
<InfobaseList msg="Welcome to Your Vue.js App" />
<InfobaseList />
<ApacheRestartMonitor />
</div>
</template>
@ -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,
},
};
</script>