diff --git a/src/backend/middlewares/admin/SettingsMWs.ts b/src/backend/middlewares/admin/SettingsMWs.ts index fbb0c181..ea443da7 100644 --- a/src/backend/middlewares/admin/SettingsMWs.ts +++ b/src/backend/middlewares/admin/SettingsMWs.ts @@ -5,12 +5,11 @@ import {ObjectManagers} from '../../model/ObjectManagers'; import {Logger} from '../../Logger'; import {Config} from '../../../common/config/private/Config'; import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics'; -import {BasicConfigDTO} from '../../../common/entities/settings/BasicConfigDTO'; +import {BasicConfigDTO, BasicConfigDTOUtil} from '../../../common/entities/settings/BasicConfigDTO'; import {OtherConfigDTO} from '../../../common/entities/settings/OtherConfigDTO'; import {ProjectPath} from '../../ProjectPath'; import { DatabaseType, - IPrivateConfig, ServerDataBaseConfig, ServerIndexingConfig, ServerJobConfig, @@ -388,19 +387,11 @@ export class SettingsMWs { try { const settings: BasicConfigDTO = req.body.settings; await ConfigDiagnostics.testImageFolder(settings.imagesFolder); - const map = (config: IPrivateConfig, input: BasicConfigDTO) => { - config.Server.port = input.port; - config.Server.host = input.host; - config.Server.Media.folder = input.imagesFolder; - config.Server.Media.tempFolder = input.tempFolder; - config.Client.publicUrl = input.publicUrl; - config.Client.urlBase = input.urlBase; - config.Client.applicationTitle = input.applicationTitle; - }; - map(Config, settings); + + BasicConfigDTOUtil.mapToConf(Config, settings); // only updating explicitly set config (not saving config set by the diagnostics) const original = await Config.original(); - map(original, settings); + BasicConfigDTOUtil.mapToConf(original, settings); original.save(); ProjectPath.reset(); await ConfigDiagnostics.runDiagnostics(); diff --git a/src/common/entities/settings/BasicConfigDTO.ts b/src/common/entities/settings/BasicConfigDTO.ts index 47ed3da8..7d9c31b2 100644 --- a/src/common/entities/settings/BasicConfigDTO.ts +++ b/src/common/entities/settings/BasicConfigDTO.ts @@ -1,3 +1,6 @@ +import {IPrivateConfig} from '../../config/private/PrivateConfig'; + + export interface BasicConfigDTO { imagesFolder: string; tempFolder: string; @@ -7,3 +10,24 @@ export interface BasicConfigDTO { port: number; host: string; } + +export const BasicConfigDTOUtil = { + mapToDTO: (s: IPrivateConfig): BasicConfigDTO => ({ + port: s.Server.port, + host: s.Server.host, + imagesFolder: s.Server.Media.folder, + tempFolder: s.Server.Media.tempFolder, + applicationTitle: s.Client.applicationTitle, + publicUrl: s.Client.publicUrl, + urlBase: s.Client.urlBase + }), + mapToConf: (config: IPrivateConfig, input: BasicConfigDTO) => { + config.Server.port = input.port; + config.Server.host = input.host; + config.Server.Media.folder = input.imagesFolder; + config.Server.Media.tempFolder = input.tempFolder; + config.Client.publicUrl = input.publicUrl; + config.Client.urlBase = input.urlBase; + config.Client.applicationTitle = input.applicationTitle; + } +}; diff --git a/src/frontend/app/ui/settings/basic/basic.settings.component.ts b/src/frontend/app/ui/settings/basic/basic.settings.component.ts index b8ab2963..9ad36f69 100644 --- a/src/frontend/app/ui/settings/basic/basic.settings.component.ts +++ b/src/frontend/app/ui/settings/basic/basic.settings.component.ts @@ -4,7 +4,7 @@ import {AuthenticationService} from '../../../model/network/authentication.servi import {NavigationService} from '../../../model/navigation.service'; import {NotificationService} from '../../../model/notification.service'; import {BasicSettingsService} from './basic.settings.service'; -import {BasicConfigDTO} from '../../../../../common/entities/settings/BasicConfigDTO'; +import {BasicConfigDTO, BasicConfigDTOUtil} from '../../../../../common/entities/settings/BasicConfigDTO'; @Component({ selector: 'app-settings-basic', @@ -23,15 +23,8 @@ export class BasicSettingsComponent extends SettingsComponentDirective ({ - port: s.Server.port, - host: s.Server.host, - imagesFolder: s.Server.Media.folder, - tempFolder: s.Server.Media.tempFolder, - applicationTitle: s.Client.applicationTitle, - publicUrl: s.Client.publicUrl, - urlBase: s.Client.urlBase - })); + super($localize`Basic`, authService, navigation, settingsService, notification, + BasicConfigDTOUtil.mapToDTO); this.checkUrlError(); } @@ -71,7 +64,7 @@ export class BasicSettingsComponent extends SettingsComponentDirective