gancio-upstream/pages/export.vue

197 lines
6.6 KiB
Vue
Raw Normal View History

2019-04-26 23:14:43 +02:00
<template lang="pug">
2022-07-01 15:55:09 +02:00
v-container.pa-0.pa-md-3
v-card
v-card-title {{$t('common.share')}}
v-card-text
p.text-body-1 {{$t('export.intro')}}
v-row
v-col(:md='2' :cols='12')
v-card-title.py-0 {{$t('common.filter')}}
v-col
Search(
:filters='filters'
@update='f => filters = f')
v-tabs(v-model='type' show-arrows :next-icon='mdiChevronRight' :prev-icon='mdiChevronLeft')
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02:00
//- TOFIX
//- 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('morning_notification')")
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.send')}} <v-icon>mdi-email</v-icon>
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02: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)
v-btn(slot='prepend' text color='primary' @click='clipboard(link)') {{$t("common.copy")}}
v-icon.ml-1(v-text='mdiContentCopy')
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02: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')
v-btn(slot='prepend' text color='primary' @click='clipboard(link)') {{$t("common.copy")}}
v-icon.ml-1(v-text='mdiContentCopy')
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02:00
v-tab List
v-tab-item
v-card
v-card-text
p(v-html='$t(`export.list_description`)')
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02:00
v-row
v-col.col-12.col-lg-4
v-text-field(v-model='list.title' :label='$t("common.title")')
v-text-field(v-model='list.maxEvents' type='number' min='1' :label='$t("common.max_events")')
v-switch(v-model='list.theme' inset true-value='dark' false-value='light' :label="$t('admin.is_dark')")
v-switch(v-model='list.sidebar' inset true-value='true' false-value='false' :label="$t('admin.widget')")
v-col.col-12.col-lg-8
gancio-events(:baseurl='settings.baseurl'
:maxlength='list.maxEvents && Number(list.maxEvents)'
:title='list.title'
:theme='list.theme'
:places='filters.places.join(",")'
:tags='filters.tags.join(",")'
:show_recurrent='filters.show_recurrent'
:sidebar="list.sidebar")
v-alert.pa-5.my-4.blue-grey.darken-4.text-body-1.lime--text.text--lighten-3 <pre>{{code}}</pre>
v-btn.float-end(text color='primary' @click='clipboard(code)') {{$t("common.copy")}}
v-icon.ml-1(v-text='mdiContentCopy')
2019-04-26 23:14:43 +02:00
2022-07-01 15:55:09 +02:00
v-tab(v-if='settings.enable_federation') {{$t('common.fediverse')}}
v-tab-item(v-if='settings.enable_federation')
FollowMe
//- 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'
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'
import clipboard from '../assets/clipboard'
2022-05-31 15:24:21 +02:00
import { mdiContentCopy, mdiChevronRight, mdiChevronLeft } from '@mdi/js'
2019-04-26 23:14:43 +02:00
export default {
2020-01-15 23:46:47 +01:00
name: 'Exports',
components: {
FollowMe,
Search
},
mixins: [clipboard],
2020-11-13 00:13:44 +01:00
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
},
2022-01-31 13:14:53 +01:00
data ({ $store }) {
2020-01-15 23:46:47 +01:00
return {
2022-05-31 15:24:21 +02:00
mdiContentCopy, mdiChevronLeft, mdiChevronRight,
2020-01-15 23:46:47 +01:00
type: 'rss',
notification: { email: '' },
list: {
title: $store.state.settings.title,
maxEvents: null,
theme: $store.state.settings['theme.is_dark'] ? 'dark' : 'light',
sidebar: 'true'
},
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']),
code () {
const params = [`baseurl="${this.settings.baseurl}"`]
if (this.list.title && this.list.sidebar === 'true') {
params.push(`title="${this.list.title}"`)
2019-05-30 12:04:14 +02:00
}
2019-05-30 12:12:51 +02:00
if (this.filters.places.length) {
params.push(`places="${this.filters.places.join(',')}"`)
2019-05-30 12:12:51 +02:00
}
if (this.filters.tags.length) {
params.push(`tags="${this.filters.tags.join(',')}"`)
}
2021-04-14 01:33:01 +02:00
if (this.filters.show_recurrent) {
2022-02-01 12:45:19 +01:00
params.push(`show_recurrent="${this.filters.show_recurrent}"`)
}
if (this.list.maxEvents) {
params.push('maxlength=' + this.list.maxEvents)
2021-04-14 01:33:01 +02:00
}
params.push('sidebar="' + this.list.sidebar + '"')
params.push(`theme="${this.list.theme}"`)
2022-01-12 22:56:58 +01:00
return `<script src="${this.settings.baseurl}\/gancio-events.es.js"><\/script>\n<gancio-events ${params.join(' ')}></gancio-events>\n\n`
2019-05-30 12:04:14 +02:00
},
link () {
2022-01-17 12:03:05 +01:00
const typeMap = ['rss', 'ics']
2021-04-14 01:33:01 +02:00
const params = []
if (this.filters.tags.length) {
2022-01-17 12:03:05 +01:00
params.push(`tags=${this.filters.tags.map(encodeURIComponent).join(',')}`)
2021-04-14 01:33:01 +02:00
}
if (this.filters.places.length) {
params.push(`places=${this.filters.places.join(',')}`)
}
if (this.filters.show_recurrent) {
params.push('show_recurrent=true')
2019-04-26 23:14:43 +02:00
}
2022-01-17 12:03:05 +01:00
return `${this.settings.baseurl}/feed/${typeMap[this.type]}${params.length ? '?' : ''}${params.join('&')}`
},
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-25 09:27:54 +01:00
async add_notification () {
// validate()
// if (!this.notification.email) {
// Message({ message: 'Inserisci una mail', showClose: true, type: 'error' })
// return this.$refs.email.focus()
// }
2021-03-18 22:39:31 +01:00
// await api.addNotification({ ...this.notification, filters: this.filters})
2020-01-15 23:46:47 +01:00
// 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.media && event.media[0].url
2020-01-15 23:46:47 +01:00
}
2019-04-26 23:14:43 +02:00
}
}
</script>