2019-04-05 00:10:19 +02:00
|
|
|
<template lang="pug">
|
2019-06-08 15:16:56 +02:00
|
|
|
el-card
|
2019-06-07 17:02:33 +02:00
|
|
|
nuxt-link.float-right(to='/')
|
2019-06-25 01:05:38 +02:00
|
|
|
v-icon(name='times' color='red')
|
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')
|
2019-04-29 00:27:29 +02:00
|
|
|
span.ml-1 {{$t('common.users')}}
|
2019-07-25 12:37:50 +02:00
|
|
|
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')
|
2019-04-29 00:27:29 +02:00
|
|
|
span.ml-1 {{$t('common.places')}}
|
2019-05-30 12:12:51 +02:00
|
|
|
p(v-html="$t('admin.place_description')")
|
2019-04-05 00:10:19 +02:00
|
|
|
el-form.mb-2(:inline='true' label-width='120px')
|
2019-04-29 00:27:29 +02:00
|
|
|
el-form-item(:label="$t('common.name')")
|
|
|
|
el-input.mr-1(:placeholder='$t("common.name")' v-model='place.name')
|
|
|
|
el-form-item(:label="$t('common.address')")
|
|
|
|
el-input.mr-1(:placeholder='$t("common.address")' v-model='place.address')
|
|
|
|
el-button(variant='primary' @click='savePlace') {{$t('common.save')}}
|
2019-05-30 12:04:14 +02:00
|
|
|
el-table(:data='paginatedPlaces' small @current-change="val => place=val")
|
2019-04-29 00:27:29 +02:00
|
|
|
el-table-column(:label="$t('common.name')")
|
|
|
|
template(slot-scope='data') {{data.row.name}}
|
|
|
|
el-table-column(:label="$t('common.address')")
|
|
|
|
template(slot-scope='data') {{data.row.address}}
|
2019-06-25 01:05:38 +02:00
|
|
|
no-ssr
|
|
|
|
el-pagination(:page-size='perPage' :currentPage.sync='placePage' :total='places.length')
|
2019-04-05 00:10:19 +02:00
|
|
|
|
|
|
|
//- EVENTS
|
|
|
|
el-tab-pane.pt-1
|
|
|
|
template(slot='label')
|
|
|
|
v-icon(name='calendar')
|
2019-04-29 00:27:29 +02:00
|
|
|
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')
|
2019-04-29 00:27:29 +02:00
|
|
|
el-table-column(:label='$t("common.name")')
|
2019-04-05 00:10:19 +02:00
|
|
|
template(slot-scope='data') {{data.row.title}}
|
2019-04-29 00:27:29 +02:00
|
|
|
el-table-column(:label='$t("common.where")')
|
2019-04-05 00:10:19 +02:00
|
|
|
template(slot-scope='data') {{data.row.place.name}}
|
2019-04-29 00:27:29 +02:00
|
|
|
el-table-column(:label='$t("common.confirm")')
|
2019-04-05 00:10:19 +02:00
|
|
|
template(slot-scope='data')
|
2019-04-29 00:27:29 +02:00
|
|
|
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-06-25 01:05:38 +02:00
|
|
|
no-ssr
|
|
|
|
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')
|
2019-04-29 00:27:29 +02:00
|
|
|
span {{$t('common.settings')}}
|
2019-06-07 17:02:33 +02:00
|
|
|
|
2019-07-11 23:31:37 +02:00
|
|
|
el-form(inline label-width="400px")
|
|
|
|
|
|
|
|
//- allow open registration
|
|
|
|
el-form-item(:label="$t('admin.allow_registration_description')")
|
|
|
|
el-switch(name='reg' v-model='allow_registration')
|
|
|
|
|
|
|
|
//- allow anon event
|
|
|
|
el-form-item(:label="$t('admin.allow_anon_event')")
|
|
|
|
el-switch(v-model='allow_anon_event')
|
|
|
|
|
|
|
|
el-form-item(:label="$t('admin.allow_recurrent_event')")
|
|
|
|
el-switch(v-model='allow_recurrent_event')
|
|
|
|
|
2019-07-13 01:02:11 +02:00
|
|
|
el-form-item(v-show='allow_recurrent_event' :label="$t('admin.recurrent_event_visible')")
|
|
|
|
el-switch(v-model='recurrent_event_visible')
|
|
|
|
|
2019-07-11 23:31:37 +02:00
|
|
|
el-divider {{$t('admin.federation')}}
|
|
|
|
el-form(inline @submit.native.prevent='associate_mastondon_instance' label-width='240px')
|
2019-06-10 01:25:05 +02:00
|
|
|
p {{$t('admin.mastodon_description')}}
|
2019-06-21 23:52:18 +02:00
|
|
|
el-form-item(:label='$t("admin.mastodon_instance")')
|
|
|
|
el-input(v-model="mastodon_instance")
|
|
|
|
el-form-item
|
|
|
|
el-button(native-type='submit' type='success' :disabled='!mastodon_instance') {{$t('common.associate')}}
|
2019-07-11 23:31:37 +02:00
|
|
|
el-form-item(:label="$t('admin.allow_comments')")
|
|
|
|
el-switch(v-model='allow_comments')
|
2019-04-05 00:10:19 +02:00
|
|
|
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-06-21 23:52:18 +02:00
|
|
|
import { mapState, mapActions } from 'vuex'
|
2019-06-18 15:13:13 +02:00
|
|
|
import { Message, MessageBox } from 'element-ui'
|
2019-07-25 12:37:50 +02:00
|
|
|
import Users from '../components/admin/Users'
|
2019-04-05 00:10:19 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Admin',
|
2019-07-25 12:37:50 +02:00
|
|
|
components: { Users },
|
2019-04-26 23:14:43 +02:00
|
|
|
middleware: ['auth'],
|
2019-04-05 00:10:19 +02:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
perPage: 10,
|
|
|
|
userFields: ['email', 'action'],
|
|
|
|
placeFields: ['name', 'address'],
|
|
|
|
placePage: 1,
|
|
|
|
eventPage: 1,
|
|
|
|
tagPage: 1,
|
|
|
|
tagFields: ['tag', 'color'],
|
|
|
|
description: '',
|
|
|
|
place: {name: '', address: '' },
|
|
|
|
tag: {name: '', color: ''},
|
|
|
|
events: [],
|
|
|
|
loading: false,
|
|
|
|
tab: "0",
|
2019-07-24 11:49:02 +02:00
|
|
|
open: true,
|
2019-04-05 00:10:19 +02:00
|
|
|
}
|
|
|
|
},
|
2019-04-29 00:27:29 +02:00
|
|
|
async mounted () {
|
|
|
|
const code = this.$route.query.code
|
|
|
|
|
|
|
|
if (code) {
|
|
|
|
this.tab = "4"
|
|
|
|
const instance = await this.$axios.$post('/user/code', {code, is_admin: true})
|
|
|
|
}
|
|
|
|
},
|
2019-04-26 23:14:43 +02:00
|
|
|
async asyncData ({ $axios, params, store }) {
|
2019-04-29 00:27:29 +02:00
|
|
|
try {
|
|
|
|
const users = await $axios.$get('/users')
|
|
|
|
const events = await $axios.$get('/event/unconfirmed')
|
2019-06-21 23:52:18 +02:00
|
|
|
return { users, events, mastodon_instance: store.state.settings.mastodon_instance }
|
2019-04-29 00:27:29 +02:00
|
|
|
} catch ( e ) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
2019-04-23 15:45:52 +02:00
|
|
|
},
|
2019-04-05 00:10:19 +02:00
|
|
|
computed: {
|
2019-06-21 23:52:18 +02:00
|
|
|
...mapState(['tags', 'places', 'settings']),
|
|
|
|
allow_registration: {
|
2019-06-25 01:05:38 +02:00
|
|
|
get () { return this.settings.allow_registration },
|
|
|
|
set (value) { this.setSetting({ key: 'allow_registration', value }) }
|
|
|
|
},
|
|
|
|
allow_anon_event: {
|
|
|
|
get () { return this.settings.allow_anon_event },
|
|
|
|
set (value) { this.setSetting({ key: 'allow_anon_event', value })}
|
2019-06-21 23:52:18 +02:00
|
|
|
},
|
2019-07-13 01:02:11 +02:00
|
|
|
allow_recurrent_event: {
|
|
|
|
get () { return this.settings.allow_recurrent_event },
|
|
|
|
set (value) { this.setSetting({ key: 'allow_recurrent_event', value })}
|
|
|
|
},
|
|
|
|
recurrent_event_visible: {
|
|
|
|
get () { return this.settings.recurrent_event_visible },
|
|
|
|
set (value) { this.setSetting({ key: 'recurrent_event_visible', value })}
|
|
|
|
},
|
|
|
|
allow_comments: {
|
|
|
|
get () { return this.settings.allow_comments },
|
|
|
|
set (value) { this.setSetting({ key: 'allow_comments', value })}
|
|
|
|
},
|
2019-04-05 00:10:19 +02:00
|
|
|
paginatedEvents () {
|
|
|
|
return this.events.slice((this.eventPage-1) * this.perPage,
|
|
|
|
this.eventPage * this.perPage)
|
|
|
|
},
|
|
|
|
paginatedTags () {
|
|
|
|
return this.tags.slice((this.tagPage-1) * this.perPage,
|
|
|
|
this.tagPage * this.perPage)
|
|
|
|
},
|
2019-07-25 12:37:50 +02:00
|
|
|
|
2019-04-29 00:27:29 +02:00
|
|
|
paginatedPlaces () {
|
|
|
|
return this.places.slice((this.placePage-1) * this.perPage,
|
|
|
|
this.placePage * this.perPage)
|
2019-05-30 12:04:14 +02:00
|
|
|
},
|
2019-04-05 00:10:19 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2019-06-21 23:52:18 +02:00
|
|
|
...mapActions(['setSetting']),
|
2019-04-05 00:10:19 +02:00
|
|
|
placeSelected (items) {
|
|
|
|
if (items.length === 0 ) {
|
|
|
|
this.place.name = this.place.address = ''
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const item = items[0]
|
|
|
|
this.place.name = item.name
|
|
|
|
this.place.address = item.address
|
|
|
|
this.place.id = item.id
|
|
|
|
},
|
|
|
|
tagSelected (tag) {
|
2019-04-29 00:27:29 +02:00
|
|
|
this.tag = { color: tag.color, tag: tag.tag }
|
2019-04-05 00:10:19 +02:00
|
|
|
},
|
|
|
|
async savePlace () {
|
2019-06-10 01:25:05 +02:00
|
|
|
const place = await this.$axios.$put('/place', this.place)
|
2019-04-05 00:10:19 +02:00
|
|
|
},
|
|
|
|
preview (id) {
|
|
|
|
this.$router.push(`/event/${id}`)
|
|
|
|
},
|
2019-06-10 01:25:05 +02:00
|
|
|
async associate_mastondon_instance () {
|
2019-06-21 23:52:18 +02:00
|
|
|
if (!this.mastodon_instance) return false
|
2019-04-29 00:27:29 +02:00
|
|
|
|
2019-06-21 23:52:18 +02:00
|
|
|
const url = await this.$axios.$post('/settings/getauthurl', { instance: this.mastodon_instance })
|
2019-04-05 00:10:19 +02:00
|
|
|
setTimeout( () => window.location.href=url, 100);
|
|
|
|
},
|
|
|
|
async confirm (id) {
|
|
|
|
try {
|
|
|
|
this.loading = true
|
2019-04-29 00:27:29 +02:00
|
|
|
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-05-30 12:04:14 +02:00
|
|
|
},
|
2019-04-05 00:10:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|