gancio/pages/admin.vue

120 lines
3.5 KiB
Vue
Raw Normal View History

2019-04-05 00:10:19 +02:00
<template lang="pug">
el-main
2019-06-07 17:02:33 +02:00
nuxt-link.float-right(to='/')
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
2019-06-07 17:02:33 +02:00
h5 {{$t('common.admin')}}
2019-06-18 14:45:04 +02:00
el-tabs(v-model='tab')
2019-04-05 00:10:19 +02:00
//- USERS
el-tab-pane.pt-1
template(slot='label')
v-icon(name='users')
span.ml-1 {{$t('common.users')}}
Users(:users='users')
2019-04-05 00:10:19 +02:00
//- PLACES
el-tab-pane.pt-1
template(slot='label')
v-icon(name='map-marker-alt')
span.ml-1 {{$t('common.places')}}
Places
2019-04-05 00:10:19 +02:00
//- EVENTS
el-tab-pane.pt-1
template(slot='label')
v-icon(name='calendar')
span.ml-1 {{$t('common.events')}}
p {{$t('admin.event_confirm_description')}}
2019-04-05 00:10:19 +02:00
el-table(:data='paginatedEvents' small primary-key='id' v-loading='loading')
el-table-column(:label='$t("common.name")' width='300')
2019-04-05 00:10:19 +02:00
template(slot-scope='data') {{data.row.title}}
el-table-column(:label='$t("common.where")' width='250')
2019-10-20 14:22:55 +02:00
template(slot-scope='data') {{data.row.place.name}}
el-table-column(:label='$t("common.confirm")' width='250')
2019-04-05 00:10:19 +02:00
template(slot-scope='data')
el-button(type='primary' @click='confirm(data.row.id)' size='mini') {{$t('common.confirm')}}
el-button(type='success' @click='preview(data.row.id)' size='mini') {{$t('common.preview')}}
2019-09-06 11:55:38 +02:00
client-only
2019-06-25 01:05:38 +02:00
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
2019-04-05 00:10:19 +02:00
//- SETTINGS
el-tab-pane.pt-1
template(slot='label')
2019-05-30 12:04:14 +02:00
v-icon(name='cog')
span {{$t('common.settings')}}
Settings
2019-06-07 17:02:33 +02:00
//- FEDERATION
el-tab-pane.pt-1
template(slot='label')
v-icon(name='network-wired')
span.ml-1 {{$t('common.federation')}}
Federation
2019-04-05 00:10:19 +02:00
</template>
<script>
import { mapState, mapActions } from 'vuex'
2019-06-18 15:13:13 +02:00
import { Message, MessageBox } from 'element-ui'
import Users from '../components/admin/Users'
import Places from '../components/admin/Places'
import Settings from '../components/admin/Settings'
import Federation from '../components/admin/Federation'
2019-04-05 00:10:19 +02:00
export default {
name: 'Admin',
components: { Users, Places, Settings, Federation },
2019-04-26 23:14:43 +02:00
middleware: ['auth'],
2019-04-05 00:10:19 +02:00
data () {
return {
perPage: 10,
eventPage: 1,
description: '',
events: [],
loading: false,
2019-09-11 19:12:24 +02:00
tab: '0',
open: true
2019-04-05 00:10:19 +02:00
}
},
2019-08-07 01:26:14 +02:00
head () {
return { title: `${this.settings.title} - ${this.$t('common.admin')}` }
},
2019-04-26 23:14:43 +02:00
async asyncData ({ $axios, params, store }) {
try {
const users = await $axios.$get('/users')
const events = await $axios.$get('/event/unconfirmed')
return { users, events, mastodon_instance: store.state.settings.mastodon_instance }
2019-09-11 19:12:24 +02:00
} catch (e) {
console.error(e)
}
2019-04-23 15:45:52 +02:00
},
2019-04-05 00:10:19 +02:00
computed: {
...mapState(['settings']),
2019-04-05 00:10:19 +02:00
paginatedEvents () {
2019-09-11 19:12:24 +02:00
return this.events.slice((this.eventPage - 1) * this.perPage,
2019-04-05 00:10:19 +02:00
this.eventPage * this.perPage)
},
},
methods: {
preview (id) {
this.$router.push(`/event/${id}`)
},
async confirm (id) {
try {
this.loading = true
await this.$axios.$get(`/event/confirm/${id}`)
2019-04-05 00:10:19 +02:00
this.loading = false
Message({
2019-05-30 12:12:51 +02:00
message: this.$t('event.confirmed'),
2019-06-25 01:05:38 +02:00
showClose: true,
2019-04-05 00:10:19 +02:00
type: 'success'
})
this.events = this.events.filter(e => e.id !== id)
} catch (e) {
}
2019-09-11 19:12:24 +02:00
}
2019-04-05 00:10:19 +02:00
}
}
</script>