1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-21 01:22:08 +02:00

starting frontend ui

This commit is contained in:
Patrik J. Braun 2024-10-27 23:25:29 +01:00
parent 2871dc586a
commit dd6db01c1a
8 changed files with 93 additions and 1 deletions

View File

@ -0,0 +1,36 @@
import {NextFunction, Request, Response} from 'express';
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
import {ObjectManagers} from '../../model/ObjectManagers';
import {StatisticDTO} from '../../../common/entities/settings/StatisticDTO';
import {MessengerRepository} from '../../model/messenger/MessengerRepository';
import {JobStartDTO} from '../../../common/entities/job/JobDTO';
export class ExtensionMWs {
public static getExtensionList(
req: Request,
res: Response,
next: NextFunction
): void {
try {
req.resultPipe = ObjectManagers.getInstance().ExtensionManager.repository.fetchList();
return next();
} catch (err) {
if (err instanceof Error) {
return next(
new ErrorDTO(
ErrorCodes.JOB_ERROR,
'Job error: ' + err.toString(),
err
)
);
}
return next(
new ErrorDTO(
ErrorCodes.JOB_ERROR,
'Job error: ' + JSON.stringify(err, null, ' '),
err
)
);
}
}
}

View File

@ -13,6 +13,7 @@ import {ExtensionObject} from './ExtensionObject';
import {ExtensionDecoratorObject} from './ExtensionDecorator';
import * as util from 'util';
import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig';
import {ExtensionRepository} from './ExtensionRepository';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const exec = util.promisify(require('child_process').exec);
@ -21,6 +22,7 @@ const LOG_TAG = '[ExtensionManager]';
export class ExtensionManager implements IObjectManager {
public static EXTENSION_API_PATH = Config.Server.apiPath + '/extension';
public repository: ExtensionRepository = new ExtensionRepository();
events: IExtensionEvents;
extObjects: { [key: string]: ExtensionObject<unknown> } = {};

View File

@ -0,0 +1,23 @@
import {Express} from 'express';
import {UserRoles} from '../../common/entities/UserDTO';
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
import {RenderingMWs} from '../middlewares/RenderingMWs';
import {ServerTimingMWs} from '../middlewares/ServerTimingMWs';
import {ExtensionManager} from '../../model/extension/ExtensionManager';
export class UserRouter {
public static route(app: Express): void {
this.addExtensionList(app);
}
private static addExtensionList(app: Express): void {
app.post(
ExtensionManager.EXTENSION_API_PATH,
AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.Admin),
ServerTimingMWs.addServerTiming,
RenderingMWs.renderSessionUser
);
}
}

View File

@ -193,6 +193,7 @@ import {StringifyGridSize} from './pipes/StringifyGridSize';
import {GalleryNavigatorService} from './ui/gallery/navigator/navigator.service';
import {GridSizeIconComponent} from './ui/utils/grid-size-icon/grid-size-icon.component';
import {SortingMethodIconComponent} from './ui/utils/sorting-method-icon/sorting-method-icon.component';
import { ExtensionInstallerComponent } from './ui/settings/extension-installer/extension-installer.component';
@Injectable()
export class MyHammerConfig extends HammerGestureConfig {
@ -345,7 +346,8 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
SortingMethodIconComponent,
GridSizeIconComponent,
SafeHtmlPipe,
SortingMethodSettingsEntryComponent
SortingMethodSettingsEntryComponent,
ExtensionInstallerComponent
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true},

View File

@ -0,0 +1 @@
<p>extension-installer works!</p>

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-extension-installer',
templateUrl: './extension-installer.component.html',
styleUrls: ['./extension-installer.component.css']
})
export class ExtensionInstallerComponent {
}

View File

@ -0,0 +1,18 @@
import { Injectable } from '@angular/core';
import {NetworkService} from '../../../model/network/network.service';
import {UserDTO} from '../../../../../common/entities/UserDTO';
@Injectable({
providedIn: 'root'
})
export class ExtensionInstallerService {
constructor(private networkService: NetworkService) {
}
public getExtensions(): Promise<Array<UserDTO>> {
return this.networkService.getJson('/user/list');
}
}