73 lines
1.8 KiB
Vue
73 lines
1.8 KiB
Vue
<template lang="pug">
|
|
#clientlist
|
|
button(@click="editing = -1") New Client
|
|
.message.error(v-if="error") {{ error }}
|
|
.entry(v-else)
|
|
pagination(:page="pagination.page" :pages="pagination.pages" v-on:page="getClients")
|
|
.list.client
|
|
o-auth-client(v-for="client in clients" v-bind="client" :key="client.id")
|
|
client-modal(:show="editing != 0" @close='editing = 0', :id='editing')
|
|
</template>
|
|
|
|
<script type="text/javascript">
|
|
import Pagination from './Pagination.vue'
|
|
import OAuthClient from './OAuthClient.vue'
|
|
import ClientModal from './ClientModal.vue'
|
|
|
|
export default {
|
|
data: function () {
|
|
return {
|
|
clients: [],
|
|
pagination: {
|
|
offset: 0,
|
|
page: 1,
|
|
pages: 1,
|
|
perPage: 6,
|
|
total: 0
|
|
},
|
|
editing: 0,
|
|
error: ''
|
|
}
|
|
},
|
|
components: {
|
|
ClientModal, Pagination, OAuthClient
|
|
},
|
|
methods: {
|
|
getClients: function (page) {
|
|
this.pagination.total = 0
|
|
this.error = ''
|
|
|
|
this.$http.get('/admin/api/clients?page=' + page).then(data => {
|
|
if (data.body && data.body.error) {
|
|
this.error = data.body.error
|
|
return
|
|
}
|
|
|
|
this.pagination = data.body.page
|
|
this.clients = data.body.clients
|
|
})
|
|
},
|
|
deleteClient: function (id) {
|
|
this.$http.post('/admin/api/client/delete/' + id).then(data => {
|
|
this.getClients(1)
|
|
})
|
|
}
|
|
},
|
|
mounted: function () {
|
|
this.getClients(1)
|
|
|
|
this.$root.$on('reload_clients', () => {
|
|
this.getClients(1)
|
|
})
|
|
|
|
this.$on('edit', function (id) {
|
|
this.editing = id
|
|
})
|
|
|
|
this.$on('delete', function (id) {
|
|
this.deleteClient(id)
|
|
})
|
|
}
|
|
}
|
|
</script>
|