Skip to content

Commit 24cabd2

Browse files
fix: Fix issue with application recovery failure (#8024)
1 parent 189ba73 commit 24cabd2

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

frontend/src/components/upload/index.vue

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div>
33
<DrawerPro
4-
v-model="upVisible"
4+
v-model="uploadOpen"
55
:header="$t('commons.button.import')"
66
:resource="title"
7-
:back="handleClose"
7+
:back="handleUploadClose"
88
size="large"
99
>
1010
<template #content>
@@ -21,6 +21,7 @@
2121
drag
2222
:on-exceed="handleExceed"
2323
:on-change="fileOnChange"
24+
:on-remove="fileOnRemove"
2425
class="upload-demo"
2526
:auto-upload="false"
2627
>
@@ -38,15 +39,14 @@
3839
></el-progress>
3940
<div
4041
v-if="type === 'mysql' || type === 'mariadb' || type === 'postgresql'"
41-
style="width: 80%"
42-
class="el-upload__tip"
42+
class="w-4/5 el-upload__tip"
4343
>
4444
<span class="input-help">{{ $t('database.supportUpType') }}</span>
4545
<span class="input-help">
4646
{{ $t('database.zipFormat') }}
4747
</span>
4848
</div>
49-
<div v-else style="width: 80%" class="el-upload__tip">
49+
<div v-else class="w-4/5 el-upload__tip">
5050
<span class="input-help">{{ $t('website.supportUpType') }}</span>
5151
<span class="input-help">
5252
{{ $t('website.zipFormat', [type + '.json']) }}
@@ -104,19 +104,23 @@
104104
</template>
105105
</DrawerPro>
106106

107-
<DialogPro v-model="open" :title="$t('commons.button.recover') + ' - ' + name" @close="handleBackupClose">
107+
<DialogPro
108+
v-model="openRecover"
109+
:title="$t('commons.button.recover') + ' - ' + name"
110+
@close="handleRecoverClose"
111+
>
108112
<el-form ref="backupForm" label-position="left" v-loading="loading">
109113
<el-form-item
110114
:label="$t('setting.compressPassword')"
111-
style="margin-top: 10px"
115+
class="mt-10"
112116
v-if="type === 'app' || type === 'website'"
113117
>
114118
<el-input v-model="secret" :placeholder="$t('setting.backupRecoverMessage')" />
115119
</el-form-item>
116120
</el-form>
117121
<template #footer>
118122
<span class="dialog-footer">
119-
<el-button @click="handleClose" :disabled="loading">
123+
<el-button @click="handleRecoverClose" :disabled="loading">
120124
{{ $t('commons.button.cancel') }}
121125
</el-button>
122126
<el-button type="primary" @click="onHandleRecover" :disabled="loading">
@@ -127,6 +131,7 @@
127131
</DialogPro>
128132

129133
<OpDialog ref="opRef" @search="search" />
134+
<TaskLog ref="taskLogRef" @close="search" />
130135
</div>
131136
</template>
132137

@@ -140,36 +145,37 @@ import { batchDeleteFile, checkFile, chunkUploadFileData, getUploadList } from '
140145
import { loadBaseDir } from '@/api/modules/setting';
141146
import { MsgError, MsgSuccess } from '@/utils/message';
142147
import { handleRecoverByUpload } from '@/api/modules/backup';
148+
import TaskLog from '@/components/task-log/index.vue';
143149
150+
interface DialogProps {
151+
type: string;
152+
name: string;
153+
detailName: string;
154+
remark: string;
155+
}
144156
const loading = ref();
145157
const isUpload = ref();
146158
const uploadPercent = ref<number>(0);
147159
const selects = ref<any>([]);
148160
const baseDir = ref();
149161
const opRef = ref();
150-
151-
const open = ref();
152-
162+
const openRecover = ref();
153163
const data = ref();
154164
const title = ref();
155165
const paginationConfig = reactive({
156166
currentPage: 1,
157167
pageSize: 10,
158168
total: 0,
159169
});
160-
161-
const upVisible = ref(false);
170+
const uploadOpen = ref(false);
162171
const type = ref();
163172
const name = ref();
164173
const detailName = ref();
165174
const remark = ref();
166175
const secret = ref();
167-
interface DialogProps {
168-
type: string;
169-
name: string;
170-
detailName: string;
171-
remark: string;
172-
}
176+
const fileName = ref();
177+
const taskLogRef = ref();
178+
173179
const acceptParams = async (params: DialogProps): Promise<void> => {
174180
type.value = params.type;
175181
name.value = params.name;
@@ -196,7 +202,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
196202
title.value = name.value;
197203
baseDir.value = `${pathRes.data}/uploads/app/${type.value}/${name.value}/`;
198204
}
199-
upVisible.value = true;
205+
uploadOpen.value = true;
200206
search();
201207
};
202208
@@ -211,45 +217,38 @@ const search = async () => {
211217
paginationConfig.total = res.data.total;
212218
};
213219
214-
const onHandleRecover = async (row?: any) => {
220+
const openTaskLog = (taskID: string) => {
221+
taskLogRef.value.openWithTaskID(taskID);
222+
};
223+
224+
const onHandleRecover = async () => {
215225
let params = {
216226
downloadAccountID: 1,
217227
type: type.value,
218228
name: name.value,
219229
detailName: detailName.value,
220-
file: baseDir.value + row.name,
230+
file: baseDir.value + fileName.value,
221231
secret: secret.value,
222232
taskID: newUUID(),
223233
};
224234
loading.value = true;
225235
await handleRecoverByUpload(params)
226236
.then(() => {
227237
loading.value = false;
228-
handleClose();
229-
handleBackupClose();
238+
handleUploadClose();
239+
handleRecoverClose();
230240
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
231241
search();
242+
openTaskLog(params.taskID);
232243
})
233244
.catch(() => {
234245
loading.value = false;
235246
});
236247
};
237248
238249
const onRecover = async (row: File.File) => {
239-
if (type.value !== 'app' && type.value !== 'website') {
240-
ElMessageBox.confirm(
241-
i18n.global.t('commons.msg.recoverHelper', [row.name]),
242-
i18n.global.t('commons.button.recover'),
243-
{
244-
confirmButtonText: i18n.global.t('commons.button.confirm'),
245-
cancelButtonText: i18n.global.t('commons.button.cancel'),
246-
},
247-
).then(async () => {
248-
onHandleRecover(row);
249-
});
250-
return;
251-
}
252-
open.value = true;
250+
fileName.value = row.name;
251+
openRecover.value = true;
253252
};
254253
255254
const uploaderFiles = ref<UploadFiles>([]);
@@ -274,13 +273,18 @@ const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
274273
uploaderFiles.value = uploadFiles;
275274
};
276275
277-
const handleClose = () => {
276+
const fileOnRemove = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
277+
uploaderFiles.value = uploadFiles;
278+
};
279+
280+
const handleUploadClose = () => {
278281
uploaderFiles.value = [];
279282
uploadRef.value!.clearFiles();
280-
upVisible.value = false;
283+
uploadOpen.value = false;
281284
};
282-
const handleBackupClose = () => {
283-
open.value = false;
285+
286+
const handleRecoverClose = () => {
287+
openRecover.value = false;
284288
};
285289
286290
const handleExceed: UploadProps['onExceed'] = (files) => {

0 commit comments

Comments
 (0)