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