testing ics / h-event import
This commit is contained in:
@@ -1,24 +1,40 @@
|
||||
<template lang="pug">
|
||||
v-card(color='secondary')
|
||||
v-card-title {{$t('event.importURL')}}
|
||||
v-card-title {{$t('common.import')}}
|
||||
v-card-text
|
||||
v-form(v-model='valid' ref='form' lazy-validation)
|
||||
v-text-field(v-model='URL' :loading='loading' :error='error' :error-messages='errorMessage')
|
||||
v-text-field(v-model='URL'
|
||||
:label="$t('common.url')"
|
||||
:hint="$t('event.import_URL')"
|
||||
persistent-hint
|
||||
:loading='loading' :error='error'
|
||||
:error-messages='errorMessage')
|
||||
|
||||
v-file-input(
|
||||
v-model='file'
|
||||
accept=".ics"
|
||||
:label="$t('common.ics')"
|
||||
:hint="$t('event.import_ICS')"
|
||||
persistent-hint
|
||||
)
|
||||
|
||||
p {{event}}
|
||||
v-card-actions
|
||||
v-spacer
|
||||
v-btn(@click='$emit("close")' color='warning') {{$t('common.cancel')}}
|
||||
v-btn(@click='importURL' :loading='loading' :disabled='loading'
|
||||
v-btn(@click='importGeneric' :loading='loading' :disabled='loading'
|
||||
color='primary') {{$t('common.import')}}
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import ical from 'ical.js'
|
||||
|
||||
export default {
|
||||
name: 'ImportDialog',
|
||||
data () {
|
||||
return {
|
||||
file: null,
|
||||
errorMessage: '',
|
||||
error: false,
|
||||
loading: false,
|
||||
@@ -28,6 +44,26 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
importGeneric () {
|
||||
if (this.file) {
|
||||
this.importICS()
|
||||
} else {
|
||||
this.importURL()
|
||||
}
|
||||
},
|
||||
async importICS() {
|
||||
const reader = new FileReader()
|
||||
reader.readAsText(this.file)
|
||||
reader.onload = () => {
|
||||
const data = reader.result
|
||||
console.error(data)
|
||||
const event = ical.parse(data)
|
||||
console.error(event)
|
||||
this.event = {
|
||||
title: event.name
|
||||
}
|
||||
}
|
||||
},
|
||||
async importURL() {
|
||||
if (!this.URL) {
|
||||
this.errorMessage = this.$validators.required('common.URL')('')
|
||||
|
||||
Reference in New Issue
Block a user