Files
endurain/frontend/app/src/stores/serverSettingsStore.js
João Vitória Silva 8bc19eaf4c Add server_images logic, env vars & login photo support
[backend] added login_photo_set column to server_settings
[backend] added ENVIRONMENT env variable
[backend] added server_images
[backend] added protections to server_images and user_images logic
[backend] fixed issue on gpx laps processing with no variables initialized
[backend] CORS now in production only accept requests from ENDURAIN_HOST variable
[docs] updated docs with new env variable and new volume
[frontend] added support to new column on server settings store
2025-04-21 12:46:24 +01:00

32 lines
1.1 KiB
JavaScript

import { defineStore } from 'pinia';
import { serverSettings } from '@/services/serverSettingsService';
export const useServerSettingsStore = defineStore('serverSettings', {
state: () => ({
serverSettings: {
id: 1,
units: 1,
public_shareable_links: false,
public_shareable_links_user_info: false,
login_photo_set: false,
},
}),
actions: {
setServerSettings(serverSettings) {
this.serverSettings = serverSettings;
localStorage.setItem('serverSettings', JSON.stringify(this.serverSettings));
},
loadServerSettingsFromStorage() {
const storedServerSettings = localStorage.getItem('serverSettings');
if (storedServerSettings) {
this.serverSettings = JSON.parse(storedServerSettings);
} else {
this.loadServerSettingsFromServer();
}
},
async loadServerSettingsFromServer() {
const settings = await serverSettings.getPublicServerSettings();
this.setServerSettings(settings);
}
},
});