mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-10-26 06:56:06 +01:00
Format everything
This commit is contained in:
@@ -34,13 +34,13 @@ If you like this project, don't forget to give it a star. It tells me that I'm n
|
||||
You easily run this service yourself via Docker. Here is an example docker-compose file:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
version: '3'
|
||||
services:
|
||||
picsur:
|
||||
image: ghcr.io/rubikscraft/picsur:latest
|
||||
container_name: picsur
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- '8080:8080'
|
||||
environment:
|
||||
# PICSUR_HOST: '0.0.0.0'
|
||||
# PICSUR_PORT: 8080
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ImageDBService {
|
||||
});
|
||||
|
||||
if (found === undefined) return Fail('Images not found');
|
||||
|
||||
|
||||
return {
|
||||
results: found,
|
||||
totalResults: amount,
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import {
|
||||
DecodedPref, PrefValueType,
|
||||
PrefValueTypeStrings
|
||||
DecodedPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import {
|
||||
AsyncFailable,
|
||||
Fail,
|
||||
Failable,
|
||||
HasFailed
|
||||
HasFailed,
|
||||
} from 'picsur-shared/dist/types';
|
||||
|
||||
type Enum = Record<string, string>;
|
||||
|
||||
@@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
DecodedSysPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings
|
||||
PrefValueTypeStrings,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
SysPreferenceList,
|
||||
SysPreferenceValueTypes
|
||||
SysPreferenceValueTypes,
|
||||
} from '../../models/constants/syspreferences.const';
|
||||
import {
|
||||
ESysPreferenceBackend,
|
||||
ESysPreferenceSchema
|
||||
ESysPreferenceSchema,
|
||||
} from '../../models/entities/sys-preference.entity';
|
||||
import { MutexFallBack } from '../../models/util/mutex-fallback';
|
||||
import { PreferenceCommonService } from './preference-common.service';
|
||||
|
||||
@@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
DecodedUsrPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings
|
||||
PrefValueTypeStrings,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
UsrPreferenceList,
|
||||
UsrPreferenceValueTypes
|
||||
UsrPreferenceValueTypes,
|
||||
} from '../../models/constants/usrpreferences.const';
|
||||
import {
|
||||
EUsrPreferenceBackend,
|
||||
EUsrPreferenceSchema
|
||||
EUsrPreferenceSchema,
|
||||
} from '../../models/entities/usr-preference.entity';
|
||||
import { MutexFallBack } from '../../models/util/mutex-fallback';
|
||||
import { PreferenceCommonService } from './preference-common.service';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { HostConfigService } from '../../config/early/host.config.service';
|
||||
import {
|
||||
ImmutableRolesList,
|
||||
SystemRoleDefaults,
|
||||
UndeletableRolesList
|
||||
UndeletableRolesList,
|
||||
} from '../../models/constants/roles.const';
|
||||
import { ERoleBackend } from '../../models/entities/role.entity';
|
||||
import { RolesService } from './role-db.service';
|
||||
|
||||
@@ -5,14 +5,14 @@ import {
|
||||
AsyncFailable,
|
||||
Fail,
|
||||
HasFailed,
|
||||
HasSuccess
|
||||
HasSuccess,
|
||||
} from 'picsur-shared/dist/types';
|
||||
import { makeUnique } from 'picsur-shared/dist/util/unique';
|
||||
import { In, Repository } from 'typeorm';
|
||||
import { Permissions } from '../../models/constants/permissions.const';
|
||||
import {
|
||||
ImmutableRolesList,
|
||||
UndeletableRolesList
|
||||
UndeletableRolesList,
|
||||
} from '../../models/constants/roles.const';
|
||||
import { ERoleBackend } from '../../models/entities/role.entity';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
AsyncFailable,
|
||||
Fail,
|
||||
HasFailed,
|
||||
HasSuccess
|
||||
HasSuccess,
|
||||
} from 'picsur-shared/dist/types';
|
||||
import { FindResult } from 'picsur-shared/dist/types/find-result';
|
||||
import { makeUnique } from 'picsur-shared/dist/util/unique';
|
||||
@@ -14,12 +14,12 @@ import { Repository } from 'typeorm';
|
||||
import { Permissions } from '../../models/constants/permissions.const';
|
||||
import {
|
||||
DefaultRolesList,
|
||||
SoulBoundRolesList
|
||||
SoulBoundRolesList,
|
||||
} from '../../models/constants/roles.const';
|
||||
import {
|
||||
ImmutableUsersList,
|
||||
LockedLoginUsersList,
|
||||
UndeletableUsersList
|
||||
UndeletableUsersList,
|
||||
} from '../../models/constants/special-users.const';
|
||||
import { EUserBackend } from '../../models/entities/user.entity';
|
||||
import { GetCols } from '../../models/util/collection';
|
||||
|
||||
@@ -7,6 +7,9 @@ export class AuthConfigService {
|
||||
constructor(private configService: ConfigService) {}
|
||||
|
||||
public getDefaultAdminPassword(): string {
|
||||
return this.configService.get<string>(`${EnvPrefix}ADMIN_PASSWORD`, 'admin');
|
||||
return this.configService.get<string>(
|
||||
`${EnvPrefix}ADMIN_PASSWORD`,
|
||||
'admin',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import {
|
||||
ServeStaticModuleOptions,
|
||||
ServeStaticModuleOptionsFactory
|
||||
ServeStaticModuleOptionsFactory,
|
||||
} from '@nestjs/serve-static';
|
||||
import { join } from 'path';
|
||||
import { EnvPrefix, PackageRoot } from '../config.static';
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
PipeTransform
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
import { Ext2Mime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { UUIDRegex } from 'picsur-shared/dist/util/common-regex';
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
Param,
|
||||
PipeTransform,
|
||||
Type
|
||||
} from '@nestjs/common';
|
||||
import { Param, PipeTransform, Type } from '@nestjs/common';
|
||||
import { ImageIdPipe } from './image-id.pipe';
|
||||
|
||||
export const ImageIdParam = (
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
PipeTransform
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
import { UUIDRegex } from 'picsur-shared/dist/util/common-regex';
|
||||
|
||||
|
||||
@@ -4,5 +4,4 @@ import { PostFilePipe } from './postfile.pipe';
|
||||
|
||||
export const PostFile = () => InjectRequest(PostFilePipe);
|
||||
|
||||
export const MultiPart = () =>
|
||||
InjectRequest(MultiPartPipe);
|
||||
export const MultiPart = () => InjectRequest(MultiPartPipe);
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
PipeTransform,
|
||||
Scope
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
@@ -14,7 +14,7 @@ import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto';
|
||||
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
||||
import {
|
||||
CreateMultiPartFieldDto,
|
||||
CreateMultiPartFileDto
|
||||
CreateMultiPartFileDto,
|
||||
} from '../../models/dto/multipart.dto';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Multipart } from '@fastify/multipart';
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Logger,
|
||||
PipeTransform,
|
||||
Scope
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Logger,
|
||||
PipeTransform,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
import { MultipartConfigService } from '../../config/early/multipart.config.service';
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createParamDecorator,
|
||||
ExecutionContext,
|
||||
SetMetadata,
|
||||
UseGuards
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { CombineFCDecorators } from 'picsur-shared/dist/util/decorator';
|
||||
import { LocalAuthGuard } from '../managers/auth/guards/local-auth.guard';
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Catch,
|
||||
ExceptionFilter,
|
||||
HttpException,
|
||||
Logger
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { ApiErrorResponse } from 'picsur-shared/dist/dto/api/api.dto';
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
NestInterceptor,
|
||||
Optional
|
||||
Optional,
|
||||
} from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { ApiAnySuccessResponse } from 'picsur-shared/dist/dto/api/api.dto';
|
||||
@@ -66,7 +66,9 @@ export class SuccessInterceptor<T> implements NestInterceptor {
|
||||
const parseResult = schema.safeParse(data);
|
||||
if (!parseResult.success) {
|
||||
this.logger.warn(
|
||||
`Function ${context.getHandler().name} failed validation: ${parseResult.error}`,
|
||||
`Function ${context.getHandler().name} failed validation: ${
|
||||
parseResult.error
|
||||
}`,
|
||||
);
|
||||
throw new InternalServerErrorException(
|
||||
'Server produced invalid response',
|
||||
@@ -76,7 +78,10 @@ export class SuccessInterceptor<T> implements NestInterceptor {
|
||||
return parseResult.data;
|
||||
}
|
||||
|
||||
private createResponse(context: ExecutionContext, data: unknown): ApiAnySuccessResponse {
|
||||
private createResponse(
|
||||
context: ExecutionContext,
|
||||
data: unknown,
|
||||
): ApiAnySuccessResponse {
|
||||
const status = context.switchToHttp().getResponse().statusCode;
|
||||
const response = {
|
||||
success: true as true, // really typescript
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
Optional,
|
||||
PipeTransform
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto';
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import fastifyHelmet from '@fastify/helmet';
|
||||
import * as multipart from '@fastify/multipart';
|
||||
import { NestFactory, Reflector } from '@nestjs/core';
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication,
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { AppModule } from './app.module';
|
||||
import { UsersService } from './collections/user-db/user-db.service';
|
||||
|
||||
@@ -3,7 +3,10 @@ import { JwtModule } from '@nestjs/jwt';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { PreferenceModule } from '../../collections/preference-db/preference-db.module';
|
||||
import { UsersModule } from '../../collections/user-db/user-db.module';
|
||||
import { JwtConfigService, JwtSecretProvider } from '../../config/late/jwt.config.service';
|
||||
import {
|
||||
JwtConfigService,
|
||||
JwtSecretProvider,
|
||||
} from '../../config/late/jwt.config.service';
|
||||
import { LateConfigModule } from '../../config/late/late-config.module';
|
||||
import { AuthManagerService } from './auth.service';
|
||||
import { GuestStrategy } from './guards/guest.strategy';
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
Logger
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
@@ -47,14 +47,18 @@ export class MainAuthGuard extends AuthGuard(['jwt', 'guest']) {
|
||||
// These are the permissions required to access the route
|
||||
const permissions = this.extractPermissions(context);
|
||||
if (HasFailed(permissions)) {
|
||||
this.logger.error('Fetching route permission failed: ' + permissions.getReason());
|
||||
this.logger.error(
|
||||
'Fetching route permission failed: ' + permissions.getReason(),
|
||||
);
|
||||
throw new InternalServerErrorException();
|
||||
}
|
||||
|
||||
// These are the permissions the user has
|
||||
const userPermissions = await this.usersService.getPermissions(user.id);
|
||||
if (HasFailed(userPermissions)) {
|
||||
this.logger.warn('Fetching user permissions failed: ' + userPermissions.getReason());
|
||||
this.logger.warn(
|
||||
'Fetching user permissions failed: ' + userPermissions.getReason(),
|
||||
);
|
||||
throw new InternalServerErrorException();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import ms from 'ms';
|
||||
import { ImageRequestParams } from 'picsur-shared/dist/dto/api/image.dto';
|
||||
import {
|
||||
FullMime,
|
||||
SupportedMimeCategory
|
||||
SupportedMimeCategory,
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
FullMime,
|
||||
ImageMime,
|
||||
SupportedMimeCategory
|
||||
SupportedMimeCategory,
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { AsyncFailable, Fail } from 'picsur-shared/dist/types';
|
||||
import { QOIColorSpace, QOIencode } from 'qoi-img';
|
||||
|
||||
@@ -10,11 +10,10 @@ export function UniversalSharp(
|
||||
): Sharp {
|
||||
// if (mime.mime === ImageMime.ICO) {
|
||||
// return icoSharp(image, options);
|
||||
// } else
|
||||
// } else
|
||||
if (mime.mime === ImageMime.BMP) {
|
||||
return bmpSharp(image, options);
|
||||
} else
|
||||
if (mime.mime === ImageMime.QOI) {
|
||||
} else if (mime.mime === ImageMime.QOI) {
|
||||
return qoiSharp(image, options);
|
||||
} else {
|
||||
return sharp(image, options);
|
||||
|
||||
@@ -12,7 +12,7 @@ export class EImageBackend implements EImage {
|
||||
user_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false
|
||||
nullable: false,
|
||||
})
|
||||
created: Date;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
import { EUserBackend } from '../entities/user.entity';
|
||||
|
||||
export function EUserBackend2EUser(
|
||||
eUser: EUserBackend,
|
||||
): EUser {
|
||||
if (eUser.hashed_password === undefined)
|
||||
return eUser as EUser;
|
||||
export function EUserBackend2EUser(eUser: EUserBackend): EUser {
|
||||
if (eUser.hashed_password === undefined) return eUser as EUser;
|
||||
|
||||
return {
|
||||
...eUser,
|
||||
|
||||
@@ -12,6 +12,6 @@ import { UserApiModule } from './user/user.module';
|
||||
ExperimentModule,
|
||||
InfoModule,
|
||||
RolesApiModule,
|
||||
]
|
||||
],
|
||||
})
|
||||
export class PicsurApiModule {}
|
||||
|
||||
@@ -2,11 +2,11 @@ import { Controller, Get } from '@nestjs/common';
|
||||
import {
|
||||
AllFormatsResponse,
|
||||
AllPermissionsResponse,
|
||||
InfoResponse
|
||||
InfoResponse,
|
||||
} from 'picsur-shared/dist/dto/api/info.dto';
|
||||
import {
|
||||
AnimMime2ExtMap,
|
||||
ImageMime2ExtMap
|
||||
ImageMime2ExtMap,
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { HostConfigService } from '../../../config/early/host.config.service';
|
||||
import { NoPermissions } from '../../../decorators/permissions.decorator';
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Param,
|
||||
Post
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Param,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SysPreferenceService } from '../../../collections/preference-db/sys-preference-db.service';
|
||||
@@ -43,9 +43,7 @@ export class SysPrefController {
|
||||
|
||||
@Get(':key')
|
||||
@Returns(GetPreferenceResponse)
|
||||
async getSysPref(
|
||||
@Param('key') key: string,
|
||||
): Promise<GetPreferenceResponse> {
|
||||
async getSysPref(@Param('key') key: string): Promise<GetPreferenceResponse> {
|
||||
const pref = await this.prefService.getPreference(key);
|
||||
if (HasFailed(pref)) {
|
||||
this.logger.warn(pref.getReason());
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Param,
|
||||
Post
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse
|
||||
UpdatePreferenceResponse,
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsrPreferenceService } from '../../../collections/preference-db/usr-preference-db.service';
|
||||
@@ -29,7 +29,9 @@ export class UsrPrefController {
|
||||
|
||||
@Get()
|
||||
@Returns(MultiplePreferencesResponse)
|
||||
async getAllSysPrefs(@ReqUserID() userid: string): Promise<MultiplePreferencesResponse> {
|
||||
async getAllSysPrefs(
|
||||
@ReqUserID() userid: string,
|
||||
): Promise<MultiplePreferencesResponse> {
|
||||
const prefs = await this.prefService.getAllPreferences(userid);
|
||||
if (HasFailed(prefs)) {
|
||||
this.logger.warn(prefs.getReason());
|
||||
@@ -46,7 +48,7 @@ export class UsrPrefController {
|
||||
@Returns(GetPreferenceResponse)
|
||||
async getSysPref(
|
||||
@Param('key') key: string,
|
||||
@ReqUserID() userid: string
|
||||
@ReqUserID() userid: string,
|
||||
): Promise<GetPreferenceResponse> {
|
||||
const pref = await this.prefService.getPreference(userid, key);
|
||||
if (HasFailed(pref)) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
RoleCreateRequest,
|
||||
RoleCreateResponse,
|
||||
RoleDeleteRequest,
|
||||
RoleDeleteResponse,
|
||||
RoleInfoRequest,
|
||||
RoleInfoResponse,
|
||||
RoleListResponse,
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse,
|
||||
SpecialRolesResponse
|
||||
RoleCreateRequest,
|
||||
RoleCreateResponse,
|
||||
RoleDeleteRequest,
|
||||
RoleDeleteResponse,
|
||||
RoleInfoRequest,
|
||||
RoleInfoResponse,
|
||||
RoleListResponse,
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse,
|
||||
SpecialRolesResponse,
|
||||
} from 'picsur-shared/dist/dto/api/roles.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { RolesService } from '../../../collections/role-db/role-db.service';
|
||||
@@ -25,10 +25,10 @@ import { RequiredPermissions } from '../../../decorators/permissions.decorator';
|
||||
import { Returns } from '../../../decorators/returns.decorator';
|
||||
import { Permission } from '../../../models/constants/permissions.const';
|
||||
import {
|
||||
DefaultRolesList,
|
||||
ImmutableRolesList,
|
||||
SoulBoundRolesList,
|
||||
UndeletableRolesList
|
||||
DefaultRolesList,
|
||||
ImmutableRolesList,
|
||||
SoulBoundRolesList,
|
||||
UndeletableRolesList,
|
||||
} from '../../../models/constants/roles.const';
|
||||
import { isPermissionsArray } from '../../../models/validators/permissions.validator';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetSpecialUsersResponse,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
UserListRequest,
|
||||
UserListResponse,
|
||||
UserUpdateRequest,
|
||||
UserUpdateResponse
|
||||
UserUpdateResponse,
|
||||
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsersService } from '../../../collections/user-db/user-db.service';
|
||||
@@ -27,7 +27,7 @@ import { Permission } from '../../../models/constants/permissions.const';
|
||||
import {
|
||||
ImmutableUsersList,
|
||||
LockedLoginUsersList,
|
||||
UndeletableUsersList
|
||||
UndeletableUsersList,
|
||||
} from '../../../models/constants/special-users.const';
|
||||
import { EUserBackend2EUser } from '../../../models/transformers/user.transformer';
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import {
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
UserLoginResponse,
|
||||
UserMePermissionsResponse,
|
||||
UserMeResponse,
|
||||
UserRegisterRequest,
|
||||
UserRegisterResponse
|
||||
UserRegisterResponse,
|
||||
} from 'picsur-shared/dist/dto/api/user.dto';
|
||||
import type { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
@@ -19,7 +19,7 @@ import { UsersService } from '../../../collections/user-db/user-db.service';
|
||||
import {
|
||||
NoPermissions,
|
||||
RequiredPermissions,
|
||||
UseLocalAuth
|
||||
UseLocalAuth,
|
||||
} from '../../../decorators/permissions.decorator';
|
||||
import { ReqUser, ReqUserID } from '../../../decorators/request-user.decorator';
|
||||
import { Returns } from '../../../decorators/returns.decorator';
|
||||
|
||||
@@ -4,21 +4,21 @@ import {
|
||||
Controller,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ImageDeleteRequest,
|
||||
ImageDeleteResponse,
|
||||
ImageListRequest,
|
||||
ImageListResponse,
|
||||
ImageUploadResponse
|
||||
ImageUploadResponse,
|
||||
} from 'picsur-shared/dist/dto/api/image-manage.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { MultiPart } from '../../decorators/multipart/multipart.decorator';
|
||||
import {
|
||||
HasPermission,
|
||||
RequiredPermissions
|
||||
RequiredPermissions,
|
||||
} from '../../decorators/permissions.decorator';
|
||||
import { ReqUserID } from '../../decorators/request-user.decorator';
|
||||
import { Returns } from '../../decorators/returns.decorator';
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
Logger,
|
||||
NotFoundException,
|
||||
Query,
|
||||
Res
|
||||
Res,
|
||||
} from '@nestjs/common';
|
||||
import type { FastifyReply } from 'fastify';
|
||||
import {
|
||||
ImageMetaResponse,
|
||||
ImageRequestParams
|
||||
ImageRequestParams,
|
||||
} from 'picsur-shared/dist/dto/api/image.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsersService } from '../../collections/user-db/user-db.service';
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
AsyncFailable,
|
||||
Fail,
|
||||
Failable,
|
||||
HasFailed
|
||||
HasFailed,
|
||||
} from 'picsur-shared/dist/types';
|
||||
import { Sharp } from 'sharp';
|
||||
import {
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
SharpWorkerRecieveMessage,
|
||||
SharpWorkerResultMessage,
|
||||
SharpWorkerSendMessage,
|
||||
SupportedSharpWorkerFunctions
|
||||
SupportedSharpWorkerFunctions,
|
||||
} from './sharp/sharp.message';
|
||||
import { SharpResult } from './sharp/universal-sharp';
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ export type SupportedSharpWorkerFunctions =
|
||||
| 'negate'
|
||||
| 'greyscale';
|
||||
|
||||
export type SharpWorkerOperation = MapSharpFunctions<SupportedSharpWorkerFunctions>;
|
||||
export type SharpWorkerOperation =
|
||||
MapSharpFunctions<SupportedSharpWorkerFunctions>;
|
||||
|
||||
export interface SharpWorkerFinishOptions {
|
||||
quality?: number;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
SharpWorkerInitMessage,
|
||||
SharpWorkerOperationMessage,
|
||||
SharpWorkerRecieveMessage,
|
||||
SharpWorkerSendMessage
|
||||
SharpWorkerSendMessage,
|
||||
} from './sharp.message';
|
||||
import { UniversalSharpIn, UniversalSharpOut } from './universal-sharp';
|
||||
|
||||
@@ -25,7 +25,7 @@ export class SharpWorker {
|
||||
}
|
||||
|
||||
const memoryLimit = parseInt(process.env['MEMORY_LIMIT_MB'] ?? '');
|
||||
|
||||
|
||||
if (isNaN(memoryLimit) || memoryLimit <= 0) {
|
||||
return this.purge('MEMORY_LIMIT_MB environment variable is not set');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
query,
|
||||
style,
|
||||
transition,
|
||||
trigger
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
|
||||
// This shit worked so beautifully on firefox, but then chrome and angular had to come along and fuck it up
|
||||
@@ -40,7 +40,7 @@ export const RouteTransitionAnimations = trigger('mainAnimation', [
|
||||
],
|
||||
{
|
||||
optional: true,
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
query(
|
||||
@@ -55,7 +55,7 @@ export const RouteTransitionAnimations = trigger('mainAnimation', [
|
||||
display: 'none',
|
||||
}),
|
||||
],
|
||||
{ optional: true }
|
||||
{ optional: true },
|
||||
),
|
||||
|
||||
query(
|
||||
@@ -69,7 +69,7 @@ export const RouteTransitionAnimations = trigger('mainAnimation', [
|
||||
}),
|
||||
animate('.1s', style({ opacity: 1 })),
|
||||
],
|
||||
{ optional: true }
|
||||
{ optional: true },
|
||||
),
|
||||
]),
|
||||
]);
|
||||
|
||||
@@ -34,7 +34,7 @@ export class AppComponent implements OnInit {
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private utilService: UtilService,
|
||||
private bootstrapService: BootstrapService
|
||||
private bootstrapService: BootstrapService,
|
||||
) {}
|
||||
|
||||
public getRouteAnimData() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Clipboard } from '@angular/cdk/clipboard';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { SnackBarType } from "src/app/models/dto/snack-bar-type.dto";
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
|
||||
@Component({
|
||||
@@ -23,7 +23,7 @@ export class CopyFieldComponent {
|
||||
|
||||
return this.utilService.showSnackBar(
|
||||
'Copying to clipboard failed',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { MatTooltip } from '@angular/material/tooltip';
|
||||
export class SpeedDialOptionDirective {
|
||||
constructor(
|
||||
@Host() @Optional() tooltip?: MatTooltip,
|
||||
@Host() @Optional() button?: MatButton
|
||||
@Host() @Optional() button?: MatButton,
|
||||
) {
|
||||
if (tooltip) tooltip.position = 'left';
|
||||
if (button) button.color = 'primary';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
stagger,
|
||||
style,
|
||||
transition,
|
||||
trigger
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
|
||||
export const SpeedDialAnimation = trigger('speedDialAnimation', [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
>Rubikscraft</a
|
||||
>
|
||||
|
||||
{{ isDemo ? " - Demo Version" : "" }}
|
||||
{{ isDemo ? ' - Demo Version' : '' }}
|
||||
</span>
|
||||
|
||||
<span class="line">
|
||||
|
||||
@@ -37,7 +37,7 @@ export class HeaderComponent implements OnInit {
|
||||
private router: Router,
|
||||
private userService: UserService,
|
||||
private permissionService: PermissionService,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { HeaderComponent } from './header.component';
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
MatMenuModule,
|
||||
MatTooltipModule
|
||||
MatTooltipModule,
|
||||
],
|
||||
declarations: [HeaderComponent],
|
||||
exports: [HeaderComponent],
|
||||
|
||||
@@ -27,7 +27,7 @@ export class MasonryItemDirective {
|
||||
constructor(
|
||||
private element: ElementRef<HTMLElement>,
|
||||
@Inject(ResizeObserverService)
|
||||
resize: Observable<ResizeObserverEntry[]>
|
||||
resize: Observable<ResizeObserverEntry[]>,
|
||||
) {
|
||||
this.resizeObserver = resize.pipe(map((entries) => entries[0]));
|
||||
this.subscribeResize();
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
<!-- <ng-content></ng-content> -->
|
||||
<div #column class="column" *ngFor="let item of [].constructor(column_count); let i = index">
|
||||
</div>
|
||||
<div
|
||||
#column
|
||||
class="column"
|
||||
*ngFor="let item of [].constructor(column_count); let i = index"
|
||||
></div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
Input,
|
||||
OnDestroy,
|
||||
QueryList,
|
||||
ViewChildren
|
||||
ViewChildren,
|
||||
} from '@angular/core';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { combineLatest, Subscription } from 'rxjs';
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
Input,
|
||||
OnChanges,
|
||||
SimpleChanges,
|
||||
ViewChild
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { FullMime, SupportedMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
||||
@@ -27,7 +27,7 @@ enum PicsurImgState {
|
||||
selector: 'picsur-img',
|
||||
templateUrl: './picsur-img.component.html',
|
||||
styleUrls: ['./picsur-img.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class PicsurImgComponent implements OnChanges {
|
||||
private readonly logger = new Logger('ZodImgComponent');
|
||||
@@ -43,7 +43,7 @@ export class PicsurImgComponent implements OnChanges {
|
||||
constructor(
|
||||
private qoiWorker: QoiWorkerService,
|
||||
private apiService: ApiService,
|
||||
private changeDetector: ChangeDetectorRef
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
) {}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
@@ -66,8 +66,6 @@ export class PicsurImgComponent implements OnChanges {
|
||||
}
|
||||
})
|
||||
.catch((e) => this.logger.error);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async update(url: string): AsyncFailable<void> {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import {
|
||||
DecodedPref,
|
||||
PrefValueType
|
||||
PrefValueType,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Subject } from 'rxjs';
|
||||
@@ -20,7 +20,7 @@ export class PrefOptionComponent implements OnInit {
|
||||
@Input() @Required pref: DecodedPref;
|
||||
@Input('update') @Required updateFunction: (
|
||||
key: string,
|
||||
pref: PrefValueType
|
||||
pref: PrefValueType,
|
||||
) => AsyncFailable<any>;
|
||||
@Input() @Required translator: {
|
||||
[key in string]: string;
|
||||
@@ -87,14 +87,11 @@ export class PrefOptionComponent implements OnInit {
|
||||
? `Enabled ${this.name}`
|
||||
: `Disabled ${this.name}`
|
||||
: '';
|
||||
this.utilService.showSnackBar(
|
||||
message,
|
||||
SnackBarType.Success
|
||||
);
|
||||
this.utilService.showSnackBar(message, SnackBarType.Success);
|
||||
} else {
|
||||
this.utilService.showSnackBar(
|
||||
`Failed to update ${this.name}`,
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class RangePipe implements PipeTransform {
|
||||
) {
|
||||
return Array.from(
|
||||
{ length: length[1] + 1 - length[0] },
|
||||
(_, i) => i + length[0]
|
||||
(_, i) => i + length[0],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ export class ValuesPickerComponent implements OnInit, OnChanges {
|
||||
private updateSelectable() {
|
||||
const selected: string[] = this.myControl.value;
|
||||
const available = this.fullSelection.filter(
|
||||
(s) => !this.isDisabled(s) && !selected.includes(s)
|
||||
(s) => !this.isDisabled(s) && !selected.includes(s),
|
||||
);
|
||||
|
||||
this.selectableSubject.next(available);
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
CanActivate,
|
||||
CanActivateChild,
|
||||
Router,
|
||||
RouterStateSnapshot
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import { isPermissionsArray } from 'picsur-shared/dist/validators/permissions.validator';
|
||||
import { PRouteData } from '../models/dto/picsur-routes.dto';
|
||||
@@ -22,7 +22,7 @@ export class PermissionGuard implements CanActivate, CanActivateChild {
|
||||
constructor(
|
||||
private permissionService: PermissionService,
|
||||
private staticInfo: StaticInfoService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
) {
|
||||
this.setupAllPermissions().catch(this.logger.error);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export class PermissionGuard implements CanActivate, CanActivateChild {
|
||||
|
||||
async canActivateChild(
|
||||
childRoute: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
state: RouterStateSnapshot,
|
||||
) {
|
||||
return await this.can(childRoute, state);
|
||||
}
|
||||
@@ -52,14 +52,14 @@ export class PermissionGuard implements CanActivate, CanActivateChild {
|
||||
!isPermissionsArray(requiredPermissions, this.allPermissionsArray)
|
||||
) {
|
||||
this.logger.error(
|
||||
`Permissions array is invalid: "${requiredPermissions}" (available: ${this.allPermissionsArray})`
|
||||
`Permissions array is invalid: "${requiredPermissions}" (available: ${this.allPermissionsArray})`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
const ourPermissions = await this.permissionService.getLoadedSnapshot();
|
||||
const weHavePermission = requiredPermissions.every((permission) =>
|
||||
ourPermissions.includes(permission)
|
||||
ourPermissions.includes(permission),
|
||||
);
|
||||
|
||||
if (!weHavePermission)
|
||||
@@ -78,7 +78,7 @@ export class PermissionGuard implements CanActivate, CanActivateChild {
|
||||
}
|
||||
if (route.firstChild) {
|
||||
permissions = permissions.concat(
|
||||
this.nestedPermissions(route.firstChild)
|
||||
this.nestedPermissions(route.firstChild),
|
||||
);
|
||||
}
|
||||
return permissions;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
CreatePasswordError,
|
||||
CreateUsernameError,
|
||||
PasswordValidators,
|
||||
UsernameValidators
|
||||
UsernameValidators,
|
||||
} from '../validators/user.validator';
|
||||
|
||||
export class LoginControl {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
CreatePasswordError,
|
||||
CreateUsernameError,
|
||||
PasswordValidators,
|
||||
UsernameValidators
|
||||
UsernameValidators,
|
||||
} from '../validators/user.validator';
|
||||
|
||||
export class RegisterControl {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UserCreateRequest, UserUpdateRequest } from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import {
|
||||
UserCreateRequest,
|
||||
UserUpdateRequest,
|
||||
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import {
|
||||
CreatePasswordError,
|
||||
CreateUsernameError,
|
||||
PasswordValidators,
|
||||
UsernameValidators
|
||||
UsernameValidators,
|
||||
} from '../validators/user.validator';
|
||||
|
||||
export class UpdateUserControl {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
AbstractControl,
|
||||
FormControl,
|
||||
ValidationErrors,
|
||||
ValidatorFn
|
||||
ValidatorFn,
|
||||
} from '@angular/forms';
|
||||
|
||||
export function Compare(compareTo: FormControl): ValidatorFn {
|
||||
|
||||
@@ -8,7 +8,7 @@ export const RoleNameValidators = [
|
||||
];
|
||||
|
||||
export const CreateRoleNameError = (
|
||||
errors: ValidationErrors | null
|
||||
errors: ValidationErrors | null,
|
||||
): string => {
|
||||
const error = errorsToError(errors);
|
||||
switch (error) {
|
||||
|
||||
@@ -11,7 +11,7 @@ export const UsernameValidators = [
|
||||
];
|
||||
|
||||
export const CreateUsernameError = (
|
||||
errors: ValidationErrors | null
|
||||
errors: ValidationErrors | null,
|
||||
): string => {
|
||||
const error = errorsToError(errors);
|
||||
switch (error) {
|
||||
@@ -34,7 +34,7 @@ export const PasswordValidators = [
|
||||
];
|
||||
|
||||
export const CreatePasswordError = (
|
||||
errors: ValidationErrors | null
|
||||
errors: ValidationErrors | null,
|
||||
): string => {
|
||||
const error = errorsToError(errors);
|
||||
switch (error) {
|
||||
@@ -50,4 +50,3 @@ export const CreatePasswordError = (
|
||||
return 'Invalid password';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ImageService } from 'src/app/services/api/image.service';
|
||||
import { Logger } from 'src/app/services/logger/logger.service';
|
||||
import {
|
||||
BootstrapService,
|
||||
BSScreenSize
|
||||
BSScreenSize,
|
||||
} from 'src/app/util/util-module/bootstrap.service';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
|
||||
@@ -31,7 +31,7 @@ export class ImagesComponent implements OnInit {
|
||||
private readonly router: Router,
|
||||
private readonly bootstrapService: BootstrapService,
|
||||
private readonly utilService: UtilService,
|
||||
private readonly imageService: ImageService
|
||||
private readonly imageService: ImageService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -101,7 +101,7 @@ export class ImagesComponent implements OnInit {
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to delete image',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
} else {
|
||||
this.utilService.showSnackBar('Image deleted', SnackBarType.Success);
|
||||
|
||||
@@ -12,7 +12,7 @@ export class ProcessingComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private imageService: ImageService,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
|
||||
@@ -6,10 +6,6 @@ import { ProcessingRoutingModule } from './processing.routing.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [ProcessingComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
ProcessingRoutingModule,
|
||||
MatProgressSpinnerModule,
|
||||
],
|
||||
imports: [CommonModule, ProcessingRoutingModule, MatProgressSpinnerModule],
|
||||
})
|
||||
export class ProcessingRouteModule {}
|
||||
|
||||
@@ -6,10 +6,6 @@ import { SettingsGeneralRoutingModule } from './settings-general.routing.module'
|
||||
|
||||
@NgModule({
|
||||
declarations: [SettingsGeneralComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
SettingsGeneralRoutingModule,
|
||||
PrefOptionModule
|
||||
],
|
||||
imports: [CommonModule, SettingsGeneralRoutingModule, PrefOptionModule],
|
||||
})
|
||||
export class SettingsGeneralRouteModule {}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12 py-4">
|
||||
<button mat-raised-button color="accent" type="submit">
|
||||
{{ editing ? "UPDATE" : "ADD" }}
|
||||
{{ editing ? 'UPDATE' : 'ADD' }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
@@ -39,12 +39,12 @@ export class SettingsRolesEditComponent implements OnInit {
|
||||
private router: Router,
|
||||
private utilService: UtilService,
|
||||
private rolesService: RolesService,
|
||||
private staticInfo: StaticInfoService
|
||||
private staticInfo: StaticInfoService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
Promise.all([this.initRole(), this.initPermissions()]).catch(
|
||||
this.logger.error
|
||||
this.logger.error,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class SettingsRolesEditComponent implements OnInit {
|
||||
if (HasFailed(resultRole)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to create role',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export class SettingsRolesEditComponent implements OnInit {
|
||||
if (HasFailed(resultRole)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to update role',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class SettingsRolesComponent implements OnInit, AfterViewInit {
|
||||
private rolesService: RolesService,
|
||||
private staticInfo: StaticInfoService,
|
||||
private router: Router,
|
||||
public bootstrapService: BootstrapService
|
||||
public bootstrapService: BootstrapService,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -82,7 +82,7 @@ export class SettingsRolesComponent implements OnInit, AfterViewInit {
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to delete role',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
} else {
|
||||
this.utilService.showSnackBar('Role deleted', SnackBarType.Success);
|
||||
|
||||
@@ -29,7 +29,7 @@ import { SettingsRolesRoutingModule } from './settings-roles.routing.module';
|
||||
MatInputModule,
|
||||
FabModule,
|
||||
ReactiveFormsModule,
|
||||
ValuesPickerModule
|
||||
ValuesPickerModule,
|
||||
],
|
||||
})
|
||||
export class SettingsRolesRouteModule {}
|
||||
|
||||
@@ -16,7 +16,7 @@ const routes: PRoutes = [
|
||||
{
|
||||
path: 'add',
|
||||
component: SettingsRolesEditComponent,
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -17,7 +17,7 @@ export class SettingsSidebarComponent implements OnInit {
|
||||
constructor(
|
||||
@Inject('SettingsRoutes') private settingsRoutes: PRoutes,
|
||||
private permissionService: PermissionService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -31,17 +31,17 @@ export class SettingsSidebarComponent implements OnInit {
|
||||
.filter((route) =>
|
||||
route.data?.permissions !== undefined
|
||||
? route.data?.permissions?.every((permission) =>
|
||||
permissions.includes(permission)
|
||||
permissions.includes(permission),
|
||||
)
|
||||
: true
|
||||
: true,
|
||||
);
|
||||
|
||||
// Split them according to their groups
|
||||
this.personalRoutes = this.accessibleRoutes.filter(
|
||||
(route) => route.data?.page?.category === 'personal'
|
||||
(route) => route.data?.page?.category === 'personal',
|
||||
);
|
||||
this.systemRoutes = this.accessibleRoutes.filter(
|
||||
(route) => route.data?.page?.category === 'system'
|
||||
(route) => route.data?.page?.category === 'system',
|
||||
);
|
||||
|
||||
// Get out of here if we have no routes
|
||||
@@ -53,7 +53,7 @@ export class SettingsSidebarComponent implements OnInit {
|
||||
@AutoUnsubscribe()
|
||||
private subscribePermissions() {
|
||||
return this.permissionService.live.subscribe(
|
||||
this.handlePermissions.bind(this)
|
||||
this.handlePermissions.bind(this),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ import { SettingsSysprefRoutingModule } from './settings-sys-pref.routing.module
|
||||
|
||||
@NgModule({
|
||||
declarations: [SettingsSysprefComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
SettingsSysprefRoutingModule,
|
||||
PrefOptionModule,
|
||||
],
|
||||
imports: [CommonModule, SettingsSysprefRoutingModule, PrefOptionModule],
|
||||
})
|
||||
export class SettingsSysprefRouteModule {}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-12">
|
||||
<mat-form-field appearance="outline" color="accent">
|
||||
<mat-label>{{ editing ? "New Password" : "Password" }}</mat-label>
|
||||
<mat-label>{{ editing ? 'New Password' : 'Password' }}</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="password"
|
||||
@@ -74,7 +74,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12 py-4">
|
||||
<button mat-raised-button color="accent" type="submit">
|
||||
{{ editing ? "UPDATE" : "ADD" }}
|
||||
{{ editing ? 'UPDATE' : 'ADD' }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
@@ -48,7 +48,7 @@ export class SettingsUsersEditComponent implements OnInit {
|
||||
private userManageService: UserAdminService,
|
||||
private utilService: UtilService,
|
||||
private rolesService: RolesService,
|
||||
private staticInfo: StaticInfoService
|
||||
private staticInfo: StaticInfoService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -116,7 +116,7 @@ export class SettingsUsersEditComponent implements OnInit {
|
||||
}
|
||||
|
||||
permissions.push(
|
||||
...fullRole.permissions.filter((p) => !permissions.includes(p))
|
||||
...fullRole.permissions.filter((p) => !permissions.includes(p)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export class SettingsUsersEditComponent implements OnInit {
|
||||
if (HasFailed(resultUser)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to create user',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ export class SettingsUsersEditComponent implements OnInit {
|
||||
if (HasFailed(resultUser)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to update user',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ export class SettingsUsersEditComponent implements OnInit {
|
||||
return false;
|
||||
} else {
|
||||
return this.ImmutableUsersList.includes(
|
||||
this.model.getDataCreate().username
|
||||
this.model.getDataCreate().username,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export class SettingsUsersComponent implements OnInit {
|
||||
private userManageService: UserAdminService,
|
||||
private staticInfo: StaticInfoService,
|
||||
private router: Router,
|
||||
public bootstrapService: BootstrapService
|
||||
public bootstrapService: BootstrapService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -80,7 +80,7 @@ export class SettingsUsersComponent implements OnInit {
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to delete user',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
} else {
|
||||
this.utilService.showSnackBar('User deleted', SnackBarType.Success);
|
||||
@@ -89,7 +89,7 @@ export class SettingsUsersComponent implements OnInit {
|
||||
|
||||
const success = await this.fetchUsers(
|
||||
this.paginator.pageSize,
|
||||
this.paginator.pageIndex
|
||||
this.paginator.pageIndex,
|
||||
);
|
||||
if (!success) {
|
||||
this.paginator.firstPage();
|
||||
@@ -103,7 +103,7 @@ export class SettingsUsersComponent implements OnInit {
|
||||
.subscribe(async (pageEvent: PageEvent) => {
|
||||
let success = await this.fetchUsers(
|
||||
pageEvent.pageSize,
|
||||
pageEvent.pageIndex
|
||||
pageEvent.pageIndex,
|
||||
);
|
||||
if (!success) {
|
||||
if (pageEvent.previousPageIndex === pageEvent.pageIndex - 1) {
|
||||
@@ -117,13 +117,13 @@ export class SettingsUsersComponent implements OnInit {
|
||||
|
||||
private async fetchUsers(
|
||||
pageSize: number,
|
||||
pageIndex: number
|
||||
pageIndex: number,
|
||||
): Promise<boolean> {
|
||||
const result = await this.userManageService.getUsers(pageSize, pageIndex);
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to fetch users',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const routes: PRoutes = [
|
||||
{
|
||||
path: 'add',
|
||||
component: SettingsUsersEditComponent,
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -13,6 +13,6 @@ ngx-dropzone {
|
||||
height: 100%;
|
||||
|
||||
&.ngx-dz-hovered {
|
||||
border-style: initial;
|
||||
}
|
||||
border-style: initial;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class UploadComponent implements OnInit {
|
||||
constructor(
|
||||
private utilService: UtilService,
|
||||
private permissionService: PermissionService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -37,7 +37,7 @@ export class UploadComponent implements OnInit {
|
||||
onSelect(event: NgxDropzoneChangeEvent) {
|
||||
if (event.addedFiles.length > 1) {
|
||||
this.utilService.showSnackBar(
|
||||
'You uploaded multiple images, only one has been uploaded'
|
||||
'You uploaded multiple images, only one has been uploaded',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export class LoginComponent implements OnInit {
|
||||
private userService: UserService,
|
||||
private permissionService: PermissionService,
|
||||
private router: Router,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -57,7 +57,7 @@ export class LoginComponent implements OnInit {
|
||||
this.logger.error(user.getReason());
|
||||
this.utilService.showSnackBar(
|
||||
'Login failed, please try again',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class RegisterComponent implements OnInit {
|
||||
private userService: UserService,
|
||||
private permissionService: PermissionService,
|
||||
private router: Router,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -57,29 +57,32 @@ export class RegisterComponent implements OnInit {
|
||||
this.logger.error(user.getReason());
|
||||
this.utilService.showSnackBar(
|
||||
'Register failed, please try again',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.userService.isLoggedIn) {
|
||||
const loginResult = await this.userService.login(data.username, data.password);
|
||||
const loginResult = await this.userService.login(
|
||||
data.username,
|
||||
data.password,
|
||||
);
|
||||
if (HasFailed(loginResult)) {
|
||||
this.logger.error(loginResult.getReason());
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to login after register',
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
}
|
||||
|
||||
this.utilService.showSnackBar(
|
||||
'Register successful',
|
||||
SnackBarType.Success
|
||||
SnackBarType.Success,
|
||||
);
|
||||
} else {
|
||||
this.utilService.showSnackBar(
|
||||
'Register successful, did not log in',
|
||||
SnackBarType.Success
|
||||
SnackBarType.Success,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import {
|
||||
ConfirmDialogComponent,
|
||||
ConfirmDialogData
|
||||
ConfirmDialogData,
|
||||
} from 'src/app/util/util-module/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
@Component({
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
export class CustomizeDialogComponent implements OnInit {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
||||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Mime2Ext,
|
||||
SupportedAnimMimes,
|
||||
SupportedImageMimes,
|
||||
SupportedMimeCategory
|
||||
SupportedMimeCategory,
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { EImage } from 'picsur-shared/dist/entities/image.entity';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
@@ -30,7 +30,7 @@ export class ViewComponent implements OnInit {
|
||||
private router: Router,
|
||||
private imageService: ImageService,
|
||||
private utilService: UtilService,
|
||||
private dialog: MatDialog
|
||||
private dialog: MatDialog,
|
||||
) {}
|
||||
|
||||
private id: string;
|
||||
@@ -68,7 +68,7 @@ export class ViewComponent implements OnInit {
|
||||
|
||||
this.previewLink = this.imageService.GetImageURL(
|
||||
this.id,
|
||||
metadata.fileMimes.master
|
||||
metadata.fileMimes.master,
|
||||
);
|
||||
|
||||
this.hasOriginal = metadata.fileMimes.original !== undefined;
|
||||
@@ -100,7 +100,7 @@ export class ViewComponent implements OnInit {
|
||||
} else {
|
||||
this.imageLinks = this.imageService.CreateImageLinksFromID(
|
||||
this.id,
|
||||
format
|
||||
format,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export class ViewComponent implements OnInit {
|
||||
{
|
||||
format: this.currentSelectedFormat,
|
||||
},
|
||||
{ dismissable: false }
|
||||
{ dismissable: false },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,14 +144,14 @@ export class ViewComponent implements OnInit {
|
||||
...SupportedImageMimes.map((mime) => ({
|
||||
value: Mime2Ext(mime)?.toUpperCase() ?? 'Error',
|
||||
key: mime,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
} else if (this.masterMime.type === SupportedMimeCategory.Animation) {
|
||||
newOptions.push(
|
||||
...SupportedAnimMimes.map((mime) => ({
|
||||
value: Mime2Ext(mime)?.toUpperCase() ?? 'Error',
|
||||
key: mime,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ export class ApiService {
|
||||
|
||||
constructor(
|
||||
private readonly keyService: KeyService,
|
||||
@Inject(WINDOW) readonly windowRef: Window
|
||||
@Inject(WINDOW) readonly windowRef: Window,
|
||||
) {}
|
||||
|
||||
public async get<T extends z.AnyZodObject>(
|
||||
type: ZodDtoStatic<T>,
|
||||
url: string
|
||||
url: string,
|
||||
): AsyncFailable<z.infer<T>> {
|
||||
return this.fetchSafeJson(type, url, { method: 'GET' });
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export class ApiService {
|
||||
sendType: ZodDtoStatic<T>,
|
||||
receiveType: ZodDtoStatic<W>,
|
||||
url: string,
|
||||
data: z.infer<T>
|
||||
data: z.infer<T>,
|
||||
): AsyncFailable<z.infer<W>> {
|
||||
const sendSchema = sendType.zodSchema;
|
||||
|
||||
@@ -71,7 +71,7 @@ export class ApiService {
|
||||
public async postForm<T extends z.AnyZodObject>(
|
||||
receiveType: ZodDtoStatic<T>,
|
||||
url: string,
|
||||
data: MultiPartRequest
|
||||
data: MultiPartRequest,
|
||||
): AsyncFailable<z.infer<T>> {
|
||||
return this.fetchSafeJson(receiveType, url, {
|
||||
method: 'POST',
|
||||
@@ -82,7 +82,7 @@ export class ApiService {
|
||||
private async fetchSafeJson<T extends z.AnyZodObject>(
|
||||
type: ZodDtoStatic<T>,
|
||||
url: RequestInfo,
|
||||
options: RequestInit
|
||||
options: RequestInit,
|
||||
): AsyncFailable<z.infer<T>> {
|
||||
const resultSchema = ApiResponseSchema(type.zodSchema as z.AnyZodObject);
|
||||
type resultType = z.infer<typeof resultSchema>;
|
||||
@@ -103,7 +103,7 @@ export class ApiService {
|
||||
|
||||
private async fetchJsonAs<T>(
|
||||
url: RequestInfo,
|
||||
options: RequestInit
|
||||
options: RequestInit,
|
||||
): AsyncFailable<T> {
|
||||
const response = await this.fetch(url, options);
|
||||
if (HasFailed(response)) {
|
||||
@@ -119,7 +119,7 @@ export class ApiService {
|
||||
|
||||
private async fetchBuffer(
|
||||
url: RequestInfo,
|
||||
options: RequestInit
|
||||
options: RequestInit,
|
||||
): AsyncFailable<ApiBuffer> {
|
||||
const response = await this.fetch(url, options);
|
||||
if (HasFailed(response)) return response;
|
||||
@@ -156,7 +156,7 @@ export class ApiService {
|
||||
|
||||
private async fetchHead(
|
||||
url: RequestInfo,
|
||||
options: RequestInit
|
||||
options: RequestInit,
|
||||
): AsyncFailable<Headers> {
|
||||
const response = await this.fetch(url, options);
|
||||
if (HasFailed(response)) return response;
|
||||
@@ -168,7 +168,7 @@ export class ApiService {
|
||||
|
||||
private async fetch(
|
||||
url: RequestInfo,
|
||||
options: RequestInit
|
||||
options: RequestInit,
|
||||
): AsyncFailable<Response> {
|
||||
try {
|
||||
const key = this.keyService.get();
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
ImageDeleteResponse,
|
||||
ImageListRequest,
|
||||
ImageListResponse,
|
||||
ImageUploadResponse
|
||||
ImageUploadResponse,
|
||||
} from 'picsur-shared/dist/dto/api/image-manage.dto';
|
||||
import { ImageMetaResponse } from 'picsur-shared/dist/dto/api/image.dto';
|
||||
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.dto';
|
||||
@@ -25,14 +25,14 @@ export class ImageService {
|
||||
private api: ApiService,
|
||||
@Inject(LOCATION) readonly location: Location,
|
||||
|
||||
private userService: UserService
|
||||
private userService: UserService,
|
||||
) {}
|
||||
|
||||
public async UploadImage(image: File): AsyncFailable<string> {
|
||||
const result = await this.api.postForm(
|
||||
ImageUploadResponse,
|
||||
'/api/image/upload',
|
||||
new ImageUploadRequest(image)
|
||||
new ImageUploadRequest(image),
|
||||
);
|
||||
|
||||
return Open(result, 'id');
|
||||
@@ -45,7 +45,7 @@ export class ImageService {
|
||||
public async ListAllImages(
|
||||
count: number,
|
||||
page: number,
|
||||
userID?: string
|
||||
userID?: string,
|
||||
): AsyncFailable<ImageListResponse> {
|
||||
return await this.api.post(
|
||||
ImageListRequest,
|
||||
@@ -55,13 +55,13 @@ export class ImageService {
|
||||
count,
|
||||
page,
|
||||
user_id: userID,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public async ListMyImages(
|
||||
count: number,
|
||||
page: number
|
||||
page: number,
|
||||
): AsyncFailable<ImageListResponse> {
|
||||
const userID = await this.userService.snapshot?.id;
|
||||
if (userID === undefined) {
|
||||
@@ -72,7 +72,7 @@ export class ImageService {
|
||||
}
|
||||
|
||||
public async DeleteImages(
|
||||
images: string[]
|
||||
images: string[],
|
||||
): AsyncFailable<ImageDeleteResponse> {
|
||||
return await this.api.post(
|
||||
ImageDeleteRequest,
|
||||
@@ -80,7 +80,7 @@ export class ImageService {
|
||||
'/api/image/delete',
|
||||
{
|
||||
ids: images,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export class ImageService {
|
||||
|
||||
if (result.images.length !== 1) {
|
||||
return Fail(
|
||||
`Image ${image} was not deleted, probably lacking permissions`
|
||||
`Image ${image} was not deleted, probably lacking permissions`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export class ImageService {
|
||||
|
||||
public CreateImageLinksFromID(
|
||||
imageID: string,
|
||||
mime: string | null
|
||||
mime: string | null,
|
||||
): ImageLinks {
|
||||
return this.CreateImageLinks(this.GetImageURL(imageID, mime));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class InfoService {
|
||||
constructor(
|
||||
private readonly api: ApiService,
|
||||
private readonly utilService: UtilService,
|
||||
@Inject(HISTORY) private readonly history: History
|
||||
@Inject(HISTORY) private readonly history: History,
|
||||
) {
|
||||
this.checkCompatibility().catch(this.logger.error);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ export class InfoService {
|
||||
if (HasFailed(isCompatible)) {
|
||||
this.utilService.showSnackBar(
|
||||
'There was an error checking compatibility',
|
||||
SnackBarType.Warning
|
||||
SnackBarType.Warning,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class PermissionService {
|
||||
|
||||
public get live(): Observable<string[]> {
|
||||
return this.permissionsSubject.pipe(
|
||||
map((permissions) => permissions ?? this.allPermissions)
|
||||
map((permissions) => permissions ?? this.allPermissions),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class PermissionService {
|
||||
return new Promise((resolve) => {
|
||||
const filtered = this.permissionsSubject.pipe(
|
||||
filter((permissions) => permissions !== null),
|
||||
take(1)
|
||||
take(1),
|
||||
);
|
||||
(filtered as Observable<string[]>).subscribe(resolve);
|
||||
});
|
||||
@@ -40,7 +40,7 @@ export class PermissionService {
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private api: ApiService,
|
||||
private staticInfo: StaticInfoService
|
||||
private staticInfo: StaticInfoService,
|
||||
) {
|
||||
this.subscribeUser();
|
||||
this.loadAllPermissions().catch(this.logger.error);
|
||||
@@ -68,7 +68,7 @@ export class PermissionService {
|
||||
private async updatePermissions(): AsyncFailable<true> {
|
||||
const got = await this.api.get(
|
||||
UserMePermissionsResponse,
|
||||
'/api/user/me/permissions'
|
||||
'/api/user/me/permissions',
|
||||
);
|
||||
if (HasFailed(got)) return got;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
RoleInfoResponse,
|
||||
RoleListResponse,
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse
|
||||
RoleUpdateResponse,
|
||||
} from 'picsur-shared/dist/dto/api/roles.dto';
|
||||
import { ERole } from 'picsur-shared/dist/entities/role.entity';
|
||||
import { AsyncFailable, Open } from 'picsur-shared/dist/types';
|
||||
@@ -34,7 +34,7 @@ export class RolesService {
|
||||
'/api/roles/info',
|
||||
{
|
||||
name,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class RolesService {
|
||||
RoleCreateRequest,
|
||||
RoleCreateResponse,
|
||||
'/api/roles/create',
|
||||
role
|
||||
role,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class RolesService {
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse,
|
||||
'/api/roles/update',
|
||||
role
|
||||
role,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export class RolesService {
|
||||
'/api/roles/delete',
|
||||
{
|
||||
name,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class StaticInfoService {
|
||||
SoulBoundRoles: [],
|
||||
UndeletableRoles: [],
|
||||
},
|
||||
() => this.api.get(SpecialRolesResponse, '/api/roles/special')
|
||||
() => this.api.get(SpecialRolesResponse, '/api/roles/special'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export class StaticInfoService {
|
||||
LockedLoginUsersList: [],
|
||||
UndeletableUsersList: [],
|
||||
},
|
||||
() => this.api.get(GetSpecialUsersResponse, '/api/user/special')
|
||||
() => this.api.get(GetSpecialUsersResponse, '/api/user/special'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ export class StaticInfoService {
|
||||
async () => {
|
||||
const res = await this.api.get(
|
||||
AllPermissionsResponse,
|
||||
'/api/info/permissions'
|
||||
'/api/info/permissions',
|
||||
);
|
||||
return Open(res, 'permissions');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import {
|
||||
DecodedPref,
|
||||
PrefValueType
|
||||
DecodedPref,
|
||||
PrefValueType,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed, Map } from 'picsur-shared/dist/types';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
@@ -41,7 +41,7 @@ export class SysPrefService {
|
||||
constructor(
|
||||
private api: ApiService,
|
||||
private permissionsService: PermissionService,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {
|
||||
this.subscribePermissions();
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export class SysPrefService {
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
"Couldn't load system preferences",
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
this.flush();
|
||||
}
|
||||
@@ -63,7 +63,7 @@ export class SysPrefService {
|
||||
|
||||
const response = await this.api.get(
|
||||
MultiplePreferencesResponse,
|
||||
'/api/pref/sys'
|
||||
'/api/pref/sys',
|
||||
);
|
||||
|
||||
return Map(response, (pref) => {
|
||||
@@ -73,14 +73,14 @@ export class SysPrefService {
|
||||
}
|
||||
|
||||
public async getPreference(
|
||||
key: string
|
||||
key: string,
|
||||
): AsyncFailable<GetPreferenceResponse> {
|
||||
if (!this.hasPermission)
|
||||
return Fail('You do not have permission to edit system preferences');
|
||||
|
||||
const response = await this.api.get(
|
||||
GetPreferenceResponse,
|
||||
`/api/pref/sys/${key}`
|
||||
`/api/pref/sys/${key}`,
|
||||
);
|
||||
|
||||
if (!HasFailed(response)) this.updatePrefArray(response);
|
||||
@@ -89,7 +89,7 @@ export class SysPrefService {
|
||||
|
||||
public async setPreference(
|
||||
key: string,
|
||||
value: PrefValueType
|
||||
value: PrefValueType,
|
||||
): AsyncFailable<UpdatePreferenceResponse> {
|
||||
if (!this.hasPermission)
|
||||
return Fail('You do not have permission to edit system preferences');
|
||||
@@ -98,7 +98,7 @@ export class SysPrefService {
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
`/api/pref/sys/${key}`,
|
||||
{ value }
|
||||
{ value },
|
||||
);
|
||||
|
||||
if (!HasFailed(response)) this.updatePrefArray(response);
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
UserListRequest,
|
||||
UserListResponse,
|
||||
UserUpdateRequest,
|
||||
UserUpdateResponse
|
||||
UserUpdateResponse,
|
||||
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
import { AsyncFailable } from 'picsur-shared/dist/types';
|
||||
@@ -26,13 +26,13 @@ export class UserAdminService {
|
||||
UserInfoRequest,
|
||||
UserInfoResponse,
|
||||
'api/user/info',
|
||||
{ id }
|
||||
{ id },
|
||||
);
|
||||
}
|
||||
|
||||
public async getUsers(
|
||||
count: number,
|
||||
page: number
|
||||
page: number,
|
||||
): AsyncFailable<UserListResponse> {
|
||||
return await this.api.post(
|
||||
UserListRequest,
|
||||
@@ -41,7 +41,7 @@ export class UserAdminService {
|
||||
{
|
||||
count,
|
||||
page,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class UserAdminService {
|
||||
UserCreateRequest,
|
||||
UserCreateResponse,
|
||||
'/api/user/create',
|
||||
user
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export class UserAdminService {
|
||||
UserUpdateRequest,
|
||||
UserUpdateResponse,
|
||||
'/api/user/update',
|
||||
user
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class UserAdminService {
|
||||
UserDeleteRequest,
|
||||
UserDeleteResponse,
|
||||
'/api/user/delete',
|
||||
{ id }
|
||||
{ id },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
UserLoginResponse,
|
||||
UserMeResponse,
|
||||
UserRegisterRequest,
|
||||
UserRegisterResponse
|
||||
UserRegisterResponse,
|
||||
} from 'picsur-shared/dist/dto/api/user.dto';
|
||||
import { JwtDataSchema } from 'picsur-shared/dist/dto/jwt.dto';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
@@ -69,7 +69,7 @@ export class UserService {
|
||||
{
|
||||
username,
|
||||
password,
|
||||
}
|
||||
},
|
||||
);
|
||||
if (HasFailed(response)) return response;
|
||||
|
||||
@@ -85,7 +85,7 @@ export class UserService {
|
||||
|
||||
public async register(
|
||||
username: string,
|
||||
password: string
|
||||
password: string,
|
||||
): AsyncFailable<EUser> {
|
||||
return await this.api.post(
|
||||
UserRegisterRequest,
|
||||
@@ -94,7 +94,7 @@ export class UserService {
|
||||
{
|
||||
username,
|
||||
password,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse
|
||||
UpdatePreferenceResponse,
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import {
|
||||
DecodedPref,
|
||||
PrefValueType
|
||||
PrefValueType,
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed, Map } from 'picsur-shared/dist/types';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
@@ -41,7 +41,7 @@ export class UsrPrefService {
|
||||
constructor(
|
||||
private api: ApiService,
|
||||
private permissionsService: PermissionService,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {
|
||||
this.subscribePermissions();
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export class UsrPrefService {
|
||||
if (HasFailed(result)) {
|
||||
this.utilService.showSnackBar(
|
||||
"Couldn't load user preferences",
|
||||
SnackBarType.Error
|
||||
SnackBarType.Error,
|
||||
);
|
||||
this.flush();
|
||||
}
|
||||
@@ -63,7 +63,7 @@ export class UsrPrefService {
|
||||
|
||||
const response = await this.api.get(
|
||||
MultiplePreferencesResponse,
|
||||
'/api/pref/usr'
|
||||
'/api/pref/usr',
|
||||
);
|
||||
|
||||
return Map(response, (pref) => {
|
||||
@@ -73,14 +73,14 @@ export class UsrPrefService {
|
||||
}
|
||||
|
||||
public async getPreference(
|
||||
key: string
|
||||
key: string,
|
||||
): AsyncFailable<GetPreferenceResponse> {
|
||||
if (!this.hasPermission)
|
||||
return Fail('You do not have permission to edit user preferences');
|
||||
|
||||
const response = await this.api.get(
|
||||
GetPreferenceResponse,
|
||||
`/api/pref/usr/${key}`
|
||||
`/api/pref/usr/${key}`,
|
||||
);
|
||||
|
||||
if (!HasFailed(response)) this.updatePrefArray(response);
|
||||
@@ -89,7 +89,7 @@ export class UsrPrefService {
|
||||
|
||||
public async setPreference(
|
||||
key: string,
|
||||
value: PrefValueType
|
||||
value: PrefValueType,
|
||||
): AsyncFailable<UpdatePreferenceResponse> {
|
||||
if (!this.hasPermission)
|
||||
return Fail('You do not have permission to edit user preferences');
|
||||
@@ -98,7 +98,7 @@ export class UsrPrefService {
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
`/api/pref/usr/${key}`,
|
||||
{ value }
|
||||
{ value },
|
||||
);
|
||||
|
||||
if (!HasFailed(response)) this.updatePrefArray(response);
|
||||
|
||||
@@ -66,7 +66,7 @@ export class GlobalLogger {
|
||||
return;
|
||||
}
|
||||
|
||||
const processedArgs = args.map(a => {
|
||||
const processedArgs = args.map((a) => {
|
||||
if (typeof a === 'string') {
|
||||
return a;
|
||||
} else if (a instanceof Error) {
|
||||
@@ -74,7 +74,7 @@ export class GlobalLogger {
|
||||
} else {
|
||||
return a.toString();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const styles = LoggerStyles[level];
|
||||
const message = ['%c' + context.source, styles, ...processedArgs];
|
||||
|
||||
@@ -12,7 +12,7 @@ export function QOIdecodeJS(
|
||||
arrayBuffer: ArrayBuffer,
|
||||
byteOffset: number | null,
|
||||
byteLength: number | null,
|
||||
outputChannels: number | null
|
||||
outputChannels: number | null,
|
||||
): {
|
||||
channels: number;
|
||||
data: Uint8Array;
|
||||
@@ -58,19 +58,19 @@ export function QOIdecodeJS(
|
||||
|
||||
if (channels < 3 || channels > 4) {
|
||||
throw new Error(
|
||||
'QOI.decode: The number of channels declared in the file is invalid'
|
||||
'QOI.decode: The number of channels declared in the file is invalid',
|
||||
);
|
||||
}
|
||||
|
||||
if (colorspace > 1) {
|
||||
throw new Error(
|
||||
'QOI.decode: The colorspace declared in the file is invalid'
|
||||
'QOI.decode: The colorspace declared in the file is invalid',
|
||||
);
|
||||
}
|
||||
|
||||
if (outputChannels < 3 || outputChannels > 4) {
|
||||
throw new Error(
|
||||
'QOI.decode: The number of channels for the output is invalid'
|
||||
'QOI.decode: The number of channels for the output is invalid',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export function QOIencodeJS(
|
||||
height: number;
|
||||
channels: number;
|
||||
colorspace: number;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const width = description.width;
|
||||
const height = description.height;
|
||||
@@ -53,7 +53,7 @@ export function QOIencodeJS(
|
||||
colorData.constructor.name !== 'Uint8ClampedArray'
|
||||
) {
|
||||
throw new Error(
|
||||
'QOI.encode: The provided colorData must be instance of Uint8Array or Uint8ClampedArray'
|
||||
'QOI.encode: The provided colorData must be instance of Uint8Array or Uint8ClampedArray',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export function QOIencodeJS(
|
||||
|
||||
if (colorspace !== 0 && colorspace !== 1) {
|
||||
throw new Error(
|
||||
'QOI.encode: Invalid description.colorspace, must be 0 or 1'
|
||||
'QOI.encode: Invalid description.colorspace, must be 0 or 1',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { throttleTime } from 'rxjs';
|
||||
|
||||
export const Throttle = <T>(time: number) => throttleTime<T>(time, undefined, { leading: true, trailing: true });
|
||||
export const Throttle = <T>(time: number) =>
|
||||
throttleTime<T>(time, undefined, { leading: true, trailing: true });
|
||||
|
||||
@@ -13,7 +13,7 @@ export class ApiErrorService {
|
||||
|
||||
constructor(
|
||||
private apiSerivce: ApiService,
|
||||
private utilService: UtilService
|
||||
private utilService: UtilService,
|
||||
) {
|
||||
this.subscribeErrors();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// .button-red {
|
||||
// background-color: #c62828;
|
||||
// }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user