Make backupSite contents configurable

This commit is contained in:
Johannes Zellner
2025-09-24 18:11:48 +02:00
parent 0dfd8b9f53
commit c8c5862b47
3 changed files with 106 additions and 3 deletions
@@ -1,14 +1,16 @@
<script setup>
import { ref, useTemplateRef } from 'vue';
import { Checkbox, Dialog, FormGroup, TextInput } from '@cloudron/pankow';
import { Checkbox, Radiobutton, MultiSelect, Dialog, FormGroup, TextInput } from '@cloudron/pankow';
import { prettyBinarySize } from '@cloudron/pankow/utils';
import { mountlike, s3like } from '../utils.js';
import AppsModel from '../models/AppsModel.js';
import BackupSitesModel from '../models/BackupSitesModel.js';
import SystemModel from '../models/SystemModel.js';
const emit = defineEmits([ 'success' ]);
const appsModel = AppsModel.create();
const backupSitesModel = BackupSitesModel.create();
const systemModel = SystemModel.create();
@@ -26,6 +28,10 @@ const uploadPartSize = ref(0);
const syncConcurrency = ref(0);
const downloadConcurrency = ref(0);
const copyConcurrency = ref(0);
const includeExclude = ref('include'); // or exclude
const contentOptions = ref([]);
const contentInclude = ref([]);
const contentExclude = ref([]);
async function onSubmit() {
busy.value = true;
@@ -44,6 +50,22 @@ async function onSubmit() {
return console.error(error);
}
let contents;
if (includeExclude.value === 'exclude') {
contents = { exclude: contentExclude.value };
} else if (includeExclude.value === 'include' && contentInclude.value.length) {
contents = { include: contentInclude.value };
} else {
contents = null;
}
[error] = await backupSitesModel.setContents(site.value.id, contents);
if (error) {
formError.value.generic = error.body ? error.body.message : 'Internal error';
busy.value = false;
return console.error(error);
}
const limits = {
memoryLimit: parseInt(memoryLimit.value),
uploadPartSize: parseInt(uploadPartSize.value),
@@ -87,6 +109,29 @@ defineExpose({
await getMemory();
const [error, result] = await appsModel.list();
if (error) return console.error(error);
contentOptions.value = [{
id: 'box',
label: 'Platform',
}];
result.forEach(a => {
contentOptions.value.push({
id: a.id,
label: `${a.label || a.fqdn} - ${a.manifest.title}`,
});
});
includeExclude.value = 'include';
if (t.contents !== null && t.contents.exclude) {
includeExclude.value = 'exclude';
contentExclude.value = t.contents.exclude;
} else if (t.contents !== null && t.contents.include) {
contentInclude.value = t.contents.include;
}
dialog.value.open();
}
});
@@ -146,6 +191,14 @@ defineExpose({
<TextInput id="backupSiteNameInput" v-model="name" required/>
</FormGroup>
<FormGroup>
<label>Contents</label>
<Radiobutton v-model="includeExclude" value="include" label="Include everything, exclude optionally the following:"/>
<MultiSelect v-model="contentInclude" v-if="includeExclude === 'include'" :options="contentOptions" :search-threshold="10" option-key="id"/>
<Radiobutton v-model="includeExclude" value="exclude" label="Only the following:"/>
<MultiSelect v-model="contentExclude" v-if="includeExclude === 'exclude'" :options="contentOptions" :search-threshold="10" option-key="id"/>
</FormGroup>
<Checkbox v-model="enableForUpdates" :label="$t('backups.configureBackupStorage.useForUpdates')" />
<FormGroup>