2020-06-07 02:03:55 +08:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
2021-02-13 15:04:36 +08:00
|
|
|
<b-navbar :fixed-top="true" v-if="$root.isLoaded">
|
2022-01-05 22:50:55 +08:00
|
|
|
<template #brand>
|
2020-06-07 02:03:55 +08:00
|
|
|
<div class="logo">
|
2020-07-26 22:13:43 +08:00
|
|
|
<router-link :to="{name: 'dashboard'}">
|
|
|
|
<img class="full" src="@/assets/logo.svg"/>
|
|
|
|
<img class="favicon" src="@/assets/favicon.png"/>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-01-05 22:50:55 +08:00
|
|
|
<template #end>
|
2021-11-10 02:56:34 +08:00
|
|
|
<navigation v-if="isMobile" :isMobile="isMobile"
|
2021-11-10 23:01:34 +08:00
|
|
|
:activeItem="activeItem" :activeGroup="activeGroup" @toggleGroup="toggleGroup"
|
|
|
|
@doLogout="doLogout" />
|
2021-11-10 02:56:34 +08:00
|
|
|
<b-navbar-item v-else tag="div">
|
|
|
|
<a href="#" @click.prevent="doLogout">{{ $t('users.logout') }}</a>
|
|
|
|
</b-navbar-item>
|
2020-07-26 22:13:43 +08:00
|
|
|
</template>
|
|
|
|
</b-navbar>
|
|
|
|
|
2021-02-13 15:04:36 +08:00
|
|
|
<div class="wrapper" v-if="$root.isLoaded">
|
2020-07-26 22:13:43 +08:00
|
|
|
<section class="sidebar">
|
|
|
|
<b-sidebar
|
|
|
|
position="static"
|
2021-11-10 02:56:34 +08:00
|
|
|
mobile="hide"
|
2020-07-26 22:13:43 +08:00
|
|
|
:fullheight="true"
|
|
|
|
:open="true"
|
|
|
|
:can-cancel="false"
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<b-menu :accordion="false">
|
2021-11-10 02:56:34 +08:00
|
|
|
<navigation v-if="!isMobile" :isMobile="isMobile"
|
|
|
|
:activeItem="activeItem" :activeGroup="activeGroup" @toggleGroup="toggleGroup" />
|
2020-07-26 22:13:43 +08:00
|
|
|
</b-menu>
|
|
|
|
</div>
|
|
|
|
</b-sidebar>
|
|
|
|
</section>
|
|
|
|
<!-- sidebar-->
|
|
|
|
|
|
|
|
<!-- body //-->
|
|
|
|
<div class="main">
|
2021-02-13 15:04:36 +08:00
|
|
|
<div class="global-notices" v-if="serverConfig.needs_restart || serverConfig.update">
|
|
|
|
<div v-if="serverConfig.needs_restart" class="notification is-danger">
|
|
|
|
{{ $t('settings.needsRestart') }}
|
2020-07-26 22:13:43 +08:00
|
|
|
—
|
|
|
|
<b-button class="is-primary" size="is-small"
|
2021-02-13 15:04:36 +08:00
|
|
|
@click="$utils.confirm($t('settings.confirmRestart'), reloadApp)">
|
|
|
|
{{ $t('settings.restart') }}
|
2020-07-26 22:13:43 +08:00
|
|
|
</b-button>
|
2020-06-07 02:03:55 +08:00
|
|
|
</div>
|
2020-08-08 19:29:47 +08:00
|
|
|
<div v-if="serverConfig.update" class="notification is-success">
|
2021-02-13 15:04:36 +08:00
|
|
|
{{ $t('settings.updateAvailable', { version: serverConfig.update.version }) }}
|
2020-08-08 19:29:47 +08:00
|
|
|
<a :href="serverConfig.update.url" target="_blank">View</a>
|
|
|
|
</div>
|
2020-07-08 19:00:14 +08:00
|
|
|
</div>
|
|
|
|
|
2020-07-26 22:13:43 +08:00
|
|
|
<router-view :key="$route.fullPath" />
|
|
|
|
</div>
|
2020-06-07 02:03:55 +08:00
|
|
|
</div>
|
2020-07-05 02:07:23 +08:00
|
|
|
|
2021-02-13 15:04:36 +08:00
|
|
|
<b-loading v-if="!$root.isLoaded" active />
|
2020-06-07 02:03:55 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Vue from 'vue';
|
2020-07-08 19:00:14 +08:00
|
|
|
import { mapState } from 'vuex';
|
2021-11-10 23:01:34 +08:00
|
|
|
import { uris } from './constants';
|
2021-11-10 02:56:34 +08:00
|
|
|
|
|
|
|
import Navigation from './components/Navigation.vue';
|
2020-06-07 02:03:55 +08:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'App',
|
|
|
|
|
2021-11-10 02:56:34 +08:00
|
|
|
components: {
|
|
|
|
Navigation,
|
|
|
|
},
|
|
|
|
|
2020-06-07 02:03:55 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
activeItem: {},
|
|
|
|
activeGroup: {},
|
2021-11-10 02:56:34 +08:00
|
|
|
windowWidth: window.innerWidth,
|
2020-06-07 02:03:55 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
$route(to) {
|
|
|
|
// Set the current route name to true for active+expanded keys in the
|
|
|
|
// menu to pick up.
|
|
|
|
this.activeItem = { [to.name]: true };
|
|
|
|
if (to.meta.group) {
|
|
|
|
this.activeGroup = { [to.meta.group]: true };
|
2020-08-24 21:45:28 +08:00
|
|
|
} else {
|
|
|
|
// Reset activeGroup to collapse menu items on navigating
|
|
|
|
// to non group items from sidebar
|
|
|
|
this.activeGroup = {};
|
2020-06-07 02:03:55 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-07-08 19:00:14 +08:00
|
|
|
methods: {
|
2020-08-25 21:46:33 +08:00
|
|
|
toggleGroup(group, state) {
|
|
|
|
this.activeGroup = state ? { [group]: true } : {};
|
|
|
|
},
|
2021-09-27 02:12:57 +08:00
|
|
|
|
2020-07-08 19:00:14 +08:00
|
|
|
reloadApp() {
|
|
|
|
this.$api.reloadApp().then(() => {
|
|
|
|
this.$utils.toast('Reloading app ...');
|
|
|
|
|
|
|
|
// Poll until there's a 200 response, waiting for the app
|
|
|
|
// to restart and come back up.
|
|
|
|
const pollId = setInterval(() => {
|
2021-02-13 15:44:52 +08:00
|
|
|
this.$api.getHealth().then(() => {
|
|
|
|
clearInterval(pollId);
|
|
|
|
document.location.reload();
|
|
|
|
});
|
2020-07-08 19:00:14 +08:00
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
},
|
2021-11-10 23:01:34 +08:00
|
|
|
|
|
|
|
doLogout() {
|
|
|
|
const http = new XMLHttpRequest();
|
|
|
|
|
|
|
|
const u = uris.root.substr(-1) === '/' ? uris.root : `${uris.root}/`;
|
|
|
|
http.open('get', `${u}api/logout`, false, 'logout_non_user', 'logout_non_user');
|
|
|
|
http.onload = () => {
|
|
|
|
document.location.href = uris.root;
|
|
|
|
};
|
|
|
|
http.onerror = () => {
|
|
|
|
document.location.href = uris.root;
|
|
|
|
};
|
|
|
|
http.send();
|
|
|
|
},
|
2020-06-07 02:03:55 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-07-08 19:00:14 +08:00
|
|
|
...mapState(['serverConfig']),
|
|
|
|
|
2020-06-07 02:03:55 +08:00
|
|
|
version() {
|
|
|
|
return process.env.VUE_APP_VERSION;
|
|
|
|
},
|
2021-11-10 02:56:34 +08:00
|
|
|
|
|
|
|
isMobile() {
|
|
|
|
return this.windowWidth <= 768;
|
|
|
|
},
|
2020-06-07 02:03:55 +08:00
|
|
|
},
|
2020-07-08 19:00:14 +08:00
|
|
|
|
|
|
|
mounted() {
|
|
|
|
// Lists is required across different views. On app load, fetch the lists
|
|
|
|
// and have them in the store.
|
2021-09-18 22:45:24 +08:00
|
|
|
this.$api.getLists({ minimal: true });
|
2021-11-10 02:56:34 +08:00
|
|
|
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
this.windowWidth = window.innerWidth;
|
|
|
|
});
|
2020-07-08 19:00:14 +08:00
|
|
|
},
|
2020-06-07 02:03:55 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import "assets/style.scss";
|
|
|
|
@import "assets/icons/fontello.css";
|
|
|
|
</style>
|