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

@@ -5,7 +5,7 @@
el-tabs.mb-2(v-model='activeTab' v-loading='sending')
//- NOT LOGGED EVENT
el-tab-pane(v-if='!logged')
el-tab-pane(v-if='!$auth.loggedIn')
span(slot='label') {{$t('event.anon')}} <v-icon name='user-secret'/>
p(v-html="$t('event.anon_description')")
el-button.float-right(@click='next' :disabled='!couldProceed') {{$t('common.next')}}
@@ -13,7 +13,14 @@
//- WHERE
el-tab-pane
span(slot='label') {{$t('common.where')}} <v-icon name='map-marker-alt'/>
div {{$t('common.where')}}
div {{$t('common.where')}}
el-popover(
placement="top-start"
width="400"
trigger="hover")
v-icon(slot='reference' color='#ff9fc4' name='question-circle')
slot
p {{$t('event.where_description')}}
el-select.mb-3(v-model='event.place.name' @change='placeChoosed' filterable allow-create default-first-option)
el-option(v-for='place in places_name' :label='place' :value='place' :key='place.id')
div {{$t("common.address")}}
@@ -119,7 +126,6 @@ export default {
places_name: state => state.places.map(p => p.name ),
places: state => state.places,
user: state => state.user,
logged: state => state.logged
}),
disableAddress () {
console.log('dentro disable Address')
@@ -128,7 +134,7 @@ export default {
return ret
},
couldProceed () {
const t = this.logged ? -1 : 0
const t = this.$auth.loggedIn ? -1 : 0
switch(Number(this.activeTab)) {
case 0+t:
return true
@@ -209,7 +215,7 @@ export default {
this.updateMeta()
this.sending = false
this.$refs.modal.hide()
Message({ type: 'success', message: this.logged ? this.$t('event.added') : this.$t('event.added_anon')})
Message({ type: 'success', message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon')})
} catch (e) {
this.sending = false
console.error(e)

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'),

22
pages/embed/list.vue Normal file
View File

@@ -0,0 +1,22 @@
<template lang="pug">
div
p porcodio
</template>
<script>
import { mapState } from 'vuex'
// import List from '../../components/List'
import moment from 'dayjs'
export default {
name: 'diocane',
layout: 'iframe',
// components: { List },
async asyncData ({ $axios, req, res }) {
const show_tags = req.query.showtags
const tags = req.query.tags
const places = req.query.places
const events = await $axios.$get('/export/json')
return { events, show_tags }
},
}
</script>

View File

@@ -3,26 +3,26 @@
b-card(no-body, :img-src='imgPath' v-loading='loading')
nuxt-link(to='/')
el-button.close_button(circle icon='el-icon-close' type='success'
@click='$refs.eventDetail.hide()')
@click.prevent='$refs.eventDetail.hide()')
b-card-header
h3 {{event.title}}
v-icon(name='clock')
span {{event.start_datetime|datetime}}
br
v-icon(name='map-marker-alt')
//- span {{event.place.name}} - {{event.place.address}}
span {{event.place.name}} - {{event.place.address}}
br
b-card-body(v-if='event.description || event.tags')
pre(v-html='event.description')
br
el-tag.mr-1(:color='tag.color || "grey"' v-for='tag in event.tags'
el-tag.mr-1(:color='tag.color' v-for='tag in event.tags'
size='mini' :key='tag.tag') {{tag.tag}}
.ml-auto(v-if='mine')
div(v-if='mine')
hr
el-button(v-if='event.is_visible' plain type='warning' @click.prevents='toggle' icon='el-icon-view') {{$t('Unconfirm')}}
el-button(v-else plain type='success' @click.prevents='toggle' icon='el-icon-view') {{$t('Confirm')}}
el-button(plain type='danger' @click.prevent='remove' icon='el-icon-remove') {{$t('Remove')}}
el-button(plain type='primary' @click='$router.replace("/edit/"+event.id)') <v-icon color='orange' name='edit'/> {{$t('Edit')}}
el-button(v-if='event.is_visible' plain type='warning' @click.prevents='toggle' icon='el-icon-view') {{$t('common.hide')}}
el-button(v-else plain type='success' @click.prevents='toggle' icon='el-icon-view') {{$t('common.confirm')}}
el-button(plain type='danger' @click.prevent='remove' icon='el-icon-remove') {{$t('common.remove')}}
el-button(plain type='primary' @click='$router.replace("/edit/"+event.id)') <v-icon color='orange' name='edit'/> {{$t('common.edit')}}
//- COMMENTS ...
//- b-navbar(type="dark" variant="dark" toggleable='lg')
@@ -34,10 +34,17 @@
//- span.mr-3 {{event.comments.length}} <v-icon name='comments'/>
//- a(href='#', @click='remove')
v-icon(color='orange' name='times')
//- b-card-footer(v-for='comment in event.comments')
strong {{comment.author}}
div(v-html='comment.text')
//- el-footer(v-for='comment in event.comments')
strong {{comment.author}}
div(v-html='comment.text')
//- el-timeline
//- el-timeline-item(v-for='comment in event.comments')
//- p(v-html='comment.text')
//- a.el-timeline-item__timestamp(href='') {{comment.createdAt}}
strong {{$t('common.comments')}}
div.text.item(v-for='comment in event.comments')
span(v-html='comment.text')
</template>
<script>
import { mapState, mapActions } from 'vuex';
@@ -46,13 +53,27 @@ import { mapState, mapActions } from 'vuex';
export default {
name: 'Event',
head () {
return {
title: this.event.title,
meta: [
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
{ hid: 'description', name: 'description', content: this.event.description },
{ hid: 'og-description', name: 'og:description', content: this.event.description },
{ hid: 'og-title', property: 'og:title', content: this.event.title },
{ hid: 'og-url', property: 'og:url', content: `event/${this.event.id}` },
{ property: 'og:type', content: 'event'},
{ property: 'og:image', content: this.imgPath }
]
}
},
computed: {
...mapState(['user']),
...mapState([]),
imgPath () {
return this.event.image_path && process.env.VUE_APP_API + '/uploads/' + this.event.image_path
return this.event.image_path && '/media/' + this.event.image_path
},
mine () {
return this.event.userId === this.user.id || this.user.is_admin
return this.event.userId === this.$auth.user.id || this.$auth.user.is_admin
}
},
data () {
@@ -90,11 +111,9 @@ export default {
try {
if (this.event.is_visible) {
await this.$axios.$get(`/event/unconfirm/${this.id}`)
// await api.unconfirmEvent(this.id)
this.event.is_visible = false
} else {
await this.$axios.$get(`/event/confirm/${this.id}`)
// await api.confirmEvent(this.id)
this.event.is_visible = true
}
} catch (e) {

View File

@@ -1,53 +1,58 @@
<template lang="pug">
b-modal(ref='modal' @hidden='$router.replace("/")'
:title='$t("Export")' :visible='true' size='lg' hide-footer)
p {{$t('export_intro')}}
:title='$t("common.export")' :visible='true' size='lg' hide-footer)
p {{$t('export.intro')}}
li(v-if='filters.tags.length') {{$t('Tags')}}:
li(v-if='filters.tags.length') {{$t('common.tags')}}:
el-tag.ml-1(color='#409EFF' size='mini' v-for='tag in filters.tags' :key='tag.tag') {{tag}}
li(v-if='filters.places.length') {{$t('Places')}}:
li(v-if='filters.places.length') {{$t('common.places')}}:
el-tag.ml-1(color='#409EFF' size='mini' v-for='place in filters.places' :key='place.id') {{place}}
el-tabs.mt-2(tabPosition='left' v-model='type')
el-tab-pane.pt-1(label='email' name='email')
p(v-html='$t(`export_email_explanation`)')
p(v-html='$t(`export.email_description`)')
el-form(@submit.native.prevent)
//- el-switch(v-model='notification.notify_on_add' :active-text="$t('notify_on_insert')")
//- br
//- el-switch.mt-2(v-model='notification.send_notification' :active-text="$t('send_notification')")
el-input.mt-2(v-model='notification.email' :placeholder="$t('Insert your address')" ref='email')
el-input.mt-2(v-model='notification.email' :placeholder="$t('common.insert_your_address')" ref='email')
el-button.mt-2.float-right(native-type= 'submit' type='success' @click='add_notification') {{$t('Send')}}
el-tab-pane.pt-1(label='feed rss' name='feed')
span(v-html='$t(`export_feed_explanation`)')
span(v-html='$t(`export.feed_description`)')
el-input(v-model='link')
el-button(slot='append' plain type="primary" icon='el-icon-document' v-clipboard:copy="link") {{$t("Copy")}}
el-button(slot='append' plain type="primary" icon='el-icon-document' v-clipboard:copy="link") {{$t("common.copy")}}
el-tab-pane.pt-1(label='ics/ical' name='ics')
p(v-html='$t(`export_ical_explanation`)')
p(v-html='$t(`export.ical_description`)')
el-input(v-model='link')
el-button(slot='append' plain type="primary" icon='el-icon-document' v-clipboard:copy="link") {{$t("Copy")}}
el-button(slot='append' plain type="primary" icon='el-icon-document' v-clipboard:copy="link") {{$t("common.opy")}}
el-tab-pane.pt-1(label='list' name='list')
p(v-html='$t(`export_list_explanation`)')
el-card.mb-1(no-body header='Eventi')
b-list-group#list(flush)
b-list-group-item.flex-column.align-items-start(v-for="event in filteredEvents" :key='event.id'
:to='`/event/${event.id}`')
//- b-media
img(v-if='event.image_path' slot="aside" :src="imgPath(event)" alt="Meia Aside" style='max-height: 60px')
small.float-right {{event.start_datetime|datetime}}
strong.mb-1 {{event.title}}
br
small.float-right {{event.place.name}}
el-tag.mr-1(:color='tag.color || "grey"' size='mini' v-for='tag in event.tags' :key='tag.tag') {{tag.tag}}
p(v-html='$t(`export.list_description`)')
//- el-form-item(:label="$t('export.show_tags')")
el-switch(v-model='list.show_tags')
iframe(:src='`http://localhost:3000/embed/list?tags=cia&showtags=${list.show_tags?"true":""}`' height='300')
//- el-card.mb-1(no-body header='Eventi')
//- b-list-group#list(flush)
//- b-list-group-item.flex-column.align-items-start(v-for="event in filteredEvents" :key='event.id'
//- :to='`/event/${event.id}`')
//- //- b-media
//- img(v-if='event.image_path' slot="aside" :src="imgPath(event)" alt="Meia Aside" style='max-height: 60px')
//- small.float-right {{event.start_datetime|datetime}}
//- strong.mb-1 {{event.title}}
//- br
//- small.float-right {{event.place.name}}
//- el-tag.mr-1(:color='tag.color || "grey"' size='mini' v-for='tag in event.tags' :key='tag.tag') {{tag.tag}}
el-input.mb-1(type='textarea' v-model='script')
el-button.float-right(plain type="primary" icon='el-icon-document' v-clipboard:copy="script") Copy
el-tab-pane.pt-1(label='calendar' name='calendar')
p(v-html='$t(`export_calendar_explanation`)')
Calendar.mb-1
p(v-html='$t(`export.calendar_description`)')
//- no-ssr
Calendar.mb-1
el-input.mb-1(type='textarea' v-model='script')
el-button.float-right(plain type="primary" icon='el-icon-document' v-clipboard:copy="script") Copy
@@ -57,13 +62,14 @@ import { mapState } from 'vuex'
import path from 'path'
// import filters from '../filters'
import Calendar from '@/components/Calendar'
import List from '@/components/List'
import {intersection} from 'lodash'
// import api from '@/api'
import { Message } from 'element-ui'
export default {
name: 'Export',
components: { Calendar },
components: { List },
data () {
return {
type: 'email',
@@ -71,6 +77,7 @@ export default {
export_list: true,
script: `<iframe>Ti piacerebbe</iframe>`,
notification: { email: '' },
list: { show_tags: true },
}
},
// filters,
@@ -113,7 +120,7 @@ export default {
},
},
computed: {
...mapState(['filters', 'user', 'logged', 'events']),
...mapState(['filters', 'events']),
filteredEvents () {
return this.$store.getters.filteredEvents.filter(e => !e.past)
},

View File

@@ -26,7 +26,7 @@ export default {
// if (code) {
// const res = await api.setCode({code})
// }
const user = await $axios.$get('/user')
const user = await $axios.$get('/auth/user')
user.mastodon_auth = ''
return { user } //, mastodon_instance: user.mastodon_auth.instance }
// this.user = user