Allow to edit backup target limits
This commit is contained in:
@@ -5,7 +5,6 @@ import { Dialog, FormGroup, TextInput, PasswordInput, Button, Checkbox } from '@
|
||||
import { prettyBinarySize } from '@cloudron/pankow/utils';
|
||||
import { REGIONS_CONTABO, REGIONS_VULTR, REGIONS_IONOS, REGIONS_OVH, REGIONS_LINODE, REGIONS_SCALEWAY, REGIONS_WASABI } from '../constants.js';
|
||||
import { mountlike, s3like } from '../utils.js';
|
||||
import BackupProviderForm from './BackupProviderForm.vue';
|
||||
import BackupTargetsModel from '../models/BackupTargetsModel.js';
|
||||
import SystemModel from '../models/SystemModel.js';
|
||||
|
||||
@@ -14,14 +13,47 @@ const emit = defineEmits([ 'success' ]);
|
||||
const backupTargetsModel = BackupTargetsModel.create();
|
||||
const systemModel = SystemModel.create();
|
||||
|
||||
const minMemoryLimit = ref(1024 * 1024 * 1024); // 1 GB
|
||||
const maxMemoryLimit = ref(minMemoryLimit.value); // set later
|
||||
|
||||
const dialog = useTemplateRef('dialog');
|
||||
const target = ref({});
|
||||
const formError = ref({});
|
||||
const busy = ref(false);
|
||||
const memoryLimit = ref(0);
|
||||
const uploadPartSize = ref(0);
|
||||
const syncConcurrency = ref(0);
|
||||
const downloadConcurrency = ref(0);
|
||||
const copyConcurrency = ref(0);
|
||||
|
||||
async function onSubmit() {
|
||||
busy.value = true;
|
||||
|
||||
const limits = {
|
||||
memoryLimit: parseInt(memoryLimit.value),
|
||||
uploadPartSize: parseInt(uploadPartSize.value),
|
||||
syncConcurrency: parseInt(syncConcurrency.value),
|
||||
downloadConcurrency: parseInt(downloadConcurrency.value),
|
||||
copyConcurrency: parseInt(copyConcurrency.value),
|
||||
};
|
||||
|
||||
const [error] = await backupTargetsModel.setLimits(target.value.id, limits);
|
||||
if (error) {
|
||||
formError.value.generic = error.body ? error.body.message : 'Internal error';
|
||||
busy.value = false;
|
||||
return console.error(error);
|
||||
}
|
||||
|
||||
emit('success');
|
||||
dialog.value.close();
|
||||
busy.value = false;
|
||||
}
|
||||
|
||||
async function getMemory() {
|
||||
const [error, result] = await systemModel.memory();
|
||||
if (error) return console.error(error);
|
||||
|
||||
maxMemoryLimit.value = Math.ceil(result.memory / (1024*1024*1024)) * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
@@ -30,7 +62,13 @@ defineExpose({
|
||||
busy.value = false;
|
||||
target.value = t;
|
||||
|
||||
console.log(t)
|
||||
memoryLimit.value = t.limits.memoryLimit || 1024 * 1024 * 1024; // 1 GB
|
||||
uploadPartSize.value = t.limits.uploadPartSize || 10 * 1024 * 1024;
|
||||
syncConcurrency.value = t.limits.syncConcurrency || 10;
|
||||
downloadConcurrency.value = t.limits.downloadConcurrency || 10;
|
||||
copyConcurrency.value = t.limits.copyConcurrency || 10;
|
||||
|
||||
await getMemory();
|
||||
|
||||
dialog.value.open();
|
||||
}
|
||||
@@ -80,6 +118,46 @@ defineExpose({
|
||||
<div class="info-label">Encryption Password Hint</div>
|
||||
<div class="info-value">{{ target.encryptionPasswordHint }}</div>
|
||||
</div>
|
||||
|
||||
<FormGroup>
|
||||
<label for="memoryLimitInput">{{ $t('backups.configureBackupStorage.memoryLimit') }}: <b>{{ prettyBinarySize(memoryLimit, '1024 MB') }}</b></label>
|
||||
<div class="small">{{ $t('backups.configureBackupStorage.memoryLimitDescription') }}</div>
|
||||
<input type="range" id="memoryLimitInput" v-model="memoryLimit" :step="256*1024*1024" :min="minMemoryLimit" :max="maxMemoryLimit" />
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-if="s3like(provider)">
|
||||
<label for="uploadPartSizeInput">{{ $t('backups.configureBackupStorage.uploadPartSize') }}: <b>{{ prettyBinarySize(uploadPartSize, 'Default (50 MiB)') }}</b></label>
|
||||
<p class="small">{{ $t('backups.configureBackupStorage.uploadPartSizeDescription') }}</p>
|
||||
<input type="range" id="uploadPartSizeInput" v-model="uploadPartSize" list="uploadPartSizeTicks" :step="1024*1024" :min="10*1024*1024" :max="1024*1024*1024" />
|
||||
<datalist id="uploadPartSizeTicks">
|
||||
<option :value="1024*1024*10"></option>
|
||||
<option :value="1024*1024*64"></option>
|
||||
<option :value="1024*1024*128"></option>
|
||||
<option :value="1024*1024*256"></option>
|
||||
<option :value="1024*1024*512"></option>
|
||||
<option :value="1024*1024*1024"></option>
|
||||
</datalist>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-if="format === 'rsync' && provider !== 'noop'">
|
||||
<label for="syncConcurrencyInput">{{ $t('backups.configureBackupStorage.uploadConcurrency') }}: <b>{{ syncConcurrency }}</b></label>
|
||||
<div class="small">{{ $t('backups.configureBackupStorage.uploadConcurrencyDescription') }}</div>
|
||||
<input type="range" id="syncConcurrencyInput" v-model="syncConcurrency" step="10" min="10" max="200" />
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-if="format === 'rsync' && (s3like(provider) || provider === 'gcs')">
|
||||
<label for="downloadConcurrencyInput">{{ $t('backups.configureBackupStorage.downloadConcurrency') }}: <b>{{ downloadConcurrency }}</b></label>
|
||||
<div class="small">{{ $t('backups.configureBackupStorage.downloadConcurrencyDescription') }}</div>
|
||||
<input type="range" id="downloadConcurrencyInput" v-model="downloadConcurrency" step="10" min="10" max="200" />
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-if="format === 'rsync' && (s3like(provider) || provider === 'gcs')">
|
||||
<label for="copyConcurrencyInput">{{ $t('backups.configureBackupStorage.copyConcurrency') }}: <b>{{ copyConcurrency }}</b></label>
|
||||
<div class="small">{{ $t('backups.configureBackupStorage.copyConcurrencyDescription') }}
|
||||
<span v-show="provider === 'digitalocean-spaces'">{{ $t('backups.configureBackupStorage.copyConcurrencyDigitalOceanNote') }}</span>
|
||||
</div>
|
||||
<input type="range" id="copyConcurrencyInput" v-model="copyConcurrency" step="10" min="10" max="500" />
|
||||
</FormGroup>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user