diff --git a/src/components/FileManageDialog.vue b/src/components/FileManageDialog.vue index 098f259..55e2c08 100644 --- a/src/components/FileManageDialog.vue +++ b/src/components/FileManageDialog.vue @@ -346,6 +346,7 @@ style="height: 69vh; width: 70%" :disable="uploader_loading" :url="getUrl" + multiple method="post" :headers="generatorFileUploadHeaders" :label="$t('select file') + ':'" @@ -687,7 +688,6 @@ export default defineComponent({ loading.value = false; }; - const refresh_file_list_async = async () => { const response = await _request_list_files(path.value); _show_files(response); @@ -912,67 +912,34 @@ export default defineComponent({ resolve_value = null; }, async onCreateNewFolder() { - $q.dialog({ - title: $t.t("create folder"), - message: $t.t("input folder name") + ":", - prompt: { - model: "", - isValid: (val: string) => !!val && val.trim().length > 0, - type: "text", - }, - ok: { - label: $t.t("ok"), - noCaps: true, - flat: true, - }, - cancel: { - label: $t.t("cancel"), - noCaps: true, - flat: true, - }, - persistent: true, - }).onOk(async (data: string) => { - const response = await GlobalData.getInstance() - .getCurrentClient() - ?.CreateDirectoryFileManager(path.value, data); - if (response && response.success) { - refresh_file_list(); - $q.notify({ - type: "positive", - message: $t.t("create folder") + $t.t("success") + "!", - position: "top", - timeout: 1500, - }); - } else { - $q.notify({ - type: "warning", - message: - $t.t("create folder") + - $t.t("fail") + - "!" + - (response ? response.error_message : ""), - position: "top", - timeout: 1500, - }); - } - }); - }, - - selectFile, - async deleteFile(file: FileEntity) { - let response = null; - try { - response = await GlobalData.getInstance() - .getCurrentClient() - ?.DeleteFileManager(path.value, file.name); - } catch (e) { - console.log(e); - } + $q.dialog({ + title: $t.t("create folder"), + message: $t.t("input folder name") + ":", + prompt: { + model: "", + isValid: (val: string) => !!val && val.trim().length > 0, + type: "text", + }, + ok: { + label: $t.t("ok"), + noCaps: true, + flat: true, + }, + cancel: { + label: $t.t("cancel"), + noCaps: true, + flat: true, + }, + persistent: true, + }).onOk(async (data: string) => { + const response = await GlobalData.getInstance() + .getCurrentClient() + ?.CreateDirectoryFileManager(path.value, data); if (response && response.success) { refresh_file_list(); $q.notify({ type: "positive", - message: $t.t("delete file") + $t.t("success") + "!", + message: $t.t("create folder") + $t.t("success") + "!", position: "top", timeout: 1500, }); @@ -980,7 +947,7 @@ export default defineComponent({ $q.notify({ type: "warning", message: - $t.t("delete file") + + $t.t("create folder") + $t.t("fail") + "!" + (response ? response.error_message : ""), @@ -988,55 +955,88 @@ export default defineComponent({ timeout: 1500, }); } + }); + }, + + selectFile, + async deleteFile(file: FileEntity) { + let response = null; + try { + response = await GlobalData.getInstance() + .getCurrentClient() + ?.DeleteFileManager(path.value, file.name); + } catch (e) { + console.log(e); + } + if (response && response.success) { + refresh_file_list(); + $q.notify({ + type: "positive", + message: $t.t("delete file") + $t.t("success") + "!", + position: "top", + timeout: 1500, + }); + } else { + $q.notify({ + type: "warning", + message: + $t.t("delete file") + + $t.t("fail") + + "!" + + (response ? response.error_message : ""), + position: "top", + timeout: 1500, + }); + } }, renameFile(file: FileEntity) { - $q.dialog({ - title: $t.t("rename"), - message: $t.t("input new file name") + ":", - prompt: { - model: file.name, - isValid: (val: string) => !!val && val.trim().length > 0, - type: "text", - }, - ok: { - label: $t.t("ok"), - noCaps: true, - flat: true, - }, - cancel: { - label: $t.t("cancel"), - noCaps: true, - flat: true, - }, - persistent: true, - }).onOk(async (data: string) => { - if (data == file.name) { - return; - } - let response = await GlobalData.getInstance() - .getCurrentClient() - ?.RenameFileManager(path.value, file.name, data); - if (response && response.success) { - refresh_file_list(); - $q.notify({ - type: "positive", - message: $t.t("file rename") + $t.t("success") + "!", - position: "top", - timeout: 1500, - }); - } else { - $q.notify({ - type: "warning", - message: - $t.t("file rename") + - $t.t("fail") + - "!" + - (response ? response.error_message : ""), - position: "top", - timeout: 1500, - }); - } - }); + $q.dialog({ + title: $t.t("rename"), + message: $t.t("input new file name") + ":", + prompt: { + model: file.name, + isValid: (val: string) => !!val && val.trim().length > 0, + type: "text", + }, + ok: { + label: $t.t("ok"), + noCaps: true, + flat: true, + }, + cancel: { + label: $t.t("cancel"), + noCaps: true, + flat: true, + }, + persistent: true, + }).onOk(async (data: string) => { + if (data == file.name) { + return; + } + let response = await GlobalData.getInstance() + .getCurrentClient() + ?.RenameFileManager(path.value, file.name, data); + if (response && response.success) { + refresh_file_list(); + $q.notify({ + type: "positive", + message: $t.t("file rename") + $t.t("success") + "!", + position: "top", + timeout: 1500, + }); + } else { + $q.notify({ + type: "warning", + message: + $t.t("file rename") + + $t.t("fail") + + "!" + + (response ? response.error_message : ""), + position: "top", + timeout: 1500, + }); + } + }); }, copyStringToClipboard(value: string) { copyToClipboard(value); @@ -1148,7 +1148,7 @@ export default defineComponent({ } }, 1); }, - onUploaded() { + onUploaded(info: any) { uploading.value = false; uploader.value.reset(); refresh_file_list(); @@ -1161,16 +1161,20 @@ export default defineComponent({ }); loading.value = false; }, - onFailed(info: any) { - console.log(info); - $q.notify({ - type: "warning", - message: $t.t("file upload") + $t.t("fail") + "!", - position: "top", - timeout: 1500, - }); - loading.value = false; - loading.value = false; + async onFailed(info: any) { + let file_list: any = await _request_list_files(path.value); + setTimeout(() => { + if (files.value.length != file_list.files.length) { + $q.notify({ + type: "warning", + message: $t.t("file upload") + $t.t("fail") + "!", + position: "top", + timeout: 1500, + }); + loading.value = false; + } + }, 500); + }, copyFile(file: FileEntity) { if (file) {