Skip to content

Commit

Permalink
feat(ui): restore file or folder (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 committed Dec 4, 2024
1 parent 3b494d6 commit 3be526d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 67 deletions.
2 changes: 1 addition & 1 deletion ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions ui/src/components/shared-folders/BackupRepositorySelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- no repositories -->
<NsEmptyState
v-else-if="!repositories.length"
:title="$t('shares.no_backup_destination_found')"
:title="$t('shares.no_backup_destination')"
/>
<!-- repo list -->
<NsTile
Expand Down Expand Up @@ -57,14 +57,14 @@
<template v-if="repo.is_generated_locally">
{{
$t("shares.from_node_name_of_this_cluster", {
name: repo.node_fqdn
name: repo.node_fqdn,
})
}}
</template>
<template v-else>
{{
$t("shares.from_node_name_of_different_cluster", {
name: repo.node_fqdn
name: repo.node_fqdn,
})
}}
</template>
Expand All @@ -73,7 +73,7 @@
<!-- node only -->
{{
$t("shares.from_node_name", {
name: repo.node_fqdn
name: repo.node_fqdn,
})
}}
</template>
Expand Down Expand Up @@ -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) {
Expand All @@ -122,8 +122,8 @@ export default {
// tile has been deselected
this.$emit("input", "");
}
}
}
},
},
};
</script>

Expand Down
16 changes: 8 additions & 8 deletions ui/src/components/shared-folders/BackupSnapshotSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ 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 {
// infinite scroll
snapshotsLoaded: [],
pageNum: 0,
pageSize: 20,
infiniteId: +new Date()
infiniteId: +new Date(),
};
},
watch: {
Expand All @@ -88,7 +88,7 @@ export default {
this.pageNum = 0;
this.infiniteId += 1;
this.infiniteScrollHandler();
}
},
},
methods: {
onTileClick(snapshot) {
Expand Down Expand Up @@ -117,8 +117,8 @@ export default {
$state.complete();
}
}
}
}
},
},
};
</script>

Expand Down
61 changes: 32 additions & 29 deletions ui/src/components/shared-folders/RestoreFileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
:description="
$t('shares.restore_file_info', {
restoredFolder: 'Restored folder',
node: installationNodeLabel
node: installationNodeLabel,
})
"
:showCloseButton="false"
Expand All @@ -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";
Expand All @@ -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 {
Expand All @@ -173,15 +173,15 @@ export default {
restoreBackupContent: false,
readBackupSnapshots: false,
getStatus: false,
seekSnapshotContents: false
seekSnapshotContents: false,
},
error: {
listBackupRepositories: "",
restoreBackupContent: "",
readBackupSnapshots: "",
getStatus: "",
seekSnapshotContents: ""
}
seekSnapshotContents: "",
},
};
},
computed: {
Expand Down Expand Up @@ -218,7 +218,7 @@ export default {
} else {
return "-";
}
}
},
},
watch: {
step: function () {
Expand All @@ -231,7 +231,7 @@ export default {
this.selectedFile = "";
this.getStatus();
}
}
},
},
methods: {
nextStep() {
Expand Down Expand Up @@ -280,8 +280,8 @@ export default {
extra: {
title: this.$t("action." + taskAction),
isNotificationHidden: true,
eventId
}
eventId,
},
})
);
const err = res[0];
Expand All @@ -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",
Expand Down Expand Up @@ -354,19 +355,20 @@ 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];

if (err) {
console.error(`error creating task ${taskAction}`, err);
this.error.readBackupSnapshots = this.getErrorMessage(err);
this.loading.readBackupSnapshots = false;
return;
}
},
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -472,8 +474,8 @@ export default {
extra: {
title: this.$t("action." + taskAction),
isNotificationHidden: true,
eventId
}
eventId,
},
})
);
const err = res[0];
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}
}
},
},
};
</script>

Expand Down
Loading

0 comments on commit 3be526d

Please sign in to comment.