This commit is contained in:
lesion
2019-05-30 12:04:14 +02:00
parent 69792b518e
commit 6099d538c0
47 changed files with 1220 additions and 998 deletions

View File

@@ -1,6 +1,6 @@
<template lang="pug">
b-modal(hide-footer @hidden='$router.replace("/")' :title='$t("About")'
:visible='true' size='lg')
el-dialog(:title='$t("common.info")' visible
:before-close='close')
h5 Chi siamo
p.
Gancio e' un progetto dell'<a href='https://autistici.org/underscore'>underscore hacklab</a> e uno dei
@@ -18,11 +18,9 @@
blockquote.
Se vieni a Torino e dici: "ehi, ci diamo un gancio alle 8?" nessuno si presenterà con i guantoni per fare a mazzate.
Darsi un gancio vuol dire beccarsi alle ore X in un posto Y
p
small A: a che ora è il gancio in radio per andare al presidio?
p
small B: non so ma domani non posso venire, ho gia' un gancio per caricare il bar.
li A: a che ora è il gancio in radio per andare al presidio?
li B: non so ma domani non posso venire, ho gia' un gancio per caricare il bar.
br
h5 Contatti
p.
@@ -31,4 +29,19 @@
<a href='https://git.lattuga.net/cisti/gancio'>qui</a>. Aiuti e suggerimenti sono sempre benvenuti, puoi scriverci
su underscore chicciola autistici.org
</template>
</template>
<script>
export default {
data () {
return {
open: true,
}
},
methods: {
close (done) {
this.$router.replace('/')
done()
}
}
}
</script>

View File

