mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
parent
22954550bf
commit
7d70c71109
@ -5,12 +5,11 @@ import {ObjectManagers} from '../../model/ObjectManagers';
|
|||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics';
|
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 {OtherConfigDTO} from '../../../common/entities/settings/OtherConfigDTO';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {
|
import {
|
||||||
DatabaseType,
|
DatabaseType,
|
||||||
IPrivateConfig,
|
|
||||||
ServerDataBaseConfig,
|
ServerDataBaseConfig,
|
||||||
ServerIndexingConfig,
|
ServerIndexingConfig,
|
||||||
ServerJobConfig,
|
ServerJobConfig,
|
||||||
@ -388,19 +387,11 @@ export class SettingsMWs {
|
|||||||
try {
|
try {
|
||||||
const settings: BasicConfigDTO = req.body.settings;
|
const settings: BasicConfigDTO = req.body.settings;
|
||||||
await ConfigDiagnostics.testImageFolder(settings.imagesFolder);
|
await ConfigDiagnostics.testImageFolder(settings.imagesFolder);
|
||||||
const map = (config: IPrivateConfig, input: BasicConfigDTO) => {
|
|
||||||
config.Server.port = input.port;
|
BasicConfigDTOUtil.mapToConf(Config, settings);
|
||||||
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);
|
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
const original = await Config.original();
|
const original = await Config.original();
|
||||||
map(original, settings);
|
BasicConfigDTOUtil.mapToConf(original, settings);
|
||||||
original.save();
|
original.save();
|
||||||
ProjectPath.reset();
|
ProjectPath.reset();
|
||||||
await ConfigDiagnostics.runDiagnostics();
|
await ConfigDiagnostics.runDiagnostics();
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import {IPrivateConfig} from '../../config/private/PrivateConfig';
|
||||||
|
|
||||||
|
|
||||||
export interface BasicConfigDTO {
|
export interface BasicConfigDTO {
|
||||||
imagesFolder: string;
|
imagesFolder: string;
|
||||||
tempFolder: string;
|
tempFolder: string;
|
||||||
@ -7,3 +10,24 @@ export interface BasicConfigDTO {
|
|||||||
port: number;
|
port: number;
|
||||||
host: string;
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -4,7 +4,7 @@ import {AuthenticationService} from '../../../model/network/authentication.servi
|
|||||||
import {NavigationService} from '../../../model/navigation.service';
|
import {NavigationService} from '../../../model/navigation.service';
|
||||||
import {NotificationService} from '../../../model/notification.service';
|
import {NotificationService} from '../../../model/notification.service';
|
||||||
import {BasicSettingsService} from './basic.settings.service';
|
import {BasicSettingsService} from './basic.settings.service';
|
||||||
import {BasicConfigDTO} from '../../../../../common/entities/settings/BasicConfigDTO';
|
import {BasicConfigDTO, BasicConfigDTOUtil} from '../../../../../common/entities/settings/BasicConfigDTO';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings-basic',
|
selector: 'app-settings-basic',
|
||||||
@ -23,15 +23,8 @@ export class BasicSettingsComponent extends SettingsComponentDirective<BasicConf
|
|||||||
navigation: NavigationService,
|
navigation: NavigationService,
|
||||||
settingsService: BasicSettingsService,
|
settingsService: BasicSettingsService,
|
||||||
notification: NotificationService) {
|
notification: NotificationService) {
|
||||||
super($localize`Basic`, authService, navigation, settingsService, notification, s => ({
|
super($localize`Basic`, authService, navigation, settingsService, notification,
|
||||||
port: s.Server.port,
|
BasicConfigDTOUtil.mapToDTO);
|
||||||
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
|
|
||||||
}));
|
|
||||||
this.checkUrlError();
|
this.checkUrlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +64,7 @@ export class BasicSettingsComponent extends SettingsComponentDirective<BasicConf
|
|||||||
this.urlBaseChanged = true;
|
this.urlBaseChanged = true;
|
||||||
|
|
||||||
this.checkUrlError();
|
this.checkUrlError();
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user