gancio-upstream/pages/export.vue

182 lines
5.8 KiB
Vue
Raw Normal View History

2019-04-26 23:14:43 +02:00
<template lang="pug">
2020-07-25 21:41:22 +02:00
v-container
p {{$t('export.intro')}}
2020-11-13 00:13:44 +01:00
v-card(outlined)
2021-01-22 23:08:26 +01:00
v-card-text
v-row
v-col(cols='4')
v-card-title {{$t('common.filter')}}
v-col
Search(
:filters='filters'
@update='updateFilters')
2020-11-13 00:13:44 +01:00
v-tabs(v-model='type')
2019-04-26 23:14:43 +02:00
2020-11-13 00:13:44 +01:00
//- TOFIX
2021-01-22 23:08:26 +01:00
v-tab {{$t('common.email')}}
v-tab-item
v-card
v-card-text
p(v-html='$t(`export.email_description`)')
v-switch.mt-0(inset :label="$t('notify_on_insert')")
v-switch.mt-0(inset :label="$t('notify_on_morning')")
v-text-field(v-model='notification.email' :placeholder="$t('export.insert_your_address')" ref='email')
v-btn(slot='prepend' text color='primary' @click='add_notification') {{$t('common.subscribe')}} <v-icon>mdi-email</v-icon>
2019-04-26 23:14:43 +02:00
2020-11-13 00:13:44 +01:00
v-tab {{$t('common.feed')}}
v-tab-item
v-card
v-card-text
p(v-html='$t(`export.feed_description`)')
v-text-field(v-model='link' readonly)
2021-01-22 23:08:26 +01:00
v-btn(slot='prepend' text color='primary'
2020-11-13 00:13:44 +01:00
v-clipboard:copy='link'
v-clipboard:success='copyLink') {{$t("common.copy")}}
v-icon.ml-1 mdi-content-copy
2019-04-26 23:14:43 +02:00
2020-11-13 00:13:44 +01:00
v-tab ics/ical
v-tab-item
v-card
v-card-text
p(v-html='$t(`export.ical_description`)')
v-text-field(v-model='link')
2021-01-22 23:08:26 +01:00
v-btn(slot='prepend' text color='primary'
2020-11-13 00:13:44 +01:00
v-clipboard:copy='link' v-clipboard:success='copyLink') {{$t("common.copy")}}
v-icon.ml-1 mdi-content-copy
2019-04-26 23:14:43 +02:00
2020-11-13 00:13:44 +01:00
v-tab List
v-tab-item
2021-01-22 23:08:26 +01:00
v-card
v-card-text
p(v-html='$t(`export.list_description`)')
2019-04-26 23:14:43 +02:00
2021-01-22 23:08:26 +01:00
v-row
v-col.mr-2(:span='11')
v-text-field(v-model='list.title' :label='$t("common.title")')
v-text-field(v-model='list.maxEvents' type='number' :label='$t("common.max_events")')
v-col.float-right(:span='12')
List(
:title='list.title'
:maxEvents='list.maxEvents'
:events='events')
v-text-field.mb-1(type='textarea' v-model='listScript' readonly )
v-btn(slot='prepend' text
color='primary' v-clipboard:copy='listScript' v-clipboard:success='copyLink') {{$t('common.copy')}}
v-icon.ml-1 mdi-content-copy
2019-04-26 23:14:43 +02:00
2021-01-11 00:17:56 +01:00
v-tab(v-if='settings.enable_federation') {{$t('common.fediverse')}}
v-tab-item(v-if='settings.enable_federation')
FollowMe
2020-11-13 00:13:44 +01:00
//- TOFIX
//- v-tab.pt-1(label='calendar' name='calendar')
//- v-tab-item
//- p(v-html='$t(`export.calendar_description`)')
//- //- no-ssr
//- Calendar.mb-1
//- v-text-field.mb-1(type='textarea' v-model='script')
//- el-button.float-right(plain type="primary" icon='el-icon-document') Copy
2019-04-26 23:14:43 +02:00
</template>
<script>
2020-11-13 00:13:44 +01:00
import dayjs from 'dayjs'
import { mapState } from 'vuex'
import List from '@/components/List'
2020-02-10 00:45:51 +01:00
import FollowMe from '../components/FollowMe'
2020-11-13 00:13:44 +01:00
import Search from '@/components/Search'
2019-04-26 23:14:43 +02:00
export default {
2020-01-15 23:46:47 +01:00
name: 'Exports',
2020-11-13 00:13:44 +01:00
components: { List, FollowMe, Search },
async asyncData ({ $axios, params, store, $api }) {
const events = await $api.getEvents({
2021-01-22 23:08:26 +01:00
start: dayjs().unix(),
show_recurrent: false
2020-11-13 00:13:44 +01:00
})
return { events }
2019-10-28 17:33:20 +01:00
},
2020-01-15 23:46:47 +01:00
data () {
return {
type: 'rss',
notification: { email: '' },
2020-11-13 00:13:44 +01:00
list: { title: 'Gancio', maxEvents: 3 },
2021-01-22 23:08:26 +01:00
filters: { tags: [], places: [], show_recurrent: false },
2020-11-13 00:13:44 +01:00
events: []
}
},
head () {
return {
title: `${this.settings.title} - ${this.$t('common.export')}`
2019-09-11 19:12:24 +02:00
}
2019-05-30 12:04:14 +02:00
},
computed: {
2020-11-13 00:13:44 +01:00
...mapState(['settings']),
2020-02-10 00:45:51 +01:00
domain () {
const URL = url.parse(this.settings.baseurl)
return URL.hostname
},
2019-05-30 12:04:14 +02:00
listScript () {
const params = []
if (this.list.title) {
params.push(`title=${this.list.title}`)
}
2019-05-30 12:12:51 +02:00
if (this.filters.places.length) {
2020-01-21 01:24:10 +01:00
params.push(`places=${this.filters.places.map(p => p.id)}`)
2019-05-30 12:12:51 +02:00
}
if (this.filters.tags.length) {
2020-01-21 01:24:10 +01:00
params.push(`tags=${this.filters.tags.map(t => t.id)}`)
}
2019-07-05 01:38:31 +02:00
return `<iframe style='border: 0px; width: 100%;' src="${this.settings.baseurl}/embed/list?${params.join('&')}"></iframe>`
2019-05-30 12:04:14 +02:00
},
link () {
2021-01-11 00:17:56 +01:00
const typeMap = ['rss', 'ics', 'list']
2020-06-05 23:04:12 +02:00
const tags = this.filters.tags.join(',')
const places = this.filters.places.join(',')
2019-04-26 23:14:43 +02:00
let query = ''
2019-09-11 19:12:24 +02:00
if (tags || places) {
2019-04-26 23:14:43 +02:00
query = '?'
2019-09-11 19:12:24 +02:00
if (tags) {
2019-04-26 23:14:43 +02:00
query += 'tags=' + tags
if (places) { query += '&places=' + places }
} else {
query += 'places=' + places
}
}
2021-01-11 00:17:56 +01:00
return `${this.settings.baseurl}/feed/${typeMap[this.type]}${query}`
},
2019-04-26 23:14:43 +02:00
showLink () {
2019-09-17 18:16:59 +02:00
return (['rss', 'ics'].includes(this.type))
2019-09-11 19:12:24 +02:00
}
2020-01-15 23:46:47 +01:00
},
methods: {
2021-01-22 23:08:26 +01:00
async updateFilters (filters) {
2020-11-13 00:13:44 +01:00
this.filters = filters
2021-01-22 23:08:26 +01:00
this.events = await this.$api.getEvents({
start: dayjs().unix(),
places: this.filters.places,
tags: this.filters.tags,
show_recurrent: this.filters.show_recurrent
})
2020-11-13 00:13:44 +01:00
},
2020-01-15 23:46:47 +01:00
copyLink () {
2020-10-07 11:12:13 +02:00
this.$root.$message('common.feed_url_copied')
2020-01-15 23:46:47 +01:00
},
add_notification () {
if (!this.notification.email) {
2020-07-25 21:41:22 +02:00
// Message({ message: 'Inserisci una mail', showClose: true, type: 'error' })
2020-01-15 23:46:47 +01:00
// return this.$refs.email.focus()
}
// await api.addNotification({ ...this.notification, filters: this.filters})
// this.$refs.modal.hide()
2020-07-25 21:41:22 +02:00
// Message({ message: this.$t('email_notification_activated'), showClose: true, type: 'success' })
2020-01-15 23:46:47 +01:00
},
imgPath (event) {
return event.image_path && event.image_path
}
2019-04-26 23:14:43 +02:00
}
}
</script>