@@ -1,8 +1,7 @@
<template lang="pug">
b-modal(ref='modal' @hidden='$router.replace("/")' size='lg' :visible='true'
:title="edit?$t('common.edit_event'):$t('common.add_event')" hide-footer)
el-form
el-tabs.mb-2(v-model='activeTab' v-loading='sending')
el-dialog(:before-close='close' :visible='open' :title="edit?$t('common.edit_event'):$t('common.add_event')")
el-form(v-loading='loading')
el-tabs.mb-2(v-model='activeTab')
//- NOT LOGGED EVENT
el-tab-pane(v-if='!$auth.loggedIn')
@@ -12,19 +11,28 @@
//- WHERE
el-tab-pane
span(slot='label') {{$t('common.where')}} <v-icon name='map-marker-alt'/>
div {{$t('common.where')}}
span(slot='label') <v-icon name='map-marker-alt'/> {{$t('common.where')}}
div {{$t('common.where')}}
el-popover(
placement="top-start"
width="400"
trigger="hover")
trigger="click")
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)
p(v-html="$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")}}
el-input.mb-3(ref='address' v-model='event.place.address' :disabled='places_name.indexOf(event.place.name)>-1' @keydown.native.enter='next')
br
br
div {{$t("common.address")}} {{event.place.name}}
el-input.mb-3(ref='address' v-model='event.place.address'
:disabled='places_name.indexOf(event.place.name)>-1'
@keydown.native.enter='next')
el-button.float-right(@click='next' :disabled='!couldProceed') {{$t('common.next')}}
//- WHEN
@@ -32,15 +40,27 @@
span(slot='label') {{$t('common.when')}} <v-icon name='clock'/>
span {{event.multidate ? $t('event.dates_description') : $t('event.date_description')}}
el-switch.float-right(v-model='event.multidate' :active-text="$t('event.multidate_description')")
v-date-picker.mb-3(:mode='event.multidate ? "range" : "single"' v-model='date' is-inline
is-expanded :min-date='new Date()' @input='date ? $refs.time_start.focus() : false')
div {{$t('event.time_start_description')}}
el-time-select.mb-3(ref='time_start'
v-model="time.start"
:picker-options="{ start: '00:00', step: '00:30', end: '24:00'}")
div {{$t('event.time_end_description')}}
el-time-select(v-model='time.end'
:picker-options="{start: '00:00', step: '00:30', end: '24:00'}")
v-date-picker.mb-3(
:mode='event.multidate ? "range" : "single"'
:attributes='attributes'
v-model='date'
is-inline
is-expanded
:min-date='new Date()'
)
el-row
el-col(:span='12')
div {{$t('event.time_start_description')}}
el-time-select.mb-3(ref='time_start'
v-model="time.start"
:picker-options="{ start: '00:00', step: '00:30', end: '24:00'}")
div {{$t('event.time_end_description')}}
el-time-select(v-model='time.end'
:picker-options="{start: '00:00', step: '00:30', end: '24:00'}")
el-col(:span='12')
List(:events='todayEvents' :title='$t("event.same_day")')
el-button.float-right(@click='next' :disabled='!couldProceed') {{$t('common.next')}}
//- WHAT
@@ -61,35 +81,45 @@
el-tab-pane
span(slot='label') {{$t('common.media')}} <v-icon name='image'/>
span {{$t('event.media_description')}}
b-form-file.mb-2(v-model='event.image', :placeholder='$t("common.poster")' accept='image/*')
el-button.float-right(@click='done') {{edit?$t('common.edit'):$t('common.send')}}
el-upload.text-center(
action=''
:limit="1"
:auto-upload='false'
drag
:on-change='uploadedFile'
:multiple='false'
:file-list="fileList"
)
i.el-icon-upload
div.el-upload__text {{$t('event.media_description')}}
el-button.float-right(@click='done' :disabled='!couldProceed') {{edit?$t('common.edit'):$t('common.send')}}
</template>
<script>
// import api from '@/plugins/api'
import { mapActions, mapState } from 'vuex'
import { mapActions, mapState, mapGetters } from 'vuex'
import moment from 'dayjs'
import Calendar from '@/components/Calendar'
import List from '@/components/List'
import { Message } from 'element-ui'
export default {
components: { Calendar },
name: 'Add',
components: { List },
data() {
return {
event: {
place: { name: '', address: '' },
title: '', description: '', tags: [],
multidate: false,
image: false
},
visible: true,
fileList: [],
open: true,
id: null,
activeTab: "0",
date: null,
time: { start: '20:00', end: null },
edit: false,
sending: false,
loading: true,
}
},
name: 'newEvent',
@@ -100,11 +130,10 @@ export default {
}
},
async mounted () {
if (this.$route.params.id) {
this.id = this.$route.params.id
if (this.$route.params.edit) {
this.id = this.$route.params.edit
this.edit = true
const event = await api.getEvent(this.id)
// this.event.place = {name: event.place.name, address: event.place.address }
const event = await this.$axios.$get('/event/'+ this.id)
this.event.place.name = event.place.name
this.event.place.address = event.place.address || ''
this.event.multidate = event.multidate
@@ -119,6 +148,7 @@ export default {
}
}
this.updateMeta()
this.loading = false
},
computed: {
...mapState({
@@ -126,12 +156,18 @@ export default {
places_name: state => state.places.map(p => p.name ),
places: state => state.places,
user: state => state.user,
events: state => state.events
}),
todayEvents () {
const date = moment(this.date)
return this.events.filter(e => date.isSame(moment(e.start_datetime), 'day'))
},
...mapGetters(['filteredEvents']),
attributes () {
return this.events.filter(e => !e.past).map(this.eventToAttribute)
},
disableAddress () {
console.log('dentro disable Address')
const ret = this.places_name.find(p => p.name === this.event.place.name)
console.log(ret)
return ret
return this.places_name.find(p => p.name === this.event.place.name)
},
couldProceed () {
const t = this.$auth.loggedIn ? -1 : 0
@@ -143,18 +179,45 @@ export default {
this.event.place.address.length>0
case 2+t:
if (this.date && this.time.start) return true
break
case 3+t:
return this.event.title.length>0
break
case 4+t:
return true
break
return this.event.place.name.length>0 &&
this.event.place.address.length>0 &&
(this.date && this.time.start) &&
this.event.title.length>0
}
}
},
methods: {
...mapActions(['addEvent', 'updateEvent', 'updateMeta']),
close (done) {
this.$router.replace('/')
done()
},
eventToAttribute(event) {
let e = {
key: event.id,
customData: event,
order: event.start_datetime,
}
const day = moment(event.start_datetime).date()
let color = event.tags && event.tags.length && event.tags[0].color ? event.tags[0].color : 'rgba(170,170,250,0.7)'
if (event.past) color = 'rgba(200,200,200,0.5)'
if (event.multidate) {
e.dates = {
start: event.start_datetime, end: event.end_datetime
}
e.highlight = { backgroundColor: color,
// borderColor: 'transparent',
borderWidth: '4px' }
} else {
e.dates = event.start_datetime
e.dot = { backgroundColor: color, borderColor: color, borderWidth: '3px' }
}
return e
},
next () {
this.activeTab = String(Number(this.activeTab)+1)
if (this.activeTab === "2") {
@@ -171,6 +234,9 @@ export default {
}
this.$refs.address.focus()
},
uploadedFile(file, fileList) {
this.event.image = file
},
async done () {
let start_datetime, end_datetime
const [ start_hour, start_minute ] = this.time.start.split(':')
@@ -191,7 +257,7 @@ export default {
const formData = new FormData()
if (this.event.image) {
formData.append('image', this.event.image, this.event.image.name)
formData.append('image', this.event.image.raw, this.event.image.name)
}
formData.append('title', this.event.title)
formData.append('place_name', this.event.place.name)
@@ -205,7 +271,7 @@ export default {
}
if (this.event.tags)
this.event.tags.forEach(tag => formData.append('tags[]', tag))
this.sending = true
this.loading = true
try {
if (this.edit) {
await this.updateEvent(formData)
@@ -213,11 +279,11 @@ export default {
await this.addEvent(formData)
}
this.updateMeta()
this.sending = false
this.$refs.modal.hide()
this.loading = false
this.$router.replace('/')
Message({ type: 'success', message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon')})
} catch (e) {
this.sending = false
this.loading = false
console.error(e)
}
}

View File

@@ -1,6 +1,5 @@
<template lang="pug">
b-modal(hide-footer @hidden='$router.replace("/")' :title='$t("common.admin")'
:visible='true' size='lg')
el-dialog(:title='$t("common.admin")' width='80%' :visible='open' :before-close='close')
el-tabs(tabPosition='left' v-model='tab')
//- USERS
@@ -35,7 +34,7 @@
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(:data='paginatedPlaces' small @current-change="val => place=val")
el-table-column(:label="$t('common.name')")
template(slot-scope='data') {{data.row.name}}
el-table-column(:label="$t('common.address')")
@@ -61,26 +60,26 @@
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
//- TAGS
el-tab-pane.pt-1
template(slot='label')
v-icon(name='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('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="$t('common.tag')")
template(slot-scope='data')
el-tag(:color='data.row.color' size='mini') {{data.row.tag}}
el-pagination(:page-size='perPage' :currentPage.sync='tagPage' :total='tags.length')
//- el-tab-pane.pt-1
//- template(slot='label')
//- v-icon(name='tags')
//- 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('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="$t('common.tag')")
//- template(slot-scope='data')
//- 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')
v-icon(name='cog')
span {{$t('common.settings')}}
el-form(inline @submit.prevent.stop='associatemastodon_instance')
span {{$t('admin.mastodon_description')}}
@@ -91,7 +90,6 @@
</template>
<script>
import { mapState } from 'vuex'
import api from '@/plugins/api'
import { Message } from 'element-ui'
export default {
@@ -116,22 +114,18 @@ export default {
mastodon_instance: '',
settings: {},
tab: "0",
open: 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()
},
async asyncData ({ $axios, params, store }) {
console.log(store.state)
try {
const users = await $axios.$get('/users')
const events = await $axios.$get('/event/unconfirmed')
@@ -158,7 +152,7 @@ export default {
paginatedPlaces () {
return this.places.slice((this.placePage-1) * this.perPage,
this.placePage * this.perPage)
},
},
},
methods: {
placeSelected (items) {
@@ -175,15 +169,15 @@ export default {
this.tag = { color: tag.color, tag: tag.tag }
},
async savePlace () {
const place = await api.updatePlace(this.place)
// const place = await api.updatePlace(this.place)
},
async toggle(user) {
user.is_active = !user.is_active
const newuser = await api.updateUser(user)
// const newuser = await api.updateUser(user)
},
async toggleAdmin(user) {
user.is_admin = !user.is_admin
const newuser = await api.updateUser(user)
// const newuser = await api.updateUser(user)
},
async updateColor () {
// try {
@@ -198,7 +192,7 @@ export default {
async associate () {
if (!this.mastodon_instance) return
const url = await this.$axios.$post('/user/getauthurl', {instance: this.mastodon_instance, admin: true})
const url = await this.$axios.$post('/settings/getauthurl', {instance: this.mastodon_instance})
setTimeout( () => window.location.href=url, 100);
},
async confirm (id) {
@@ -207,13 +201,18 @@ export default {
await this.$axios.$get(`/event/confirm/${id}`)
this.loading = false
Message({
message: this.$t('event_confirmed'),
message: this.$t('common.event_confirmed'),
type: 'success'
})
this.events = this.events.filter(e => e.id !== id)
} catch (e) {
}
}
},
close (done) {
console.log('oppure qui !')
this.$router.replace('/')
// done()
}
}
}
</script>

View File

@@ -1,22 +1,26 @@
<template lang="pug">
div
p porcodio
List(:events="events" :title='title')
</template>
<script>
import { mapState } from 'vuex'
// import List from '../../components/List'
import { SHARED_CONF } from '../../config'
import List from '../../components/List'
import moment from 'dayjs'
export default {
name: 'diocane',
layout: 'iframe',
// components: { List },
components: { List },
async asyncData ({ $axios, req, res }) {
const title = req.query.title || SHARED_CONF.title
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 }
const now = new Date()
// TODO: filter future events based on tags/places/userid
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
return { show_tags, events, title }
},
}
</script>

View File

@@ -1,54 +1,81 @@
<template lang="pug">
b-modal#eventDetail(ref='eventDetail' hide-body hide-header hide-footer @hidden='$router.replace("/")' size='lg' :visible='true')
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.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}}
br
b-card-body(v-if='event.description || event.tags')
pre(v-html='event.description')
el-tag.mr-1(:color='tag.color' v-for='tag in event.tags'
size='mini' :key='tag.tag') {{tag.tag}}
div(v-if='mine')
hr
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')}}
el-card#eventDetail(
visible hide-header
no-header :show-close='false'
top='0vh !important'
:appendToBody='true')
b-card-body(v-if='event.activitypub_id')
strong {{$t('common.resources')}} -
//- close button
nuxt-link.float-right(to='/')
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
//- title, where, when
h5.text-center {{event.title}}
div.nextprev
nuxt-link(v-if='prev' :to='`/event/${prev.id}`')
el-button(icon='el-icon-arrow-left' round size='small' type='success' plain)
nuxt-link.float-right(v-if='next' :to='`/event/${next.id}`')
el-button(icon='el-icon-arrow-right' round size='small' plain type='success')
//- image
img(:src='imgPath' v-if='event.image_path')
.info
div {{event|event_when}}
div {{event.place.name}} - {{event.place.address}}
//- description and tags
div(v-if='event.description || event.tags')
pre(v-html='event.description')
el-tag.mr-1(v-for='tag in event.tags'
size='mini' :key='tag.tag') {{tag.tag}}
//- show hide, confirm, delete, edit buttons when allowed
div(v-if='mine')
hr
el-button(v-if='event.is_visible' size='mini' plain type='warning' @click.prevents='toggle' icon='el-icon-view') {{$t('common.hide')}}
el-button(v-else plain type='success' size='mini' @click.prevents='toggle' icon='el-icon-view') {{$t('common.confirm')}}
el-button(plain type='danger' size='mini' @click.prevent='remove' icon='el-icon-remove') {{$t('common.remove')}}
el-button(plain type='primary' size='mini' @click='$router.replace(`/add/${event.id}`)' icon='el-icon-edit') {{$t('common.edit')}}
//- comments
.card-body(v-if='event.activitypub_id')
strong {{$t('common.related')}} -
a(:href='`https://mastodon.cisti.org/web/statuses/${event.activitypub_id}`') {{$t('common.add')}}
b-card-header(v-for='comment in event.comments' :key='comment.id')
.card-header(v-for='comment in event.comments' :key='comment.id')
img.avatar(:src='comment.data.last_status.account.avatar')
strong {{comment.author}}
a.float-right(:href='comment.data.last_status.url')
small {{comment.data.last_status.created_at|datetime}}
div.mt-1(v-html='comment_filter(comment.text)')
img(v-for='img in comment.data.last_status.media_attachments' :src='img.preview_url')
//- span {{comment}}
</template>
<script>
import { mapState, mapActions } from 'vuex';
// import api from '@/plugins/api'
//import filters from '@/filters'
import { mapState, mapActions, mapGetters } from 'vuex'
import config from '@/config'
export default {
name: 'Event',
// transition: null,
// Watch for $route.query.page to call Component methods (asyncData, fetch, validate, layout, etc.)
// watchQuery: ['id'],
// Key for <NuxtChild> (transitions)
// key: to => to.fullPath,
// Called to know which transition to apply
// transition(to, from) {
// console.log('dentro transition')
// if (!from) return 'slide-left'
// return +to.params.id < +from.params.id ? 'slide-right' : 'slide-left'
// },
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: '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'},
@@ -57,33 +84,43 @@ export default {
}
},
computed: {
...mapState([]),
...mapGetters(['filteredEvents']),
next () {
let found = false
return this.filteredEvents.find(e => {
if (found) return e
if (e.id === this.event.id) found = true
})
},
prev () {
let prev = false
this.filteredEvents.find(e => {
if (e.id === this.event.id) return true
prev = e
})
return prev
},
imgPath () {
return this.event.image_path && '/media/' + this.event.image_path
},
mine () {
if (!this.$auth.user) return false
return this.event.userId === this.$auth.user.id || this.$auth.user.is_admin
},
},
data () {
return {
event: { comments: [], place: {}, title: ''},
id: null,
loading: true,
}
},
async asyncData ( { $axios, params }) {
const event = await $axios.$get(`/event/${params.id}`)
return { event, id: params.id, loading: false }
return { event, id: params.id}
},
methods: {
...mapActions(['delEvent']),
keydown (e) {
console.error(e)
},
comment_filter (value) {
console.log('dentro comment_filter')
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
// get extension
const ext = url.slice(-4)
console.log('dentro il replace ', ext)
if (['.mp3', '.ogg'].indexOf(ext)>-1) {
return `<audio controls><source src='${url}'></audio>`
} else {
@@ -92,9 +129,13 @@ export default {
})
},
async remove () {
await api.delEvent(this.event.id)
this.delEvent(this.event.id)
this.$refs.eventDetail.hide()
try {
await this.$axios.delete(`/user/event/${this.id}`)
this.delEvent(Number(this.id))
this.$router.back()
} catch (e) {
console.error(e)
}
},
async toggle () {
try {
@@ -106,49 +147,60 @@ export default {
this.event.is_visible = true
}
} catch (e) {
console.error(e)
}
}
}
}
</script>
<style>
<style lang='less'>
#eventDetail .avatar {
height: 40px;
border-radius: 5px;
#eventDetail {
max-width: 1000px;
border-radius: 0px;
margin: 0 auto;
pre {
color: #404246;
font-size: 1em;
font-family: BlinkMacSystemFont,-apple-system,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,Helvetica,Arial,sans-serif !important;
}
h5 {
font-size: 1.4em;
min-height: 40px;
}
.info {
margin: 10px;
font-size: 1.3em;
font-weight: 600;
text-align: center;
}
img {
width: 100%;
max-height: 89vh;
object-fit: contain;
}
.avatar {
width: auto;
height: 40px;
border-radius: 5px;
}
.nextprev {
font-size: 10px;
margin-bottom: 5px;
}
}
#eventDetail .image {
max-height: 200px;
@media only screen and (max-width: 768px) {
#eventDetail {
font-size: 12px;
}
}
/* #eventDetail {
display: block !important;
opacity: 1;
} */
#eventDetail .modal-body {
padding: 0px;
width: 100%;
}
#eventDetail .close_button:hover {
background-color: rgba(200, 100, 100, 0.4);
}
#eventDetail .card {
border: 0px;
}
#eventDetail .close_button {
background-color: rgba(100, 100, 100, 0.3);
color: red;
font-size: 20px;
border: 1px dashed rgba(20,20,20,0.3);
position: absolute;
top: 10px;
right: 10px;
}
</style>

