mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
f33dbdfe9a
* Add Exif-Rating * Integrate star rating as own component * Add e2e tests for rating and validation * Rename component and async handleChangeRating * Display rating can be enabled in app settings * Correct i18n reference Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * Star rating: change from slider to buttons * Star rating for clarity * Design updates. * Renaming and code optimization * chore: clean up * chore: e2e formatting * light mode border and default value --------- Co-authored-by: Christoph Suter <christoph@suter-burri.ch> Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
125 lines
2.6 KiB
TypeScript
125 lines
2.6 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import { IsDateString, IsEnum, IsInt, IsPositive, ValidateNested } from 'class-validator';
|
|
import { UserAvatarColor, UserPreferences } from 'src/entities/user-metadata.entity';
|
|
import { Optional, ValidateBoolean } from 'src/validation';
|
|
|
|
class AvatarUpdate {
|
|
@Optional()
|
|
@IsEnum(UserAvatarColor)
|
|
@ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor })
|
|
color?: UserAvatarColor;
|
|
}
|
|
|
|
class MemoryUpdate {
|
|
@ValidateBoolean({ optional: true })
|
|
enabled?: boolean;
|
|
}
|
|
|
|
class RatingUpdate {
|
|
@ValidateBoolean({ optional: true })
|
|
enabled?: boolean;
|
|
}
|
|
|
|
class EmailNotificationsUpdate {
|
|
@ValidateBoolean({ optional: true })
|
|
enabled?: boolean;
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
albumInvite?: boolean;
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
albumUpdate?: boolean;
|
|
}
|
|
|
|
class DownloadUpdate {
|
|
@Optional()
|
|
@IsInt()
|
|
@IsPositive()
|
|
@ApiProperty({ type: 'integer' })
|
|
archiveSize?: number;
|
|
}
|
|
|
|
class PurchaseUpdate {
|
|
@ValidateBoolean({ optional: true })
|
|
showSupportBadge?: boolean;
|
|
|
|
@IsDateString()
|
|
@Optional()
|
|
hideBuyButtonUntil?: string;
|
|
}
|
|
|
|
export class UserPreferencesUpdateDto {
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => RatingUpdate)
|
|
rating?: RatingUpdate;
|
|
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => AvatarUpdate)
|
|
avatar?: AvatarUpdate;
|
|
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => MemoryUpdate)
|
|
memories?: MemoryUpdate;
|
|
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => EmailNotificationsUpdate)
|
|
emailNotifications?: EmailNotificationsUpdate;
|
|
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => DownloadUpdate)
|
|
download?: DownloadUpdate;
|
|
|
|
@Optional()
|
|
@ValidateNested()
|
|
@Type(() => PurchaseUpdate)
|
|
purchase?: PurchaseUpdate;
|
|
}
|
|
|
|
class AvatarResponse {
|
|
@ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor })
|
|
color!: UserAvatarColor;
|
|
}
|
|
|
|
class RatingResponse {
|
|
enabled!: boolean;
|
|
}
|
|
|
|
class MemoryResponse {
|
|
enabled!: boolean;
|
|
}
|
|
|
|
class EmailNotificationsResponse {
|
|
enabled!: boolean;
|
|
albumInvite!: boolean;
|
|
albumUpdate!: boolean;
|
|
}
|
|
|
|
class DownloadResponse {
|
|
@ApiProperty({ type: 'integer' })
|
|
archiveSize!: number;
|
|
}
|
|
|
|
class PurchaseResponse {
|
|
showSupportBadge!: boolean;
|
|
hideBuyButtonUntil!: string;
|
|
}
|
|
|
|
export class UserPreferencesResponseDto implements UserPreferences {
|
|
rating!: RatingResponse;
|
|
memories!: MemoryResponse;
|
|
avatar!: AvatarResponse;
|
|
emailNotifications!: EmailNotificationsResponse;
|
|
download!: DownloadResponse;
|
|
purchase!: PurchaseResponse;
|
|
}
|
|
|
|
export const mapPreferences = (preferences: UserPreferences): UserPreferencesResponseDto => {
|
|
return preferences;
|
|
};
|