mille storie

commenti da mastodon, widget con custom widget test...
This commit is contained in:
lesion
2019-04-29 00:27:29 +02:00
parent 3b80dd5f73
commit ac5ef6e324
34 changed files with 573 additions and 275 deletions

View File

@@ -1,5 +1,5 @@
<template lang="pug">
b-modal(hide-footer @hidden='$router.replace("/")' :title='$t("Admin")'
b-modal(hide-footer @hidden='$router.replace("/")' :title='$t("common.admin")'
:visible='true' size='lg')
el-tabs(tabPosition='left' v-model='tab')
@@ -7,55 +7,56 @@
el-tab-pane.pt-1
template(slot='label')
v-icon(name='users')
span.ml-1 {{$t('Users')}}
span.ml-1 {{$t('common.users')}}
el-table(:data='paginatedUsers' small)
el-table-column(label='Email')
template(slot-scope='data')
el-popover(trigger='hover' :content='data.row.description' width='400')
span(slot='reference') {{data.row.email}}
el-table-column(label='Azioni')
el-table-column(:label="$t('common.actions')")
template(slot-scope='data')
el-button.mr-1(size='mini'
:type='data.row.is_active?"warning":"success"'
@click='toggle(data.row)') {{data.row.is_active?$t('Deactivate'):$t('Activate')}}
@click='toggle(data.row)') {{data.row.is_active?$t('common.deactivate'):$t('common.activate')}}
el-button(size='mini'
:type='data.row.is_admin?"danger":"warning"'
@click='toggleAdmin(data.row)') {{data.row.is_admin?$t('Remove Admin'):$t('Admin')}}
@click='toggleAdmin(data.row)') {{data.row.is_admin?$t('common.remove_admin'):$t('common.admin')}}
el-pagination(:page-size='perPage' :currentPage.sync='userPage' :total='users.length')
//- PLACES
el-tab-pane.pt-1
template(slot='label')
v-icon(name='map-marker-alt')
span.ml-1 {{$t('Places')}}
p {{$t('admin_place_explanation')}}
span.ml-1 {{$t('common.places')}}
p {{$t('admin.place_description')}}
el-form.mb-2(:inline='true' label-width='120px')
el-form-item(:label="$t('Name')")
el-input.mr-1(:placeholder='$t("Name")' v-model='place.name')
el-form-item(:label="$t('Address')")
el-input.mr-1(:placeholder='$t("Address")' v-model='place.address')
el-button(variant='primary' @click='savePlace') {{$t('Save')}}
b-table(selectable :items='places' :fields='placeFields' striped hover
small selectedVariant='success' primary-key='id'
select-mode="single" @row-selected='placeSelected'
:per-page='perPage' :current-page='placePage')
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')}}
el-table(:data='paginatedPlaces' small)
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}}
el-pagination(:page-size='perPage' :currentPage.sync='placePage' :total='places.length')
//- EVENTS
el-tab-pane.pt-1
template(slot='label')
v-icon(name='calendar')
span.ml-1 {{$t('Events')}}
p {{$t('event_confirm_explanation')}}
span.ml-1 {{$t('common.events')}}
p {{$t('admin.event_confirm_description')}}
el-table(:data='paginatedEvents' small primary-key='id' v-loading='loading')
el-table-column(:label='$t("Name")')
el-table-column(:label='$t("common.name")')
template(slot-scope='data') {{data.row.title}}
el-table-column(:label='$t("Where")')
el-table-column(:label='$t("common.where")')
template(slot-scope='data') {{data.row.place.name}}
el-table-column(:label='$t("Confirm")')
el-table-column(:label='$t("common.confirm")')
template(slot-scope='data')
el-button(type='primary' @click='confirm(data.row.id)' size='mini') {{$t('Confirm')}}
el-button(type='success' @click='preview(data.row.id)' size='mini') {{$t('Preview')}}
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')}}
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
@@ -63,29 +64,29 @@
el-tab-pane.pt-1
template(slot='label')
v-icon(name='tag')
span {{$t('Tags')}}
p {{$t('admin_tag_explanation')}}
el-tag(v-if='tag.tag' :color='tag.color || "grey"' size='mini') {{tag.tag}}
span {{$t('common.tags')}}
p {{$t('admin.tag_description')}}
el-tag(v-if='tag.tag' :color='tag.color' size='mini') {{tag.tag}}
el-form(:inline='true' label-width='120px')
el-form-item(:label="$t('Color')")
el-form-item(:label="$t('common.color')")
el-color-picker(v-model='tag.color' @change='updateColor')
el-table(:data='paginatedTags' striped small hover
highlight-current-row @current-change="tagSelected")
el-table-column(label='Tag')
el-table-column(:label="$t('common.tag')")
template(slot-scope='data')
el-tag(:color='data.row.color || "grey"' size='mini') {{data.row.tag}}
el-tag(:color='data.row.color' size='mini') {{data.row.tag}}
el-pagination(:page-size='perPage' :currentPage.sync='tagPage' :total='tags.length')
//- SETTINGS
el-tab-pane.pt-1
template(slot='label')
v-icon(name='tools')
span {{$t('Settings')}}
el-form(inline)
span {{$t('admin_mastodon_explanation')}}
span {{$t('common.settings')}}
el-form(inline @submit.prevent.stop='associatemastodon_instance')
span {{$t('admin.mastodon_description')}}
el-input(v-model="mastodon_instance")
span(slot='prepend') {{$t('Mastodon instance')}}
el-button(slot='append' @click='associate' variant='success' type='success') {{$t('Associate')}}
span(slot='prepend') {{$t('admin.mastodon_instance')}}
el-button(slot='append' @click='associate' :disabled='!mastodon_instance.length') {{$t('common.associate')}}
</template>
<script>
@@ -117,21 +118,28 @@ export default {
tab: "0",
}
},
// async mounted () {
// const code = this.$route.query.code
// if (code) {
// this.tab = "4"
// const instance = await api.setCode({code, is_admin: true})
// }
async mounted () {
console.log('sono dentro mounted', this.$route)
const code = this.$route.query.code
if (code) {
this.tab = "4"
const instance = await this.$axios.$post('/user/code', {code, is_admin: true})
}
// // this.users = await api.getUsers()
// // this.events = await api.getUnconfirmedEvents()
// // this.settings = await api.getAdminSettings()
// this.mastodon_instance = this.settings.mastodon_auth && this.settings.mastodon_auth.instance
// },
},
async asyncData ({ $axios, params, store }) {
console.log(store.state)
const users = await $axios.$get('/users')
return { users }
try {
const users = await $axios.$get('/users')
const events = await $axios.$get('/event/unconfirmed')
const settings = await $axios.$get('/settings')
return { users, events, settings, mastodon_instance: settings.mastodon_auth && settings.mastodon_auth.instance}
} catch ( e ) {
console.error(e)
}
},
computed: {
...mapState(['tags', 'places']),
@@ -146,7 +154,11 @@ export default {
paginatedUsers () {
return this.users.slice((this.userPage-1) * this.perPage,
this.userPage * this.perPage)
}
},
paginatedPlaces () {
return this.places.slice((this.placePage-1) * this.perPage,
this.placePage * this.perPage)
},
},
methods: {
placeSelected (items) {
@@ -160,7 +172,7 @@ export default {
this.place.id = item.id
},
tagSelected (tag) {
this.tag = tag
this.tag = { color: tag.color, tag: tag.tag }
},
async savePlace () {
const place = await api.updatePlace(this.place)
@@ -174,20 +186,25 @@ export default {
const newuser = await api.updateUser(user)
},
async updateColor () {
const newTag = await api.updateTag(this.tag)
// try {
// const newTag = await this.$axios.$put('/tag', this.tag)
// } catch (e) {
// console.log(e)
// }
},
preview (id) {
this.$router.push(`/event/${id}`)
},
async associate () {
if (!this.mastodon_instance) return
const url = await api.getAuthURL({instance: this.mastodon_instance, admin: true})
const url = await this.$axios.$post('/user/getauthurl', {instance: this.mastodon_instance, admin: true})
setTimeout( () => window.location.href=url, 100);
},
async confirm (id) {
try {
this.loading = true
await api.confirmEvent(id)
await this.$axios.$get(`/event/confirm/${id}`)
this.loading = false
Message({
message: this.$t('event_confirmed'),