|
|
@ -129,8 +129,14 @@ |
|
|
|
|
|
|
|
<div class="input-group mb-3"> |
|
|
|
<button class="btn btn-outline-primary" @click="downloadBackup">{{ $t("Export") }}</button> |
|
|
|
<button type="button" class="btn btn-outline-primary" @click="importBackup">{{ $t("Import") }}</button> |
|
|
|
<input id="importBackup" type="file" class="form-control"> |
|
|
|
<button type="button" class="btn btn-outline-primary" :disabled="processing" @click="importBackup"> |
|
|
|
<div v-if="processing" class="spinner-border spinner-border-sm me-1"></div> |
|
|
|
{{ $t("Import") }} |
|
|
|
</button> |
|
|
|
<input id="importBackup" type="file" class="form-control" accept="application/json"> |
|
|
|
</div> |
|
|
|
<div v-if="importAlert" class="alert alert-danger mt-3" style="padding: 6px 16px;"> |
|
|
|
{{ importAlert }} |
|
|
|
</div> |
|
|
|
|
|
|
|
<p><strong>{{ $t("backupDescription3") }}</strong></p> |
|
|
@ -276,6 +282,8 @@ export default { |
|
|
|
|
|
|
|
}, |
|
|
|
loaded: false, |
|
|
|
importAlert: null, |
|
|
|
processing: false, |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
@ -369,9 +377,17 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
importBackup() { |
|
|
|
this.processing = true; |
|
|
|
let uploadItem = document.getElementById("importBackup").files; |
|
|
|
|
|
|
|
if (uploadItem.length <= 0) { |
|
|
|
return false; |
|
|
|
this.processing = false; |
|
|
|
return this.importAlert = this.$t("alertNoFile") |
|
|
|
} |
|
|
|
|
|
|
|
if (uploadItem.item(0).type !== "application/json") { |
|
|
|
this.processing = false; |
|
|
|
return this.importAlert = this.$t("alertWrongFileType") |
|
|
|
} |
|
|
|
|
|
|
|
let fileReader = new FileReader(); |
|
|
@ -379,6 +395,8 @@ export default { |
|
|
|
|
|
|
|
fileReader.onload = item => { |
|
|
|
this.$root.uploadBackup(item.target.result, (res) => { |
|
|
|
this.processing = false; |
|
|
|
|
|
|
|
if (res.ok) { |
|
|
|
toast.success(res.msg); |
|
|
|
} else { |
|
|
|