mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-12 14:55:39 +01:00
Refactor shared components
This commit is contained in:
@@ -71,7 +71,7 @@ export class ImageDBService {
|
||||
|
||||
return {
|
||||
results: found,
|
||||
totalResults: amount,
|
||||
total: amount,
|
||||
page,
|
||||
pages: Math.ceil(amount / count),
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.dto';
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.enum';
|
||||
import { AsyncFailable, Fail } from 'picsur-shared/dist/types';
|
||||
import { In, LessThan, Repository } from 'typeorm';
|
||||
import { EImageDerivativeBackend } from '../../models/entities/image-derivative.entity';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { PrefValueType } from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum';
|
||||
import { generateRandomString } from 'picsur-shared/dist/util/random';
|
||||
import { EarlyJwtConfigService } from '../../config/early/early-jwt.config.service';
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
DecodedSysPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings,
|
||||
PrefValueTypeStrings
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
SysPreferenceList,
|
||||
SysPreferenceValueTypes,
|
||||
SysPreferenceValueTypes
|
||||
} from '../../models/constants/syspreferences.const';
|
||||
import {
|
||||
ESysPreferenceBackend,
|
||||
ESysPreferenceSchema,
|
||||
ESysPreferenceSchema
|
||||
} from '../../models/entities/sys-preference.entity';
|
||||
import { MutexFallBack } from '../../models/util/mutex-fallback';
|
||||
import { PreferenceCommonService } from './preference-common.service';
|
||||
|
||||
@@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
DecodedUsrPref,
|
||||
PrefValueType,
|
||||
PrefValueTypeStrings,
|
||||
PrefValueTypeStrings
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
UsrPreferenceList,
|
||||
UsrPreferenceValueTypes,
|
||||
UsrPreferenceValueTypes
|
||||
} from '../../models/constants/usrpreferences.const';
|
||||
import {
|
||||
EUsrPreferenceBackend,
|
||||
EUsrPreferenceSchema,
|
||||
EUsrPreferenceSchema
|
||||
} from '../../models/entities/usr-preference.entity';
|
||||
import { MutexFallBack } from '../../models/util/mutex-fallback';
|
||||
import { PreferenceCommonService } from './preference-common.service';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import {
|
||||
AsyncFailable,
|
||||
Fail,
|
||||
HasFailed,
|
||||
HasSuccess,
|
||||
HasSuccess
|
||||
} from 'picsur-shared/dist/types';
|
||||
import { FindResult } from 'picsur-shared/dist/types/find-result';
|
||||
import { makeUnique } from 'picsur-shared/dist/util/unique';
|
||||
@@ -14,12 +14,12 @@ import { Repository } from 'typeorm';
|
||||
import { Permissions } from '../../models/constants/permissions.const';
|
||||
import {
|
||||
DefaultRolesList,
|
||||
SoulBoundRolesList,
|
||||
SoulBoundRolesList
|
||||
} from '../../models/constants/roles.const';
|
||||
import {
|
||||
ImmutableUsersList,
|
||||
LockedLoginUsersList,
|
||||
UndeletableUsersList,
|
||||
UndeletableUsersList
|
||||
} from '../../models/constants/special-users.const';
|
||||
import { EUserBackend } from '../../models/entities/user.entity';
|
||||
import { GetCols } from '../../models/util/collection';
|
||||
@@ -228,7 +228,7 @@ export class UsersService {
|
||||
|
||||
return {
|
||||
results: users,
|
||||
totalResults: amount,
|
||||
total: amount,
|
||||
page,
|
||||
pages: Math.ceil(amount / count),
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@ import ms from 'ms';
|
||||
import { ImageRequestParams } from 'picsur-shared/dist/dto/api/image.dto';
|
||||
import {
|
||||
FullMime,
|
||||
SupportedMimeCategory,
|
||||
SupportedMimeCategory
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SysPreferenceService } from '../../collections/preference-db/sys-preference-db.service';
|
||||
import { SharpWrapper } from '../../workers/sharp.wrapper';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Logger, Module, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
||||
import ms from 'ms';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { ImageDBModule } from '../../collections/image-db/image-db.module';
|
||||
import { ImageFileDBService } from '../../collections/image-db/image-file-db.service';
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import Crypto from 'crypto';
|
||||
import { fileTypeFromBuffer, FileTypeResult } from 'file-type';
|
||||
import { ImageRequestParams } from 'picsur-shared/dist/dto/api/image.dto';
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.dto';
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.enum';
|
||||
import { FullMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum';
|
||||
import { AsyncFailable, Fail, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { FindResult } from 'picsur-shared/dist/types/find-result';
|
||||
import { ParseMime } from 'picsur-shared/dist/util/parse-mime';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Config
|
||||
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
export { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
export { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
|
||||
// Derivatives
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PrefValueTypeStrings } 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.enum';
|
||||
|
||||
export type SysPreferences = SysPreference[];
|
||||
export const SysPreferenceList: string[] = Object.values(SysPreference);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PrefValueTypeStrings } 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.enum';
|
||||
|
||||
export type UsrPreferences = UsrPreference[];
|
||||
export const UsrPreferenceList: string[] = Object.values(UsrPreference);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.dto';
|
||||
import { ImageFileType } from 'picsur-shared/dist/dto/image-file-types.enum';
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn, Unique } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Controller, Get, Request } from '@nestjs/common';
|
||||
import { UserInfoResponse } from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { RequiredPermissions } from '../../../decorators/permissions.decorator';
|
||||
import { ReqUserID } from '../../../decorators/request-user.decorator';
|
||||
import { Returns } from '../../../decorators/returns.decorator';
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Param,
|
||||
Post,
|
||||
Post
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
UpdatePreferenceResponse
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SysPreferenceService } from '../../../collections/preference-db/sys-preference-db.service';
|
||||
@@ -36,7 +36,7 @@ export class SysPrefController {
|
||||
}
|
||||
|
||||
return {
|
||||
preferences: prefs,
|
||||
results: prefs,
|
||||
total: prefs.length,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Param,
|
||||
Post,
|
||||
Post
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
UpdatePreferenceResponse
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsrPreferenceService } from '../../../collections/preference-db/usr-preference-db.service';
|
||||
@@ -39,7 +39,7 @@ export class UsrPrefController {
|
||||
}
|
||||
|
||||
return {
|
||||
preferences: prefs,
|
||||
results: prefs,
|
||||
total: prefs.length,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
Post
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
RoleCreateRequest,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
RoleListResponse,
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse,
|
||||
SpecialRolesResponse,
|
||||
SpecialRolesResponse
|
||||
} from 'picsur-shared/dist/dto/api/roles.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { RolesService } from '../../../collections/role-db/role-db.service';
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
DefaultRolesList,
|
||||
ImmutableRolesList,
|
||||
SoulBoundRolesList,
|
||||
UndeletableRolesList,
|
||||
UndeletableRolesList
|
||||
} from '../../../models/constants/roles.const';
|
||||
import { isPermissionsArray } from '../../../models/validators/permissions.validator';
|
||||
|
||||
@@ -52,7 +52,7 @@ export class RolesController {
|
||||
}
|
||||
|
||||
return {
|
||||
roles,
|
||||
results: roles,
|
||||
total: roles.length,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
Post
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
GetSpecialUsersResponse,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
UserListRequest,
|
||||
UserListResponse,
|
||||
UserUpdateRequest,
|
||||
UserUpdateResponse,
|
||||
UserUpdateResponse
|
||||
} from 'picsur-shared/dist/dto/api/user-manage.dto';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsersService } from '../../../collections/user-db/user-db.service';
|
||||
@@ -27,7 +27,7 @@ import { Permission } from '../../../models/constants/permissions.const';
|
||||
import {
|
||||
ImmutableUsersList,
|
||||
LockedLoginUsersList,
|
||||
UndeletableUsersList,
|
||||
UndeletableUsersList
|
||||
} from '../../../models/constants/special-users.const';
|
||||
import { EUserBackend2EUser } from '../../../models/transformers/user.transformer';
|
||||
|
||||
@@ -49,12 +49,8 @@ export class UserAdminController {
|
||||
throw new InternalServerErrorException('Could not list users');
|
||||
}
|
||||
|
||||
return {
|
||||
users: found.results.map(EUserBackend2EUser),
|
||||
page: found.page,
|
||||
pages: found.pages,
|
||||
total: found.totalResults,
|
||||
};
|
||||
found.results = found.results.map(EUserBackend2EUser);
|
||||
return found;
|
||||
}
|
||||
|
||||
@Post('create')
|
||||
|
||||
@@ -4,21 +4,21 @@ import {
|
||||
Controller,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
Post
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ImageDeleteRequest,
|
||||
ImageDeleteResponse,
|
||||
ImageListRequest,
|
||||
ImageListResponse,
|
||||
ImageUploadResponse,
|
||||
ImageUploadResponse
|
||||
} from 'picsur-shared/dist/dto/api/image-manage.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { MultiPart } from '../../decorators/multipart/multipart.decorator';
|
||||
import {
|
||||
HasPermission,
|
||||
RequiredPermissions,
|
||||
RequiredPermissions
|
||||
} from '../../decorators/permissions.decorator';
|
||||
import { ReqUserID } from '../../decorators/request-user.decorator';
|
||||
import { Returns } from '../../decorators/returns.decorator';
|
||||
@@ -71,12 +71,7 @@ export class ImageManageController {
|
||||
throw new InternalServerErrorException('Could not list images');
|
||||
}
|
||||
|
||||
return {
|
||||
images: found.results,
|
||||
page: found.page,
|
||||
pages: found.pages,
|
||||
total: found.totalResults,
|
||||
};
|
||||
return found;
|
||||
}
|
||||
|
||||
@Post('delete')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
Input,
|
||||
OnChanges,
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { FullMime, SupportedMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { FullMime, ImageMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
|
||||
import { URLRegex } from 'picsur-shared/dist/util/common-regex';
|
||||
import { ParseMime } from 'picsur-shared/dist/util/parse-mime';
|
||||
@@ -72,7 +72,7 @@ export class PicsurImgComponent implements OnChanges {
|
||||
const mime = await this.getMime(url);
|
||||
if (HasFailed(mime)) return mime;
|
||||
|
||||
if (mime.mime === SupportedMime.QOI) {
|
||||
if (mime.mime === ImageMime.QOI) {
|
||||
const result = await this.qoiWorker.decode(url);
|
||||
if (HasFailed(result)) return result;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
|
||||
export const UIFriendlyPermissions: {
|
||||
[key in Permission]: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.dto';
|
||||
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
|
||||
|
||||
export const SysPreferenceFriendlyNames: {
|
||||
[key in SysPreference]: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.dto';
|
||||
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum';
|
||||
|
||||
export const UsrPreferenceFriendlyNames: {
|
||||
[key in UsrPreference]: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { SupportedMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { ImageMime } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { EImage } from 'picsur-shared/dist/entities/image.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types/failable';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
@@ -9,7 +9,7 @@ import { ImageService } from 'src/app/services/api/image.service';
|
||||
import { Logger } from 'src/app/services/logger/logger.service';
|
||||
import {
|
||||
BootstrapService,
|
||||
BSScreenSize,
|
||||
BSScreenSize
|
||||
} from 'src/app/util/util-module/bootstrap.service';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
|
||||
@@ -47,13 +47,13 @@ export class ImagesComponent implements OnInit {
|
||||
|
||||
this.subscribeMobile();
|
||||
|
||||
const result = await this.imageService.ListMyImages(24, this.page - 1);
|
||||
if (HasFailed(result)) {
|
||||
return this.logger.error(result.getReason());
|
||||
const list = await this.imageService.ListMyImages(24, this.page - 1);
|
||||
if (HasFailed(list)) {
|
||||
return this.logger.error(list.getReason());
|
||||
}
|
||||
|
||||
this.pages = result.pages;
|
||||
this.images = result.images;
|
||||
this.pages = list.pages;
|
||||
this.images = list.results;
|
||||
}
|
||||
|
||||
@AutoUnsubscribe()
|
||||
@@ -71,7 +71,7 @@ export class ImagesComponent implements OnInit {
|
||||
|
||||
getThumbnailUrl(image: EImage) {
|
||||
return (
|
||||
this.imageService.GetImageURL(image.id, SupportedMime.QOI) + '?height=480'
|
||||
this.imageService.GetImageURL(image.id, ImageMime.QOI) + '?height=480'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { PermissionGuard } from 'src/app/guards/permission.guard';
|
||||
import { PRoutes } from 'src/app/models/dto/picsur-routes.dto';
|
||||
import { ImagesComponent } from './images.component';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { ERole } from 'picsur-shared/dist/entities/role.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { PermissionGuard } from 'src/app/guards/permission.guard';
|
||||
import { PRoutes } from 'src/app/models/dto/picsur-routes.dto';
|
||||
import { SidebarResolverService } from 'src/app/services/sidebar-resolver/sidebar-resolver.service';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { ERole } from 'picsur-shared/dist/entities/role.entity';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n';
|
||||
|
||||
@@ -119,8 +119,8 @@ export class SettingsUsersComponent implements OnInit {
|
||||
pageSize: number,
|
||||
pageIndex: number,
|
||||
): Promise<boolean> {
|
||||
const result = await this.userManageService.getUsers(pageSize, pageIndex);
|
||||
if (HasFailed(result)) {
|
||||
const response = await this.userManageService.getUsers(pageSize, pageIndex);
|
||||
if (HasFailed(response)) {
|
||||
this.utilService.showSnackBar(
|
||||
'Failed to fetch users',
|
||||
SnackBarType.Error,
|
||||
@@ -128,9 +128,9 @@ export class SettingsUsersComponent implements OnInit {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.users.length > 0) {
|
||||
this.dataSubject.next(result.users);
|
||||
this.totalUsers = result.total;
|
||||
if (response.results.length > 0) {
|
||||
this.dataSubject.next(response.results);
|
||||
this.totalUsers = response.total;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { NgxDropzoneChangeEvent } from 'ngx-dropzone';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { debounceTime } from 'rxjs';
|
||||
import { PermissionService } from 'src/app/services/api/permission.service';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
import { UserPassModel } from 'src/app/models/forms-dto/userpass.dto';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto';
|
||||
import { UserPassModel } from 'src/app/models/forms-dto/userpass.dto';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { PermissionGuard } from 'src/app/guards/permission.guard';
|
||||
import { PRoutes } from 'src/app/models/dto/picsur-routes.dto';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.dto';
|
||||
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class';
|
||||
import {
|
||||
AnimMime,
|
||||
FullMime,
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Mime2Ext,
|
||||
SupportedAnimMimes,
|
||||
SupportedImageMimes,
|
||||
SupportedMimeCategory,
|
||||
SupportedMimeCategory
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { EImage } from 'picsur-shared/dist/entities/image.entity';
|
||||
import { EUser } from 'picsur-shared/dist/entities/user.entity';
|
||||
@@ -20,7 +20,7 @@ import { ImageService } from 'src/app/services/api/image.service';
|
||||
import { UtilService } from 'src/app/util/util-module/util.service';
|
||||
import {
|
||||
CustomizeDialogComponent,
|
||||
CustomizeDialogData,
|
||||
CustomizeDialogData
|
||||
} from './customize-dialog/customize-dialog.component';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import { PermissionGuard } from 'src/app/guards/permission.guard';
|
||||
import { PRoutes } from 'src/app/models/dto/picsur-routes.dto';
|
||||
import { ViewComponent } from './view.component';
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
ImageDeleteResponse,
|
||||
ImageListRequest,
|
||||
ImageListResponse,
|
||||
ImageUploadResponse,
|
||||
ImageUploadResponse
|
||||
} from 'picsur-shared/dist/dto/api/image-manage.dto';
|
||||
import {
|
||||
ImageMetaResponse,
|
||||
ImageRequestParams,
|
||||
ImageRequestParams
|
||||
} 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.class';
|
||||
import { Mime2Ext } from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { EImage } from 'picsur-shared/dist/entities/image.entity';
|
||||
import { AsyncFailable } from 'picsur-shared/dist/types';
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
RoleInfoResponse,
|
||||
RoleListResponse,
|
||||
RoleUpdateRequest,
|
||||
RoleUpdateResponse,
|
||||
RoleUpdateResponse
|
||||
} from 'picsur-shared/dist/dto/api/roles.dto';
|
||||
import { ERole } from 'picsur-shared/dist/entities/role.entity';
|
||||
import { AsyncFailable, Open } from 'picsur-shared/dist/types';
|
||||
@@ -22,9 +22,9 @@ export class RolesService {
|
||||
constructor(private api: ApiService) {}
|
||||
|
||||
public async getRoles(): AsyncFailable<ERole[]> {
|
||||
const result = await this.api.get(RoleListResponse, '/api/roles/list');
|
||||
const response = await this.api.get(RoleListResponse, '/api/roles/list');
|
||||
|
||||
return Open(result, 'roles');
|
||||
return Open(response, 'results');
|
||||
}
|
||||
|
||||
public async getRole(name: string): AsyncFailable<ERole> {
|
||||
|
||||
@@ -4,12 +4,12 @@ import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
UpdatePreferenceResponse
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import {
|
||||
DecodedPref,
|
||||
PrefValueType,
|
||||
PrefValueType
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed, Map } from 'picsur-shared/dist/types';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
@@ -67,8 +67,8 @@ export class SysPrefService {
|
||||
);
|
||||
|
||||
return Map(response, (pref) => {
|
||||
this.sysprefObservable.next(pref.preferences);
|
||||
return pref.preferences;
|
||||
this.sysprefObservable.next(pref.results);
|
||||
return pref.results;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import {
|
||||
GetPreferenceResponse,
|
||||
MultiplePreferencesResponse,
|
||||
UpdatePreferenceRequest,
|
||||
UpdatePreferenceResponse,
|
||||
UpdatePreferenceResponse
|
||||
} from 'picsur-shared/dist/dto/api/pref.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions.enum';
|
||||
import {
|
||||
DecodedPref,
|
||||
PrefValueType,
|
||||
PrefValueType
|
||||
} from 'picsur-shared/dist/dto/preferences.dto';
|
||||
import { AsyncFailable, Fail, HasFailed, Map } from 'picsur-shared/dist/types';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
@@ -67,8 +67,8 @@ export class UsrPrefService {
|
||||
);
|
||||
|
||||
return Map(response, (pref) => {
|
||||
this.usrprefObservable.next(pref.preferences);
|
||||
return pref.preferences;
|
||||
this.usrprefObservable.next(pref.results);
|
||||
return pref.results;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ export const ImageListRequestSchema = z.object({
|
||||
export class ImageListRequest extends createZodDto(ImageListRequestSchema) {}
|
||||
|
||||
export const ImageListResponseSchema = z.object({
|
||||
images: z.array(EImageSchema),
|
||||
results: z.array(EImageSchema),
|
||||
total: IsPosInt(),
|
||||
page: IsPosInt(),
|
||||
pages: IsPosInt(),
|
||||
total: IsPosInt(),
|
||||
});
|
||||
export class ImageListResponse extends createZodDto(ImageListResponseSchema) {}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||
import { EImageSchema } from '../../entities/image.entity';
|
||||
import { EUserSchema } from '../../entities/user.entity';
|
||||
import { createZodDto } from '../../util/create-zod-dto';
|
||||
import { ImageFileType } from '../image-file-types.dto';
|
||||
import { ImageFileType } from '../image-file-types.enum';
|
||||
|
||||
const parseBool = (value: unknown): boolean | null => {
|
||||
if (value === true || value === 'true' || value === '1' || value === 'yes')
|
||||
|
||||
@@ -13,7 +13,7 @@ export class GetPreferenceResponse extends createZodDto(
|
||||
|
||||
// Get preferences
|
||||
export const MultiplePreferencesResponseSchema = z.object({
|
||||
preferences: z.array(DecodedPrefSchema),
|
||||
results: z.array(DecodedPrefSchema),
|
||||
total: IsPosInt(),
|
||||
});
|
||||
export class MultiplePreferencesResponse extends createZodDto(
|
||||
|
||||
@@ -16,7 +16,7 @@ export class RoleInfoResponse extends createZodDto(RoleInfoResponseSchema) {}
|
||||
|
||||
// RoleList
|
||||
export const RoleListResponseSchema = z.object({
|
||||
roles: z.array(ERoleSchema),
|
||||
results: z.array(ERoleSchema),
|
||||
total: IsPosInt(),
|
||||
});
|
||||
export class RoleListResponse extends createZodDto(RoleListResponseSchema) {}
|
||||
|
||||
@@ -13,7 +13,7 @@ export const UserListRequestSchema = z.object({
|
||||
export class UserListRequest extends createZodDto(UserListRequestSchema) {}
|
||||
|
||||
export const UserListResponseSchema = z.object({
|
||||
users: z.array(EUserSchema),
|
||||
results: z.array(EUserSchema),
|
||||
page: IsPosInt(),
|
||||
pages: IsPosInt(),
|
||||
total: IsPosInt(),
|
||||
|
||||
@@ -14,13 +14,11 @@ export enum AnimMime {
|
||||
GIF = 'image/gif',
|
||||
}
|
||||
|
||||
export const SupportedMime = { ...ImageMime, ...AnimMime };
|
||||
|
||||
// Derivatives
|
||||
|
||||
export const SupportedImageMimes: string[] = Object.values(ImageMime);
|
||||
export const SupportedAnimMimes: string[] = Object.values(AnimMime);
|
||||
export const SupportedMimes: string[] = Object.values(SupportedMime);
|
||||
export const SupportedMimes: string[] = Object.values({ ...ImageMime, ...AnimMime });
|
||||
|
||||
export enum SupportedMimeCategory {
|
||||
Image = 'image',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export interface FindResult<T> {
|
||||
results: T[];
|
||||
totalResults: number;
|
||||
total: number;
|
||||
|
||||
page: number;
|
||||
pages: number;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
type FCDecorator = MethodDecorator & ClassDecorator;
|
||||
|
||||
// FC = Function, Class
|
||||
export function CombineFCDecorators(...decorators: FCDecorator[]) {
|
||||
return (target: any, key: string, descriptor: PropertyDescriptor) => {
|
||||
decorators.forEach((decorator) => {
|
||||
@@ -8,6 +9,7 @@ export function CombineFCDecorators(...decorators: FCDecorator[]) {
|
||||
};
|
||||
}
|
||||
|
||||
// P = Property
|
||||
export const CombinePDecorators = (
|
||||
...decorators: PropertyDecorator[]
|
||||
): (() => PropertyDecorator) => {
|
||||
|
||||
@@ -2,16 +2,16 @@ import {
|
||||
FullMime,
|
||||
SupportedAnimMimes,
|
||||
SupportedImageMimes,
|
||||
SupportedMimeCategory,
|
||||
SupportedMimeCategory
|
||||
} from '../dto/mimes.dto';
|
||||
import { Fail, Failable } from '../types';
|
||||
|
||||
export function ParseMime(mime: string): Failable<FullMime> {
|
||||
if (SupportedImageMimes.includes(mime)) {
|
||||
if (SupportedImageMimes.includes(mime))
|
||||
return { mime, type: SupportedMimeCategory.Image };
|
||||
}
|
||||
if (SupportedAnimMimes.includes(mime)) {
|
||||
|
||||
if (SupportedAnimMimes.includes(mime))
|
||||
return { mime, type: SupportedMimeCategory.Animation };
|
||||
}
|
||||
|
||||
return Fail('Unsupported mime type');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user