gancio-upstream/pages/Admin.vue

157 lines
5.8 KiB
Vue
Raw Permalink Normal View History

2020-01-15 23:40:44 +01:00
<template lang="pug">
2022-07-01 15:55:09 +02:00
v-container.container.pa-0.pa-md-3
v-card
2024-02-09 22:33:27 +01:00
template(v-if='$auth.user.is_admin')
v-alert(v-if='url!==settings.baseurl' rounded="0" flat border="left" type='warning' show-icon :icon='mdiAlert')
span(v-html="$t('admin.wrong_domain_warning', { url, baseurl: settings.baseurl })")
v-alert(v-if='!selfReachable' rounded="0" flat border="left" type='warning' show-icon :icon='mdiAlert')
span(v-html="$t('admin.not_reachable_warning', { baseurl: settings.baseurl })")
2022-07-01 15:55:09 +02:00
v-tabs(v-model='selectedTab' show-arrows :next-icon='mdiChevronRight' :prev-icon='mdiChevronLeft')
2020-01-15 23:40:44 +01:00
2022-07-01 15:55:09 +02:00
//- SETTINGS
2024-02-09 22:33:27 +01:00
v-tab(href='#settings' v-if='$auth.user.is_admin') {{$t('common.settings')}}
2022-11-29 14:40:46 +01:00
v-tab-item(value='settings')
2022-07-01 15:55:09 +02:00
Settings
2020-01-15 23:40:44 +01:00
//- EVENTS
v-tab(href='#unconfirmed_events')
v-badge(:value='!!unconfirmedEvents.length' :content='unconfirmedEvents.length') {{$t('common.events')}}
v-tab-item(value='unconfirmed_events')
Events(:unconfirmedEvents='unconfirmedEvents'
@confirmed='id => { unconfirmedEvents = unconfirmedEvents.filter(e => e.id !== id)}')
2022-07-01 15:55:09 +02:00
//- USERS
2024-02-09 22:33:27 +01:00
v-tab(href='#users' v-if='$auth.user.is_admin')
2022-07-01 15:55:09 +02:00
v-badge(:value='!!unconfirmedUsers.length' :content='unconfirmedUsers.length') {{$t('common.users')}}
2022-11-29 14:40:46 +01:00
v-tab-item(value='users')
2022-07-01 15:55:09 +02:00
Users(:users='users' @update='updateUsers')
2020-07-28 12:24:39 +02:00
2024-02-28 22:37:01 +01:00
//- Collections
v-tab(href='#collections' v-if='$auth.user.is_admin') {{$t('common.collections')}}
v-tab-item(value='collections')
Collections
//- FEDERATION
v-tab(href='#federation' v-if='$auth.user.is_admin') {{$t('common.federation')}}
v-tab-item(value='federation')
Federation
//- MODERATION
v-tab(v-if='settings.enable_federation' href='#moderation') {{$t('common.moderation')}}
v-tab-item(value='moderation')
Moderation
2022-07-01 15:55:09 +02:00
//- PLACES
2024-02-09 22:33:27 +01:00
v-tab(href='#places' v-if='$auth.user.is_admin') {{$t('common.places')}}
2022-11-29 14:40:46 +01:00
v-tab-item(value='places')
2022-07-01 15:55:09 +02:00
Places
//- TAGS
2024-02-09 22:33:27 +01:00
v-tab(href='#tags' v-if='$auth.user.is_admin') {{$t('common.tags')}}
v-tab-item(value='tags')
Tags
2024-02-28 22:37:01 +01:00
//- THEME
v-tab(href='#theme' v-if='$auth.user.is_admin') {{$t('common.theme')}}
v-tab-item(value='theme')
Theme
//- GEOCODING / MAPS
2024-02-09 22:33:27 +01:00
v-tab(href='#geolocation' v-if='settings.allow_geolocation && $auth.user.is_admin') {{$t('admin.geolocation')}}
v-tab-item(value='geolocation')
2022-12-07 10:16:55 +01:00
client-only(placeholder='Loading...')
Geolocation
2020-01-15 23:40:44 +01:00
2022-07-01 15:55:09 +02:00
//- ANNOUNCEMENTS
2024-02-09 22:33:27 +01:00
v-tab(href='#announcements' v-if='$auth.user.is_admin') {{$t('common.announcements')}}
2022-11-29 14:40:46 +01:00
v-tab-item(value='announcements')
2022-07-01 15:55:09 +02:00
Announcement
2020-01-15 23:40:44 +01:00
2022-08-09 18:33:05 +02:00
//- PLUGINS
2024-02-09 22:33:27 +01:00
v-tab(href='#plugins' v-if='$auth.user.is_admin') {{$t('common.plugins')}}
2022-11-29 14:40:46 +01:00
v-tab-item(value='plugins')
2022-08-09 18:33:05 +02:00
Plugin
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'
2020-01-15 23:40:44 +01:00
export default {
name: 'Admin',
components: {
2023-04-14 10:47:54 +02:00
Settings: () => import(/* webpackChunkName: "admin" */'../components/admin/Settings.vue'),
Users: () => import(/* webpackChunkName: "admin" */'../components/admin/Users'),
Events: () => import(/* webpackChunkName: "admin" */'../components/admin/Events'),
Places: () => import(/* webpackChunkName: "admin" */'../components/admin/Places'),
Tags: () => import(/* webpackChunkName: "admin" */'../components/admin/Tags'),
2022-06-18 01:11:19 +02:00
Collections: () => import(/* webpackChunkName: "admin" */'../components/admin/Collections'),
2022-12-07 10:16:55 +01:00
[process.client && 'Geolocation']: () => import(/* webpackChunkName: "admin" */'../components/admin/Geolocation.vue'),
Federation: () => import(/* webpackChunkName: "admin" */'../components/admin/Federation.vue'),
Moderation: () => import(/* webpackChunkName: "admin" */'../components/admin/Moderation.vue'),
2022-08-09 18:33:05 +02:00
Plugin: () => import(/* webpackChunkName: "admin" */'../components/admin/Plugin.vue'),
Announcement: () => import(/* webpackChunkName: "admin" */'../components/admin/Announcement.vue'),
Theme: () => import(/* webpackChunkName: "admin" */'../components/admin/Theme.vue')
},
2024-02-09 22:33:27 +01:00
middleware: ['auth', 'isAdminOrEditor'],
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')
const selfReachable = await $axios.$get('/reachable')
return { users, unconfirmedEvents, url, selfReachable }
2020-06-02 00:02:02 +02:00
} catch (e) {
return { users: [], unconfirmedEvents: [], url, selfReachable: false }
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: [],
selfReachable: false
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)
2022-11-29 14:40:46 +01:00
},
selectedTab: {
set (tab) {
this.$router.replace({ query: { ...this.$route.query, tab } })
},
get () {
return this.$route.query.tab
}
}
2020-01-15 23:40:44 +01:00
},
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>