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">
|
|
|
|
<div class="navbar-item logo">
|
2018-09-11 07:02:32 +02:00
|
|
|
<img src="images/logo-full.svg"/>
|
2018-09-09 17:23:06 +02:00
|
|
|
</div>
|
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">
|
|
|
|
<router-link :to="{name: 'editNamespace', params: {id: n.id} }" class="button nsettings">
|
|
|
|
<span class="icon">
|
|
|
|
<icon icon="cog"/>
|
|
|
|
</span>
|
2018-09-11 19:46:14 +02:00
|
|
|
</router-link>
|
2018-09-14 19:45:56 +02:00
|
|
|
<router-link :to="{ name: 'newList', params: { id: n.id} }" class="button is-success nsettings" :key="n.id + 'newList'">
|
|
|
|
<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>
|
|
|
|
<router-view/>
|
|
|
|
</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-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: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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>
|
|
|
|
|
2018-09-09 22:09:20 +02:00
|
|
|
<style lang="scss">
|
2018-09-09 17:23:06 +02:00
|
|
|
/* Logout-icon */
|
|
|
|
.logout-icon {
|
|
|
|
padding-right: 2em !important;
|
|
|
|
}
|
|
|
|
|
2018-09-11 08:31:00 +02:00
|
|
|
/* Logo */
|
2018-09-09 17:23:06 +02:00
|
|
|
.logo {
|
|
|
|
|
|
|
|
padding-left: 2rem !important;
|
|
|
|
|
|
|
|
img {
|
|
|
|
max-height: 3rem !important;
|
|
|
|
margin-right: 1rem;
|
|
|
|
}
|
|
|
|
}
|
2018-09-09 19:09:46 +02:00
|
|
|
|
|
|
|
/* Buttons icons */
|
2018-09-09 19:41:43 +02:00
|
|
|
.button .icon.is-small {
|
2018-09-09 19:09:46 +02:00
|
|
|
margin-right: 0.05rem !important;
|
|
|
|
}
|
2018-09-09 19:41:43 +02:00
|
|
|
|
|
|
|
/* List active link */
|
|
|
|
.menu-list a.router-link-active{
|
|
|
|
background: darken(#fff, 5%);
|
|
|
|
}
|
2018-09-09 21:41:04 +02:00
|
|
|
|
|
|
|
/* menu buttons */
|
|
|
|
.button-bottom {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
2018-09-11 19:46:14 +02:00
|
|
|
|
2018-09-14 19:45:56 +02:00
|
|
|
/* Namespaces list */
|
|
|
|
.namespaces-lists{
|
|
|
|
.menu-label {
|
|
|
|
font-size: 1em;
|
|
|
|
font-weight: 400;
|
|
|
|
min-height: 2.5em;
|
|
|
|
padding-top: 0.3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Namespace settings */
|
|
|
|
.button{
|
|
|
|
vertical-align: middle;
|
|
|
|
float: right;
|
|
|
|
margin-left: 0.5rem;
|
|
|
|
min-width: 2.648em;
|
|
|
|
}
|
2018-09-11 19:46:14 +02:00
|
|
|
}
|
2018-08-28 22:50:22 +02:00
|
|
|
</style>
|