From 1502e8015042072ff6a7ae5be069a4065213c626 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 2 Mar 2024 22:18:31 +0100 Subject: [PATCH] Add basic extension UI #784 --- package-lock.json | 14 +++++++------- package.json | 2 +- src/backend/middlewares/RenderingMWs.ts | 1 - src/backend/middlewares/SharingMWs.ts | 1 - src/backend/middlewares/admin/SettingsMWs.ts | 6 +++--- .../model/extension/ExtensionConfigWrapper.ts | 10 ++-------- src/backend/model/extension/ExtensionManager.ts | 4 ++++ src/backend/model/jobs/jobs/TopPickSendJob.ts | 1 - .../private/subconfigs/ServerExtensionsConfig.ts | 1 + .../search-field-base.gallery.component.ts | 1 - .../settings-entry/settings-entry.component.ts | 1 - 11 files changed, 18 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4770b33..06dc3a97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.7", + "typeconfig": "2.2.11", "typeorm": "0.3.12", "xml2js": "0.6.2" }, @@ -20361,9 +20361,9 @@ } }, "node_modules/typeconfig": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.7.tgz", - "integrity": "sha512-xxMJky/XUsmWss8HM99uPeN+sZYF67AAht3Gajtnbp4k5bxBwplnahU+1N1GUKhmvFuqQoIQbiXsu9WpvznI1g==", + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", + "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", "dependencies": { "minimist": "1.2.8" } @@ -35280,9 +35280,9 @@ } }, "typeconfig": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.7.tgz", - "integrity": "sha512-xxMJky/XUsmWss8HM99uPeN+sZYF67AAht3Gajtnbp4k5bxBwplnahU+1N1GUKhmvFuqQoIQbiXsu9WpvznI1g==", + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.11.tgz", + "integrity": "sha512-Knj+1kbIJ4zOZlUm2TPSWZUoiOW4txrmPyf6oyuBhaDQDlGxpSL5jobF3vVV9mZElK1V3ZQVeTgvGaiDyeT8mQ==", "requires": { "minimist": "1.2.8" } diff --git a/package.json b/package.json index d5b78dfb..65e65868 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "reflect-metadata": "0.1.13", "sharp": "0.31.3", "ts-node-iptc": "1.0.11", - "typeconfig": "2.2.7", + "typeconfig": "2.2.11", "typeorm": "0.3.12", "xml2js": "0.6.2" }, diff --git a/src/backend/middlewares/RenderingMWs.ts b/src/backend/middlewares/RenderingMWs.ts index 2576db38..404c1814 100644 --- a/src/backend/middlewares/RenderingMWs.ts +++ b/src/backend/middlewares/RenderingMWs.ts @@ -119,7 +119,6 @@ export class RenderingMWs { skipTags: {secret: true} as TAGS }) as PrivateConfigClass ); - console.log(message.result.Extensions.extensions); res.json(message); } diff --git a/src/backend/middlewares/SharingMWs.ts b/src/backend/middlewares/SharingMWs.ts index 943a3c1f..e4552561 100644 --- a/src/backend/middlewares/SharingMWs.ts +++ b/src/backend/middlewares/SharingMWs.ts @@ -171,7 +171,6 @@ export class SharingMWs { sharing, forceUpdate ); - console.log(req.resultPipe); return next(); } catch (err) { return next( diff --git a/src/backend/middlewares/admin/SettingsMWs.ts b/src/backend/middlewares/admin/SettingsMWs.ts index 0e7af1ca..7e8d37bc 100644 --- a/src/backend/middlewares/admin/SettingsMWs.ts +++ b/src/backend/middlewares/admin/SettingsMWs.ts @@ -1,12 +1,12 @@ import {NextFunction, Request, Response} from 'express'; import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error'; -import {Logger} from '../../Logger'; import {Config} from '../../../common/config/private/Config'; import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics'; import {ConfigClassBuilder} from 'typeconfig/node'; import {TAGS} from '../../../common/config/public/ClientConfig'; import {ObjectManagers} from '../../model/ObjectManagers'; import {ExtensionConfigWrapper} from '../../model/extension/ExtensionConfigWrapper'; +import {Logger} from '../../Logger'; const LOG_TAG = '[SettingsMWs]'; @@ -21,8 +21,8 @@ export class SettingsMWs { */ public static async updateSettings(req: Request, res: Response, next: NextFunction): Promise { if ((typeof req.body === 'undefined') - || (typeof req.body.settings === 'undefined') - || (typeof req.body.settingsPath !== 'string')) { + || (typeof req.body.settings === 'undefined') + || (typeof req.body.settingsPath !== 'string')) { return next(new ErrorDTO(ErrorCodes.INPUT_ERROR, 'settings is needed')); } diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index 2b61ab2c..ae932d18 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -12,12 +12,13 @@ export class ExtensionConfigWrapper { static async original(): Promise { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); try { - await pc.load(); + await pc.load(); // loading the basic configs but we do not know the extension config hierarchy yet if (ObjectManagers.isReady()) { for (const ext of Object.values(ObjectManagers.getInstance().ExtensionManager.extObjects)) { ext.config.loadToConfig(ConfigClassBuilder.attachPrivateInterface(pc)); } } + await pc.load(); // loading the extension related configs } catch (e) { console.error('Error during loading original config. Reverting to defaults.'); console.error(e); @@ -58,13 +59,6 @@ export class ExtensionConfig implements IExtensionConfig { const confTemplate = ConfigClassBuilder.attachPrivateInterface(new this.template()); const extConf = this.findConfig(config); - // confTemplate.__loadJSONObject(Utils.clone(extConf.configs || {})); extConf.configs = confTemplate; - console.log(((config as any).toJSON({attachState: true})).Extensions.extensions); - /* Object.defineProperty(config.Extensions.extensions2[this.extensionFolder].configs, this.extensionFolder, - ConfigProperty({type: this.template})(config.Extensions.extensions2[this.extensionFolder], this.extensionFolder)); - console.log(config.Extensions.extensions2[this.extensionFolder].configs); - config.Extensions.extensions2[this.extensionFolder].configs = confTemplate as any; - console.log(config.Extensions.extensions2[this.extensionFolder].configs);*/ } } diff --git a/src/backend/model/extension/ExtensionManager.ts b/src/backend/model/extension/ExtensionManager.ts index 795a6b09..f5256861 100644 --- a/src/backend/model/extension/ExtensionManager.ts +++ b/src/backend/model/extension/ExtensionManager.ts @@ -109,6 +109,10 @@ export class ExtensionManager implements IObjectManager { for (let i = 0; i < Config.Extensions.extensions.length; ++i) { const extFolder = Config.Extensions.extensions[i].path; let extName = extFolder; + + if(Config.Extensions.extensions[i].enabled === false){ + Logger.silly(LOG_TAG, `Skipping ${extFolder} initiation. Extension is disabled.`); + } const extPath = path.join(ProjectPath.ExtensionFolder, extFolder); const serverExtPath = path.join(extPath, 'server.js'); const packageJsonPath = path.join(extPath, 'package.json'); diff --git a/src/backend/model/jobs/jobs/TopPickSendJob.ts b/src/backend/model/jobs/jobs/TopPickSendJob.ts index 2ba0450c..c748e19f 100644 --- a/src/backend/model/jobs/jobs/TopPickSendJob.ts +++ b/src/backend/model/jobs/jobs/TopPickSendJob.ts @@ -100,7 +100,6 @@ export class TopPickSendJob extends Job<{ arr.findIndex(m => MediaDTOUtils.equals(m, value)) === index); this.Progress.Processed++; - // console.log(this.mediaList); return false; } diff --git a/src/common/config/private/subconfigs/ServerExtensionsConfig.ts b/src/common/config/private/subconfigs/ServerExtensionsConfig.ts index 4d62097e..0efcbf03 100644 --- a/src/common/config/private/subconfigs/ServerExtensionsConfig.ts +++ b/src/common/config/private/subconfigs/ServerExtensionsConfig.ts @@ -19,6 +19,7 @@ export class ServerExtensionsEntryConfig { enabled: boolean = true; @ConfigProperty({ + readonly: true, tags: { name: $localize`Extension folder`, priority: ConfigPriority.underTheHood, diff --git a/src/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.ts b/src/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.ts index e304504d..ba8b4e9c 100644 --- a/src/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.ts +++ b/src/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.ts @@ -167,7 +167,6 @@ export class GallerySearchFieldBaseComponent 0, this.rawSearchText.length - token.current.length ) + item.queryHint; - console.log('aa'); this.onChange(); this.emptyAutoComplete(); } 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 4857ba25..548e898e 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 @@ -467,7 +467,6 @@ export class SettingsEntryComponent const reader = new FileReader(); reader.onload = () => { - console.log(reader.result); const parser = new DOMParser(); const doc = parser.parseFromString(reader.result as string, 'image/svg+xml'); try {