Add trello migration (#336)

Reload namespaces and lists after migrating

Add trello logo

Add trello migration

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/336
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad 2020-12-17 13:44:22 +00:00
parent 3c3d6a4af3
commit 60c5097d82
3 changed files with 25 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -64,7 +64,7 @@ export default {
isMigrating: false, isMigrating: false,
lastMigrationDate: null, lastMigrationDate: null,
message: '', message: '',
wunderlistCode: '', migratorAuthCode: '',
} }
}, },
props: { props: {
@ -82,14 +82,26 @@ export default {
this.getAuthUrl() this.getAuthUrl()
this.message = '' this.message = ''
if (typeof this.$route.query.code !== 'undefined') { if (typeof this.$route.query.code !== 'undefined' || location.hash.startsWith('#token=')) {
this.wunderlistCode = this.$route.query.code if (location.hash.startsWith('#token=')) {
this.migratorAuthCode = location.hash.substring(7)
console.log(location.hash.substring(7))
} else {
this.migratorAuthCode = this.$route.query.code
}
this.migrationService.getStatus() this.migrationService.getStatus()
.then(r => { .then(r => {
if (r.time) { if (r.time) {
if (typeof r.time === 'string' && r.time.startsWith('0001-')) {
this.lastMigrationDate = null
} else {
this.lastMigrationDate = new Date(r.time) this.lastMigrationDate = new Date(r.time)
}
if (this.lastMigrationDate) {
return return
} }
}
this.migrate() this.migrate()
}) })
.catch(e => { .catch(e => {
@ -109,10 +121,12 @@ export default {
}, },
migrate() { migrate() {
this.isMigrating = true this.isMigrating = true
this.lastMigrationDate = 0 this.lastMigrationDate = null
this.migrationService.migrate({code: this.wunderlistCode}) this.message = ''
this.migrationService.migrate({code: this.migratorAuthCode})
.then(r => { .then(r => {
this.message = r.message this.message = r.message
this.$store.dispatch('namespaces/loadNamespaces')
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e, this)

View file

@ -33,6 +33,10 @@ export default {
this.name = 'Todoist' this.name = 'Todoist'
this.identifier = 'todoist' this.identifier = 'todoist'
break break
case 'trello':
this.name = 'Trello'
this.identifier = 'trello'
break
default: default:
router.push({name: '404'}) router.push({name: '404'})
} }