Fixed namespace nav

This commit is contained in:
kolaente 2018-09-07 22:44:07 +02:00
parent 324996abcf
commit b55b99a82c
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -9,19 +9,21 @@
<div class="columns"> <div class="columns">
<div class="column is-3"> <div class="column is-3">
<aside class="menu"> <aside class="menu">
<p class="menu-label" v-if="loading">Loading...</p>
<template v-for="n in namespaces"> <template v-for="n in namespaces">
<p v-bind:key="n.id" class="menu-label"> <p class="menu-label" :key="n.id">
{{n.name}} {{n.name}}
</p> </p>
<ul v-bind:key="n.lists" class="menu-list"> <ul class="menu-list" :key="n.id + 'child'">
<template v-for="l in n.lists"> <li v-for="l in n.lists" :key="l.id">
<li v-bind:key="l.id"><a>{{l.title}}</a></li> <a>{{l.title}}</a>
</template> </li>
</ul> </ul>
</template> </template>
</aside> </aside>
</div> </div>
<div class="column is-9"> <div class="column is-9">
<button class="button is-success" v-on:click="loadNamespaces()">Load Namespaces</button>
<router-view/> <router-view/>
</div> </div>
</div> </div>
@ -61,16 +63,17 @@
HTTP.get(`namespaces`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}}) HTTP.get(`namespaces`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => { .then(response => {
let namespaces = response.data let nps = response.data
// Get the lists // Loop through the namespaces and get their lists
for (const n in namespaces) { for (const n in nps) {
this.namespaces[n] = namespaces[n] this.namespaces.push(nps[n])
HTTP.get(`namespaces/` + namespaces[n].id + `/lists`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}}) HTTP.get(`namespaces/` + nps[n].id + `/lists`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => { .then(response => {
this.namespaces[n].lists = response.data // This adds a new element "list" to our object which contains all lists
this.$set(this.namespaces[n], 'lists', response.data)
}) })
.catch(e => { .catch(e => {
this.loading = false this.loading = false
@ -79,9 +82,6 @@
}) })
} }
// eslint-disable-next-line
console.log(this.namespaces)
this.loading = false this.loading = false
}) })
.catch(e => { .catch(e => {