2018-08-28 22:50:22 +02:00
|
|
|
<template>
|
2018-09-07 08:42:17 +02:00
|
|
|
<div id="app" class="container">
|
2018-09-09 17:33:24 +02:00
|
|
|
<nav class="navbar" role="navigation" aria-label="main navigation" v-if="user.authenticated">
|
2018-09-09 19:54:28 +02:00
|
|
|
<div class="navbar-brand">
|
2018-10-03 19:06:50 +02:00
|
|
|
<router-link :to="{name: 'home'}" class="navbar-item logo">
|
2018-09-11 07:02:32 +02:00
|
|
|
<img src="images/logo-full.svg"/>
|
2018-10-03 19:06:50 +02:00
|
|
|
</router-link>
|
2018-09-09 19:54:28 +02:00
|
|
|
</div>
|
|
|
|
<div class="navbar-menu">
|
2018-09-09 17:33:24 +02:00
|
|
|
<div class="navbar-end">
|
|
|
|
<span class="navbar-item">{{user.infos.username}}</span>
|
|
|
|
<span class="navbar-item image">
|
|
|
|
<img :src="gravatar()" class="is-rounded" alt=""/>
|
2018-09-09 17:23:06 +02:00
|
|
|
</span>
|
2018-09-09 17:33:24 +02:00
|
|
|
<a v-on:click="logout()" class="navbar-item is-right logout-icon">
|
|
|
|
<span class="icon is-medium">
|
|
|
|
<icon icon="sign-out-alt" size="2x"/>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
2018-09-09 17:23:06 +02:00
|
|
|
</div>
|
|
|
|
</nav>
|
2018-09-07 08:42:17 +02:00
|
|
|
<div class="column is-centered">
|
2018-09-09 21:00:27 +02:00
|
|
|
<div v-if="user.authenticated">
|
|
|
|
<div class="box">
|
2018-09-07 08:42:17 +02:00
|
|
|
<div class="columns">
|
2018-09-09 19:09:46 +02:00
|
|
|
<div class="column is-3">
|
2018-09-14 07:23:25 +02:00
|
|
|
<router-link :to="{name: 'listTeams'}" class="button is-primary is-fullwidth button-bottom">
|
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="users"/>
|
|
|
|
</span>
|
|
|
|
Teams
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{name: 'newNamespace'}" class="button is-success is-fullwidth button-bottom">
|
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="layer-group"/>
|
|
|
|
</span>
|
|
|
|
New Namespace
|
|
|
|
</router-link>
|
2018-09-14 19:45:56 +02:00
|
|
|
<aside class="menu namespaces-lists">
|
2018-09-07 22:44:07 +02:00
|
|
|
<p class="menu-label" v-if="loading">Loading...</p>
|
2018-09-07 08:42:17 +02:00
|
|
|
<template v-for="n in namespaces">
|
2018-09-14 19:45:56 +02:00
|
|
|
<div :key="n.id">
|
2018-09-17 07:36:25 +02:00
|
|
|
<router-link :to="{name: 'editNamespace', params: {id: n.id} }" class="nsettings">
|
2018-09-14 19:45:56 +02:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="cog"/>
|
|
|
|
</span>
|
2018-09-11 19:46:14 +02:00
|
|
|
</router-link>
|
2018-09-17 07:36:25 +02:00
|
|
|
<router-link :to="{ name: 'newList', params: { id: n.id} }" class="is-success nsettings" :key="n.id + 'newList'">
|
2018-09-14 19:45:56 +02:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
|
|
|
</router-link>
|
|
|
|
<div class="menu-label">
|
|
|
|
{{n.name}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-09-07 22:44:07 +02:00
|
|
|
<ul class="menu-list" :key="n.id + 'child'">
|
|
|
|
<li v-for="l in n.lists" :key="l.id">
|
2018-09-08 23:33:09 +02:00
|
|
|
<router-link :to="{ name: 'showList', params: { id: l.id} }">{{l.title}}</router-link>
|
2018-09-07 22:44:07 +02:00
|
|
|
</li>
|
2018-09-07 08:42:17 +02:00
|
|
|
</ul>
|
|
|
|
</template>
|
|
|
|
</aside>
|
|
|
|
</div>
|
2018-09-09 21:00:27 +02:00
|
|
|
<div class="column is-9">
|
2018-09-07 08:42:17 +02:00
|
|
|
<router-view/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2018-11-01 22:34:29 +01:00
|
|
|
<div class="container has-text-centered">
|
|
|
|
<div class="column is-4 is-offset-4">
|
|
|
|
<img src="images/logo-full.svg"/>
|
|
|
|
<router-view/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-09-07 08:42:17 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-09-08 21:43:16 +02:00
|
|
|
<notifications position="bottom left" />
|
2018-09-06 19:46:09 +02:00
|
|
|
</div>
|
2018-08-28 22:50:22 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-07 08:42:17 +02:00
|
|
|
import auth from './auth'
|
|
|
|
import {HTTP} from './http-common'
|
2018-09-08 21:43:16 +02:00
|
|
|
import message from './message'
|
2018-11-01 22:34:29 +01:00
|
|
|
import router from './router'
|
2018-09-07 08:42:17 +02:00
|
|
|
|
2018-09-06 19:46:09 +02:00
|
|
|
export default {
|
2018-09-07 08:42:17 +02:00
|
|
|
name: 'app',
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
user: auth.user,
|
|
|
|
loading: false,
|
|
|
|
namespaces: [],
|
|
|
|
}
|
|
|
|
},
|
2018-11-01 22:34:29 +01:00
|
|
|
beforeMount() {
|
|
|
|
// Password reset
|
|
|
|
if(this.$route.query.userPasswordReset !== undefined) {
|
|
|
|
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token
|
|
|
|
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
|
|
|
router.push({name: 'passwordReset'})
|
|
|
|
}
|
|
|
|
},
|
2018-09-07 08:42:17 +02:00
|
|
|
created() {
|
2018-09-08 21:24:10 +02:00
|
|
|
if (this.user.authenticated) {
|
|
|
|
this.loadNamespaces()
|
|
|
|
}
|
2018-09-07 08:42:17 +02:00
|
|
|
},
|
2018-09-09 16:17:56 +02:00
|
|
|
watch: {
|
|
|
|
// call the method again if the route changes
|
|
|
|
'$route': 'loadNamespacesIfNeeded'
|
|
|
|
},
|
2018-09-07 08:42:17 +02:00
|
|
|
methods: {
|
|
|
|
logout() {
|
|
|
|
auth.logout()
|
|
|
|
},
|
2018-09-09 17:23:06 +02:00
|
|
|
gravatar() {
|
|
|
|
return 'https://www.gravatar.com/avatar/' + this.user.infos.avatar + '?s=50'
|
|
|
|
},
|
2018-09-07 08:42:17 +02:00
|
|
|
loadNamespaces() {
|
|
|
|
this.loading = true
|
|
|
|
this.namespaces = []
|
|
|
|
HTTP.get(`namespaces`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
|
|
|
.then(response => {
|
2018-09-17 07:34:22 +02:00
|
|
|
this.$set(this, 'namespaces', response.data)
|
2018-09-07 08:42:17 +02:00
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2018-09-08 21:43:16 +02:00
|
|
|
this.handleError(e)
|
2018-09-07 08:42:17 +02:00
|
|
|
})
|
|
|
|
},
|
2018-09-09 16:17:56 +02:00
|
|
|
loadNamespacesIfNeeded(e){
|
|
|
|
if (this.user.authenticated && e.name === 'home') {
|
|
|
|
this.loadNamespaces()
|
|
|
|
}
|
|
|
|
},
|
2018-09-08 21:43:16 +02:00
|
|
|
handleError(e) {
|
|
|
|
this.loading = false
|
|
|
|
message.error(e, this)
|
|
|
|
}
|
2018-09-07 08:42:17 +02:00
|
|
|
},
|
2018-09-06 19:46:09 +02:00
|
|
|
}
|
2018-08-28 22:50:22 +02:00
|
|
|
</script>
|