1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Add basic extension UI #784

This commit is contained in:
Patrik J. Braun 2024-03-02 22:18:31 +01:00
parent 9172f89e78
commit 1502e80150
11 changed files with 18 additions and 24 deletions

14
package-lock.json generated
View File

@ -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"
}

View File

@ -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"
},

View File

@ -119,7 +119,6 @@ export class RenderingMWs {
skipTags: {secret: true} as TAGS
}) as PrivateConfigClass
);
console.log(message.result.Extensions.extensions);
res.json(message);
}

View File

@ -171,7 +171,6 @@ export class SharingMWs {
sharing,
forceUpdate
);
console.log(req.resultPipe);
return next();
} catch (err) {
return next(

View File

@ -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<void> {
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'));
}

View File

@ -12,12 +12,13 @@ export class ExtensionConfigWrapper {
static async original(): Promise<PrivateConfigClass & IConfigClass> {
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<C> implements IExtensionConfig<C> {
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);*/
}
}

View File

@ -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');

View File

@ -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;
}

View File

@ -19,6 +19,7 @@ export class ServerExtensionsEntryConfig {
enabled: boolean = true;
@ConfigProperty({
readonly: true,
tags: {
name: $localize`Extension folder`,
priority: ConfigPriority.underTheHood,

View File

@ -167,7 +167,6 @@ export class GallerySearchFieldBaseComponent
0,
this.rawSearchText.length - token.current.length
) + item.queryHint;
console.log('aa');
this.onChange();
this.emptyAutoComplete();
}

View File

@ -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 {