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

fixing building errors

This commit is contained in:
Patrik J. Braun 2022-04-25 18:36:18 +02:00
parent b1c9827729
commit 782cf78b03
8 changed files with 40 additions and 83 deletions

View File

@ -157,7 +157,7 @@ export class GalleryMWs {
return next();
}
const cw: ContentWrapper = req.resultPipe;
const cw = req.resultPipe as ContentWrapper;
if (cw.notModified === true) {
return next();
}
@ -253,7 +253,7 @@ export class GalleryMWs {
if (!req.resultPipe) {
return next();
}
const fullMediaPath: string = req.resultPipe;
const fullMediaPath = req.resultPipe as string;
const convertedVideo =
VideoProcessing.generateConvertedFilePath(fullMediaPath);

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {LoginCredential} from '../../../common/entities/LoginCredential';
import {UserDTO} from '../../../common/entities/UserDTO';
@ -12,7 +13,7 @@ declare global {
}
interface Response {
tpl?: any;
tpl?: Record<string, any>;
}
interface Session {

View File

@ -1,38 +1,10 @@
import { NextFunction, Request, Response } from 'express';
import { ErrorCodes, ErrorDTO } from '../../../common/entities/Error';
import { ObjectManagers } from '../../model/ObjectManagers';
import { Utils } from '../../../common/Utils';
import { Config } from '../../../common/config/private/Config';
import {NextFunction, Request, Response} from 'express';
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
import {ObjectManagers} from '../../model/ObjectManagers';
import {Utils} from '../../../common/Utils';
import {Config} from '../../../common/config/private/Config';
export class UserMWs {
public static async changePassword(
req: Request,
res: Response,
next: NextFunction
): Promise<void> {
if (Config.Client.authenticationRequired === false) {
return next(new ErrorDTO(ErrorCodes.USER_MANAGEMENT_DISABLED));
}
if (
typeof req.body === 'undefined' ||
typeof req.body.userModReq === 'undefined' ||
typeof req.body.userModReq.id === 'undefined' ||
typeof req.body.userModReq.oldPassword === 'undefined' ||
typeof req.body.userModReq.newPassword === 'undefined'
) {
return next();
}
try {
await ObjectManagers.getInstance().UserManager.changePassword(
req.body.userModReq
);
return next();
} catch (err) {
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, null, err));
}
}
public static async createUser(
req: Request,
res: Response,

View File

@ -86,10 +86,6 @@ export class UserManager implements IUserManager {
}
}
public async changePassword(request: any): Promise<void> {
throw new Error('not implemented'); // TODO: implement
}
private loadDB(): void {
const data = fs.readFileSync(this.dbPath, 'utf8');
this.db = JSON.parse(data);

View File

@ -11,7 +11,6 @@ export class UserRouter {
this.addLogin(app);
this.addLogout(app);
this.addGetSessionUser(app);
this.addChangePassword(app);
this.addCreateUser(app);
this.addDeleteUser(app);
@ -47,17 +46,6 @@ export class UserRouter {
);
}
private static addChangePassword(app: Express): void {
app.post(
'/api/user/:id/password',
AuthenticationMWs.authenticate,
UserRequestConstrainsMWs.forceSelfRequest,
UserMWs.changePassword,
ServerTimingMWs.addServerTiming,
RenderingMWs.renderOK
);
}
private static addCreateUser(app: Express): void {
app.put(
'/api/user',

View File

@ -174,7 +174,8 @@ export class Utils {
public static enumToArray(EnumType: any): { key: number; value: string }[] {
const arr: Array<{ key: number; value: string }> = [];
for (const enumMember in EnumType) {
if (!EnumType.hasOwn(enumMember)) {
// eslint-disable-next-line no-prototype-builtins
if (!EnumType.hasOwnProperty(enumMember)) {
continue;
}
const key = parseInt(enumMember, 10);

View File

@ -1,10 +1,10 @@
import { Injectable } from '@angular/core';
import { GalleryCacheService } from './cache.gallery.service';
import { Media } from './Media';
import { MediaIcon } from './MediaIcon';
import { Config } from '../../../../common/config/public/Config';
import { PersonDTO } from '../../../../common/entities/PersonDTO';
import { Person } from '../faces/Person';
import {Injectable} from '@angular/core';
import {GalleryCacheService} from './cache.gallery.service';
import {Media} from './Media';
import {MediaIcon} from './MediaIcon';
import {Config} from '../../../../common/config/public/Config';
import {PersonDTO} from '../../../../common/entities/PersonDTO';
import {Person} from '../faces/Person';
export enum ThumbnailLoadingPriority {
extraHigh = 4,
@ -18,13 +18,14 @@ export class ThumbnailLoaderService {
que: Array<ThumbnailTask> = [];
runningRequests = 0;
constructor(private galleryCacheService: GalleryCacheService) {}
constructor(private galleryCacheService: GalleryCacheService) {
}
run = (): void => {
if (
this.que.length === 0 ||
this.runningRequests >=
Config.Client.Media.Thumbnail.concurrentThumbnailGenerations
Config.Client.Media.Thumbnail.concurrentThumbnailGenerations
) {
return;
}
@ -153,7 +154,7 @@ export class ThumbnailLoaderService {
this.que.push(thTask);
}
const thumbnailTaskEntity = { priority, listener, parentTask: thTask };
const thumbnailTaskEntity = {priority, listener, parentTask: thTask};
thTask.taskEntities.push(thumbnailTaskEntity);
if (thTask.inProgress === true) {
listener.onStartedLoading();
@ -191,7 +192,7 @@ export class ThumbnailLoaderService {
const i = this.que.indexOf(task);
if (i === -1) {
if (task.taskEntities.length !== 0) {
console.error("ThumbnailLoader: can't find poolTask to remove");
console.error('ThumbnailLoader: can\'t find poolTask to remove');
}
return;
}
@ -202,7 +203,7 @@ export class ThumbnailLoaderService {
export interface ThumbnailLoadingListener {
onStartedLoading: () => void;
onLoad: () => void;
onError: (error: Error) => void;
onError: (error: Event | string) => void;
}
export interface ThumbnailTaskEntity {

View File

@ -1,18 +1,15 @@
import { EventEmitter, Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import {
JobProgressDTO,
JobProgressStates,
} from '../../../../common/entities/job/JobProgressDTO';
import { NetworkService } from '../../model/network/network.service';
import { JobScheduleDTO } from '../../../../common/entities/job/JobScheduleDTO';
import { JobDTOUtils } from '../../../../common/entities/job/JobDTO';
import { BackendtextService } from '../../model/backendtext.service';
import { NotificationService } from '../../model/notification.service';
import {EventEmitter, Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {JobProgressDTO, JobProgressStates,} from '../../../../common/entities/job/JobProgressDTO';
import {NetworkService} from '../../model/network/network.service';
import {JobScheduleDTO} from '../../../../common/entities/job/JobScheduleDTO';
import {JobDTOUtils} from '../../../../common/entities/job/JobDTO';
import {BackendtextService} from '../../model/backendtext.service';
import {NotificationService} from '../../model/notification.service';
@Injectable()
export class ScheduledJobsService {
public progress: BehaviorSubject<{ [key: string]: JobProgressDTO }>;
public progress: BehaviorSubject<Record<string, JobProgressDTO>>;
public onJobFinish: EventEmitter<string> = new EventEmitter<string>();
timer: number = null;
public jobStartingStopping: { [key: string]: boolean } = {};
@ -29,7 +26,7 @@ export class ScheduledJobsService {
getProgress(schedule: JobScheduleDTO): JobProgressDTO {
return this.progress.value[
JobDTOUtils.getHashName(schedule.jobName, schedule.config)
];
];
}
subscribeToProgress(): void {
@ -62,7 +59,7 @@ export class ScheduledJobsService {
);
// placeholder to force showing running job
this.addDummyProgress(jobName, config);
} finally {
} finally {
delete this.jobStartingStopping[jobName];
this.forceUpdate();
}
@ -86,10 +83,11 @@ export class ScheduledJobsService {
);
for (const prg of Object.keys(prevPrg)) {
if (
!this.progress.value.hasOwn(prg) ||
// eslint-disable-next-line no-prototype-builtins
!(this.progress.value).hasOwnProperty(prg) ||
// state changed from running to finished
((prevPrg[prg].state === JobProgressStates.running ||
prevPrg[prg].state === JobProgressStates.cancelling) &&
prevPrg[prg].state === JobProgressStates.cancelling) &&
!(
this.progress.value[prg].state === JobProgressStates.running ||
this.progress.value[prg].state === JobProgressStates.cancelling
@ -98,8 +96,8 @@ export class ScheduledJobsService {
this.onJobFinish.emit(prg);
this.notification.success(
$localize`Job finished` +
': ' +
this.backendTextService.getJobName(prevPrg[prg].jobName)
': ' +
this.backendTextService.getJobName(prevPrg[prg].jobName)
);
}
}