From 3be526df88f07f1c9e93fff845d023ca0265ccaf Mon Sep 17 00:00:00 2001 From: Andrea Leardini Date: Wed, 4 Dec 2024 09:47:10 +0100 Subject: [PATCH] feat(ui): restore file or folder (wip) --- ui/public/i18n/en/translation.json | 2 +- .../BackupRepositorySelector.vue | 20 +++--- .../shared-folders/BackupSnapshotSelector.vue | 16 ++--- .../shared-folders/RestoreFileModal.vue | 61 ++++++++++--------- ui/src/views/Shares.vue | 38 ++++++------ 5 files changed, 70 insertions(+), 67 deletions(-) diff --git a/ui/public/i18n/en/translation.json b/ui/public/i18n/en/translation.json index 95e4fd0c..8c995951 100644 --- a/ui/public/i18n/en/translation.json +++ b/ui/public/i18n/en/translation.json @@ -69,7 +69,7 @@ "select_backup_destination": "Select backup destination", "select_backup_snapshot": "Select backup snapshot", "select_file_or_folder_to_restore": "Select file or folder to restore", - "no_backup_destination_found": "No backup destination found", + "no_backup_destination": "No backup destination", "from_node_name_of_this_cluster": "From node {name} of this cluster", "from_node_name_of_different_cluster": "From node {name} of a different cluster", "from_this_cluster": "From this cluster", diff --git a/ui/src/components/shared-folders/BackupRepositorySelector.vue b/ui/src/components/shared-folders/BackupRepositorySelector.vue index 379456ea..1bb38f9b 100644 --- a/ui/src/components/shared-folders/BackupRepositorySelector.vue +++ b/ui/src/components/shared-folders/BackupRepositorySelector.vue @@ -22,7 +22,7 @@ {{ $t("shares.from_node_name_of_this_cluster", { - name: repo.node_fqdn + name: repo.node_fqdn, }) }} @@ -73,7 +73,7 @@ {{ $t("shares.from_node_name", { - name: repo.node_fqdn + name: repo.node_fqdn, }) }} @@ -102,17 +102,17 @@ export default { props: { value: { type: String, - required: true + required: true, }, repositories: { type: Array, - required: true + required: true, }, loading: { type: Boolean, - default: false + default: false, }, - light: Boolean + light: Boolean, }, methods: { onTileClick(repo) { @@ -122,8 +122,8 @@ export default { // tile has been deselected this.$emit("input", ""); } - } - } + }, + }, }; diff --git a/ui/src/components/shared-folders/BackupSnapshotSelector.vue b/ui/src/components/shared-folders/BackupSnapshotSelector.vue index 05a77a34..6c813c45 100644 --- a/ui/src/components/shared-folders/BackupSnapshotSelector.vue +++ b/ui/src/components/shared-folders/BackupSnapshotSelector.vue @@ -61,17 +61,17 @@ export default { props: { value: { type: String, - required: true + required: true, }, snapshots: { type: Array, - required: true + required: true, }, loading: { type: Boolean, - default: false + default: false, }, - light: Boolean + light: Boolean, }, data() { return { @@ -79,7 +79,7 @@ export default { snapshotsLoaded: [], pageNum: 0, pageSize: 20, - infiniteId: +new Date() + infiniteId: +new Date(), }; }, watch: { @@ -88,7 +88,7 @@ export default { this.pageNum = 0; this.infiniteId += 1; this.infiniteScrollHandler(); - } + }, }, methods: { onTileClick(snapshot) { @@ -117,8 +117,8 @@ export default { $state.complete(); } } - } - } + }, + }, }; diff --git a/ui/src/components/shared-folders/RestoreFileModal.vue b/ui/src/components/shared-folders/RestoreFileModal.vue index dfc3e62d..abd7446a 100644 --- a/ui/src/components/shared-folders/RestoreFileModal.vue +++ b/ui/src/components/shared-folders/RestoreFileModal.vue @@ -108,7 +108,7 @@ :description=" $t('shares.restore_file_info', { restoredFolder: 'Restored folder', - node: installationNodeLabel + node: installationNodeLabel, }) " :showCloseButton="false" @@ -133,7 +133,7 @@ import { UtilService, TaskService, IconService, - NsComboSearchBox + NsComboSearchBox, } from "@nethserver/ns8-ui-lib"; import to from "await-to-js"; import { mapState } from "vuex"; @@ -145,15 +145,15 @@ export default { components: { BackupRepositorySelector, BackupSnapshotSelector, - NsComboSearchBox + NsComboSearchBox, }, mixins: [UtilService, TaskService, IconService], props: { isShown: { type: Boolean, - default: true + default: true, }, - shareName: String + shareName: String, }, data() { return { @@ -173,15 +173,15 @@ export default { restoreBackupContent: false, readBackupSnapshots: false, getStatus: false, - seekSnapshotContents: false + seekSnapshotContents: false, }, error: { listBackupRepositories: "", restoreBackupContent: "", readBackupSnapshots: "", getStatus: "", - seekSnapshotContents: "" - } + seekSnapshotContents: "", + }, }; }, computed: { @@ -218,7 +218,7 @@ export default { } else { return "-"; } - } + }, }, watch: { step: function () { @@ -231,7 +231,7 @@ export default { this.selectedFile = ""; this.getStatus(); } - } + }, }, methods: { nextStep() { @@ -280,8 +280,8 @@ export default { extra: { title: this.$t("action." + taskAction), isNotificationHidden: true, - eventId - } + eventId, + }, }) ); const err = res[0]; @@ -295,12 +295,13 @@ export default { }, listBackupRepositoriesAborted(taskResult, taskContext) { console.error(`${taskContext.action} aborted`, taskResult); + this.error.listBackupRepositories = this.$t("error.generic_error"); this.loading.listBackupRepositories = false; }, listBackupRepositoriesCompleted(taskContext, taskResult) { let backupRepositories = taskResult.output; - //// remove mockup + //// remove mock // backupRepositories.push({ // cluster_uuid: "fff09e38-7ca3-4934-862c-2ae15996a1b3", // installed_instance: "samba2", @@ -354,12 +355,12 @@ export default { action: taskAction, data: { repository: this.selectedRepositoryId, - path: this.selectedRepository.path + path: this.selectedRepository.path, }, extra: { title: this.$t("action." + taskAction), - isNotificationHidden: true - } + isNotificationHidden: true, + }, }) ); const err = res[0]; @@ -367,6 +368,7 @@ export default { if (err) { console.error(`error creating task ${taskAction}`, err); this.error.readBackupSnapshots = this.getErrorMessage(err); + this.loading.readBackupSnapshots = false; return; } }, @@ -416,14 +418,14 @@ export default { destination: this.selectedRepositoryId, repopath: this.selectedRepository.path, share: this.shareName, - content: this.selectedFile + content: this.selectedFile, }, extra: { title: this.$t("action." + taskAction), description: this.$t("shares.restoring_to_share_name", { - name: this.shareName - }) - } + name: this.shareName, + }), + }, }) ); const err = res[0]; @@ -442,8 +444,8 @@ export default { }, restoreBackupContentAborted(taskResult, taskContext) { console.error(`${taskContext.action} aborted`, taskResult); + this.error.restoreBackupContent = this.$t("error.generic_error"); this.loading.restoreBackupContent = false; - this.$emit("hide"); }, restoreBackupContentCompleted() { this.loading.restoreBackupContent = false; @@ -472,8 +474,8 @@ export default { extra: { title: this.$t("action." + taskAction), isNotificationHidden: true, - eventId - } + eventId, + }, }) ); const err = res[0]; @@ -521,13 +523,13 @@ export default { repopath: this.selectedRepository.path, share: this.shareName, limit: 50, - query: textQuery + query: textQuery, }, extra: { title: this.$t("action." + taskAction), isNotificationHidden: true, - eventId - } + eventId, + }, }) ); const err = res[0]; @@ -541,19 +543,20 @@ export default { }, seekSnapshotContentsAborted(taskResult, taskContext) { console.error(`${taskContext.action} aborted`, taskResult); + this.error.seekSnapshotContents = this.$t("error.generic_error"); this.loading.seekSnapshotContents = false; }, seekSnapshotContentsCompleted(taskContext, taskResult) { this.fileSearchResults = taskResult.output.contents.map((item) => ({ name: item, label: item, - value: item + value: item, })); this.resultsLimitReached = taskResult.output.limit_reached; this.loading.seekSnapshotContents = false; - } - } + }, + }, }; diff --git a/ui/src/views/Shares.vue b/ui/src/views/Shares.vue index 7d3b2b40..b795fd83 100644 --- a/ui/src/views/Shares.vue +++ b/ui/src/views/Shares.vue @@ -167,18 +167,18 @@ :name="currentShare ? currentShare.name : ''" :title=" $t('shares.delete_shared_folder_name', { - name: currentShare ? currentShare.name : '' + name: currentShare ? currentShare.name : '', }) " :warning="core.$t('common.please_read_carefully')" :description=" $t('shares.delete_shared_folder_description', { - name: currentShare ? currentShare.name : '' + name: currentShare ? currentShare.name : '', }) " :typeToConfirm=" core.$t('common.type_to_confirm', { - name: currentShare ? currentShare.name : '' + name: currentShare ? currentShare.name : '', }) " :isErrorShown="!!error.removeShare" @@ -199,7 +199,7 @@ import { UtilService, TaskService, IconService, - PageTitleService + PageTitleService, } from "@nethserver/ns8-ui-lib"; import CreateSharedFolderModal from "@/components/shared-folders/CreateSharedFolderModal.vue"; import EditDescriptionModal from "@/components/shared-folders/EditDescriptionModal.vue"; @@ -215,14 +215,14 @@ export default { EditDescriptionModal, ShowAclsModal, SetPermissionsModal, - RestoreFileModal + RestoreFileModal, }, mixins: [ TaskService, IconService, UtilService, QueryParamService, - PageTitleService + PageTitleService, ], pageTitle() { return this.$t("shares.title") + " - " + this.appName; @@ -230,7 +230,7 @@ export default { data() { return { q: { - page: "shares" + page: "shares", }, urlCheckInterval: null, shares: [], @@ -244,16 +244,16 @@ export default { RecentlyViewed20, loading: { listShares: false, - removeShare: false + removeShare: false, }, error: { listShares: "", - removeShare: "" - } + removeShare: "", + }, }; }, computed: { - ...mapState(["instanceName", "core", "appName"]) + ...mapState(["instanceName", "core", "appName"]), }, beforeRouteEnter(to, from, next) { next((vm) => { @@ -293,8 +293,8 @@ export default { extra: { title: this.$t("action." + taskAction), isNotificationHidden: true, - eventId - } + eventId, + }, }) ); const err = res[0]; @@ -397,15 +397,15 @@ export default { this.createModuleTaskForApp(this.instanceName, { action: taskAction, data: { - name: this.currentShare.name + name: this.currentShare.name, }, extra: { title: this.$t("shares.delete_shared_folder_name", { - name: this.currentShare.name + name: this.currentShare.name, }), description: this.$t("common.processing"), - eventId - } + eventId, + }, }) ); const err = res[0]; @@ -446,8 +446,8 @@ export default { // reload shares this.listShares(); - } - } + }, + }, };