forked from vikunja/frontend
konrad
85e55d1300
Fixes vikunja/frontend#489 Co-authored-by: kolaente <k@knt.li> Reviewed-on: vikunja/frontend#493 Co-authored-by: konrad <konrad@kola-entertainments.de> Co-committed-by: konrad <konrad@kola-entertainments.de>
141 lines
3.5 KiB
Vue
141 lines
3.5 KiB
Vue
<template>
|
|
<div class="content">
|
|
<h1>Import your data from {{ name }} to Vikunja</h1>
|
|
<p>Vikunja will import all lists, tasks, notes, reminders and files you have access to.</p>
|
|
<template v-if="isMigrating === false && message === '' && lastMigrationDate === null">
|
|
<p>To authorize Vikunja to access your {{ name }} Account, click the button below.</p>
|
|
<x-button
|
|
:loading="migrationService.loading"
|
|
:disabled="migrationService.loading"
|
|
:href="authUrl"
|
|
>
|
|
Get Started
|
|
</x-button>
|
|
</template>
|
|
<div
|
|
class="migration-in-progress-container"
|
|
v-else-if="isMigrating === true && message === '' && lastMigrationDate === null">
|
|
<div class="migration-in-progress">
|
|
<img :alt="name" :src="`/images/migration/${identifier}.png`"/>
|
|
<div class="progress-dots">
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
</div>
|
|
<img alt="Vikunja" src="/images/logo.svg">
|
|
</div>
|
|
<p>Importing in progress, hang tight...</p>
|
|
</div>
|
|
<div v-else-if="lastMigrationDate">
|
|
<p>
|
|
It looks like you've already imported your stuff from {{ name }} at {{ formatDate(lastMigrationDate) }}.<br/>
|
|
Importing again is possible, but might create duplicates.
|
|
Are you sure?
|
|
</p>
|
|
<div class="buttons">
|
|
<x-button @click="migrate">I am sure, please start migrating now!</x-button>
|
|
<x-button :to="{name: 'home'}" type="tertary" class="has-text-danger">Cancel</x-button>
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<div class="message is-primary">
|
|
<div class="message-body">
|
|
{{ message }}
|
|
</div>
|
|
</div>
|
|
<x-button :to="{name: 'home'}">Refresh</x-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import AbstractMigrationService from '../../services/migrator/abstractMigrationService'
|
|
|
|
export default {
|
|
name: 'migration',
|
|
data() {
|
|
return {
|
|
authUrl: '',
|
|
isMigrating: false,
|
|
lastMigrationDate: null,
|
|
message: '',
|
|
migratorAuthCode: '',
|
|
}
|
|
},
|
|
props: {
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
identifier: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
},
|
|
created() {
|
|
this.migrationService = new AbstractMigrationService(this.identifier)
|
|
this.getAuthUrl()
|
|
this.message = ''
|
|
|
|
if (typeof this.$route.query.code !== 'undefined' || location.hash.startsWith('#token=')) {
|
|
if (location.hash.startsWith('#token=')) {
|
|
this.migratorAuthCode = location.hash.substring(7)
|
|
console.debug(location.hash.substring(7))
|
|
} else {
|
|
this.migratorAuthCode = this.$route.query.code
|
|
}
|
|
this.migrationService.getStatus()
|
|
.then(r => {
|
|
if (r.time) {
|
|
if (typeof r.time === 'string' && r.time.startsWith('0001-')) {
|
|
this.lastMigrationDate = null
|
|
} else {
|
|
this.lastMigrationDate = new Date(r.time)
|
|
}
|
|
|
|
if (this.lastMigrationDate) {
|
|
return
|
|
}
|
|
}
|
|
this.migrate()
|
|
})
|
|
.catch(e => {
|
|
this.error(e, this)
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
getAuthUrl() {
|
|
this.migrationService.getAuthUrl()
|
|
.then(r => {
|
|
this.authUrl = r.url
|
|
})
|
|
.catch(e => {
|
|
this.error(e, this)
|
|
})
|
|
},
|
|
migrate() {
|
|
this.isMigrating = true
|
|
this.lastMigrationDate = null
|
|
this.message = ''
|
|
this.migrationService.migrate({code: this.migratorAuthCode})
|
|
.then(r => {
|
|
this.message = r.message
|
|
this.$store.dispatch('namespaces/loadNamespaces')
|
|
})
|
|
.catch(e => {
|
|
this.error(e, this)
|
|
})
|
|
.finally(() => {
|
|
this.isMigrating = false
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|