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

View File

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

View File

@ -1,38 +1,10 @@
import { NextFunction, Request, Response } from 'express'; import {NextFunction, Request, Response} from 'express';
import { ErrorCodes, ErrorDTO } from '../../../common/entities/Error'; import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
import { ObjectManagers } from '../../model/ObjectManagers'; import {ObjectManagers} from '../../model/ObjectManagers';
import { Utils } from '../../../common/Utils'; import {Utils} from '../../../common/Utils';
import { Config } from '../../../common/config/private/Config'; import {Config} from '../../../common/config/private/Config';
export class UserMWs { 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( public static async createUser(
req: Request, req: Request,
res: Response, 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 { private loadDB(): void {
const data = fs.readFileSync(this.dbPath, 'utf8'); const data = fs.readFileSync(this.dbPath, 'utf8');
this.db = JSON.parse(data); this.db = JSON.parse(data);

View File

@ -11,7 +11,6 @@ export class UserRouter {
this.addLogin(app); this.addLogin(app);
this.addLogout(app); this.addLogout(app);
this.addGetSessionUser(app); this.addGetSessionUser(app);
this.addChangePassword(app);
this.addCreateUser(app); this.addCreateUser(app);
this.addDeleteUser(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 { private static addCreateUser(app: Express): void {
app.put( app.put(
'/api/user', '/api/user',

View File

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

View File

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

View File

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