Added settings to backend and frontend.
This commit is contained in:
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user