gancio-upstream/pages/Admin.vue

126 lines
3.9 KiB
Vue
Raw Normal View History

2020-01-15 23:40:44 +01:00
<template lang="pug">
v-container.container.pa-0.pa-md-3
2020-08-05 17:30:41 +02:00
v-card
2022-05-31 15:23:58 +02:00
v-alert(v-if='url!==settings.baseurl' outlined type='warning' color='red' show-icon :icon='mdiAlert')
span(v-html="$t('admin.wrong_domain_warning', { url, baseurl: settings.baseurl })")
v-tabs(v-model='selectedTab' show-arrows :next-icon='mdiChevronRight' :prev-icon='mdiChevronLeft')
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- SETTINGS
v-tab {{$t('common.settings')}}
v-tab-item
Settings
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- THEME
v-tab {{$t('common.theme')}}
v-tab-item
Theme
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- USERS
v-tab
v-badge(:value='!!unconfirmedUsers.length' :content='unconfirmedUsers.length') {{$t('common.users')}}
2020-08-05 17:30:41 +02:00
v-tab-item
2021-03-18 15:44:04 +01:00
Users(:users='users' @update='updateUsers')
2020-07-28 12:24:39 +02:00
2020-08-05 17:30:41 +02:00
//- PLACES
v-tab {{$t('common.places')}}
v-tab-item
Places
2020-01-15 23:40:44 +01:00
2022-05-20 12:33:30 +02:00
//- Cohorts
2022-06-06 16:55:45 +02:00
v-tab {{$t('common.blobs')}}
2022-05-20 12:33:30 +02:00
v-tab-item
Cohorts
2020-08-05 17:30:41 +02:00
//- EVENTS
v-tab
v-badge(:value='!!unconfirmedEvents.length' :content='unconfirmedEvents.length') {{$t('common.events')}}
2020-08-05 17:30:41 +02:00
v-tab-item
2020-10-28 01:30:37 +01:00
Events(:unconfirmedEvents='unconfirmedEvents'
@confirmed='id => { unconfirmedEvents = unconfirmedEvents.filter(e => e.id !== id)}')
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- ANNOUNCEMENTS
v-tab {{$t('common.announcements')}}
v-tab-item
Announcement
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- FEDERATION
v-tab {{$t('common.federation')}}
v-tab-item
Federation
2020-01-15 23:40:44 +01:00
2020-08-05 17:30:41 +02:00
//- MODERATION
v-tab(v-if='settings.enable_federation') {{$t('common.moderation')}}
v-tab-item
Moderation
2020-01-15 23:40:44 +01:00
</template>
<script>
import { mapState } from 'vuex'
2022-05-31 15:23:58 +02:00
import { mdiAlert, mdiChevronRight, mdiChevronLeft } from '@mdi/js'
2022-06-06 16:55:45 +02:00
import Settings from '@/components/admin/Settings'
2020-01-15 23:40:44 +01:00
export default {
name: 'Admin',
components: {
2022-06-06 16:55:45 +02:00
Settings,
Users: () => import(/* webpackChunkName: "admin" */'../components/admin/Users'),
Events: () => import(/* webpackChunkName: "admin" */'../components/admin/Events'),
Places: () => import(/* webpackChunkName: "admin" */'../components/admin/Places'),
2022-05-20 12:33:30 +02:00
Cohorts: () => import(/* webpackChunkName: "admin" */'../components/admin/Cohorts'),
Federation: () => import(/* webpackChunkName: "admin" */'../components/admin/Federation.vue'),
Moderation: () => import(/* webpackChunkName: "admin" */'../components/admin/Moderation.vue'),
Announcement: () => import(/* webpackChunkName: "admin" */'../components/admin/Announcement.vue'),
Theme: () => import(/* webpackChunkName: "admin" */'../components/admin/Theme.vue')
},
2020-01-15 23:40:44 +01:00
middleware: ['auth'],
async asyncData ({ $axios, req }) {
let url
if (process.client) {
url = window.location.protocol + '//' + window.location.host
} else {
url = req.protocol + '://' + req.headers.host
}
2020-06-02 00:02:02 +02:00
try {
const users = await $axios.$get('/users')
const unconfirmedEvents = await $axios.$get('/event/unconfirmed')
return { users, unconfirmedEvents, selectedTab: 0, url }
2020-06-02 00:02:02 +02:00
} catch (e) {
return { users: [], unconfirmedEvents: [], selectedTab: 0, url }
2020-06-02 00:02:02 +02:00
}
},
2020-01-15 23:40:44 +01:00
data () {
return {
2022-05-31 15:23:58 +02:00
mdiAlert, mdiChevronRight, mdiChevronLeft,
2022-04-28 23:28:40 +02:00
users: [],
2020-01-15 23:40:44 +01:00
description: '',
2021-01-25 01:17:25 +01:00
unconfirmedEvents: [],
selectedTab: 0
2020-01-15 23:40:44 +01:00
}
},
2021-03-18 15:44:04 +01:00
head () {
return { title: `${this.settings.title} - ${this.$t('common.admin')}` }
},
2020-01-15 23:40:44 +01:00
computed: {
...mapState(['settings']),
unconfirmedUsers () {
return this.users.filter(u => !u.is_active)
}
},
methods: {
2021-03-18 15:44:04 +01:00
async updateUsers () {
this.users = await this.$axios.$get('/users')
},
2020-01-15 23:40:44 +01:00
preview (id) {
this.$router.push(`/event/${id}`)
},
async confirm (id) {
2020-10-07 11:12:13 +02:00
this.loading = true
await this.$axios.$get(`/event/confirm/${id}`)
this.loading = false
this.$root.$message('event.confirmed', { color: 'success' })
2020-10-07 11:12:13 +02:00
this.unconfirmedEvents = this.unconfirmedEvents.filter(e => e.id !== id)
2020-01-15 23:40:44 +01:00
}
}
}
</script>