Skip to content

Commit

Permalink
starting frontend ui
Browse files Browse the repository at this point in the history
  • Loading branch information
bpatrik committed Oct 27, 2024
1 parent 2871dc5 commit dd6db01
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/backend/middlewares/admin/ExtensionMWs.ts
Original file line number Diff line number Diff line change
@@ -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
)
);
}
}
}
2 changes: 2 additions & 0 deletions src/backend/model/extension/ExtensionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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> } = {};
Expand Down
23 changes: 23 additions & 0 deletions src/backend/routes/admin/ExtensionRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Express} from 'express';
import {UserRoles} from '../../common/entities/UserDTO';

Check failure on line 2 in src/backend/routes/admin/ExtensionRouter.ts

View workflow job for this annotation

GitHub Actions / test (18.x)

Cannot find module '../../common/entities/UserDTO' or its corresponding type declarations.
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';

Check failure on line 3 in src/backend/routes/admin/ExtensionRouter.ts

View workflow job for this annotation

GitHub Actions / test (18.x)

Cannot find module '../middlewares/user/AuthenticationMWs' or its corresponding type declarations.
import {RenderingMWs} from '../middlewares/RenderingMWs';

Check failure on line 4 in src/backend/routes/admin/ExtensionRouter.ts

View workflow job for this annotation

GitHub Actions / test (18.x)

Cannot find module '../middlewares/RenderingMWs' or its corresponding type declarations.
import {ServerTimingMWs} from '../middlewares/ServerTimingMWs';

Check failure on line 5 in src/backend/routes/admin/ExtensionRouter.ts

View workflow job for this annotation

GitHub Actions / test (18.x)

Cannot find module '../middlewares/ServerTimingMWs' or its corresponding type declarations.
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
);
}

}
4 changes: 3 additions & 1 deletion src/frontend/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -345,7 +346,8 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
SortingMethodIconComponent,
GridSizeIconComponent,
SafeHtmlPipe,
SortingMethodSettingsEntryComponent
SortingMethodSettingsEntryComponent,
ExtensionInstallerComponent
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true},
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>extension-installer works!</p>
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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');
}
}

0 comments on commit dd6db01

Please sign in to comment.