martabal 1 ano atrás
pai
commit
77fb3e9ce2

+ 3 - 7
web/src/routes/admin/system-settings/+page.server.ts

@@ -1,7 +1,6 @@
 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, locals }) => {
   const { user } = await parent();
@@ -12,12 +11,9 @@ export const load: PageServerLoad = async ({ parent, locals }) => {
     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);
-
+  const { data: config } = await locals.api.systemConfigApi.getConfig();
+  const { data: defaultConfig } = await locals.api.systemConfigApi.getDefaults();
+  const { data: templateOptions } = await locals.api.systemConfigApi.getStorageTemplateOptions();
   return {
     user,
     config,

+ 4 - 3
web/src/routes/admin/system-settings/+page.svelte

@@ -13,11 +13,12 @@
     notificationController,
     NotificationType,
   } from '$lib/components/shared-components/notification/notification';
+  import { cloneDeep } from 'lodash-es';
 
   export let data: PageData;
   let config: SystemConfigDto = data.config;
 
-  let currentConfig: SystemConfigDto = JSON.parse(JSON.stringify(config));
+  let currentConfig: SystemConfigDto = cloneDeep(config);
   let defaultConfig: SystemConfigDto = data.defaultConfig;
   let templateOptions: SystemConfigTemplateStorageOptionDto = data.templateOptions;
 
@@ -27,8 +28,8 @@
         systemConfigDto: config,
       });
 
-      config = JSON.parse(JSON.stringify(data));
-      currentConfig = JSON.parse(JSON.stringify(data));
+      config = cloneDeep(data);
+      currentConfig = cloneDeep(data);
       notificationController.show({
         message: `${settingsMessage} settings saved`,
         type: NotificationType.Info,