mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-02 02:15:46 +01:00
Make all services readonly
This commit is contained in:
@@ -11,13 +11,13 @@ import { EImageBackend } from '../../models/entities/image.entity';
|
|||||||
export class ImageDBService {
|
export class ImageDBService {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(EImageBackend)
|
@InjectRepository(EImageBackend)
|
||||||
private imageRepo: Repository<EImageBackend>,
|
private readonly imageRepo: Repository<EImageBackend>,
|
||||||
|
|
||||||
@InjectRepository(EImageFileBackend)
|
@InjectRepository(EImageFileBackend)
|
||||||
private imageFileRepo: Repository<EImageFileBackend>,
|
private readonly imageFileRepo: Repository<EImageFileBackend>,
|
||||||
|
|
||||||
@InjectRepository(EImageDerivativeBackend)
|
@InjectRepository(EImageDerivativeBackend)
|
||||||
private imageDerivativeRepo: Repository<EImageDerivativeBackend>,
|
private readonly imageDerivativeRepo: Repository<EImageDerivativeBackend>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async create(userid: string): AsyncFailable<EImageBackend> {
|
public async create(userid: string): AsyncFailable<EImageBackend> {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ const A_DAY_IN_SECONDS = 24 * 60 * 60;
|
|||||||
export class ImageFileDBService {
|
export class ImageFileDBService {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(EImageFileBackend)
|
@InjectRepository(EImageFileBackend)
|
||||||
private imageFileRepo: Repository<EImageFileBackend>,
|
private readonly imageFileRepo: Repository<EImageFileBackend>,
|
||||||
|
|
||||||
@InjectRepository(EImageDerivativeBackend)
|
@InjectRepository(EImageDerivativeBackend)
|
||||||
private imageDerivativeRepo: Repository<EImageDerivativeBackend>,
|
private readonly imageDerivativeRepo: Repository<EImageDerivativeBackend>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async setFile(
|
public async setFile(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { EarlyJwtConfigService } from '../../config/early/early-jwt.config.servi
|
|||||||
export class PreferenceDefaultsService {
|
export class PreferenceDefaultsService {
|
||||||
private readonly logger = new Logger('PreferenceDefaultsService');
|
private readonly logger = new Logger('PreferenceDefaultsService');
|
||||||
|
|
||||||
constructor(private jwtConfigService: EarlyJwtConfigService) {}
|
constructor(private readonly jwtConfigService: EarlyJwtConfigService) {}
|
||||||
|
|
||||||
public readonly usrDefaults: {
|
public readonly usrDefaults: {
|
||||||
[key in UsrPreference]: () => PrefValueType;
|
[key in UsrPreference]: () => PrefValueType;
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export class SysPreferenceService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(ESysPreferenceBackend)
|
@InjectRepository(ESysPreferenceBackend)
|
||||||
private sysPreferenceRepository: Repository<ESysPreferenceBackend>,
|
private readonly sysPreferenceRepository: Repository<ESysPreferenceBackend>,
|
||||||
private defaultsService: PreferenceDefaultsService,
|
private readonly defaultsService: PreferenceDefaultsService,
|
||||||
private prefCommon: PreferenceCommonService,
|
private readonly prefCommon: PreferenceCommonService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async setPreference(
|
public async setPreference(
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export class UsrPreferenceService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(EUsrPreferenceBackend)
|
@InjectRepository(EUsrPreferenceBackend)
|
||||||
private usrPreferenceRepository: Repository<EUsrPreferenceBackend>,
|
private readonly usrPreferenceRepository: Repository<EUsrPreferenceBackend>,
|
||||||
private defaultsService: PreferenceDefaultsService,
|
private readonly defaultsService: PreferenceDefaultsService,
|
||||||
private prefCommon: PreferenceCommonService,
|
private readonly prefCommon: PreferenceCommonService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async setPreference(
|
public async setPreference(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { HostConfigService } from '../../config/early/host.config.service';
|
|||||||
import {
|
import {
|
||||||
ImmutableRolesList,
|
ImmutableRolesList,
|
||||||
SystemRoleDefaults,
|
SystemRoleDefaults,
|
||||||
UndeletableRolesList,
|
UndeletableRolesList
|
||||||
} from '../../models/constants/roles.const';
|
} from '../../models/constants/roles.const';
|
||||||
import { ERoleBackend } from '../../models/entities/role.entity';
|
import { ERoleBackend } from '../../models/entities/role.entity';
|
||||||
import { RolesService } from './role-db.service';
|
import { RolesService } from './role-db.service';
|
||||||
@@ -20,8 +20,8 @@ export class RolesModule implements OnModuleInit {
|
|||||||
private readonly logger = new Logger('RolesModule');
|
private readonly logger = new Logger('RolesModule');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private hostConfig: HostConfigService,
|
private readonly hostConfig: HostConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import {
|
|||||||
AsyncFailable,
|
AsyncFailable,
|
||||||
Fail,
|
Fail,
|
||||||
HasFailed,
|
HasFailed,
|
||||||
HasSuccess,
|
HasSuccess
|
||||||
} from 'picsur-shared/dist/types';
|
} from 'picsur-shared/dist/types';
|
||||||
import { makeUnique } from 'picsur-shared/dist/util/unique';
|
import { makeUnique } from 'picsur-shared/dist/util/unique';
|
||||||
import { In, Repository } from 'typeorm';
|
import { In, Repository } from 'typeorm';
|
||||||
import { Permissions } from '../../models/constants/permissions.const';
|
import { Permissions } from '../../models/constants/permissions.const';
|
||||||
import {
|
import {
|
||||||
ImmutableRolesList,
|
ImmutableRolesList,
|
||||||
UndeletableRolesList,
|
UndeletableRolesList
|
||||||
} from '../../models/constants/roles.const';
|
} from '../../models/constants/roles.const';
|
||||||
import { ERoleBackend } from '../../models/entities/role.entity';
|
import { ERoleBackend } from '../../models/entities/role.entity';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export class RolesService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(ERoleBackend)
|
@InjectRepository(ERoleBackend)
|
||||||
private rolesRepository: Repository<ERoleBackend>,
|
private readonly rolesRepository: Repository<ERoleBackend>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async create(
|
public async create(
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ export class UsersModule implements OnModuleInit {
|
|||||||
private readonly logger = new Logger('UsersModule');
|
private readonly logger = new Logger('UsersModule');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private usersService: UsersService,
|
private readonly usersService: UsersService,
|
||||||
private authConfigService: AuthConfigService,
|
private readonly authConfigService: AuthConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ export class UsersService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(EUserBackend)
|
@InjectRepository(EUserBackend)
|
||||||
private usersRepository: Repository<EUserBackend>,
|
private readonly usersRepository: Repository<EUserBackend>,
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private prefService: SysPreferenceService,
|
private readonly prefService: SysPreferenceService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// Creation and deletion
|
// Creation and deletion
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { EnvPrefix } from '../config.static';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthConfigService {
|
export class AuthConfigService {
|
||||||
constructor(private configService: ConfigService) {}
|
constructor(private readonly configService: ConfigService) {}
|
||||||
|
|
||||||
public getDefaultAdminPassword(): string {
|
public getDefaultAdminPassword(): string {
|
||||||
return this.configService.get<string>(
|
return this.configService.get<string>(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { EnvPrefix } from '../config.static';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EarlyJwtConfigService {
|
export class EarlyJwtConfigService {
|
||||||
constructor(private configService: ConfigService) {}
|
constructor(private readonly configService: ConfigService) {}
|
||||||
|
|
||||||
public getJwtSecret(): string | undefined {
|
public getJwtSecret(): string | undefined {
|
||||||
return this.configService.get<string>(`${EnvPrefix}JWT_SECRET`);
|
return this.configService.get<string>(`${EnvPrefix}JWT_SECRET`);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { EnvPrefix } from '../config.static';
|
|||||||
export class HostConfigService {
|
export class HostConfigService {
|
||||||
private readonly logger = new Logger('HostConfigService');
|
private readonly logger = new Logger('HostConfigService');
|
||||||
|
|
||||||
constructor(private configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
this.logger.log('Host: ' + this.getHost());
|
this.logger.log('Host: ' + this.getHost());
|
||||||
this.logger.log('Port: ' + this.getPort());
|
this.logger.log('Port: ' + this.getPort());
|
||||||
this.logger.log('Demo: ' + this.isDemo());
|
this.logger.log('Demo: ' + this.isDemo());
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { EnvPrefix } from '../config.static';
|
|||||||
export class MultipartConfigService {
|
export class MultipartConfigService {
|
||||||
private readonly logger = new Logger('MultipartConfigService');
|
private readonly logger = new Logger('MultipartConfigService');
|
||||||
|
|
||||||
constructor(private configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
this.logger.log('Max file size: ' + this.getMaxFileSize());
|
this.logger.log('Max file size: ' + this.getMaxFileSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
|
|||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import {
|
import {
|
||||||
ServeStaticModuleOptions,
|
ServeStaticModuleOptions,
|
||||||
ServeStaticModuleOptionsFactory,
|
ServeStaticModuleOptionsFactory
|
||||||
} from '@nestjs/serve-static';
|
} from '@nestjs/serve-static';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { EnvPrefix, PackageRoot } from '../config.static';
|
import { EnvPrefix, PackageRoot } from '../config.static';
|
||||||
@@ -15,7 +15,7 @@ export class ServeStaticConfigService
|
|||||||
|
|
||||||
private defaultLocation = join(PackageRoot, '../frontend/dist');
|
private defaultLocation = join(PackageRoot, '../frontend/dist');
|
||||||
|
|
||||||
constructor(private configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
this.logger.log('Static directory: ' + this.getStaticDirectory());
|
this.logger.log('Static directory: ' + this.getStaticDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
|
|||||||
private readonly logger = new Logger('TypeOrmConfigService');
|
private readonly logger = new Logger('TypeOrmConfigService');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private hostService: HostConfigService,
|
private readonly hostService: HostConfigService,
|
||||||
) {
|
) {
|
||||||
const varOptions = this.getTypeOrmServerOptions();
|
const varOptions = this.getTypeOrmServerOptions();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { SysPreferenceService } from '../../collections/preference-db/sys-prefer
|
|||||||
export class JwtConfigService implements JwtOptionsFactory {
|
export class JwtConfigService implements JwtOptionsFactory {
|
||||||
private readonly logger = new Logger('JwtConfigService');
|
private readonly logger = new Logger('JwtConfigService');
|
||||||
|
|
||||||
constructor(private prefService: SysPreferenceService) {
|
constructor(private readonly prefService: SysPreferenceService) {
|
||||||
this.printDebug().catch(this.logger.error);
|
this.printDebug().catch(this.logger.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ export class LateConfigModule implements OnModuleInit {
|
|||||||
private readonly logger = new Logger('LateConfigModule');
|
private readonly logger = new Logger('LateConfigModule');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private envJwtConfigService: EarlyJwtConfigService,
|
private readonly envJwtConfigService: EarlyJwtConfigService,
|
||||||
private prefService: SysPreferenceService,
|
private readonly prefService: SysPreferenceService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Logger,
|
Logger,
|
||||||
PipeTransform,
|
PipeTransform,
|
||||||
Scope,
|
Scope
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { FastifyRequest } from 'fastify';
|
import { FastifyRequest } from 'fastify';
|
||||||
import { HasFailed } from 'picsur-shared/dist/types';
|
import { HasFailed } from 'picsur-shared/dist/types';
|
||||||
@@ -14,14 +14,16 @@ import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto';
|
|||||||
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
||||||
import {
|
import {
|
||||||
CreateMultiPartFieldDto,
|
CreateMultiPartFieldDto,
|
||||||
CreateMultiPartFileDto,
|
CreateMultiPartFileDto
|
||||||
} from '../../models/dto/multipart.dto';
|
} from '../../models/dto/multipart.dto';
|
||||||
|
|
||||||
@Injectable({ scope: Scope.REQUEST })
|
@Injectable({ scope: Scope.REQUEST })
|
||||||
export class MultiPartPipe implements PipeTransform {
|
export class MultiPartPipe implements PipeTransform {
|
||||||
private readonly logger = new Logger('MultiPartPipe');
|
private readonly logger = new Logger('MultiPartPipe');
|
||||||
|
|
||||||
constructor(private multipartConfigService: MultipartConfigService) {}
|
constructor(
|
||||||
|
private readonly multipartConfigService: MultipartConfigService,
|
||||||
|
) {}
|
||||||
|
|
||||||
async transform<T extends Object>(
|
async transform<T extends Object>(
|
||||||
req: FastifyRequest,
|
req: FastifyRequest,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
Injectable,
|
Injectable,
|
||||||
Logger,
|
Logger,
|
||||||
PipeTransform,
|
PipeTransform,
|
||||||
Scope,
|
Scope
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { FastifyRequest } from 'fastify';
|
import { FastifyRequest } from 'fastify';
|
||||||
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
||||||
@@ -13,7 +13,9 @@ import { MultipartConfigService } from '../../config/early/multipart.config.serv
|
|||||||
export class PostFilePipe implements PipeTransform {
|
export class PostFilePipe implements PipeTransform {
|
||||||
private readonly logger = new Logger('PostFilePipe');
|
private readonly logger = new Logger('PostFilePipe');
|
||||||
|
|
||||||
constructor(private multipartConfigService: MultipartConfigService) {}
|
constructor(
|
||||||
|
private readonly multipartConfigService: MultipartConfigService,
|
||||||
|
) {}
|
||||||
|
|
||||||
async transform({ req }: { req: FastifyRequest }) {
|
async transform({ req }: { req: FastifyRequest }) {
|
||||||
if (!req.isMultipart()) throw new BadRequestException('Invalid file');
|
if (!req.isMultipart()) throw new BadRequestException('Invalid file');
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Logger,
|
Logger,
|
||||||
NestInterceptor,
|
NestInterceptor,
|
||||||
Optional,
|
Optional
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Reflector } from '@nestjs/core';
|
import { Reflector } from '@nestjs/core';
|
||||||
import { ApiAnySuccessResponse } from 'picsur-shared/dist/dto/api/api.dto';
|
import { ApiAnySuccessResponse } from 'picsur-shared/dist/dto/api/api.dto';
|
||||||
@@ -26,7 +26,7 @@ export class SuccessInterceptor<T> implements NestInterceptor {
|
|||||||
private strict: boolean;
|
private strict: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private reflector: Reflector,
|
private readonly reflector: Reflector,
|
||||||
@Optional() options?: ZodValidationInterceptorOptions,
|
@Optional() options?: ZodValidationInterceptorOptions,
|
||||||
) {
|
) {
|
||||||
this.strict = options?.strict ?? true;
|
this.strict = options?.strict ?? true;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { AsyncFailable, Fail } from 'picsur-shared/dist/types';
|
|||||||
export class AuthManagerService {
|
export class AuthManagerService {
|
||||||
private readonly logger = new Logger('AuthService');
|
private readonly logger = new Logger('AuthService');
|
||||||
|
|
||||||
constructor(private jwtService: JwtService) {}
|
constructor(private readonly jwtService: JwtService) {}
|
||||||
|
|
||||||
async createToken(user: EUser): AsyncFailable<string> {
|
async createToken(user: EUser): AsyncFailable<string> {
|
||||||
const jwtData = {
|
const jwtData = {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class GuestStrategy extends PassportStrategy(
|
|||||||
GuestPassportStrategy,
|
GuestPassportStrategy,
|
||||||
'guest',
|
'guest',
|
||||||
) {
|
) {
|
||||||
constructor(private guestService: GuestService) {
|
constructor(private readonly guestService: GuestService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { EUserBackend2EUser } from '../../../models/transformers/user.transforme
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LocalAuthStrategy extends PassportStrategy(Strategy, 'local') {
|
export class LocalAuthStrategy extends PassportStrategy(Strategy, 'local') {
|
||||||
constructor(private usersService: UsersService) {
|
constructor(private readonly usersService: UsersService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
ForbiddenException,
|
ForbiddenException,
|
||||||
Injectable,
|
Injectable,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Logger,
|
Logger
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Reflector } from '@nestjs/core';
|
import { Reflector } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
@@ -22,8 +22,8 @@ export class MainAuthGuard extends AuthGuard(['jwt', 'guest']) {
|
|||||||
private readonly logger = new Logger('MainAuthGuard');
|
private readonly logger = new Logger('MainAuthGuard');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private reflector: Reflector,
|
private readonly reflector: Reflector,
|
||||||
private usersService: UsersService,
|
private readonly usersService: UsersService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { EUserBackend } from '../../models/entities/user.entity';
|
|||||||
export class GuestService {
|
export class GuestService {
|
||||||
private fallBackUser: EUserBackend;
|
private fallBackUser: EUserBackend;
|
||||||
|
|
||||||
constructor(private usersService: UsersService) {
|
constructor(private readonly usersService: UsersService) {
|
||||||
this.fallBackUser = new EUserBackend();
|
this.fallBackUser = new EUserBackend();
|
||||||
this.fallBackUser.username = 'guest';
|
this.fallBackUser.username = 'guest';
|
||||||
this.fallBackUser.roles = ['guest'];
|
this.fallBackUser.roles = ['guest'];
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class DemoManagerModule implements OnModuleInit, OnModuleDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly demoManagerService: DemoManagerService,
|
private readonly demoManagerService: DemoManagerService,
|
||||||
private hostConfigService: HostConfigService,
|
private readonly hostConfigService: HostConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export class DemoManagerService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly imagesService: ImageDBService,
|
private readonly imagesService: ImageDBService,
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async setupRoles() {
|
public async setupRoles() {
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export class ImageManagerModule implements OnModuleInit, OnModuleDestroy {
|
|||||||
private interval: NodeJS.Timeout;
|
private interval: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private prefManager: SysPreferenceService,
|
private readonly prefManager: SysPreferenceService,
|
||||||
private imageFileDB: ImageFileDBService,
|
private readonly imageFileDB: ImageFileDBService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { Controller, Get } from '@nestjs/common';
|
|||||||
import {
|
import {
|
||||||
AllFormatsResponse,
|
AllFormatsResponse,
|
||||||
AllPermissionsResponse,
|
AllPermissionsResponse,
|
||||||
InfoResponse,
|
InfoResponse
|
||||||
} from 'picsur-shared/dist/dto/api/info.dto';
|
} from 'picsur-shared/dist/dto/api/info.dto';
|
||||||
import {
|
import {
|
||||||
AnimMime2ExtMap,
|
AnimMime2ExtMap,
|
||||||
ImageMime2ExtMap,
|
ImageMime2ExtMap
|
||||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||||
import { HostConfigService } from '../../../config/early/host.config.service';
|
import { HostConfigService } from '../../../config/early/host.config.service';
|
||||||
import { NoPermissions } from '../../../decorators/permissions.decorator';
|
import { NoPermissions } from '../../../decorators/permissions.decorator';
|
||||||
@@ -16,7 +16,7 @@ import { PermissionsList } from '../../../models/constants/permissions.const';
|
|||||||
@Controller('api/info')
|
@Controller('api/info')
|
||||||
@NoPermissions()
|
@NoPermissions()
|
||||||
export class InfoController {
|
export class InfoController {
|
||||||
constructor(private hostConfig: HostConfigService) {}
|
constructor(private readonly hostConfig: HostConfigService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Returns(InfoResponse)
|
@Returns(InfoResponse)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { Permission } from '../../../models/constants/permissions.const';
|
|||||||
export class SysPrefController {
|
export class SysPrefController {
|
||||||
private readonly logger = new Logger('SysPrefController');
|
private readonly logger = new Logger('SysPrefController');
|
||||||
|
|
||||||
constructor(private prefService: SysPreferenceService) {}
|
constructor(private readonly prefService: SysPreferenceService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Returns(MultiplePreferencesResponse)
|
@Returns(MultiplePreferencesResponse)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { Permission } from '../../../models/constants/permissions.const';
|
|||||||
export class UsrPrefController {
|
export class UsrPrefController {
|
||||||
private readonly logger = new Logger('UsrPrefController');
|
private readonly logger = new Logger('UsrPrefController');
|
||||||
|
|
||||||
constructor(private prefService: UsrPreferenceService) {}
|
constructor(private readonly prefService: UsrPreferenceService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Returns(MultiplePreferencesResponse)
|
@Returns(MultiplePreferencesResponse)
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export class RolesController {
|
|||||||
private readonly logger = new Logger('RolesController');
|
private readonly logger = new Logger('RolesController');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private usersService: UsersService,
|
private readonly usersService: UsersService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get('list')
|
@Get('list')
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import { EUserBackend2EUser } from '../../../models/transformers/user.transforme
|
|||||||
export class UserAdminController {
|
export class UserAdminController {
|
||||||
private readonly logger = new Logger('UserAdminController');
|
private readonly logger = new Logger('UserAdminController');
|
||||||
|
|
||||||
constructor(private usersService: UsersService) {}
|
constructor(private readonly usersService: UsersService) {}
|
||||||
|
|
||||||
@Post('list')
|
@Post('list')
|
||||||
@Returns(UserListResponse)
|
@Returns(UserListResponse)
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Logger,
|
Logger,
|
||||||
Post,
|
Post
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
UserLoginResponse,
|
UserLoginResponse,
|
||||||
UserMePermissionsResponse,
|
UserMePermissionsResponse,
|
||||||
UserMeResponse,
|
UserMeResponse,
|
||||||
UserRegisterRequest,
|
UserRegisterRequest,
|
||||||
UserRegisterResponse,
|
UserRegisterResponse
|
||||||
} from 'picsur-shared/dist/dto/api/user.dto';
|
} from 'picsur-shared/dist/dto/api/user.dto';
|
||||||
import type { EUser } from 'picsur-shared/dist/entities/user.entity';
|
import type { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||||
import { HasFailed } from 'picsur-shared/dist/types';
|
import { HasFailed } from 'picsur-shared/dist/types';
|
||||||
@@ -19,7 +19,7 @@ import { UsersService } from '../../../collections/user-db/user-db.service';
|
|||||||
import {
|
import {
|
||||||
NoPermissions,
|
NoPermissions,
|
||||||
RequiredPermissions,
|
RequiredPermissions,
|
||||||
UseLocalAuth,
|
UseLocalAuth
|
||||||
} from '../../../decorators/permissions.decorator';
|
} from '../../../decorators/permissions.decorator';
|
||||||
import { ReqUser, ReqUserID } from '../../../decorators/request-user.decorator';
|
import { ReqUser, ReqUserID } from '../../../decorators/request-user.decorator';
|
||||||
import { Returns } from '../../../decorators/returns.decorator';
|
import { Returns } from '../../../decorators/returns.decorator';
|
||||||
@@ -32,8 +32,8 @@ export class UserController {
|
|||||||
private readonly logger = new Logger('UserController');
|
private readonly logger = new Logger('UserController');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private usersService: UsersService,
|
private readonly usersService: UsersService,
|
||||||
private authService: AuthManagerService,
|
private readonly authService: AuthManagerService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Post('login')
|
@Post('login')
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
AsyncFailable,
|
AsyncFailable,
|
||||||
Fail,
|
Fail,
|
||||||
Failable,
|
Failable,
|
||||||
HasFailed,
|
HasFailed
|
||||||
} from 'picsur-shared/dist/types';
|
} from 'picsur-shared/dist/types';
|
||||||
import { Sharp } from 'sharp';
|
import { Sharp } from 'sharp';
|
||||||
import {
|
import {
|
||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
SharpWorkerRecieveMessage,
|
SharpWorkerRecieveMessage,
|
||||||
SharpWorkerResultMessage,
|
SharpWorkerResultMessage,
|
||||||
SharpWorkerSendMessage,
|
SharpWorkerSendMessage,
|
||||||
SupportedSharpWorkerFunctions,
|
SupportedSharpWorkerFunctions
|
||||||
} from './sharp/sharp.message';
|
} from './sharp/sharp.message';
|
||||||
import { SharpResult } from './sharp/universal-sharp';
|
import { SharpResult } from './sharp/universal-sharp';
|
||||||
|
|
||||||
@@ -35,7 +35,10 @@ export class SharpWrapper {
|
|||||||
|
|
||||||
private worker: ChildProcess | null = null;
|
private worker: ChildProcess | null = null;
|
||||||
|
|
||||||
constructor(private instance_timeout: number, private memory_limit: number) {}
|
constructor(
|
||||||
|
private readonly instance_timeout: number,
|
||||||
|
private readonly memory_limit: number,
|
||||||
|
) {}
|
||||||
|
|
||||||
public async start(image: Buffer, mime: FullMime): AsyncFailable<true> {
|
public async start(image: Buffer, mime: FullMime): AsyncFailable<true> {
|
||||||
this.worker = fork(SharpWrapper.WORKER_PATH, {
|
this.worker = fork(SharpWrapper.WORKER_PATH, {
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ import {
|
|||||||
ActivatedRoute,
|
ActivatedRoute,
|
||||||
NavigationEnd,
|
NavigationEnd,
|
||||||
NavigationError,
|
NavigationError,
|
||||||
Router,
|
Router
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||||
import { RouteTransitionAnimations } from './app.animation';
|
import { RouteTransitionAnimations } from './app.animation';
|
||||||
import { PRouteData } from './models/dto/picsur-routes.dto';
|
import { PRouteData } from './models/dto/picsur-routes.dto';
|
||||||
import { BootstrapService } from './util/util-module/bootstrap.service';
|
import { BootstrapService } from './util/util-module/bootstrap.service';
|
||||||
import { UtilService } from './util/util-module/util.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -20,7 +19,7 @@ import { UtilService } from './util/util-module/util.service';
|
|||||||
animations: [RouteTransitionAnimations],
|
animations: [RouteTransitionAnimations],
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
readonly logger = console;
|
private readonly logger = console;
|
||||||
|
|
||||||
@ViewChild(MatSidenav) sidebar: MatSidenav;
|
@ViewChild(MatSidenav) sidebar: MatSidenav;
|
||||||
|
|
||||||
@@ -31,10 +30,9 @@ export class AppComponent implements OnInit {
|
|||||||
hasSidebar: boolean = false;
|
hasSidebar: boolean = false;
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private activatedRoute: ActivatedRoute,
|
private readonly activatedRoute: ActivatedRoute,
|
||||||
private utilService: UtilService,
|
private readonly bootstrapService: BootstrapService,
|
||||||
private bootstrapService: BootstrapService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public getRouteAnimData() {
|
public getRouteAnimData() {
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ export class CopyFieldComponent {
|
|||||||
@Input() label: string = 'Loading...';
|
@Input() label: string = 'Loading...';
|
||||||
@Input() value: string = 'Loading...';
|
@Input() value: string = 'Loading...';
|
||||||
|
|
||||||
constructor(private utilService: UtilService, private clipboard: Clipboard) {}
|
constructor(
|
||||||
|
private readonly utilService: UtilService,
|
||||||
|
private readonly clipboard: Clipboard,
|
||||||
|
) {}
|
||||||
|
|
||||||
public copy() {
|
public copy() {
|
||||||
if (this.clipboard.copy(this.value)) {
|
if (this.clipboard.copy(this.value)) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { InfoService } from 'src/app/services/api/info.service';
|
|||||||
styleUrls: ['./footer.component.scss'],
|
styleUrls: ['./footer.component.scss'],
|
||||||
})
|
})
|
||||||
export class FooterComponent implements OnInit {
|
export class FooterComponent implements OnInit {
|
||||||
constructor(private infoService: InfoService) {}
|
constructor(private readonly infoService: InfoService) {}
|
||||||
|
|
||||||
isDemo: boolean = false;
|
isDemo: boolean = false;
|
||||||
version: string = 'Unkown Version';
|
version: string = 'Unkown Version';
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ export class HeaderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private userService: UserService,
|
private readonly userService: UserService,
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ export class PaginatorComponent implements OnInit {
|
|||||||
lastPagesRange: [number, number] | null = null;
|
lastPagesRange: [number, number] | null = null;
|
||||||
pagesRange: [number, number] = [0, 0];
|
pagesRange: [number, number] = [0, 0];
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.calculateRanges();
|
this.calculateRanges();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ export class PicsurImgComponent implements OnChanges {
|
|||||||
public state: PicsurImgState = PicsurImgState.Loading;
|
public state: PicsurImgState = PicsurImgState.Loading;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private qoiWorker: QoiWorkerService,
|
private readonly qoiWorker: QoiWorkerService,
|
||||||
private apiService: ApiService,
|
private readonly apiService: ApiService,
|
||||||
private changeDetector: ChangeDetectorRef,
|
private readonly changeDetector: ChangeDetectorRef,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
|
|||||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||||
import {
|
import {
|
||||||
DecodedPref,
|
DecodedPref,
|
||||||
PrefValueType,
|
PrefValueType
|
||||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||||
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
@@ -28,7 +28,7 @@ export class PrefOptionComponent implements OnInit {
|
|||||||
|
|
||||||
private updateSubject = new Subject<PrefValueType>();
|
private updateSubject = new Subject<PrefValueType>();
|
||||||
|
|
||||||
constructor(private utilService: UtilService) {}
|
constructor(private readonly utilService: UtilService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.subscribeUpdate();
|
this.subscribeUpdate();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
CanActivate,
|
CanActivate,
|
||||||
CanActivateChild,
|
CanActivateChild,
|
||||||
Router,
|
Router,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { isPermissionsArray } from 'picsur-shared/dist/validators/permissions.validator';
|
import { isPermissionsArray } from 'picsur-shared/dist/validators/permissions.validator';
|
||||||
import { PRouteData } from '../models/dto/picsur-routes.dto';
|
import { PRouteData } from '../models/dto/picsur-routes.dto';
|
||||||
@@ -20,9 +20,9 @@ export class PermissionGuard implements CanActivate, CanActivateChild {
|
|||||||
private allPermissionsArray: string[] | null = null;
|
private allPermissionsArray: string[] | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
) {
|
) {
|
||||||
this.setupAllPermissions().catch(this.logger.error);
|
this.setupAllPermissions().catch(this.logger.error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import { UtilService } from 'src/app/util/util-module/util.service';
|
|||||||
})
|
})
|
||||||
export class ProcessingComponent implements OnInit {
|
export class ProcessingComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private imageService: ImageService,
|
private readonly imageService: ImageService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class SettingsGeneralComponent {
|
|||||||
|
|
||||||
preferences: Observable<DecodedPref[]>;
|
preferences: Observable<DecodedPref[]>;
|
||||||
|
|
||||||
constructor(public usrPrefService: UsrPrefService) {
|
constructor(public readonly usrPrefService: UsrPrefService) {
|
||||||
this.preferences = usrPrefService.live;
|
this.preferences = usrPrefService.live;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ export class SettingsRolesEditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private readonly route: ActivatedRoute,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -37,11 +37,12 @@ export class SettingsRolesComponent implements OnInit, AfterViewInit {
|
|||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
public bootstrapService: BootstrapService,
|
// Public because used in template
|
||||||
|
public readonly bootstrapService: BootstrapService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ export class SettingsSidebarComponent implements OnInit {
|
|||||||
systemRoutes: PRoutes = [];
|
systemRoutes: PRoutes = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject('SettingsRoutes') private settingsRoutes: PRoutes,
|
@Inject('SettingsRoutes') private readonly settingsRoutes: PRoutes,
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import { SysPrefService } from 'src/app/services/api/sys-pref.service';
|
|||||||
templateUrl: './settings-sys-pref.component.html',
|
templateUrl: './settings-sys-pref.component.html',
|
||||||
})
|
})
|
||||||
export class SettingsSysprefComponent {
|
export class SettingsSysprefComponent {
|
||||||
public translator = SysPreferenceFriendlyNames;
|
public readonly translator = SysPreferenceFriendlyNames;
|
||||||
|
|
||||||
preferences: Observable<DecodedPref[]>;
|
preferences: Observable<DecodedPref[]>;
|
||||||
|
|
||||||
constructor(public sysPrefService: SysPrefService) {
|
constructor(public readonly sysPrefService: SysPrefService) {
|
||||||
this.preferences = sysPrefService.live;
|
this.preferences = sysPrefService.live;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ export class SettingsUsersEditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private readonly route: ActivatedRoute,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private userManageService: UserAdminService,
|
private readonly userManageService: UserAdminService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private rolesService: RolesService,
|
private readonly rolesService: RolesService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -34,11 +34,12 @@ export class SettingsUsersComponent implements OnInit {
|
|||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private userManageService: UserAdminService,
|
private readonly userManageService: UserAdminService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
public bootstrapService: BootstrapService,
|
// Public because used in template
|
||||||
|
public readonly bootstrapService: BootstrapService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export class UploadComponent implements OnInit {
|
|||||||
canUpload = true;
|
canUpload = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ import { LoginControl } from '../../../models/forms/login.control';
|
|||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
private readonly logger = new Logger('LoginComponent');
|
private readonly logger = new Logger('LoginComponent');
|
||||||
|
|
||||||
showRegister = false;
|
public showRegister = false;
|
||||||
|
|
||||||
model = new LoginControl();
|
public readonly model = new LoginControl();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
private readonly userService: UserService,
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ import { RegisterControl } from '../../../models/forms/register.control';
|
|||||||
export class RegisterComponent implements OnInit {
|
export class RegisterComponent implements OnInit {
|
||||||
private readonly logger = new Logger('RegisterComponent');
|
private readonly logger = new Logger('RegisterComponent');
|
||||||
|
|
||||||
showLogin = false;
|
public showLogin = false;
|
||||||
|
|
||||||
model = new RegisterControl();
|
public readonly model = new RegisterControl();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
private readonly userService: UserService,
|
||||||
private permissionService: PermissionService,
|
private readonly permissionService: PermissionService,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export class CustomizeDialogComponent implements OnInit {
|
|||||||
public quality: number;
|
public quality: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<CustomizeDialogComponent>,
|
public readonly dialogRef: MatDialogRef<CustomizeDialogComponent>,
|
||||||
private imageService: ImageService,
|
private readonly imageService: ImageService,
|
||||||
@Inject(MAT_DIALOG_DATA) data: CustomizeDialogData,
|
@Inject(MAT_DIALOG_DATA) data: CustomizeDialogData,
|
||||||
) {
|
) {
|
||||||
this.formatOptions = data.formatOptions;
|
this.formatOptions = data.formatOptions;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class';
|
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class';
|
||||||
import {
|
import {
|
||||||
@@ -29,11 +28,10 @@ import {
|
|||||||
})
|
})
|
||||||
export class ViewComponent implements OnInit {
|
export class ViewComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private readonly route: ActivatedRoute,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private imageService: ImageService,
|
private readonly imageService: ImageService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
private dialog: MatDialog,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private id: string;
|
private id: string;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
|
import { WINDOW } from '@ng-web-apis/common';
|
||||||
import { ApiResponseSchema } from 'picsur-shared/dist/dto/api/api.dto';
|
import { ApiResponseSchema } from 'picsur-shared/dist/dto/api/api.dto';
|
||||||
import { Mime2Ext } from 'picsur-shared/dist/dto/mimes.dto';
|
import { Mime2Ext } from 'picsur-shared/dist/dto/mimes.dto';
|
||||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||||
@@ -10,7 +11,6 @@ import { z } from 'zod';
|
|||||||
import { MultiPartRequest } from '../../models/dto/multi-part-request.dto';
|
import { MultiPartRequest } from '../../models/dto/multi-part-request.dto';
|
||||||
import { Logger } from '../logger/logger.service';
|
import { Logger } from '../logger/logger.service';
|
||||||
import { KeyService } from '../storage/key.service';
|
import { KeyService } from '../storage/key.service';
|
||||||
import { WINDOW } from '@ng-web-apis/common';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Proud of this, it works so smoooth
|
Proud of this, it works so smoooth
|
||||||
@@ -30,7 +30,7 @@ export class ApiService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly keyService: KeyService,
|
private readonly keyService: KeyService,
|
||||||
@Inject(WINDOW) readonly windowRef: Window,
|
@Inject(WINDOW) private readonly windowRef: Window,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async get<T extends z.AnyZodObject>(
|
public async get<T extends z.AnyZodObject>(
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import { UserService } from './user.service';
|
|||||||
})
|
})
|
||||||
export class ImageService {
|
export class ImageService {
|
||||||
constructor(
|
constructor(
|
||||||
private api: ApiService,
|
private readonly api: ApiService,
|
||||||
@Inject(LOCATION) readonly location: Location,
|
@Inject(LOCATION) private readonly location: Location,
|
||||||
|
|
||||||
private userService: UserService,
|
private readonly userService: UserService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async UploadImage(image: File): AsyncFailable<string> {
|
public async UploadImage(image: File): AsyncFailable<string> {
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ export class PermissionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
private readonly userService: UserService,
|
||||||
private api: ApiService,
|
private readonly api: ApiService,
|
||||||
private staticInfo: StaticInfoService,
|
private readonly staticInfo: StaticInfoService,
|
||||||
) {
|
) {
|
||||||
this.subscribeUser();
|
this.subscribeUser();
|
||||||
this.loadAllPermissions().catch(this.logger.error);
|
this.loadAllPermissions().catch(this.logger.error);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { ApiService } from './api.service';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class RolesService {
|
export class RolesService {
|
||||||
constructor(private api: ApiService) {}
|
constructor(private readonly api: ApiService) {}
|
||||||
|
|
||||||
public async getRoles(): AsyncFailable<ERole[]> {
|
public async getRoles(): AsyncFailable<ERole[]> {
|
||||||
const response = await this.api.get(RoleListResponse, '/api/roles/list');
|
const response = await this.api.get(RoleListResponse, '/api/roles/list');
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import { ApiService } from './api.service';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class StaticInfoService {
|
export class StaticInfoService {
|
||||||
constructor(private api: ApiService, private cache: CacheService) {}
|
constructor(
|
||||||
|
private readonly api: ApiService,
|
||||||
|
private readonly cache: CacheService,
|
||||||
|
) {}
|
||||||
|
|
||||||
public async getSpecialRoles(): Promise<SpecialRolesResponse> {
|
public async getSpecialRoles(): Promise<SpecialRolesResponse> {
|
||||||
return this.cache.getFallback(
|
return this.cache.getFallback(
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export class SysPrefService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private api: ApiService,
|
private readonly api: ApiService,
|
||||||
private permissionsService: PermissionService,
|
private readonly permissionsService: PermissionService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {
|
) {
|
||||||
this.subscribePermissions();
|
this.subscribePermissions();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
UserListRequest,
|
UserListRequest,
|
||||||
UserListResponse,
|
UserListResponse,
|
||||||
UserUpdateRequest,
|
UserUpdateRequest,
|
||||||
UserUpdateResponse,
|
UserUpdateResponse
|
||||||
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||||
import { AsyncFailable } from 'picsur-shared/dist/types';
|
import { AsyncFailable } from 'picsur-shared/dist/types';
|
||||||
@@ -19,7 +19,7 @@ import { ApiService } from './api.service';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class UserAdminService {
|
export class UserAdminService {
|
||||||
constructor(private api: ApiService) {}
|
constructor(private readonly api: ApiService) {}
|
||||||
|
|
||||||
public async getUser(id: string): AsyncFailable<EUser> {
|
public async getUser(id: string): AsyncFailable<EUser> {
|
||||||
return await this.api.post(
|
return await this.api.post(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
UserLoginResponse,
|
UserLoginResponse,
|
||||||
UserMeResponse,
|
UserMeResponse,
|
||||||
UserRegisterRequest,
|
UserRegisterRequest,
|
||||||
UserRegisterResponse,
|
UserRegisterResponse
|
||||||
} from 'picsur-shared/dist/dto/api/user.dto';
|
} from 'picsur-shared/dist/dto/api/user.dto';
|
||||||
import { JwtDataSchema } from 'picsur-shared/dist/dto/jwt.dto';
|
import { JwtDataSchema } from 'picsur-shared/dist/dto/jwt.dto';
|
||||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||||
@@ -34,7 +34,10 @@ export class UserService {
|
|||||||
return this.userSubject.getValue() !== null;
|
return this.userSubject.getValue() !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private api: ApiService, private key: KeyService) {
|
constructor(
|
||||||
|
private readonly api: ApiService,
|
||||||
|
private readonly key: KeyService,
|
||||||
|
) {
|
||||||
this.init().catch(this.logger.error);
|
this.init().catch(this.logger.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export class UsrPrefService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private api: ApiService,
|
private readonly api: ApiService,
|
||||||
private permissionsService: PermissionService,
|
private readonly permissionsService: PermissionService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {
|
) {
|
||||||
this.subscribePermissions();
|
this.subscribePermissions();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { PRouteData } from 'src/app/models/dto/picsur-routes.dto';
|
|||||||
export class SidebarResolverService
|
export class SidebarResolverService
|
||||||
implements Resolve<Portal<unknown> | undefined>
|
implements Resolve<Portal<unknown> | undefined>
|
||||||
{
|
{
|
||||||
constructor(private injector: Injector) {}
|
constructor(private readonly injector: Injector) {}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot) {
|
resolve(route: ActivatedRouteSnapshot) {
|
||||||
const data: PRouteData = route.data;
|
const data: PRouteData = route.data;
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ export class ApiErrorService {
|
|||||||
private readonly logger = new Logger('ApiErrorService');
|
private readonly logger = new Logger('ApiErrorService');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiSerivce: ApiService,
|
private readonly apiSerivce: ApiService,
|
||||||
private utilService: UtilService,
|
private readonly utilService: UtilService,
|
||||||
) {
|
) {
|
||||||
this.subscribeErrors();
|
this.subscribeErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nothing(): void {}
|
||||||
|
|
||||||
@AutoUnsubscribe()
|
@AutoUnsubscribe()
|
||||||
private subscribeErrors() {
|
private subscribeErrors() {
|
||||||
return this.apiSerivce.networkErrors.subscribe((error) => {
|
return this.apiSerivce.networkErrors.subscribe((error) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BreakpointObserver } from '@angular/cdk/layout';
|
import { BreakpointObserver } from '@angular/cdk/layout';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||||
import { Observable, map, BehaviorSubject, zip, combineLatest } from 'rxjs';
|
import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs';
|
||||||
import { Logger } from 'src/app/services/logger/logger.service';
|
import { Logger } from 'src/app/services/logger/logger.service';
|
||||||
|
|
||||||
export enum BSScreenSize {
|
export enum BSScreenSize {
|
||||||
@@ -28,7 +28,7 @@ export class BootstrapService {
|
|||||||
private screenSizeSubject: BehaviorSubject<BSScreenSize> =
|
private screenSizeSubject: BehaviorSubject<BSScreenSize> =
|
||||||
new BehaviorSubject<BSScreenSize>(BSScreenSize.xs);
|
new BehaviorSubject<BSScreenSize>(BSScreenSize.xs);
|
||||||
|
|
||||||
constructor(private breakPointObserver: BreakpointObserver) {
|
constructor(private readonly breakPointObserver: BreakpointObserver) {
|
||||||
this.smObservable = this.createObserver('(min-width: 576px)');
|
this.smObservable = this.createObserver('(min-width: 576px)');
|
||||||
this.mdObservable = this.createObserver('(min-width: 768px)');
|
this.mdObservable = this.createObserver('(min-width: 768px)');
|
||||||
this.lgObservable = this.createObserver('(min-width: 992px)');
|
this.lgObservable = this.createObserver('(min-width: 992px)');
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export interface ConfirmDialogData {
|
|||||||
})
|
})
|
||||||
export class ConfirmDialogComponent {
|
export class ConfirmDialogComponent {
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
public readonly dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData,
|
@Inject(MAT_DIALOG_DATA) public readonly data: ConfirmDialogData,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
onButton(name: string) {
|
onButton(name: string) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export interface DownloadDialogData {
|
|||||||
})
|
})
|
||||||
export class DownloadDialogComponent {
|
export class DownloadDialogComponent {
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<DownloadDialogComponent>,
|
public readonly dialogRef: MatDialogRef<DownloadDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: DownloadDialogData,
|
@Inject(MAT_DIALOG_DATA) public readonly data: DownloadDialogData,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { MatDialogModule } from '@angular/material/dialog';
|
|||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import {
|
import {
|
||||||
MatSnackBarModule,
|
MatSnackBarModule,
|
||||||
MAT_SNACK_BAR_DEFAULT_OPTIONS,
|
MAT_SNACK_BAR_DEFAULT_OPTIONS
|
||||||
} from '@angular/material/snack-bar';
|
} from '@angular/material/snack-bar';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { ApiErrorService } from './api-error.service';
|
import { ApiErrorService } from './api-error.service';
|
||||||
@@ -39,6 +39,8 @@ export class UtilModule {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start apiErrorService
|
// Start apiErrorService, the nothing function does nothing, but it silents the error.
|
||||||
constructor(private apiErrorService: ApiErrorService) {}
|
constructor(apiErrorService: ApiErrorService) {
|
||||||
|
apiErrorService.nothing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { SnackBarType } from '../../models/dto/snack-bar-type.dto';
|
|||||||
import { BootstrapService, BSScreenSize } from './bootstrap.service';
|
import { BootstrapService, BSScreenSize } from './bootstrap.service';
|
||||||
import {
|
import {
|
||||||
ConfirmDialogComponent,
|
ConfirmDialogComponent,
|
||||||
ConfirmDialogData,
|
ConfirmDialogData
|
||||||
} from './confirm-dialog/confirm-dialog.component';
|
} from './confirm-dialog/confirm-dialog.component';
|
||||||
import { DownloadDialogComponent } from './download-dialog/download-dialog.component';
|
import { DownloadDialogComponent } from './download-dialog/download-dialog.component';
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ export class UtilService {
|
|||||||
private readonly logger = new Logger('UtilService');
|
private readonly logger = new Logger('UtilService');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private snackBar: MatSnackBar,
|
private readonly snackBar: MatSnackBar,
|
||||||
private dialog: MatDialog,
|
private readonly dialog: MatDialog,
|
||||||
private router: Router,
|
private readonly router: Router,
|
||||||
private api: ApiService,
|
private readonly api: ApiService,
|
||||||
private bootstrap: BootstrapService,
|
private readonly bootstrap: BootstrapService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public quitError(message: string) {
|
public quitError(message: string) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class QoiWorkerService {
|
|||||||
private worker: Worker | null = null;
|
private worker: Worker | null = null;
|
||||||
private job: Promise<QOIJob> | null = null;
|
private job: Promise<QOIJob> | null = null;
|
||||||
|
|
||||||
constructor(private keyService: KeyService) {
|
constructor(private readonly keyService: KeyService) {
|
||||||
if (typeof Worker !== 'undefined') {
|
if (typeof Worker !== 'undefined') {
|
||||||
this.worker = new Worker(new URL('./qoi.worker', import.meta.url));
|
this.worker = new Worker(new URL('./qoi.worker', import.meta.url));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user