diff --git a/dashboard/src/models/BackupsModel.js b/dashboard/src/models/BackupsModel.js index 1725977ae..be169de1e 100644 --- a/dashboard/src/models/BackupsModel.js +++ b/dashboard/src/models/BackupsModel.js @@ -111,6 +111,28 @@ function create() { if (error || result.status !== 202) return [error || result]; return [null, result.body.taskId]; }, + async mountStatus() { + let error, result; + try { + result = await fetcher.get(`${API_ORIGIN}/api/v1/backups/mount_status`, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error || result.status !== 200) return [error || result]; + return [null, result.body]; + }, + async remount() { + let error, result; + try { + result = await fetcher.post(`${API_ORIGIN}/api/v1/backups/remount`, {}, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error || result.status !== 202) return [error || result]; + return [null, result.body]; + }, }; } diff --git a/dashboard/src/views/BackupsView.vue b/dashboard/src/views/BackupsView.vue index 719222758..3cb48c29f 100644 --- a/dashboard/src/views/BackupsView.vue +++ b/dashboard/src/views/BackupsView.vue @@ -21,34 +21,46 @@ const manualBackupApps = ref([]); const config = ref({}); const mountOptions = ref({}); const mountStatus = ref({}); -const remountBusy = ref(false); const backupDialog = useTemplateRef('backupDialog'); function onConfigure() { backupDialog.value.open(); } -function onRemount() { - // TODO +const remountBusy = ref(false); + +async function onRemount() { + if (!mountlike(config.value.provider)) return; + + remountBusy.value = true; + + const [error] = await backupsModel.remount(); + if (error) { + console.error('Failed to remount backup storage.', error); + window.pankow.notify({ text: `Remount failed: ${error.message}`, persistent: true, type: 'danger' }); + } + + // give the backend some time + setTimeout(() => { + remountBusy.value = false; + refresh(); + }, 2000); } async function refresh() { - const [error, result] = await backupsModel.getConfig(); + let [error, result] = await backupsModel.getConfig(); if (error) return console.error(error); config.value = result; mountOptions.value = result.mountOptions || {}; + mountStatus.value = {}; - // $scope.backupConfig = backupConfig; - // $scope.mountStatus = null; + if (!mountlike(config.value.provider)) return; - // if (!$scope.mountlike($scope.backupConfig.provider)) return; + [error, result] = await backupsModel.mountStatus(); + if (error) return console.error(error); - // Client.getBackupMountStatus(function (error, mountStatus) { - // if (error) return console.error(error); - - // $scope.mountStatus = mountStatus; - // }); + mountStatus.value = result; } onMounted(async () => { @@ -88,7 +100,7 @@ onMounted(async () => {