diff --git a/src/backend/middlewares/GalleryMWs.ts b/src/backend/middlewares/GalleryMWs.ts index 31319513..90a8de1d 100644 --- a/src/backend/middlewares/GalleryMWs.ts +++ b/src/backend/middlewares/GalleryMWs.ts @@ -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); diff --git a/src/backend/middlewares/customtypings/ExtendedRequest.d.ts b/src/backend/middlewares/customtypings/ExtendedRequest.d.ts index dfa2905b..d297ae5a 100644 --- a/src/backend/middlewares/customtypings/ExtendedRequest.d.ts +++ b/src/backend/middlewares/customtypings/ExtendedRequest.d.ts @@ -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; } interface Session { diff --git a/src/backend/middlewares/user/UserMWs.ts b/src/backend/middlewares/user/UserMWs.ts index 92ad3186..774fbed2 100644 --- a/src/backend/middlewares/user/UserMWs.ts +++ b/src/backend/middlewares/user/UserMWs.ts @@ -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 { - 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, diff --git a/src/backend/model/database/memory/UserManager.ts b/src/backend/model/database/memory/UserManager.ts index 3c32f7fe..49a8fd22 100644 --- a/src/backend/model/database/memory/UserManager.ts +++ b/src/backend/model/database/memory/UserManager.ts @@ -86,10 +86,6 @@ export class UserManager implements IUserManager { } } - public async changePassword(request: any): Promise { - throw new Error('not implemented'); // TODO: implement - } - private loadDB(): void { const data = fs.readFileSync(this.dbPath, 'utf8'); this.db = JSON.parse(data); diff --git a/src/backend/routes/UserRouter.ts b/src/backend/routes/UserRouter.ts index c8afdeb9..a7e5f8f7 100644 --- a/src/backend/routes/UserRouter.ts +++ b/src/backend/routes/UserRouter.ts @@ -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', diff --git a/src/common/Utils.ts b/src/common/Utils.ts index 8aad4438..26876faa 100644 --- a/src/common/Utils.ts +++ b/src/common/Utils.ts @@ -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); diff --git a/src/frontend/app/ui/gallery/thumbnailLoader.service.ts b/src/frontend/app/ui/gallery/thumbnailLoader.service.ts index 36156976..23994e9c 100644 --- a/src/frontend/app/ui/gallery/thumbnailLoader.service.ts +++ b/src/frontend/app/ui/gallery/thumbnailLoader.service.ts @@ -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 = []; 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 { diff --git a/src/frontend/app/ui/settings/scheduled-jobs.service.ts b/src/frontend/app/ui/settings/scheduled-jobs.service.ts index 81a616f0..9752fd40 100644 --- a/src/frontend/app/ui/settings/scheduled-jobs.service.ts +++ b/src/frontend/app/ui/settings/scheduled-jobs.service.ts @@ -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>; public onJobFinish: EventEmitter = new EventEmitter(); 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) ); } }