Fix BackupProviderForm usage in restore view

This commit is contained in:
Johannes Zellner
2025-08-16 19:26:19 +02:00
parent 20b75b4065
commit 4ff90029b1
2 changed files with 22 additions and 12 deletions
+21 -11
View File
@@ -1,13 +1,12 @@
<script setup>
import { ref, onMounted, useTemplateRef } from 'vue';
import { Notification, ProgressBar, Button, SingleSelect, FormGroup, TextInput, Checkbox } from '@cloudron/pankow';
import { Notification, ProgressBar, Button, SingleSelect, FormGroup, PasswordInput, TextInput, Checkbox } from '@cloudron/pankow';
import { copyToClipboard } from '@cloudron/pankow/utils';
import { REGIONS_CONTABO, REGIONS_VULTR, REGIONS_IONOS, REGIONS_OVH, REGIONS_LINODE, REGIONS_SCALEWAY, REGIONS_WASABI } from '../constants.js';
import { redirectIfNeeded, mountlike, s3like } from '../utils.js';
import ProvisionModel from '../models/ProvisionModel.js';
import BackupProviderForm from '../components/BackupProviderForm.vue';
import { SECRET_PLACEHOLDER } from '../constants.js';
const provisionModel = ProvisionModel.create();
@@ -28,6 +27,8 @@ const provider = ref('');
const providerConfig = ref({});
const remotePath = ref('');
const format = ref('');
const encrypted = ref(false);
const encryptionPasswordHint = ref('');
const encryptionPassword = ref('');
const encryptedFilenames = ref(false);
const showAdvanced = ref(false);
@@ -125,9 +126,9 @@ async function onSubmit() {
skipDnsSetup: skipDnsSetup.value,
};
if (providerConfig.value.encryptionPassword) {
data.backupConfig.encryptedFilenames = providerConfig.value.encryptedFilenames;
data.backupConfig.encryptionPassword = providerConfig.value.encryptionPassword;
if (encrypted.value) {
data.backupConfig.encryptionPassword = encryptionPassword.value;
data.backupConfig.encryptedFilenames = encryptedFilenames.value;
}
if (s3like(provider.value)) {
@@ -269,7 +270,9 @@ function onBackupConfigChanged(event) {
remotePath.value = data.remotePath;
providerConfig.value = data.config;
format.value = data.format;
encryptionPassword.value = data.encrypted ? SECRET_PLACEHOLDER : '';
encrypted.value = !!data.encrypted;
encryptionPasswordHint.value = data.encryptionPasswordHint || '';
encryptionPassword.value = '';
encryptedFilenames.value = data.encryptedFilenames;
};
@@ -290,10 +293,10 @@ onMounted(async () => {
let [error, result] = await provisionModel.status();
if (error) return console.error(error);
if (redirectIfNeeded(result, 'restore')) return; // redirected to some other view...
// if (redirectIfNeeded(result, 'restore')) return; // redirected to some other view...
[error, result] = await provisionModel.detectIp();
if (error) return console.error(error);
// [error, result] = await provisionModel.detectIp();
// if (error) return console.error(error);
ipv4Provider.value = result.ipv4 ? 'generic' : 'noop';
ipv6Provider.value = result.ipv6 ? 'generic' : 'noop';
@@ -347,13 +350,20 @@ onMounted(async () => {
v-model:provider="provider"
v-model:provider-config="providerConfig"
v-model:format="format"
v-model:encryptionPassword="encryptionPassword"
v-model:encryptedFilenames="encryptedFilenames"
:form-error="formError"
:provisioning="true"
:import-only="true" />
<div v-show="showAdvanced">
<!-- TODO translate -->
<Checkbox style="padding-top: 12px" v-model="encrypted" label="Backup uses encryption"/>
<FormGroup v-if="encrypted">
<label for="encryptionPassswordInput">{{ $t('backups.configureBackupStorage.encryptionPassword') }}</label>
<PasswordInput id="encryptionPassswordInput" v-model="encryptionPassword" :placeholder="$t('backups.configureBackupStorage.encryptionPasswordPlaceholder')" required/>
<div class="warning-label" v-if="encryptionPasswordHint">{{ $t('backups.configureBackupStorage.encryptionHint') }}: {{ encryptionPasswordHint }}</div>
</FormGroup>
<Checkbox v-if="encrypted && format === 'rsync'" v-model="encryptedFilenames" :label="$t('backups.configureBackupStorage.encryptFilenames')"/>
<!-- IPv4 provider -->
<FormGroup>
<label class="control-label">IPv4 Configuration <sup><a href="https://docs.cloudron.io/networking/#ip-configuration" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>