From a902cdcdfca124989ac7644d16375d4810524d0c Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Wed, 4 Jan 2023 23:07:50 +0100 Subject: [PATCH] Improving config cloning performance #569 --- package-lock.json | 14 +++++++------- package.json | 2 +- src/common/config/private/PrivateConfig.ts | 9 +++++++-- src/common/config/private/WebConfig.ts | 9 --------- src/common/config/public/ClientConfig.ts | 3 +-- src/frontend/app/ui/admin/admin.component.ts | 1 - .../settings-entry.component.ts | 3 ++- .../settings/template/template.component.ts | 19 +++++++++++-------- 8 files changed, 29 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 31a86740..561d8a3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "sharp": "0.31.2", "ts-exif-parser": "0.2.2", "ts-node-iptc": "1.0.11", - "typeconfig": "2.0.29", + "typeconfig": "2.0.32", "typeorm": "0.3.10", "xml2js": "0.4.23" }, @@ -20825,9 +20825,9 @@ } }, "node_modules/typeconfig": { - "version": "2.0.29", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.29.tgz", - "integrity": "sha512-0eQ4QkRUTxG1sy6aFuQV/uxpFamFShhdVQFVkMqhLUpNCAcgNS8VJkY4ZxVp09RnDdoR+L/Oj/3f655XyeNcPQ==", + "version": "2.0.32", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.32.tgz", + "integrity": "sha512-hbdt3SG0q9Sv6aqPMdmubY/513YokbiLRpqiAOY1HgaROTTw+3QdqYh4uKBoeKVHFgGgT66zBu1tyUkU8xO1lA==", "dependencies": { "minimist": "1.2.7" } @@ -38126,9 +38126,9 @@ } }, "typeconfig": { - "version": "2.0.29", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.29.tgz", - "integrity": "sha512-0eQ4QkRUTxG1sy6aFuQV/uxpFamFShhdVQFVkMqhLUpNCAcgNS8VJkY4ZxVp09RnDdoR+L/Oj/3f655XyeNcPQ==", + "version": "2.0.32", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.32.tgz", + "integrity": "sha512-hbdt3SG0q9Sv6aqPMdmubY/513YokbiLRpqiAOY1HgaROTTw+3QdqYh4uKBoeKVHFgGgT66zBu1tyUkU8xO1lA==", "requires": { "minimist": "1.2.7" } diff --git a/package.json b/package.json index 5989ce9c..68955c44 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "sharp": "0.31.2", "ts-exif-parser": "0.2.2", "ts-node-iptc": "1.0.11", - "typeconfig": "2.0.29", + "typeconfig": "2.0.32", "xml2js": "0.4.23", "typeorm": "0.3.10" }, diff --git a/src/common/config/private/PrivateConfig.ts b/src/common/config/private/PrivateConfig.ts index e97a960e..32ad6fee 100644 --- a/src/common/config/private/PrivateConfig.ts +++ b/src/common/config/private/PrivateConfig.ts @@ -612,13 +612,18 @@ export class ServerJobConfig { description: $localize`Jobs load this many photos or videos form the DB for processing at once.` }) mediaProcessingBatchSize: number = 1000; - @ConfigProperty({arrayType: JobScheduleConfig}) + @ConfigProperty({ + arrayType: JobScheduleConfig, + tags: { + name: $localize`Scheduled jobs`, + priority: ConfigPriority.advanced} + }) scheduled: JobScheduleConfig[] = [ new JobScheduleConfig( DefaultsJobs[DefaultsJobs.Indexing], DefaultsJobs[DefaultsJobs.Indexing], new NeverJobTriggerConfig(), - {indexChangesOnly: true} // set config explicitly so it is not undefined on the UI + {indexChangesOnly: true} // set config explicitly, so it is not undefined on the UI ), new JobScheduleConfig( DefaultsJobs[DefaultsJobs['Preview Filling']], diff --git a/src/common/config/private/WebConfig.ts b/src/common/config/private/WebConfig.ts index bbd6e481..00bf3548 100644 --- a/src/common/config/private/WebConfig.ts +++ b/src/common/config/private/WebConfig.ts @@ -3,19 +3,10 @@ import 'reflect-metadata'; import {ServerConfig} from './PrivateConfig'; import {WebConfigClass} from 'typeconfig/web'; import {ConfigState} from 'typeconfig/common'; -import {WebConfigClassBuilder} from '../../../../node_modules/typeconfig/src/decorators/builders/WebConfigClassBuilder'; -import {IWebConfigClassPrivate} from '../../../../node_modules/typeconfig/src/decorators/class/IWebConfigClass'; -import {TAGS} from '../public/ClientConfig'; @WebConfigClass({softReadonly: true}) export class WebConfig extends ServerConfig { @ConfigState() State: any; - - clone(): IWebConfigClassPrivate & WebConfig { - const wcg = WebConfigClassBuilder.attachPrivateInterface(new WebConfig()); - wcg.load(WebConfigClassBuilder.attachPrivateInterface(this).toJSON()); - return wcg; - } } diff --git a/src/common/config/public/ClientConfig.ts b/src/common/config/public/ClientConfig.ts index dc723f2b..d77fa68f 100644 --- a/src/common/config/public/ClientConfig.ts +++ b/src/common/config/public/ClientConfig.ts @@ -482,11 +482,10 @@ export class ClientGalleryConfig { }) enableOnScrollThumbnailPrioritising: boolean = true; @ConfigProperty({ - type: NavBarConfig, tags: { name: $localize`Navigation bar`, priority: ConfigPriority.advanced, - } + } as TAGS }) NavBar: NavBarConfig = new NavBarConfig(); @ConfigProperty({ diff --git a/src/frontend/app/ui/admin/admin.component.ts b/src/frontend/app/ui/admin/admin.component.ts index 1f82f951..a2f214a6 100644 --- a/src/frontend/app/ui/admin/admin.component.ts +++ b/src/frontend/app/ui/admin/admin.component.ts @@ -7,7 +7,6 @@ import {NavigationService} from '../../model/navigation.service'; import {PageHelper} from '../../model/page.helper'; import {SettingsService} from '../settings/settings.service'; import {ConfigPriority} from '../../../../common/config/public/ClientConfig'; -import {Utils} from '../../../../common/Utils'; import {WebConfig} from '../../../../common/config/private/WebConfig'; import {ISettingsComponent} from '../settings/template/ISettingsComponent'; import {WebConfigClassBuilder} from '../../../../../node_modules/typeconfig/src/decorators/builders/WebConfigClassBuilder'; diff --git a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts index 22c26a44..7639144c 100644 --- a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts +++ b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts @@ -83,8 +83,9 @@ export class SettingsEntryComponent for (const k of Object.keys(this.state.value[i].__state)) { if (!Utils.equalsFilter( this.state.value[i]?.__state[k]?.value, - this.state.default[i]?.__state[k]?.value, + this.state.default[i] ? this.state.default[i][k] : undefined, ['default', '__propPath', '__created', '__prototype', '__rootConfig'])) { + return true; } } diff --git a/src/frontend/app/ui/settings/template/template.component.ts b/src/frontend/app/ui/settings/template/template.component.ts index 5141e9e5..ef72e5c5 100644 --- a/src/frontend/app/ui/settings/template/template.component.ts +++ b/src/frontend/app/ui/settings/template/template.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {Component, Input, OnChanges, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {AuthenticationService} from '../../../model/network/authentication.service'; import {NavigationService} from '../../../model/navigation.service'; import {NotificationService} from '../../../model/notification.service'; @@ -55,7 +55,7 @@ export interface RecursiveState extends ConfigState { templateUrl: './template.component.html', styleUrls: ['./template.component.css'] }) -export class TemplateComponent implements OnInit, OnDestroy, ISettingsComponent { +export class TemplateComponent implements OnInit, OnChanges, OnDestroy, ISettingsComponent { public icon: string; @Input() ConfigPath: string; @@ -83,6 +83,14 @@ export class TemplateComponent implements OnInit, OnDestroy, ISettingsComponent ) { } + ngOnChanges(): void { + if (!this.ConfigPath) { + this.setSliceFN(c => ({value: c as any, isConfigType: true, type: WebConfig} as any)); + } else { + this.setSliceFN(c => c.__state[this.ConfigPath]); + } + this.name = this.states.tags?.name || this.ConfigPath; + } ngOnInit(): void { @@ -100,12 +108,7 @@ export class TemplateComponent implements OnInit, OnDestroy, ISettingsComponent this.onOptionChange(); }); - if (!this.ConfigPath) { - this.setSliceFN(c => ({value: c as any, isConfigType: true, type: WebConfig} as any)); - } else { - this.setSliceFN(c => c.__state[this.ConfigPath]); - } - this.name = this.states.tags?.name || this.ConfigPath; + }