gancio-upstream/pages/export.vue

151 lines
4.8 KiB
Vue
Raw Normal View History

2019-04-26 23:14:43 +02:00
<template lang="pug">
2019-06-06 23:54:32 +02:00
el-card
nuxt-link.float-right(to='/')
2019-07-05 01:38:31 +02:00
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
2019-06-06 23:54:32 +02:00
h5 {{$t('common.export')}}
p {{$t('export.intro')}}
2019-05-30 12:12:51 +02:00
Search
2019-05-30 12:04:14 +02:00
el-tabs.mt-2(v-model='type')
2019-04-26 23:14:43 +02:00
2019-08-07 19:15:15 +02:00
//- TOFIX
//- el-tab-pane.pt-1(label='email' name='email')
//- 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
2019-09-11 19:12:24 +02:00
//- //- 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')}}
2019-04-26 23:14:43 +02:00
2019-09-17 18:16:59 +02:00
el-tab-pane.pt-1(label='feed rss' name='rss')
span(v-html='$t(`export.feed_description`)')
2019-04-26 23:14:43 +02:00
el-input(v-model='link')
2019-09-11 19:12:24 +02:00
el-button(slot='append' plain
2019-07-05 01:38:31 +02:00
v-clipboard:copy='link'
type="primary" icon='el-icon-document' ) {{$t("common.copy")}}
2019-04-26 23:14:43 +02:00
el-tab-pane.pt-1(label='ics/ical' name='ics')
p(v-html='$t(`export.ical_description`)')
2019-04-26 23:14:43 +02:00
el-input(v-model='link')
2019-07-05 01:38:31 +02:00
el-button(slot='append' v-clipboard:copy='link' plain type="primary" icon='el-icon-document') {{$t("common.copy")}}
2019-04-26 23:14:43 +02:00
el-tab-pane.pt-1(label='list' name='list')
p(v-html='$t(`export.list_description`)')
2019-04-26 23:14:43 +02:00
2019-05-30 12:04:14 +02:00
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 )
2019-07-05 01:38:31 +02:00
el-button.float-right(plain v-clipboard:copy='listScript' type='primary' icon='el-icon-document') {{$t('common.copy')}}
2019-04-26 23:14:43 +02:00
2019-08-07 19:15:15 +02:00
//- TOFIX
2019-05-30 12:04:14 +02:00
//- 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
2019-04-26 23:14:43 +02:00
</template>
<script>
2019-05-30 12:04:14 +02:00
import { mapState, mapGetters } from 'vuex'
2019-04-26 23:14:43 +02:00
import Calendar from '@/components/Calendar'
import List from '@/components/List'
2019-05-30 12:12:51 +02:00
import Search from '@/components/Search'
2019-09-11 19:12:24 +02:00
import { intersection } from 'lodash'
2019-04-26 23:14:43 +02:00
import { Message } from 'element-ui'
export default {
name: 'Export',
2019-05-30 12:12:51 +02:00
components: { List, Search },
2019-08-07 19:15:15 +02:00
head () {
return {
title: `${this.settings.title} - ${this.$t('common.export')}`
}
},
2019-09-25 21:14:33 +02:00
async asyncData ({ $axios, params, store }) {
// get metadata just in case we are not coming from home
if (store.state.tags.length) return
const { tags, places } = await $axios.$get('/event/meta')
store.commit('update', { tags, places })
},
2019-04-26 23:14:43 +02:00
data () {
return {
2019-09-17 18:16:59 +02:00
type: 'rss',
2019-04-26 23:14:43 +02:00
notification: { email: '' },
2019-09-11 19:12:24 +02:00
list: { title: 'Gancio' }
2019-04-26 23:14:43 +02:00
}
},
methods: {
2019-07-11 23:31:37 +02:00
copy (msg) {
2019-09-11 19:12:24 +02:00
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ', e))
2019-07-11 23:31:37 +02:00
},
2019-04-26 23:14:43 +02:00
async add_notification () {
2019-09-11 19:12:24 +02:00
if (!this.notification.email) {
Message({ message: 'Inserisci una mail', showClose: true, type: 'error' })
2019-06-06 23:54:32 +02:00
// return this.$refs.email.focus()
2019-04-26 23:14:43 +02:00
}
2019-05-30 12:04:14 +02:00
// await api.addNotification({ ...this.notification, filters: this.filters})
// this.$refs.modal.hide()
2019-09-11 19:12:24 +02:00
Message({ message: this.$t('email_notification_activated'), showClose: true, type: 'success' })
2019-04-26 23:14:43 +02:00
},
2019-05-30 12:04:14 +02:00
imgPath (event) {
return event.image_path && event.image_path
2019-09-11 19:12:24 +02:00
}
2019-05-30 12:04:14 +02:00
},
computed: {
2019-06-25 01:05:38 +02:00
...mapState(['filters', 'events', 'settings']),
2019-05-30 12:04:14 +02:00
...mapGetters(['filteredEvents']),
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) {
2019-05-30 12:12:51 +02:00
params.push(`places=${this.filters.places}`)
}
if (this.filters.tags.length) {
params.push(`tags=${this.filters.tags}`)
}
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 () {
2019-04-26 23:14:43 +02:00
const tags = this.filters.tags.join(',')
const places = this.filters.places.join(',')
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
}
}
2019-09-17 18:16:59 +02:00
return `${this.settings.baseurl}/feed/${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
}
2019-04-26 23:14:43 +02:00
}
}
</script>
<style>
#list {
max-height: 400px;
2019-06-12 22:29:32 +02:00
overflow-y: auto;
2019-04-26 23:14:43 +02:00
}
</style>