diff --git a/web/src/routes/admin/system-settings/+page.server.ts b/web/src/routes/admin/system-settings/+page.server.ts index 65a9485de..9616a4a80 100644 --- a/web/src/routes/admin/system-settings/+page.server.ts +++ b/web/src/routes/admin/system-settings/+page.server.ts @@ -1,8 +1,9 @@ import { AppRoute } from '$lib/constants'; import { redirect } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; +import type { SystemConfigDto, SystemConfigTemplateStorageOptionDto } from '@api'; -export const load: PageServerLoad = async ({ parent }) => { +export const load: PageServerLoad = async ({ parent, locals }) => { const { user } = await parent(); if (!user) { @@ -11,8 +12,17 @@ export const load: PageServerLoad = async ({ parent }) => { throw redirect(302, AppRoute.PHOTOS); } + const config: SystemConfigDto = await locals.api.systemConfigApi.getConfig().then((res) => res.data); + const defaultConfig: SystemConfigDto = await locals.api.systemConfigApi.getDefaults().then((res) => res.data); + const templateOptions: SystemConfigTemplateStorageOptionDto = await locals.api.systemConfigApi + .getStorageTemplateOptions() + .then((res) => res.data); + return { user, + config, + defaultConfig, + templateOptions, meta: { title: 'System Settings', }, diff --git a/web/src/routes/admin/system-settings/+page.svelte b/web/src/routes/admin/system-settings/+page.svelte index 6c8d3041d..12fac25f5 100644 --- a/web/src/routes/admin/system-settings/+page.svelte +++ b/web/src/routes/admin/system-settings/+page.svelte @@ -7,93 +7,71 @@ import PasswordLoginSettings from '$lib/components/admin-page/settings/password-login/password-login-settings.svelte'; import SettingAccordion from '$lib/components/admin-page/settings/setting-accordion.svelte'; import StorageTemplateSettings from '$lib/components/admin-page/settings/storage-template/storage-template-settings.svelte'; - import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte'; - import { SystemConfigDto, SystemConfigTemplateStorageOptionDto, api } from '@api'; + import type { SystemConfigDto, SystemConfigTemplateStorageOptionDto } from '@api'; import type { PageData } from './$types'; export let data: PageData; - let config: SystemConfigDto; - let currentConfig: SystemConfigDto; - let defaultConfig: SystemConfigDto; - let templateOptions: SystemConfigTemplateStorageOptionDto; - const getConfig = async () => { - [config, defaultConfig, templateOptions] = await Promise.all([ - api.systemConfigApi.getConfig().then((res) => res.data), - api.systemConfigApi.getDefaults().then((res) => res.data), - api.systemConfigApi.getStorageTemplateOptions().then((res) => res.data), - ]); - - // deep copy - currentConfig = JSON.parse(JSON.stringify(config)); - }; + let config: SystemConfigDto = data.config; + let currentConfig: SystemConfigDto = JSON.parse(JSON.stringify(config)); + let defaultConfig: SystemConfigDto = data.defaultConfig; + let templateOptions: SystemConfigTemplateStorageOptionDto = data.templateOptions; -
- {#await getConfig()} -
- -
- {:then} - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - {/await} -
+ + +