linting
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
|
||||
el-button.float-right(@click.native='next' :disabled='!couldProceed') {{$t('common.next')}}
|
||||
|
||||
|
||||
//- WHERE
|
||||
el-tab-pane
|
||||
span(slot='label') <v-icon name='map-marker-alt'/> {{$t('common.where')}}
|
||||
@@ -89,7 +88,7 @@
|
||||
el-form-item(:label="$t('event.due')")
|
||||
el-time-select(v-model='time.end'
|
||||
:picker-options="{start: '00:00', step: '00:30', end: '24:00'}")
|
||||
|
||||
|
||||
List(v-if='event.type==="normal" && todayEvents.length' :events='todayEvents' :title='$t("event.same_day")')
|
||||
el-button.float-right(@click='next' type='succes' :disabled='!couldProceed') {{$t('common.next')}}
|
||||
|
||||
@@ -123,8 +122,9 @@ import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: 'Add',
|
||||
name: 'newEvent',
|
||||
components: { List },
|
||||
validate ({store}) {
|
||||
validate ({ store }) {
|
||||
return (store.state.auth.loggedIn || store.state.settings.allow_anon_event)
|
||||
},
|
||||
head () {
|
||||
@@ -132,61 +132,50 @@ export default {
|
||||
title: `${this.settings.title} - ${this.$t('common.add_event')}`
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const month = moment().month()+1
|
||||
data () {
|
||||
const month = moment().month() + 1
|
||||
const year = moment().year()
|
||||
return {
|
||||
event: {
|
||||
type: 'normal',
|
||||
place: { name: '', address: '' },
|
||||
title: '', description: '', tags: [],
|
||||
title: '',
|
||||
description: '',
|
||||
tags: [],
|
||||
image: false,
|
||||
recurrent: { frequency: '1w', days: [], type: 'weekday' },
|
||||
recurrent: { frequency: '1w', days: [], type: 'weekday' }
|
||||
},
|
||||
page: { month, year},
|
||||
page: { month, year },
|
||||
fileList: [],
|
||||
id: null,
|
||||
activeTab: "0",
|
||||
activeTab: '0',
|
||||
date: null,
|
||||
time: { start: '20:00', end: null },
|
||||
edit: false,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
name: 'newEvent',
|
||||
watch: {
|
||||
'time.start' (value) {
|
||||
if (!value) return
|
||||
let [h, m] = value.split(':')
|
||||
this.time.end = (Number(h)+1) + ':' + m
|
||||
if (!value) { return }
|
||||
const [h, m] = value.split(':')
|
||||
this.time.end = (Number(h) + 1) + ':' + m
|
||||
},
|
||||
// month selected
|
||||
page () {
|
||||
this.updateEvents(this.page)
|
||||
}
|
||||
},
|
||||
async fetch ({ store, $axios }) {
|
||||
try {
|
||||
const now = new Date()
|
||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||
store.commit('setEvents', events)
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
} catch(e) {
|
||||
console.error('Error ', e)
|
||||
}
|
||||
moment.locale(store.state.locale)
|
||||
},
|
||||
async asyncData ( { params, $axios, error, store }) {
|
||||
async asyncData ({ params, $axios, error, store }) {
|
||||
if (params.edit) {
|
||||
const data = { time: {}, event: { place: {} }}
|
||||
const data = { time: {}, event: { place: {} } }
|
||||
data.id = params.edit
|
||||
data.edit = true
|
||||
let event
|
||||
try {
|
||||
event = await $axios.$get('/event/'+ data.id)
|
||||
event = await $axios.$get('/event/' + data.id)
|
||||
} catch (e) {
|
||||
error({ statusCode: 404, message: 'Event not found!'})
|
||||
error({ statusCode: 404, message: 'Event not found!' })
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -195,7 +184,7 @@ export default {
|
||||
if (event.multidate) {
|
||||
data.date = { start: moment.unix(event.start_datetime), end: moment.unix(event.end_datetime) }
|
||||
data.event.type = 'multidate'
|
||||
} else if (event.recurrent ) {
|
||||
} else if (event.recurrent) {
|
||||
data.event.type = 'recurrent'
|
||||
data.event.recurrent = JSON.parse(event.recurrent)
|
||||
} else {
|
||||
@@ -216,10 +205,22 @@ export default {
|
||||
}
|
||||
return {}
|
||||
},
|
||||
async fetch ({ store, $axios }) {
|
||||
try {
|
||||
const now = new Date()
|
||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||
store.commit('setEvents', events)
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
} catch (e) {
|
||||
console.error('Error ', e)
|
||||
}
|
||||
moment.locale(store.state.locale)
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
tags: state => state.tags.map(t => t.tag ),
|
||||
places_name: state => state.places.map(p => p.name ).sort((a, b) => b.weigth-a.weigth),
|
||||
tags: state => state.tags.map(t => t.tag),
|
||||
places_name: state => state.places.map(p => p.name).sort((a, b) => b.weigth - a.weigth),
|
||||
places: state => state.places,
|
||||
user: state => state.user,
|
||||
events: state => state.events,
|
||||
@@ -227,18 +228,18 @@ export default {
|
||||
}),
|
||||
whenPatterns () {
|
||||
const dates = this.date
|
||||
if (!dates || !dates.length) return
|
||||
if (!dates || !dates.length) { return }
|
||||
|
||||
const freq = this.event.recurrent.frequency
|
||||
const weekDays = uniq(map(dates, date => moment(date).format('dddd')))
|
||||
if (freq === '1w' || freq === '2w') {
|
||||
return this.$t(`event.recurrent_${freq}_days`, {days: weekDays.join(', ')})
|
||||
return this.$t(`event.recurrent_${freq}_days`, { days: weekDays.join(', ') })
|
||||
} else if (freq === '1m' || freq === '2m') {
|
||||
const days = uniq(map(dates, date => moment(date).date()))
|
||||
const n = Math.floor((days[0]-1)/7)+1
|
||||
const n = Math.floor((days[0] - 1) / 7) + 1
|
||||
return [
|
||||
{ label: this.$tc(`event.recurrent_${freq}_days`, days.length, {days}), key: 'ordinal' },
|
||||
{ label: this.$tc(`event.recurrent_${freq}_ordinal`, days.length, {n: this.$t(`ordinal.${n}`), days: weekDays.join(', ')}), key: 'weekday' }
|
||||
{ label: this.$tc(`event.recurrent_${freq}_days`, days.length, { days }), key: 'ordinal' },
|
||||
{ label: this.$tc(`event.recurrent_${freq}_ordinal`, days.length, { n: this.$t(`ordinal.${n}`), days: weekDays.join(', ') }), key: 'weekday' }
|
||||
]
|
||||
} else if (freq === '1d') {
|
||||
return this.$t('event.recurrent_each_day')
|
||||
@@ -246,23 +247,23 @@ export default {
|
||||
},
|
||||
todayEvents () {
|
||||
if (this.event.type === 'multidate') {
|
||||
if (!this.date || !this.date.start) return
|
||||
if (!this.date || !this.date.start) { return }
|
||||
const date_start = moment(this.date.start)
|
||||
const date_end = moment(this.date.end)
|
||||
return this.events.filter(e =>
|
||||
!e.multidate ?
|
||||
date_start.isSame(moment.unix(e.start_datetime), 'day') ||
|
||||
date_start.isBefore(moment.unix(e.start_datime)) && date_end.isAfter(moment.unix(e.start_datetime)) :
|
||||
date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) ||
|
||||
!e.multidate
|
||||
? date_start.isSame(moment.unix(e.start_datetime), 'day') ||
|
||||
date_start.isBefore(moment.unix(e.start_datime)) && date_end.isAfter(moment.unix(e.start_datetime))
|
||||
: date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) ||
|
||||
date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime)))
|
||||
} else if (this.event.type === 'recurrent' ) {
|
||||
} else if (this.event.type === 'recurrent') {
|
||||
|
||||
} else {
|
||||
const date = moment(this.date)
|
||||
return this.events.filter(e =>
|
||||
!e.multidate ?
|
||||
!e.recurrent && date.isSame(moment.unix(e.start_datetime), 'day') :
|
||||
moment.unix(e.start_datetime).isSame(date, 'day') ||
|
||||
!e.multidate
|
||||
? !e.recurrent && date.isSame(moment.unix(e.start_datetime), 'day')
|
||||
: moment.unix(e.start_datetime).isSame(date, 'day') ||
|
||||
moment.unix(e.start_datetime).isBefore(date) && moment.unix(e.end_datetime).isAfter(date)
|
||||
)
|
||||
}
|
||||
@@ -270,16 +271,18 @@ export default {
|
||||
...mapGetters(['filteredEvents']),
|
||||
attributes () {
|
||||
let attributes = []
|
||||
attributes.push ({ key: 'today', dates: new Date(), highlight: { color: 'yellow' }})
|
||||
attributes.push({ key: 'today', dates: new Date(), highlight: { color: 'yellow' } })
|
||||
|
||||
attributes = attributes.concat(this.filteredEvents
|
||||
.filter(e => !e.multidate && (!e.recurrent || this.event.type === 'recurrent'))
|
||||
.map(e => ({ key: e.id, dot: { color: this.event.type === 'recurrent' ? 'orange' : 'green' }, dates: moment.unix(e.start_datetime).toDate()})))
|
||||
.map(e => ({ key: e.id, dot: { color: this.event.type === 'recurrent' ? 'orange' : 'green' }, dates: moment.unix(e.start_datetime).toDate() })))
|
||||
|
||||
attributes = attributes.concat(this.filteredEvents
|
||||
.filter(e => e.multidate && !e.recurrent)
|
||||
.map( e => ({ key: e.id, highlight: {}, dates: {
|
||||
start: moment.unix(e.start_datetime).toDate(), end: moment.unix(e.end_datetime).toDate() }})))
|
||||
.map(e => ({ key: e.id,
|
||||
highlight: {},
|
||||
dates: {
|
||||
start: moment.unix(e.start_datetime).toDate(), end: moment.unix(e.end_datetime).toDate() } })))
|
||||
|
||||
return attributes
|
||||
},
|
||||
@@ -288,45 +291,42 @@ export default {
|
||||
},
|
||||
couldProceed () {
|
||||
const t = this.$auth.loggedIn ? -1 : 0
|
||||
switch(Number(this.activeTab)) {
|
||||
case 0+t:
|
||||
switch (Number(this.activeTab)) {
|
||||
case 0 + t:
|
||||
return true
|
||||
case 1+t:
|
||||
return this.event.title.length>0
|
||||
case 2+t:
|
||||
return this.event.place.name.length>0 &&
|
||||
this.event.place.address.length>0
|
||||
case 3+t:
|
||||
if (this.date && this.time.start) return true
|
||||
case 4+t:
|
||||
return this.event.place.name.length>0 &&
|
||||
this.event.place.address.length>0 &&
|
||||
case 1 + t:
|
||||
return this.event.title.length > 0
|
||||
case 2 + t:
|
||||
return this.event.place.name.length > 0 &&
|
||||
this.event.place.address.length > 0
|
||||
case 3 + t:
|
||||
if (this.date && this.time.start) { return true }
|
||||
case 4 + t:
|
||||
return this.event.place.name.length > 0 &&
|
||||
this.event.place.address.length > 0 &&
|
||||
(this.date && this.time.start) &&
|
||||
this.event.title.length>0
|
||||
this.event.title.length > 0
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']),
|
||||
recurrentDays () {
|
||||
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) return
|
||||
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }
|
||||
const type = this.event.recurrent.type
|
||||
if (type === 'ordinal')
|
||||
return map(this.date, d => moment(d).date())
|
||||
else if (type === 'weekday')
|
||||
return map(this.date, moment(d).day()+1)
|
||||
if (type === 'ordinal') { return map(this.date, d => moment(d).date()) } else if (type === 'weekday') { return map(this.date, moment(d).day() + 1) }
|
||||
},
|
||||
next () {
|
||||
this.activeTab = String(Number(this.activeTab)+1)
|
||||
if (this.activeTab === "2") {
|
||||
this.activeTab = String(Number(this.activeTab) + 1)
|
||||
if (this.activeTab === '2') {
|
||||
this.$refs.title.focus()
|
||||
}
|
||||
},
|
||||
prev () {
|
||||
this.activeTab = String(Number(this.activeTab-1))
|
||||
this.activeTab = String(Number(this.activeTab - 1))
|
||||
},
|
||||
placeChoosed () {
|
||||
const place = this.places.find( p => p.name === this.event.place.name )
|
||||
const place = this.places.find(p => p.name === this.event.place.name)
|
||||
if (place && place.address) {
|
||||
this.event.place.address = place.address
|
||||
} else {
|
||||
@@ -337,13 +337,13 @@ export default {
|
||||
cleanFile () {
|
||||
this.event.image = null
|
||||
},
|
||||
uploadedFile(file, fileList) {
|
||||
if (file.size / 1024/ 1024 > 4) {
|
||||
uploadedFile (file, fileList) {
|
||||
if (file.size / 1024 / 1024 > 4) {
|
||||
Message({ type: 'warning', showClose: true, message: this.$tc('event.image_too_big') })
|
||||
this.fileList = []
|
||||
return false
|
||||
}
|
||||
this.fileList = [{name: file.name, url: file.url}]
|
||||
this.fileList = [{ name: file.name, url: file.url }]
|
||||
this.event.image = file
|
||||
},
|
||||
async done () {
|
||||
@@ -351,7 +351,7 @@ export default {
|
||||
let start_datetime, end_datetime
|
||||
const [ start_hour, start_minute ] = this.time.start.split(':')
|
||||
if (!this.time.end) {
|
||||
this.time.end = (Number(start_hour)+2) + ':' + start_minute
|
||||
this.time.end = (Number(start_hour) + 2) + ':' + start_minute
|
||||
}
|
||||
const [ end_hour, end_minute ] = this.time.end.split(':')
|
||||
|
||||
@@ -365,7 +365,7 @@ export default {
|
||||
} else if (this.event.type === 'normal') {
|
||||
start_datetime = moment(this.date).set('hour', start_hour).set('minute', start_minute)
|
||||
end_datetime = moment(this.date).set('hour', end_hour).set('minute', end_minute)
|
||||
if (end_hour<start_hour) {
|
||||
if (end_hour < start_hour) {
|
||||
end_datetime = end_datetime.add(1, 'day')
|
||||
}
|
||||
} else if (this.event.type === 'recurrent') {
|
||||
@@ -373,12 +373,12 @@ export default {
|
||||
end_datetime = moment().set('hour', end_hour).set('minute', end_minute)
|
||||
const recurrent = {
|
||||
frequency: this.event.recurrent.frequency,
|
||||
days: this.event.recurrent.type === 'ordinal' ? map(this.date, d => moment(d).date() ) : map(this.date, d => moment(d).day()+1 ),
|
||||
type: this.event.recurrent.type,
|
||||
days: this.event.recurrent.type === 'ordinal' ? map(this.date, d => moment(d).date()) : map(this.date, d => moment(d).day() + 1),
|
||||
type: this.event.recurrent.type
|
||||
}
|
||||
if (end_hour<start_hour) {
|
||||
if (end_hour < start_hour) {
|
||||
end_datetime = end_datetime.add(1, 'day')
|
||||
}
|
||||
}
|
||||
formData.append('recurrent', JSON.stringify(recurrent))
|
||||
}
|
||||
|
||||
@@ -396,8 +396,7 @@ export default {
|
||||
if (this.edit) {
|
||||
formData.append('id', this.event.id)
|
||||
}
|
||||
if (this.event.tags)
|
||||
this.event.tags.forEach(tag => formData.append('tags[]', tag))
|
||||
if (this.event.tags) { this.event.tags.forEach(tag => formData.append('tags[]', tag)) }
|
||||
try {
|
||||
if (this.edit) {
|
||||
await this.updateEvent(formData)
|
||||
@@ -407,12 +406,12 @@ export default {
|
||||
this.updateMeta()
|
||||
this.$router.replace('/')
|
||||
this.loading = false
|
||||
Message({ type: 'success', showClose: true, message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon')})
|
||||
Message({ type: 'success', showClose: true, message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon') })
|
||||
} catch (e) {
|
||||
switch(e.request.status) {
|
||||
switch (e.request.status) {
|
||||
case 413:
|
||||
Message({ type: 'error', showClose: true, message: this.$t('event.image_too_big') })
|
||||
break;
|
||||
break
|
||||
default:
|
||||
Message({ type: 'error', showClose: true, message: e })
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
el-form-item(v-show='allow_recurrent_event' :label="$t('admin.recurrent_event_visible')")
|
||||
el-switch(v-model='recurrent_event_visible')
|
||||
|
||||
|
||||
el-divider {{$t('admin.federation')}}
|
||||
el-form(inline label-width='400px')
|
||||
el-form-item(:label="$t('admin.enable_federation')")
|
||||
@@ -88,33 +87,33 @@ export default {
|
||||
tagPage: 1,
|
||||
tagFields: ['tag', 'color'],
|
||||
description: '',
|
||||
tag: {name: '', color: ''},
|
||||
tag: { name: '', color: '' },
|
||||
events: [],
|
||||
loading: false,
|
||||
tab: "0",
|
||||
open: true,
|
||||
tab: '0',
|
||||
open: true
|
||||
}
|
||||
},
|
||||
head () {
|
||||
return { title: `${this.settings.title} - ${this.$t('common.admin')}` }
|
||||
},
|
||||
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})
|
||||
}
|
||||
},
|
||||
async asyncData ({ $axios, params, store }) {
|
||||
try {
|
||||
const users = await $axios.$get('/users')
|
||||
const events = await $axios.$get('/event/unconfirmed')
|
||||
return { users, events, mastodon_instance: store.state.settings.mastodon_instance }
|
||||
} catch ( e ) {
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
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 })
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['tags', 'settings']),
|
||||
allow_registration: {
|
||||
@@ -123,28 +122,28 @@ export default {
|
||||
},
|
||||
allow_anon_event: {
|
||||
get () { return this.settings.allow_anon_event },
|
||||
set (value) { this.setSetting({ key: 'allow_anon_event', value })}
|
||||
set (value) { this.setSetting({ key: 'allow_anon_event', value }) }
|
||||
},
|
||||
allow_recurrent_event: {
|
||||
get () { return this.settings.allow_recurrent_event },
|
||||
set (value) { this.setSetting({ key: 'allow_recurrent_event', value })}
|
||||
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 })}
|
||||
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
|
||||
},
|
||||
enable_federation: {
|
||||
get () { return this.settings.enable_federation },
|
||||
set (value) { this.setSetting({ key: 'enable_federation', value })}
|
||||
set (value) { this.setSetting({ key: 'enable_federation', value }) }
|
||||
},
|
||||
paginatedEvents () {
|
||||
return this.events.slice((this.eventPage-1) * this.perPage,
|
||||
return this.events.slice((this.eventPage - 1) * this.perPage,
|
||||
this.eventPage * this.perPage)
|
||||
},
|
||||
paginatedTags () {
|
||||
return this.tags.slice((this.tagPage-1) * this.perPage,
|
||||
return this.tags.slice((this.tagPage - 1) * this.perPage,
|
||||
this.tagPage * this.perPage)
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['setSetting']),
|
||||
@@ -167,7 +166,7 @@ export default {
|
||||
this.events = this.events.filter(e => e.id !== id)
|
||||
} catch (e) {
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
components: { List },
|
||||
data () {
|
||||
return {
|
||||
title : ''
|
||||
title: ''
|
||||
}
|
||||
},
|
||||
async asyncData ({ query, $axios }) {
|
||||
@@ -22,13 +22,13 @@ export default {
|
||||
const now = new Date()
|
||||
|
||||
let params = []
|
||||
if (places) params.push(`places=${places}`)
|
||||
if (tags) params.push(`tags=${tags}`)
|
||||
if (places) { params.push(`places=${places}`) }
|
||||
if (tags) { params.push(`tags=${tags}`) }
|
||||
|
||||
params = params.length ? `?${params.join('&')}` : ''
|
||||
const events = await $axios.$get(`/export/json${params}`)
|
||||
|
||||
return { events, title }
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
el-button(v-if='event.is_visible' size='mini' plain type='warning' @click.prevents='toggle') {{$t('common.hide')}}
|
||||
el-button(v-else plain type='success' size='mini' @click.prevents='toggle') {{$t('common.confirm')}}
|
||||
el-button(plain type='danger' size='mini' @click.prevent='remove') {{$t('common.remove')}}
|
||||
el-button(plain type='primary' size='mini' @click='$router.replace(`/add/${event.id}`)') {{$t('common.edit')}}
|
||||
el-button(plain type='primary' size='mini' @click='$router.replace(`/add/${event.id}`)') {{$t('common.edit')}}
|
||||
|
||||
//- comments from fediverse
|
||||
#comments.card-body(v-if='settings.enable_federation')
|
||||
small.float-right 🔖 {{event.likes.length}}
|
||||
small.float-right 🔖 {{event.likes.length}}
|
||||
small.float-right.mr-3 ✊ {{event.boost.length}}<br/>
|
||||
strong {{$tc('common.comments', event.comments.length)}} -
|
||||
<small>{{$t('event.interact_with_me_at')}} <u>{{event.user && event.user.username}}@{{settings.baseurl|url2host}}</u></small>
|
||||
@@ -60,7 +60,7 @@ import { MessageBox } from 'element-ui'
|
||||
export default {
|
||||
name: 'Event',
|
||||
// transition: null,
|
||||
// Watch for $route.query.page to call
|
||||
// Watch for $route.query.page to call
|
||||
// Component methods (asyncData, fetch, validate, layout, etc.)
|
||||
// watchQuery: ['id'],
|
||||
// Key for <NuxtChild> (transitions)
|
||||
@@ -72,76 +72,78 @@ export default {
|
||||
// },
|
||||
|
||||
head () {
|
||||
if (!this.event) return {}
|
||||
if (!this.event) { return {} }
|
||||
return {
|
||||
title: `${this.settings.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.slice(0, 1000) },
|
||||
{ hid: 'og-description', name: 'og:description',
|
||||
content: this.event.description.slice(0, 100) },
|
||||
{ hid: 'description',
|
||||
name: 'description',
|
||||
content: this.event.description.slice(0, 1000) },
|
||||
{ hid: 'og-description',
|
||||
name: 'og:description',
|
||||
content: this.event.description.slice(0, 100) },
|
||||
{ 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:type', content: 'event' },
|
||||
{ property: 'og:image', content: this.imgPath }
|
||||
]
|
||||
}
|
||||
},
|
||||
async asyncData ({ $axios, params, error }) {
|
||||
try {
|
||||
const [ id, start_datetime ] = params.id.split('_')
|
||||
const event = await $axios.$get(`/event/${id}`)
|
||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||
event.end_datetime = event.end_datetime
|
||||
return { event, id: Number(id) }
|
||||
} catch (e) {
|
||||
error({ statusCode: 404, message: 'Event not found' })
|
||||
}
|
||||
},
|
||||
async fetch ({ $axios, store }) {
|
||||
try {
|
||||
const now = new Date()
|
||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||
return store.commit('setEvents', events)
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
async asyncData ( { $axios, params, error }) {
|
||||
try {
|
||||
const [ id, start_datetime ] = params.id.split('_')
|
||||
const event = await $axios.$get(`/event/${id}`)
|
||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||
event.end_datetime = event.end_datetime
|
||||
return { event, id: Number(id) }
|
||||
} catch(e) {
|
||||
error({ statusCode: 404, message: 'Event not found'})
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['filteredEvents']),
|
||||
...mapState(['settings']),
|
||||
next () {
|
||||
let found = false
|
||||
const event = this.filteredEvents.find(e => {
|
||||
if (found) return e
|
||||
if (found) { return e }
|
||||
found = (e.start_datetime === this.event.start_datetime && e.id === this.event.id)
|
||||
})
|
||||
if (!event) return false
|
||||
if (!event) { return false }
|
||||
if (event.recurrent) {
|
||||
return `${event.id}_${event.start_datetime}`
|
||||
}
|
||||
return event.id
|
||||
},
|
||||
},
|
||||
prev () {
|
||||
let event = false
|
||||
this.filteredEvents.find(e => {
|
||||
if (e.start_datetime === this.event.start_datetime && e.id === this.event.id) return true
|
||||
if (e.start_datetime === this.event.start_datetime && e.id === this.event.id) { return true }
|
||||
event = e
|
||||
})
|
||||
if (!event) return false
|
||||
if (!event) { return false }
|
||||
if (event.recurrent) {
|
||||
return `${event.id}_${event.start_datetime}`
|
||||
}
|
||||
return event.id
|
||||
return event.id
|
||||
},
|
||||
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
|
||||
},
|
||||
mine () {
|
||||
if (!this.$auth.user) { return false }
|
||||
return this.event.userId === this.$auth.user.id || this.$auth.user.is_admin
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['delEvent']),
|
||||
@@ -149,7 +151,7 @@ export default {
|
||||
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
|
||||
// get extension
|
||||
const ext = url.slice(-4)
|
||||
if (['.mp3', '.ogg'].indexOf(ext)>-1) {
|
||||
if (['.mp3', '.ogg'].includes(ext)) {
|
||||
return `<audio controls><source src='${url}'></audio>`
|
||||
} else {
|
||||
return orig
|
||||
@@ -161,10 +163,10 @@ export default {
|
||||
await MessageBox.confirm(this.$t('event.remove_confirmation'), this.$t('common.confirm'), {
|
||||
confirmButtonText: this.$t('common.ok'),
|
||||
cancelButtonText: this.$t('common.cancel'),
|
||||
type: 'error'})
|
||||
type: 'error' })
|
||||
await this.$axios.delete(`/user/event/${this.id}`)
|
||||
this.delEvent(Number(this.id))
|
||||
this.$router.replace("/")
|
||||
this.$router.replace('/')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
@@ -247,4 +249,3 @@ export default {
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
//- 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-switch.mt-2(v-model='notification.send_notification' :active-text="$t('send_notification')")
|
||||
//- 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
|
||||
el-button(slot='append' plain
|
||||
v-clipboard:copy='link'
|
||||
type="primary" icon='el-icon-document' ) {{$t("common.copy")}}
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
el-input.mb-1(type='textarea' v-model='listScript' readonly )
|
||||
el-button.float-right(plain v-clipboard:copy='listScript' type='primary' icon='el-icon-document') {{$t('common.copy')}}
|
||||
|
||||
|
||||
//- TOFIX
|
||||
//- el-tab-pane.pt-1(label='calendar' name='calendar')
|
||||
//- p(v-html='$t(`export.calendar_description`)')
|
||||
@@ -61,7 +60,7 @@ import Calendar from '@/components/Calendar'
|
||||
import List from '@/components/List'
|
||||
import Search from '@/components/Search'
|
||||
|
||||
import {intersection} from 'lodash'
|
||||
import { intersection } from 'lodash'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
@@ -76,25 +75,25 @@ export default {
|
||||
return {
|
||||
type: 'feed',
|
||||
notification: { email: '' },
|
||||
list: { title: 'Gancio' },
|
||||
list: { title: 'Gancio' }
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
copy (msg) {
|
||||
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ',e))
|
||||
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ', e))
|
||||
},
|
||||
async add_notification () {
|
||||
if (!this.notification.email){
|
||||
Message({message:'Inserisci una mail', showClose: true, type: 'error'})
|
||||
if (!this.notification.email) {
|
||||
Message({ message: 'Inserisci una mail', showClose: true, type: 'error' })
|
||||
// return this.$refs.email.focus()
|
||||
}
|
||||
// await api.addNotification({ ...this.notification, filters: this.filters})
|
||||
// this.$refs.modal.hide()
|
||||
Message({message: this.$t('email_notification_activated'), showClose: true, type: 'success'})
|
||||
Message({ message: this.$t('email_notification_activated'), showClose: true, type: 'success' })
|
||||
},
|
||||
imgPath (event) {
|
||||
return event.image_path && event.image_path
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['filters', 'events', 'settings']),
|
||||
@@ -119,9 +118,9 @@ export default {
|
||||
const tags = this.filters.tags.join(',')
|
||||
const places = this.filters.places.join(',')
|
||||
let query = ''
|
||||
if (tags || places) {
|
||||
if (tags || places) {
|
||||
query = '?'
|
||||
if (tags) {
|
||||
if (tags) {
|
||||
query += 'tags=' + tags
|
||||
if (places) { query += '&places=' + places }
|
||||
} else {
|
||||
@@ -132,8 +131,8 @@ export default {
|
||||
return `${this.settings.baseurl}/api/export/${this.type}${query}`
|
||||
},
|
||||
showLink () {
|
||||
return (['feed', 'ics'].indexOf(this.type)>-1)
|
||||
},
|
||||
return (['feed', 'ics'].includes(this.type))
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -143,5 +142,3 @@ export default {
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ export default {
|
||||
store.commit('setEvents', events)
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
computed: mapState(['events']),
|
||||
components: { Nav, Home },
|
||||
components: { Nav, Home }
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
disabled () {
|
||||
if (process.server) return false
|
||||
if (process.server) { return false }
|
||||
return !this.email || !this.password
|
||||
}
|
||||
},
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
...mapActions(['login']),
|
||||
async forgot () {
|
||||
if (!this.email) {
|
||||
Message({ message: this.$t('login.insert_email'), showClose:true, type: 'error' })
|
||||
Message({ message: this.$t('login.insert_email'), showClose: true, type: 'error' })
|
||||
this.$refs.email.focus()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
el-button(plain type="success" icon='el-icon-send', @click='change_password') {{$t('common.send')}}
|
||||
|
||||
div(v-else) {{$t('recover.not_valid_code')}}
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { Message } from 'element-ui'
|
||||
@@ -22,13 +21,12 @@ export default {
|
||||
data () {
|
||||
return { new_password: '' }
|
||||
},
|
||||
async asyncData({ params, $axios }) {
|
||||
async asyncData ({ params, $axios }) {
|
||||
const code = params.code
|
||||
try {
|
||||
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
|
||||
return { valid, code }
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
return { valid: false }
|
||||
}
|
||||
},
|
||||
@@ -40,9 +38,9 @@ export default {
|
||||
showClose: true,
|
||||
type: 'success',
|
||||
message: this.$t('common.password_updated')
|
||||
})
|
||||
})
|
||||
this.$router.replace('/login')
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
Message({
|
||||
showClose: true,
|
||||
type: 'warning',
|
||||
@@ -53,5 +51,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@ export default {
|
||||
title: this.settings.title + ' - ' + this.$t('common.register')
|
||||
}
|
||||
},
|
||||
validate ({store}) {
|
||||
validate ({ store }) {
|
||||
return store.state.settings.allow_registration
|
||||
},
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
disabled () {
|
||||
if (process.server) return false
|
||||
if (process.server) { return false }
|
||||
return !this.user.password || !this.user.email || !this.user.description
|
||||
}
|
||||
},
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
message: this.$t(`register.${user.is_admin ? 'admin_' : ''}complete`),
|
||||
type: 'success'
|
||||
})
|
||||
this.$router.replace("/")
|
||||
this.$router.replace('/')
|
||||
} catch (e) {
|
||||
const error = get(e, 'response.data.errors[0].message', String(e))
|
||||
Message({
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
div(v-if='settings.enable_federation')
|
||||
el-form-item(:label="$t('admin.enable_federation')")
|
||||
el-switch(v-model='user.settings.enable_federation')
|
||||
|
||||
|
||||
div(v-if='user.settings.enable_federation')
|
||||
el-form-item(:label="$t('common.username')")
|
||||
el-input(v-if='user.username.length==0' type='text' name='username' v-model='user.username')
|
||||
template(slot='suffix') @{{baseurl}}
|
||||
span(v-else) {{user.username}}@{{baseurl}}
|
||||
//- el-button(slot='append') {{$t('common.save')}}
|
||||
|
||||
|
||||
el-form-item(:label="$t('common.displayname')")
|
||||
el-input(type='text' v-model='user.display_name')
|
||||
|
||||
el-button(type='success' native-type='submit') {{$t('common.save')}}
|
||||
|
||||
|
||||
el-divider {{$t('settings.danger_section')}}
|
||||
p {{$t('settings.remove_account')}}
|
||||
el-button(type='danger' @click='remove_account') {{$t('common.remove')}}
|
||||
@@ -34,16 +34,16 @@
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { Message, MessageBox } from 'element-ui'
|
||||
import url from'url'
|
||||
import url from 'url'
|
||||
|
||||
export default {
|
||||
name: 'Settings',
|
||||
data () {
|
||||
return {
|
||||
password: '',
|
||||
user: { }
|
||||
}
|
||||
},
|
||||
name: 'Settings',
|
||||
head () {
|
||||
return {
|
||||
title: `${this.settings.title} - ${this.$t('common.settings')}`
|
||||
@@ -61,8 +61,8 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async change_password () {
|
||||
if (!this.password) return
|
||||
const user_data = { id : this.$auth.user.id, password: this.password }
|
||||
if (!this.password) { return }
|
||||
const user_data = { id: this.$auth.user.id, password: this.password }
|
||||
try {
|
||||
const user = await this.$axios.$put('/user', user_data)
|
||||
Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
|
||||
@@ -73,9 +73,9 @@ export default {
|
||||
},
|
||||
async update_settings () {
|
||||
try {
|
||||
const user = await this.$axios.$put('/user', { ...this.user, password: this.password } )
|
||||
const user = await this.$axios.$put('/user', { ...this.user, password: this.password })
|
||||
this.user = user
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
Message({ message: e, showClose: true, type: 'warning' })
|
||||
}
|
||||
},
|
||||
@@ -84,7 +84,7 @@ export default {
|
||||
confirmButtonText: this.$t('common.ok'),
|
||||
cancelButtonText: this.$t('common.cancel'),
|
||||
type: 'error'
|
||||
}).then( () => {
|
||||
}).then(() => {
|
||||
this.$axios.$delete('/user')
|
||||
this.$auth.logout()
|
||||
this.$router.replace('/')
|
||||
@@ -93,4 +93,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
h5 <img src='/favicon.ico'/> {{$t('confirm.title')}}
|
||||
p(v-if='valid' v-html='$t("confirm.valid")')
|
||||
p(v-else) {{$t('confirm.not_valid')}}
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { Message } from 'element-ui'
|
||||
@@ -16,7 +16,7 @@ export default {
|
||||
data () {
|
||||
return { valid: true }
|
||||
},
|
||||
async asyncData({ params, $axios }) {
|
||||
async asyncData ({ params, $axios }) {
|
||||
const recover_code = params.code
|
||||
try {
|
||||
const valid = await $axios.$post('/user/check_recover_code', { recover_code })
|
||||
@@ -27,5 +27,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user