gancio-upstream/pages/Admin.vue

117 lines
2.8 KiB
Vue
Raw Normal View History

2020-01-15 23:40:44 +01:00
<template lang="pug">
2020-07-25 21:41:22 +02:00
v-container
2020-01-15 23:40:44 +01:00
2020-07-25 21:41:22 +02:00
v-tabs
2020-01-15 23:40:44 +01:00
2020-02-20 20:56:24 +01:00
//- SETTINGS
2020-07-25 21:41:22 +02:00
v-tab {{$t('common.settings')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Settings
2020-01-15 23:40:44 +01:00
2020-07-28 12:24:39 +02:00
//- THEME
v-tab {{$t('common.theme')}}
v-tab-item
Theme
2020-02-20 20:56:24 +01:00
//- USERS
2020-07-25 21:41:22 +02:00
v-tab
v-badge(:value='unconfirmedUsers.length' :content='unconfirmedUsers.length') {{$t('common.users')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Users(:users='users')
2020-01-15 23:40:44 +01:00
2020-02-20 20:56:24 +01:00
//- PLACES
2020-07-25 21:41:22 +02:00
v-tab {{$t('common.places')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Places
2020-01-15 23:40:44 +01:00
2020-02-20 20:56:24 +01:00
//- EVENTS
2020-07-25 21:41:22 +02:00
v-tab
2020-07-28 12:24:39 +02:00
v-badge(:value='events.length') {{$t('common.events')}}
2020-07-25 21:41:22 +02:00
v-tab-item
2020-07-28 12:24:39 +02:00
v-container
v-subheader {{$t('admin.event_confirm_description')}}
v-data-table(
:items='events'
:headers='eventHeaders')
2020-01-15 23:40:44 +01:00
2020-02-20 20:56:24 +01:00
//- ANNOUNCEMENTS
2020-07-25 21:41:22 +02:00
v-tab {{$t('common.announcements')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Announcement
2020-01-15 23:40:44 +01:00
2020-02-20 20:56:24 +01:00
//- FEDERATION
2020-07-25 21:41:22 +02:00
v-tab {{$t('common.federation')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Federation
2020-02-05 00:42:05 +01:00
2020-02-20 20:56:24 +01:00
//- MODERATION
2020-07-25 21:41:22 +02:00
v-tab(v-if='settings.enable_federation') {{$t('common.moderation')}}
v-tab-item
2020-02-20 20:56:24 +01:00
Moderation
2020-01-15 23:40:44 +01:00
</template>
<script>
import { mapState } from 'vuex'
import { Message } 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'
2020-02-05 00:44:20 +01:00
import Moderation from '../components/admin/Moderation'
import Announcement from '../components/admin/Announcement'
2020-07-28 12:24:39 +02:00
import Theme from '../components/admin/Theme'
2020-01-15 23:40:44 +01:00
export default {
name: 'Admin',
2020-07-28 12:24:39 +02:00
components: { Users, Places, Settings, Federation, Moderation, Announcement, Theme },
2020-01-15 23:40:44 +01:00
middleware: ['auth'],
2020-06-02 00:02:02 +02:00
async asyncData ({ $axios, params, store }) {
try {
const users = await $axios.$get('/users')
const events = await $axios.$get('/event/unconfirmed')
return { users, events }
} catch (e) {
console.error(e)
return { users: [], events: [] }
}
},
2020-01-15 23:40:44 +01:00
data () {
return {
description: '',
2020-07-28 12:24:39 +02:00
events: [],
eventHeaders: [
{ value: 'title', text: 'Title' }
]
2020-01-15 23:40:44 +01:00
}
},
computed: {
...mapState(['settings']),
unconfirmedUsers () {
return this.users.filter(u => !u.is_active)
}
},
methods: {
preview (id) {
this.$router.push(`/event/${id}`)
},
async confirm (id) {
try {
this.loading = true
await this.$axios.$get(`/event/confirm/${id}`)
this.loading = false
Message({
message: this.$t('event.confirmed'),
showClose: true,
type: 'success'
})
this.events = this.events.filter(e => e.id !== id)
} catch (e) {
}
}
2020-07-25 21:41:22 +02:00
},
head () {
return { title: `${this.settings.title} - ${this.$t('common.admin')}` }
2020-01-15 23:40:44 +01:00
}
}
</script>