View File

@@ -1,13 +1,12 @@
<template lang="pug">
b-modal(ref='modal' @hidden='$router.replace("/")'
:title='$t("common.export")' :visible='true' size='lg' hide-footer)
el-dialog(:title='$t("common.export")' visible :before-close='close')
p {{$t('export.intro')}}
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}}
el-tag.ml-1(size='mini' v-for='tag in filters.tags' :key='tag.tag') {{tag}}
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-tag.ml-1(size='mini' v-for='place in filters.places' :key='place.id') {{place}}
el-tabs.mt-2(v-model='type')
el-tab-pane.pt-1(label='email' name='email')
p(v-html='$t(`export.email_description`)')
@@ -15,57 +14,50 @@
//- 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('common.insert_your_address')" ref='email')
el-button.mt-2.float-right(native-type= 'submit' type='success' @click='add_notification') {{$t('Send')}}
el-input.mt-2(v-model='notification.email' :placeholder="$t('export.insert_your_address')" ref='email')
el-button.mt-2.float-right(native-type= 'submit' type='success' @click='add_notification') {{$t('common.send')}}
el-tab-pane.pt-1(label='feed rss' name='feed')
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("common.copy")}}
el-button(slot='append' plain type="primary" icon='el-icon-document' ) {{$t("common.copy")}}
el-tab-pane.pt-1(label='ics/ical' name='ics')
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("common.opy")}}
el-button(slot='append' plain type="primary" icon='el-icon-document') {{$t("common.copy")}}
el-tab-pane.pt-1(label='list' name='list')
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-row
el-col.mr-2(:span='11')
el-input(v-model='list.title') Title
el-col.float-right(:span='12')
List(
:title='list.title'
:events='filteredEvents'
)
el-input.mb-1(type='textarea' v-model='listScript' readonly )
el-button.float-right(plain type="primary" icon='el-icon-document') {{$t('common.copy')}}
el-tab-pane.pt-1(label='calendar' name='calendar')
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
//- el-tab-pane.pt-1(label='calendar' name='calendar')
//- 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') Copy
</template>
<script>
import { mapState } from 'vuex'
import { mapState, mapGetters } 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'
const { SHARED_CONF } = require('@/config')
export default {
name: 'Export',
@@ -73,33 +65,40 @@ export default {
data () {
return {
type: 'email',
link: '',
export_list: true,
script: `<iframe>Ti piacerebbe</iframe>`,
notification: { email: '' },
list: { show_tags: true },
list: { title: SHARED_CONF.title },
}
},
// filters,
mounted () {
this.link = this.loadLink()
},
watch: {
type (value) {
this.link = this.loadLink()
}
},
methods: {
async add_notification () {
if (!this.notification.email){
Message({message:'Inserisci una mail', type: 'error'})
return this.$refs.email.focus()
}
await api.addNotification({ ...this.notification, filters: this.filters})
this.$refs.modal.hide()
// await api.addNotification({ ...this.notification, filters: this.filters})
// this.$refs.modal.hide()
Message({message: this.$t('email_notification_activated'), type: 'success'})
},
loadLink () {
imgPath (event) {
return event.image_path && event.image_path
},
close (done) {
this.$router.replace('/')
done()
}
},
computed: {
...mapState(['filters', 'events']),
...mapGetters(['filteredEvents']),
listScript () {
const params = []
if (this.list.title) {
params.push(`title=${this.list.title}`)
}
return `<iframe src="${SHARED_CONF.baseurl}/embed/list?${params.join('&')}"></iframe>`
},
link () {
const tags = this.filters.tags.join(',')
const places = this.filters.places.join(',')
let query = ''
@@ -113,17 +112,8 @@ export default {
}
}
return `${process.env.VUE_APP_API}/api/export/${this.type}${query}`
},
imgPath (event) {
return event.image_path && event.image_path
},
},
computed: {
...mapState(['filters', 'events']),
filteredEvents () {
return this.$store.getters.filteredEvents.filter(e => !e.past)
},
return `${SHARED_CONF.baseurl}/api/export/${this.type}${query}`
},
showLink () {
return (['feed', 'ics'].indexOf(this.type)>-1)
},

View File

@@ -1,2 +1,15 @@
<template lang="pug">
#home
Nav
Home
</template>
<script>
import Home from '~/components/Home.vue'
import Nav from '~/components/Nav.vue'
export default {
name: 'Index',
components: { Nav, Home },
}
</script>

View File

@@ -1,15 +1,21 @@
<template lang='pug'>
b-modal(@shown="$refs.email.focus()" :title='$t("common.login")' hide-footer
@hidden='$router.replace("/")' :visible='true' ref='modal')
el-dialog(:title='$t("common.login")' :before-close='close' visible)
el-form(v-loading='loading')
p(v-html="$t('login.description')")
el-input.mb-2(v-model='email' type='email' :placeholder='$t("common.email")' autocomplete='email' ref='email')
v-icon(name='user' slot='prepend')
i.el-icon-user(slot='prepend')
el-input.mb-1(v-model='password' @keyup.enter.native="submit" type='password' :placeholder='$t("common.password")')
v-icon(name="lock" slot='prepend')
el-button.mr-1(plain type="success" @click='submit') {{$t('common.login')}}
router-link(to='/register')
i.el-icon-lock(slot='prepend')
el-button.mr-1(plain type="success" :disabled='!email || !password' @click='submit') {{$t('common.login')}}
nuxt-link(to='/register')
el-button.mt-1(plain type="primary") {{$t('login.not_registered')}}
a.float-right(href='#' @click='forgot') {{$t('login.forgot_password')}}
</template>
@@ -17,18 +23,22 @@
const Cookie = process.client ? require('js-cookie') : undefined
import { mapActions } from 'vuex'
import { Message } from 'element-ui'
// import api from '@/plugins/api'
import get from 'lodash/get'
export default {
name: 'Login',
data () {
return {
open: true,
password: '',
email: '',
loading: false
}
},
methods: {
close () {
this.$router.replace('/')
},
...mapActions(['login']),
async forgot () {
if (!this.email) {
@@ -37,7 +47,7 @@ export default {
return
}
this.loading = true
// await api.forgotPassword(this.email)
await this.$axios.$post('/user/recover', { email: this.email })
this.loading = false
Message({ message: this.$t('login.check_email'), type: 'success' })
},
@@ -49,12 +59,12 @@ export default {
this.loading = false
Message({ message: this.$t('login.ok'), type: 'success' })
} catch (e) {
Message({ message: this.$t('login.error') + e, type: 'error' })
e = get(e, 'response.data.message', e)
Message({ message: this.$t('login.error') + this.$t(e), type: 'error' })
this.loading = false
return
}
this.email = this.password = ''
this.$refs.modal.hide()
}
}
}

View File

@@ -1,9 +1,8 @@
<template lang='pug'>
b-modal(hide-footer @hidden='$router.replace("/")' ref='modal'
:title="$t('common.register')" :visible='true' @shown='$refs.email.focus()')
el-dialog(:title="$t('common.register')" visible :before-close='() => $router.replace("/")' @open='$refs.email.focus()')
el-form
p(v-html="$t('register.description')")
el-input.mb-2(ref='email' v-model='user.email' type='email'
el-input.mb-2(ref='email' v-model='user.email' type='email' required
:placeholder='$t("common.email")' autocomplete='email')
span(slot='prepend') @
@@ -13,11 +12,10 @@
el-input.mb-2(v-model='user.description' type="textarea" rows='3' :placeholder="$t('common.description')")
v-icon(name='envelope-open-text')
el-button.float-right(plain type="success" icon='el-icon-arrow-right' @click='register') {{$t('common.send')}}
el-button(plain type="success" icon='el-icon-arrow-right' :disabled='!user.password || !user.email || !user.description' @click='register') {{$t('common.send')}}
</template>
<script>
import api from '@/plugins/api'
import { mapActions } from 'vuex'
import { Message } from 'element-ui'
@@ -28,23 +26,29 @@ export default {
error: {},
user: { }
}
},
computed: {
},
methods: {
...mapActions(['login']),
async register () {
try {
const user = await this.$axios.$post('/user', this.user)
this.$refs.modal.hide()
Message({
message: this.$t(`register.${user.is_admin && 'admin_'}complete`),
type: 'success'
})
this.$router.replace("/")
} catch (e) {
console.log('DENTRO CATCH!!!', e)
const error = e && e.response && e.response.data && e.response.data.errors[0].message || e
console.error(error)
console.error(e)
Message({
message: this.$t('register.error') + e,
message: this.$t('register.error') + error,
type: 'error'
})
console.error(e)
}
}
}

View File

@@ -1,58 +1,40 @@
<template lang="pug">
b-modal(:title="$t('common.settings')" hide-footer @hidden='$router.replace("/")' :visible='true')
h5 {{user.name}}
el-input(v-model="mastodon_instance" @enter.native='associate')
span(slot='prepend') {{$t('settings.mastodon_instance')}}
el-button(v-if='!user.mastodon_auth' slot='append' @click='associate' type='success') {{$t('settings.associate')}}
el-button(v-else slot='append' @click='deassociate' variant='success') {{$t('settings.unassociate')}}
el-input.mt-2(v-model='password' type='password')
span(slot='prepend') {{$t('settings.change_password')}}
el-button(slot='append' @click='change' type='success') {{$t('settings.change')}}
el-dialog(:title="$t('common.settings')" :before-close='close' visible)
//- el-form
//- el-form-item {{$t('settings.change_password')}}
el-divider {{$t('settings.change_password')}}
el-input(v-model='password' type='password')
el-button(slot='append' @click='change' type='success') {{$t('common.send')}}
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
props: ['code'],
data () {
return {
mastodon_instance: '',
password: '',
user: {}
}
},
computed: mapState(['oauth', 'user']),
async asyncData ({ $axios, params }) {
// const code = this.$route.query.code
// if (code) {
// const res = await api.setCode({code})
// }
const user = await $axios.$get('/auth/user')
user.mastodon_auth = ''
return { user } //, mastodon_instance: user.mastodon_auth.instance }
// this.user = user
// this.mastodon_instance = user.mastodon_auth.instance
},
// computed: mapState(['user']),
// async asyncData ({ $axios, params }) {
// const user = await $axios.$get('/auth/user')
// user.mastodon_auth = ''
// return { user }
// },
methods: {
async change () {
if (!this.password) return
const user = this.user
user.password = this.password
try {
await api.updateUser(user)
} catch (e) {
console.log(e)
}
},
async deassociate () {
const user = this.user
user.mastodon_auth = ''
this.mastodon_instance = ''
await api.updateUser(user)
},
async associate () {
if (!this.mastodon_instance) return
const url = await this.$axios.$post('/user/getauthurl', {instance: this.mastodon_instance})
setTimeout( () => window.location.href=url, 100);
async change () {
if (!this.password) return
const user = this.user
user.password = this.password
try {
// this.$axios.
// await api.updateUser(user)
} catch (e) {
console.log(e)
}
},
close (done) {
this.$router.back()
done()
}
}
}