🔨 Add autoclean setting menu

This commit is contained in:
SebClem 2023-01-13 18:14:30 +01:00
parent 154cd724af
commit c0c648ae2e
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
4 changed files with 113 additions and 6 deletions

View File

@ -25,7 +25,7 @@
<template v-slot:default="{ expanded }"> <template v-slot:default="{ expanded }">
{{ CronModeFriendly[cron.mode] }} {{ CronModeFriendly[cron.mode] }}
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-fade-transition leave-absolute> <v-fade-transition>
<v-chip <v-chip
v-if="!expanded && cron.monthDay != undefined" v-if="!expanded && cron.monthDay != undefined"
append-icon="mdi-calendar" append-icon="mdi-calendar"
@ -34,7 +34,7 @@
{{ cron.monthDay }} {{ cron.monthDay }}
</v-chip> </v-chip>
</v-fade-transition> </v-fade-transition>
<v-fade-transition leave-absolute> <v-fade-transition>
<v-chip <v-chip
v-if="!expanded && cron.weekday != undefined" v-if="!expanded && cron.weekday != undefined"
append-icon="mdi-calendar" append-icon="mdi-calendar"
@ -44,7 +44,7 @@
{{ weekdayFriendly[cron.weekday] }} {{ weekdayFriendly[cron.weekday] }}
</v-chip> </v-chip>
</v-fade-transition> </v-fade-transition>
<v-fade-transition leave-absolute> <v-fade-transition>
<v-chip <v-chip
v-if="!expanded && cron.hour" v-if="!expanded && cron.hour"
append-icon="mdi-clock" append-icon="mdi-clock"
@ -54,7 +54,7 @@
{{ cron.hour }} {{ cron.hour }}
</v-chip> </v-chip>
</v-fade-transition> </v-fade-transition>
<v-fade-transition leave-absolute> <v-fade-transition>
<v-chip <v-chip
v-if="!expanded && cron.custom" v-if="!expanded && cron.custom"
append-icon="mdi-clock-edit" append-icon="mdi-clock-edit"
@ -163,6 +163,12 @@
</v-row> </v-row>
</v-expansion-panel-text> </v-expansion-panel-text>
</v-expansion-panel> </v-expansion-panel>
<div
v-if="data.cron?.length == 0"
class="my-3 text-subtitle-2 text-medium-emphasis"
>
No auto backup configured
</div>
</v-expansion-panels> </v-expansion-panels>
</v-card-text> </v-card-text>
</v-card> </v-card>

View File

@ -0,0 +1,85 @@
<template>
<v-card variant="elevated" elevation="7">
<v-card-title class="bg-light-blue-darken-4 text-center">
Auto Clean
</v-card-title>
<v-card-text>
<v-row class="mt-0" v-if="!loading">
<v-col class="" cols="12" md="6">
<v-row dense>
<v-col>
<v-switch
label="Auto clean Home Assistant Backups"
v-model="data.autoClean.homeAssistant.enabled"
hide-details="auto"
density="compact"
inset
:loading="loading"
color="orange"
></v-switch>
</v-col>
</v-row>
<v-fade-transition>
<v-row dense v-if="data.autoClean.homeAssistant.enabled">
<v-col>
<div class="text-subtitle-1 text-medium-emphasis">
Number of backup to keep
</div>
<v-text-field
v-model="data.autoClean.homeAssistant.nbrToKeep"
type="number"
hide-details="auto"
density="compact"
variant="outlined"
color="orange"
min="1"
></v-text-field>
</v-col>
</v-row>
</v-fade-transition>
</v-col>
<v-col cols="12" md="6">
<v-row dense>
<v-col>
<v-switch
label="Auto clean Cloud Backups"
v-model="data.autoClean.webdav.enabled"
hide-details="auto"
density="compact"
inset
:loading="loading"
color="orange"
></v-switch>
</v-col>
</v-row>
<v-fade-transition>
<v-row dense v-if="data.autoClean.webdav.enabled">
<v-col>
<div class="text-subtitle-1 text-medium-emphasis">
Number of backup to keep
</div>
<v-text-field
v-model="data.autoClean.webdav.nbrToKeep"
type="number"
hide-details="auto"
density="compact"
variant="outlined"
color="orange"
min="1"
></v-text-field>
</v-col>
</v-row>
</v-fade-transition>
</v-col>
</v-row>
</v-card-text>
</v-card>
</template>
<script setup lang="ts">
import { useBackupConfigStore } from "@/stores/backupConfig";
import { storeToRefs } from "pinia";
defineProps<{ loading: boolean }>();
const backupConfigStore = useBackupConfigStore();
const { data } = storeToRefs(backupConfigStore);
</script>

View File

@ -45,11 +45,16 @@
</v-sheet> </v-sheet>
</v-col> </v-col>
</v-row> </v-row>
<v-row> <v-row dense>
<v-col> <v-col>
<BackupConfigAutoBackup :loading="loading"></BackupConfigAutoBackup> <BackupConfigAutoBackup :loading="loading"></BackupConfigAutoBackup>
</v-col> </v-col>
</v-row> </v-row>
<v-row dense>
<v-col>
<BackupConfigAutoClean :loading="loading"></BackupConfigAutoClean>
</v-col>
</v-row>
</v-form> </v-form>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -62,6 +67,7 @@ import { storeToRefs } from "pinia";
import BackupConfigAddon from "./BackupConfig/BackupConfigAddon.vue"; import BackupConfigAddon from "./BackupConfig/BackupConfigAddon.vue";
import BackupConfigAutoBackup from "./BackupConfig/BackupConfigAutoBackup.vue"; import BackupConfigAutoBackup from "./BackupConfig/BackupConfigAutoBackup.vue";
import BackupConfigFolder from "./BackupConfig/BackupConfigFolder.vue"; import BackupConfigFolder from "./BackupConfig/BackupConfigFolder.vue";
import BackupConfigAutoClean from "./BackupConfig/BackupConfigAutoClean.vue";
const backupConfigStore = useBackupConfigStore(); const backupConfigStore = useBackupConfigStore();
const { data } = storeToRefs(backupConfigStore); const { data } = storeToRefs(backupConfigStore);

View File

@ -21,7 +21,17 @@ export function getBackupConfig() {
export function saveBackupConfig(config: BackupConfig) { export function saveBackupConfig(config: BackupConfig) {
return kyClient return kyClient
.put("config/backup", { .put("config/backup", {
json: config, json: cleanupConfig(config),
}) })
.json(); .json();
} }
function cleanupConfig(config: BackupConfig) {
if (!config.autoClean.homeAssistant.enabled) {
config.autoClean.homeAssistant.nbrToKeep = undefined;
}
if (!config.autoClean.webdav.enabled) {
config.autoClean.webdav.nbrToKeep = undefined;
}
return config;
}