mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-22 09:12:58 +01:00
🔨 Fix backup type chang
This commit is contained in:
parent
6cb6705c93
commit
ff21d77f78
@ -32,17 +32,21 @@ import { watch } from "vue";
|
|||||||
defineProps<{ loading: boolean }>();
|
defineProps<{ loading: boolean }>();
|
||||||
const backupConfigStore = useBackupConfigStore();
|
const backupConfigStore = useBackupConfigStore();
|
||||||
const { data, addons, invertedAddons } = storeToRefs(backupConfigStore);
|
const { data, addons, invertedAddons } = storeToRefs(backupConfigStore);
|
||||||
watch(invertedAddons, () => {
|
watch(invertedAddons, manageInverted);
|
||||||
|
|
||||||
|
manageInverted();
|
||||||
|
|
||||||
|
function manageInverted() {
|
||||||
if (!data.value.exclude) {
|
if (!data.value.exclude) {
|
||||||
data.value.exclude = { addon: [], folder: [] };
|
backupConfigStore.initExcludes();
|
||||||
}
|
}
|
||||||
data.value.exclude.addon = [];
|
data.value.exclude!.addon = [];
|
||||||
for (const addon of addons.value) {
|
for (const addon of addons.value) {
|
||||||
if (!invertedAddons.value.includes(addon.slug)) {
|
if (!invertedAddons.value.includes(addon.slug)) {
|
||||||
data.value.exclude.addon.push(addon.slug);
|
data.value.exclude!.addon.push(addon.slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
@ -33,14 +33,21 @@ defineProps<{ loading: boolean }>();
|
|||||||
const backupConfigStore = useBackupConfigStore();
|
const backupConfigStore = useBackupConfigStore();
|
||||||
|
|
||||||
const { data, folders, invertedFolders } = storeToRefs(backupConfigStore);
|
const { data, folders, invertedFolders } = storeToRefs(backupConfigStore);
|
||||||
watch(invertedFolders, () => {
|
watch(invertedFolders, manageInverted);
|
||||||
data.value.exclude.folder = [];
|
|
||||||
|
manageInverted();
|
||||||
|
|
||||||
|
function manageInverted() {
|
||||||
|
if (!data.value.exclude) {
|
||||||
|
backupConfigStore.initExcludes();
|
||||||
|
}
|
||||||
|
data.value.exclude!.folder = [];
|
||||||
for (const folder of folders.value) {
|
for (const folder of folders.value) {
|
||||||
if (!invertedFolders.value.includes(folder.slug)) {
|
if (!invertedFolders.value.includes(folder.slug)) {
|
||||||
data.value.exclude.folder.push(folder.slug);
|
data.value.exclude!.folder.push(folder.slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { getBackupConfig } from "@/services/configService";
|
import { getBackupConfig } from "@/services/configService";
|
||||||
import { getAddons, getFolders } from "@/services/homeAssistantService";
|
import { getAddons, getFolders } from "@/services/homeAssistantService";
|
||||||
import { CronMode, type BackupConfig } from "@/types/backupConfig";
|
import { BackupType, CronMode, type BackupConfig } from "@/types/backupConfig";
|
||||||
import type { Folder, AddonModel } from "@/types/homeAssistant";
|
import type { Folder, AddonModel } from "@/types/homeAssistant";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
@ -20,6 +20,7 @@ export const useBackupConfigStore = defineStore("backupConfig", () => {
|
|||||||
const foldersProm = getFolders();
|
const foldersProm = getFolders();
|
||||||
const addonsProm = getAddons();
|
const addonsProm = getAddons();
|
||||||
return Promise.all([conf, foldersProm, addonsProm]).then((value) => {
|
return Promise.all([conf, foldersProm, addonsProm]).then((value) => {
|
||||||
|
if (value[0].backupType == BackupType.Partial && value[0].exclude) {
|
||||||
for (const folder of value[1]) {
|
for (const folder of value[1]) {
|
||||||
if (!value[0].exclude.folder.includes(folder.slug)) {
|
if (!value[0].exclude.folder.includes(folder.slug)) {
|
||||||
invertedFolders.value.push(folder.slug);
|
invertedFolders.value.push(folder.slug);
|
||||||
@ -30,6 +31,8 @@ export const useBackupConfigStore = defineStore("backupConfig", () => {
|
|||||||
invertedAddons.value.push(addon.slug);
|
invertedAddons.value.push(addon.slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.value = value[0];
|
data.value = value[0];
|
||||||
folders.value = value[1];
|
folders.value = value[1];
|
||||||
addons.value = value[2].addons;
|
addons.value = value[2].addons;
|
||||||
@ -43,6 +46,16 @@ export const useBackupConfigStore = defineStore("backupConfig", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initExcludes() {
|
||||||
|
data.value.exclude = { addon: [], folder: [] };
|
||||||
|
addons.value.forEach((value) => {
|
||||||
|
invertedAddons.value.push(value.slug);
|
||||||
|
});
|
||||||
|
folders.value.forEach((value) => {
|
||||||
|
invertedFolders.value.push(value.slug);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function removeCron(id: string) {
|
function removeCron(id: string) {
|
||||||
data.value.cron = data.value.cron.filter((value) => value.id != id);
|
data.value.cron = data.value.cron.filter((value) => value.id != id);
|
||||||
}
|
}
|
||||||
@ -56,5 +69,6 @@ export const useBackupConfigStore = defineStore("backupConfig", () => {
|
|||||||
loadAll,
|
loadAll,
|
||||||
addEmptyCron,
|
addEmptyCron,
|
||||||
removeCron,
|
removeCron,
|
||||||
|
initExcludes,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user