2020-07-06 19:08:34 +02:00
|
|
|
<template>
|
2020-07-15 10:30:19 +02:00
|
|
|
<div id="app" class="container">
|
2020-07-07 18:56:12 +02:00
|
|
|
<header>
|
|
|
|
<b-navbar>
|
|
|
|
<b-navbar-brand to="/" exact exact-active-class="active"><img alt="Yunohost logo" src="./assets/logo.png"></b-navbar-brand>
|
|
|
|
<b-navbar-nav class="ml-auto">
|
|
|
|
<li class="nav-item">
|
2020-07-08 14:35:22 +02:00
|
|
|
<b-button href="/yunohost/sso" variant="primary" block size="sm">
|
2020-07-14 19:48:16 +02:00
|
|
|
{{ $t('user_interface_link') }} <icon iname="user"/>
|
2020-07-08 14:35:22 +02:00
|
|
|
</b-button>
|
2020-07-07 18:56:12 +02:00
|
|
|
</li>
|
2020-07-12 19:09:53 +02:00
|
|
|
<li class="nav-item" v-show="connected">
|
2020-07-10 18:42:40 +02:00
|
|
|
<b-button @click.prevent="logout" to="/logout" variant="outline-dark" block size="sm" >
|
2020-07-14 19:48:16 +02:00
|
|
|
{{ $t('logout') }} <icon iname="sign-out"/>
|
2020-07-08 14:35:22 +02:00
|
|
|
</b-button>
|
2020-07-07 18:56:12 +02:00
|
|
|
</li>
|
|
|
|
</b-navbar-nav>
|
|
|
|
</b-navbar>
|
|
|
|
</header>
|
|
|
|
|
2020-07-07 21:59:29 +02:00
|
|
|
<main>
|
2020-07-12 19:09:53 +02:00
|
|
|
<router-view v-if="isReady"/>
|
2020-07-07 21:59:29 +02:00
|
|
|
</main>
|
2020-07-07 18:56:12 +02:00
|
|
|
|
|
|
|
<footer>
|
|
|
|
<nav>
|
|
|
|
<b-nav>
|
2020-07-08 14:35:22 +02:00
|
|
|
<b-nav-item href="https://yunohost.org/docs" target="_blank" link-classes='text-secondary'>
|
2020-07-14 19:48:16 +02:00
|
|
|
<icon iname="book"/> Documentation
|
2020-07-08 14:35:22 +02:00
|
|
|
</b-nav-item>
|
|
|
|
<b-nav-item href="https://yunohost.org/help" target="_blank" link-classes='text-secondary'>
|
2020-07-14 19:48:16 +02:00
|
|
|
<icon iname="life-ring"/> Need help?
|
2020-07-08 14:35:22 +02:00
|
|
|
</b-nav-item>
|
|
|
|
<b-nav-item href="https://donate.yunohost.org/" target="_blank" link-classes='text-secondary'>
|
2020-07-14 19:48:16 +02:00
|
|
|
<icon iname="heart"/> Donate
|
2020-07-08 14:35:22 +02:00
|
|
|
</b-nav-item>
|
2020-07-12 19:09:53 +02:00
|
|
|
<i18n v-if="yunohostInfos" path="footer_version" tag="b-nav-text" class="ml-auto" id="yunohost-version">
|
|
|
|
<template v-slot:ynh><b-link href="https://yunohost.org">YunoHost</b-link></template>
|
|
|
|
<template v-slot:version>{{ yunohostInfos.version }}</template>
|
|
|
|
<template v-slot:repo>{{ yunohostInfos.repo }}</template>
|
|
|
|
</i18n>
|
2020-07-07 18:56:12 +02:00
|
|
|
</b-nav>
|
|
|
|
</nav>
|
|
|
|
</footer>
|
2020-07-07 13:48:54 +02:00
|
|
|
</div>
|
2020-07-06 19:08:34 +02:00
|
|
|
</template>
|
2020-07-07 13:54:01 +02:00
|
|
|
|
2020-07-10 18:42:40 +02:00
|
|
|
<script>
|
2020-07-12 19:09:53 +02:00
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
2020-07-10 18:42:40 +02:00
|
|
|
import api from '@/helpers/api'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'App',
|
2020-07-12 19:09:53 +02:00
|
|
|
data: () => {
|
|
|
|
return {
|
|
|
|
// isReady blocks the rendering of the rooter-view until we have a true info
|
|
|
|
// about the connected state of the user.
|
|
|
|
isReady: false,
|
2020-07-10 18:42:40 +02:00
|
|
|
}
|
|
|
|
},
|
2020-07-12 19:09:53 +02:00
|
|
|
computed: {
|
|
|
|
...mapState(['connected', 'yunohostInfos']),
|
|
|
|
},
|
2020-07-10 18:42:40 +02:00
|
|
|
methods: {
|
|
|
|
async logout() {
|
2020-07-12 19:09:53 +02:00
|
|
|
await api.logout()
|
|
|
|
this.$store.commit('CONNECTED', false);
|
|
|
|
this.$router.push('/login')
|
|
|
|
},
|
2020-07-10 18:42:40 +02:00
|
|
|
},
|
2020-07-12 19:09:53 +02:00
|
|
|
// This hook is only triggered at page reload so the value of state.connected
|
|
|
|
// always come from the localStorage
|
|
|
|
async created() {
|
|
|
|
if (!this.$store.state.connected) {
|
|
|
|
// user is not connected: allow the login view to be rendered.
|
|
|
|
this.isReady = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// localStorage 'connected' value may be true, but session may have expired.
|
|
|
|
// Try to get the yunohost version.
|
|
|
|
try {
|
|
|
|
const data = await api.getVersion()
|
|
|
|
this.$store.commit('YUNOHOST_INFOS', data.yunohost)
|
|
|
|
} catch (err) {
|
|
|
|
// Session expired, reset the 'connected' state and redirect with a query
|
|
|
|
// FIXME is there a case where the error may not be a 401 therefor requires
|
|
|
|
// better handling ?
|
|
|
|
this.$store.commit('CONNECTED', false);
|
|
|
|
this.$router.push({name: 'login', query: {redirect: this.$route.path}})
|
|
|
|
} finally {
|
|
|
|
// in any case allow the router-view to be rendered
|
|
|
|
this.isReady = true;
|
|
|
|
}
|
|
|
|
}
|
2020-07-10 18:42:40 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-07-07 13:54:01 +02:00
|
|
|
<style lang="scss">
|
|
|
|
@import '@/scss/main.scss';
|
2020-07-07 18:56:12 +02:00
|
|
|
|
2020-07-14 22:44:09 +02:00
|
|
|
#app > header {
|
2020-07-07 18:56:12 +02:00
|
|
|
border-bottom: 1px solid #eee;
|
2020-07-15 10:30:19 +02:00
|
|
|
padding-top: 1rem;
|
2020-07-14 19:48:16 +02:00
|
|
|
margin-bottom: 1rem;
|
2020-07-07 18:56:12 +02:00
|
|
|
|
|
|
|
.navbar {
|
2020-07-10 18:42:40 +02:00
|
|
|
padding: 1rem 0;
|
2020-07-07 18:56:12 +02:00
|
|
|
|
|
|
|
img {
|
|
|
|
width: 70px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar-nav {
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
li {
|
|
|
|
margin: .2rem 0;
|
|
|
|
}
|
2020-07-08 14:35:22 +02:00
|
|
|
icon {
|
|
|
|
margin-left: .5rem;
|
|
|
|
}
|
2020-07-07 18:56:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-14 22:44:09 +02:00
|
|
|
#app > footer {
|
2020-07-07 18:56:12 +02:00
|
|
|
padding: 1rem 0;
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
font-size: 0.875rem;
|
2020-07-07 21:59:29 +02:00
|
|
|
margin-top: 2rem;
|
2020-07-07 18:56:12 +02:00
|
|
|
|
2020-07-12 19:09:53 +02:00
|
|
|
.nav-item {
|
2020-07-14 19:48:16 +02:00
|
|
|
& + .nav-item a::before {
|
2020-07-07 18:56:12 +02:00
|
|
|
content: "•";
|
|
|
|
width: 1rem;
|
|
|
|
display: inline-block;
|
2020-07-12 19:09:53 +02:00
|
|
|
margin-left: -1.15rem;
|
2020-07-07 18:56:12 +02:00
|
|
|
}
|
|
|
|
&:first-child {
|
|
|
|
margin-left: -1rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-07 13:54:01 +02:00
|
|
|
</style>
|