feat(backup): display import stats

This commit is contained in:
Denis Gukov 2024-10-08 22:23:04 +05:00
parent 6604f7a31a
commit e0251b51ed
5 changed files with 44 additions and 15 deletions

View File

@ -3,10 +3,32 @@
<YesNoDialog
:title="$t('projectRestoreResult')"
:text="restoreProjectResult"
v-model="restoreProjectResultDialog"
hide-no-button
/>
:yes-button-title="$t('close')"
:max-width="400"
>
<div class="pt-3" v-if="restoreProjectResult">
<v-alert
dense
outlined
type="success"
>
Project {{ restoreProjectResult.projectName }} restored.
</v-alert>
<v-alert
dense
outlined
type="error"
class="mb-0"
>
<b>{{ restoreProjectResult.emptyKeys }} empty keys added.</b>
Please update the keys before running tasks.
</v-alert>
</div>
</YesNoDialog>
<EditDialog
v-model="passwordDialog"
@ -974,14 +996,14 @@ export default {
case 'new':
text = `Project ${projectName} created`;
break;
case 'restore':
break;
case 'edit':
text = `Project ${projectName} saved`;
break;
case 'delete':
text = `Project ${projectName} deleted`;
break;
case 'restore':
break;
default:
throw new Error('Unknown project action');
}
@ -993,7 +1015,10 @@ export default {
responseType: 'json',
})).data.filter((k) => k.empty);
this.restoreProjectResult = `Project ${projectName} restored. ${emptyKeys.length} empty keys added.`;
this.restoreProjectResult = {
projectName,
emptyKeys: emptyKeys.length,
};
this.restoreProjectResultDialog = true;
} else {
EventBus.$emit('i-snackbar', {

View File

@ -105,6 +105,10 @@ export default {
return {};
},
getSaveAction() {
return this.isNew ? 'new' : 'edit';
},
async loadData() {
await this.beforeLoadData();
@ -175,7 +179,7 @@ export default {
this.$emit('save', {
item: item || this.item,
action: this.isNew ? 'new' : 'edit',
action: this.getSaveAction(),
});
} catch (err) {
this.formError = getErrorMessage(err);

View File

@ -43,6 +43,10 @@ export default {
this.item.meta.name = this.projectName;
},
getSaveAction() {
return 'restore';
},
/**
* @param file {File}
*/

View File

@ -1,12 +1,14 @@
<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
<v-dialog
v-model="dialog"
max-width="290"
:max-width="maxWidth || 290"
>
<v-card>
<v-card-title class="headline">{{ title }}</v-card-title>
<v-card-text>{{ text }}</v-card-text>
<v-card-text>
<slot>{{ text }}</slot>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
@ -41,6 +43,7 @@ export default {
yesButtonTitle: String,
noButtonTitle: String,
hideNoButton: Boolean,
maxWidth: Number,
},
data() {

View File

@ -33,13 +33,6 @@ export default {
},
methods: {
onSave(e) {
EventBus.$emit('i-project', {
action: 'restore',
item: e.item,
});
},
showDrawer() {
EventBus.$emit('i-show-drawer');
},