Added settings to backend and frontend.

This commit is contained in:
2026-02-02 03:41:56 +01:00
parent 2fb74839e4
commit c34b2391eb
10 changed files with 429 additions and 0 deletions
+34
View File
@@ -6,6 +6,7 @@ import {Origin} from "~/types/origin";
import type {Variant} from "~/types/variant";
import {Unit} from "~/types/unit";
import type {Label} from "~/types/label";
import type {Settings} from "~/types/settings";
interface State {
config: RuntimeConfig,
@@ -24,6 +25,8 @@ interface State {
labels: Array<Label>,
settings: Settings | null,
origins: Array<Origin>,
units: Array<Unit>,
}
@@ -46,6 +49,8 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
labels: [],
settings: null,
origins: [
Origin.EU,
Origin.NonEU,
@@ -122,6 +127,35 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
this.addNotification(false, "Benachrichtigungen gelöscht")
},
// Settings
async loadSettings() {
try {
this.settings = await $fetch<Settings>(this.config.public.url + '/settings', {
method: 'GET',
});
this.addNotification(false, 'Einstellungen geladen');
} catch {
this.addNotification(true, 'Fehler beim laden der Einstellungen');
}
},
async updateSettings(settings: Settings) {
try {
this.settings = await $fetch<Settings>(this.config.public.url + '/settings', {
method: 'POST',
body: JSON.stringify(settings),
});
this.addNotification(false, 'Einstellungen aktualisiert.');
} catch {
this.addNotification(true, 'Fehler beim aktualisieren der Einstellungen.');
}
},
// Labels:
async loadLabels() {
try {
const labels: Array<Label> = await $fetch<Array<Label>>(this.config.public.url + '/label', {