2021-09-04 21:26:38 +02:00
|
|
|
<template>
|
|
|
|
<div class="content">
|
|
|
|
<h1>{{ $t('user.export.downloadTitle') }}</h1>
|
2021-10-31 14:16:28 +01:00
|
|
|
<template v-if="isLocalUser">
|
|
|
|
<p>{{ $t('user.export.descriptionPasswordRequired') }}</p>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="currentPasswordDataExport">
|
|
|
|
{{ $t('user.settings.currentPassword') }}
|
|
|
|
</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
:class="{'is-danger': errPasswordRequired}"
|
|
|
|
id="currentPasswordDataExport"
|
|
|
|
:placeholder="$t('user.settings.currentPasswordPlaceholder')"
|
|
|
|
type="password"
|
|
|
|
v-model="password"
|
|
|
|
@keyup="() => errPasswordRequired = password === ''"
|
|
|
|
ref="passwordInput"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<p class="help is-danger" v-if="errPasswordRequired">
|
|
|
|
{{ $t('user.deletion.passwordRequired') }}
|
|
|
|
</p>
|
2021-09-04 21:26:38 +02:00
|
|
|
</div>
|
2021-10-31 14:16:28 +01:00
|
|
|
</template>
|
2021-09-04 21:26:38 +02:00
|
|
|
|
|
|
|
<x-button
|
|
|
|
v-focus
|
|
|
|
:loading="dataExportService.loading"
|
|
|
|
@click="download()"
|
|
|
|
class="mt-4">
|
|
|
|
{{ $t('misc.download') }}
|
|
|
|
</x-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
<script setup>
|
|
|
|
import {ref, computed, reactive} from 'vue'
|
|
|
|
import DataExportService from '@/services/dataExport'
|
|
|
|
import {store} from '@/store'
|
2021-09-04 21:26:38 +02:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
const dataExportService = reactive(new DataExportService())
|
|
|
|
const password = ref('')
|
|
|
|
const errPasswordRequired = ref(false)
|
|
|
|
const passwordInput = ref(null)
|
2021-09-04 21:26:38 +02:00
|
|
|
|
2021-11-14 21:57:36 +01:00
|
|
|
const isLocalUser = computed(() => store.state.auth.info?.isLocalUser)
|
|
|
|
|
|
|
|
function download() {
|
|
|
|
if (password.value === '' && isLocalUser.value) {
|
|
|
|
errPasswordRequired.value = true
|
|
|
|
passwordInput.value.focus()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
dataExportService.download(password.value)
|
2021-09-04 21:26:38 +02:00
|
|
|
}
|
|
|
|
</script>
|