2020-05-24 15:31:27 +02:00
|
|
|
<template>
|
2021-10-26 22:21:19 +02:00
|
|
|
<div class="content">
|
|
|
|
<h1>{{ $t('migrate.titleService', {name: migrator.name}) }}</h1>
|
|
|
|
<p>{{ $t('migrate.descriptionDo') }}</p>
|
|
|
|
|
|
|
|
<template v-if="message === '' && lastMigrationDate === null">
|
|
|
|
<template v-if="isMigrating === false">
|
|
|
|
<template v-if="migrator.isFileMigrator">
|
|
|
|
<p>{{ $t('migrate.importUpload', {name: migrator.name}) }}</p>
|
|
|
|
<input
|
|
|
|
@change="migrate"
|
|
|
|
class="is-hidden"
|
|
|
|
ref="uploadInput"
|
|
|
|
type="file"
|
|
|
|
/>
|
|
|
|
<x-button
|
|
|
|
:loading="migrationService.loading"
|
|
|
|
:disabled="migrationService.loading || null"
|
|
|
|
@click="$refs.uploadInput.click()"
|
|
|
|
>
|
|
|
|
{{ $t('migrate.upload') }}
|
|
|
|
</x-button>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<p>{{ $t('migrate.authorize', {name: migrator.name}) }}</p>
|
|
|
|
<x-button
|
|
|
|
:loading="migrationService.loading"
|
|
|
|
:disabled="migrationService.loading || null"
|
|
|
|
:href="authUrl"
|
|
|
|
>
|
|
|
|
{{ $t('migrate.getStarted') }}
|
|
|
|
</x-button>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="migration-in-progress-container"
|
|
|
|
>
|
|
|
|
<div class="migration-in-progress">
|
2021-11-15 15:26:46 +01:00
|
|
|
<img :alt="migrator.name" :src="migrator.icon" class="logo"/>
|
2021-10-26 22:21:19 +02:00
|
|
|
<div class="progress-dots">
|
2021-11-28 15:18:27 +01:00
|
|
|
<span v-for="i in progressDotsCount" :key="i"/>
|
2021-10-26 22:21:19 +02:00
|
|
|
</div>
|
2021-11-15 15:26:46 +01:00
|
|
|
<Logo class="logo"/>
|
2021-10-26 22:21:19 +02:00
|
|
|
</div>
|
|
|
|
<p>{{ $t('migrate.inProgress') }}</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div v-else-if="lastMigrationDate">
|
|
|
|
<p>
|
|
|
|
{{ $t('migrate.alreadyMigrated1', {name: migrator.name, date: formatDate(lastMigrationDate)}) }}<br/>
|
|
|
|
{{ $t('migrate.alreadyMigrated2') }}
|
|
|
|
</p>
|
|
|
|
<div class="buttons">
|
|
|
|
<x-button @click="migrate">{{ $t('migrate.confirm') }}</x-button>
|
|
|
|
<x-button :to="{name: 'home'}" type="tertary" class="has-text-danger">{{ $t('misc.cancel') }}</x-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2021-11-28 15:18:27 +01:00
|
|
|
<message class="mb-4">
|
|
|
|
{{ message }}
|
|
|
|
</message>
|
2021-10-26 22:21:19 +02:00
|
|
|
<x-button :to="{name: 'home'}">{{ $t('misc.refresh') }}</x-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-24 15:31:27 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-10-26 22:21:19 +02:00
|
|
|
import AbstractMigrationService from '@/services/migrator/abstractMigration'
|
|
|
|
import AbstractMigrationFileService from '@/services/migrator/abstractMigrationFile'
|
2021-11-13 15:16:14 +01:00
|
|
|
import Logo from '@/assets/logo.svg?component'
|
2021-11-28 15:18:27 +01:00
|
|
|
import Message from '@/components/misc/message'
|
2021-10-26 22:21:19 +02:00
|
|
|
|
2021-11-13 15:16:14 +01:00
|
|
|
import {MIGRATORS} from './migrators'
|
2021-10-26 22:21:19 +02:00
|
|
|
|
|
|
|
const PROGRESS_DOTS_COUNT = 8
|
2020-05-24 15:31:27 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
2021-10-26 22:21:19 +02:00
|
|
|
name: 'MigrateService',
|
2021-11-13 15:16:14 +01:00
|
|
|
|
2021-11-28 15:18:27 +01:00
|
|
|
components: {
|
|
|
|
Logo,
|
|
|
|
Message,
|
|
|
|
},
|
2021-11-13 15:16:14 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2021-10-26 22:21:19 +02:00
|
|
|
progressDotsCount: PROGRESS_DOTS_COUNT,
|
|
|
|
authUrl: '',
|
|
|
|
isMigrating: false,
|
|
|
|
lastMigrationDate: null,
|
|
|
|
message: '',
|
|
|
|
migratorAuthCode: '',
|
|
|
|
migrationService: null,
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
2021-10-26 22:21:19 +02:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
migrator() {
|
|
|
|
return MIGRATORS[this.$route.params.service]
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2021-10-26 22:21:19 +02:00
|
|
|
|
|
|
|
beforeRouteEnter(to) {
|
|
|
|
if (MIGRATORS[to.params.service] === undefined) {
|
2021-11-28 15:18:27 +01:00
|
|
|
return {name: 'not-found'}
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
2021-10-26 22:21:19 +02:00
|
|
|
|
|
|
|
created() {
|
|
|
|
this.initMigration()
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.setTitle(this.$t('migrate.titleService', {name: this.migrator.name}))
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async initMigration() {
|
|
|
|
this.migrationService = this.migrator.isFileMigrator
|
|
|
|
? new AbstractMigrationFileService(this.migrator.id)
|
|
|
|
: new AbstractMigrationService(this.migrator.id)
|
|
|
|
|
|
|
|
if (this.migrator.isFileMigrator) {
|
|
|
|
return
|
|
|
|
}
|
2021-11-28 15:18:27 +01:00
|
|
|
|
2021-10-26 22:21:19 +02:00
|
|
|
this.authUrl = await this.migrationService.getAuthUrl().then(({url}) => url)
|
|
|
|
|
|
|
|
this.migratorAuthCode = location.hash.startsWith('#token=')
|
|
|
|
? location.hash.substring(7)
|
|
|
|
: this.$route.query.code
|
|
|
|
|
|
|
|
if (!this.migratorAuthCode) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const {time} = await this.migrationService.getStatus()
|
|
|
|
if (time) {
|
|
|
|
this.lastMigrationDate = typeof time === 'string' && time?.startsWith('0001-')
|
|
|
|
? null
|
|
|
|
: new Date(time)
|
|
|
|
|
|
|
|
if (this.lastMigrationDate) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await this.migrate()
|
|
|
|
},
|
|
|
|
|
|
|
|
async migrate() {
|
|
|
|
this.isMigrating = true
|
|
|
|
this.lastMigrationDate = null
|
|
|
|
this.message = ''
|
|
|
|
|
2021-11-28 15:18:27 +01:00
|
|
|
let migrationConfig = {code: this.migratorAuthCode}
|
2021-10-26 22:21:19 +02:00
|
|
|
|
|
|
|
if (this.migrator.isFileMigrator) {
|
|
|
|
if (this.$refs.uploadInput.files.length === 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
migrationConfig = this.$refs.uploadInput.files[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-11-28 15:18:27 +01:00
|
|
|
const {message} = await this.migrationService.migrate(migrationConfig)
|
2021-10-26 22:21:19 +02:00
|
|
|
this.message = message
|
|
|
|
return this.$store.dispatch('namespaces/loadNamespaces')
|
|
|
|
} finally {
|
|
|
|
this.isMigrating = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2020-05-24 15:31:27 +02:00
|
|
|
</script>
|
|
|
|
|
2021-10-26 22:21:19 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.migration-in-progress-container {
|
2021-11-28 15:18:27 +01:00
|
|
|
max-width: 400px;
|
|
|
|
margin: 4rem auto 0;
|
|
|
|
text-align: center;
|
2021-10-26 22:21:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.migration-in-progress {
|
2021-11-28 15:18:27 +01:00
|
|
|
text-align: center;
|
|
|
|
display: flex;
|
|
|
|
max-width: 400px;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin-bottom: 2rem;
|
2021-11-15 15:26:46 +01:00
|
|
|
}
|
2021-10-26 22:21:19 +02:00
|
|
|
|
2021-11-15 15:26:46 +01:00
|
|
|
.logo {
|
2021-11-28 15:18:27 +01:00
|
|
|
display: block;
|
|
|
|
max-height: 100px;
|
|
|
|
max-width: 100px;
|
2021-10-26 22:21:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.progress-dots {
|
|
|
|
height: 40px;
|
|
|
|
width: 140px;
|
|
|
|
overflow: visible;
|
|
|
|
|
|
|
|
span {
|
|
|
|
transition: all 500ms ease;
|
2021-11-22 22:12:54 +01:00
|
|
|
background: var(--grey-500);
|
2021-10-26 22:21:19 +02:00
|
|
|
height: 10px;
|
|
|
|
width: 10px;
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 10px;
|
|
|
|
animation: wave 2s ease infinite;
|
|
|
|
margin-right: 5px;
|
|
|
|
|
|
|
|
&:nth-child(1) {
|
|
|
|
animation-delay: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(2) {
|
|
|
|
animation-delay: 100ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(3) {
|
|
|
|
animation-delay: 200ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(4) {
|
|
|
|
animation-delay: 300ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(5) {
|
|
|
|
animation-delay: 400ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(6) {
|
|
|
|
animation-delay: 500ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(7) {
|
|
|
|
animation-delay: 600ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:nth-child(8) {
|
|
|
|
animation-delay: 700ms;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes wave {
|
|
|
|
0%, 40%, 100% {
|
|
|
|
transform: translate(0, 0);
|
2021-11-22 22:12:54 +01:00
|
|
|
background-color: var(--primary);
|
2021-10-26 22:21:19 +02:00
|
|
|
}
|
|
|
|
10% {
|
|
|
|
transform: translate(0, -15px);
|
2021-11-22 22:12:54 +01:00
|
|
|
background-color: var(--primary-dark);
|
2021-10-26 22:21:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|