Adapt web client to consume new server response format

This commit is contained in:
Min Idzelis
2025-04-29 13:45:40 +00:00
parent 077703adcc
commit bc5d4b45a6
17 changed files with 367 additions and 60 deletions

View File

@@ -2,7 +2,7 @@ import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsInt, IsString, Min } from 'class-validator';
import { AssetOrder } from 'src/enum';
import { TimeBucketAssets, TimelineStack } from 'src/services/timeline.service.types';
import { AssetDescription, TimeBucketAssets, TimelineStack } from 'src/services/timeline.service.types';
import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation';
export class TimeBucketDto {
@@ -64,6 +64,13 @@ export class TimelineStackResponseDto implements TimelineStack {
assetCount!: number;
}
export class TimelineAssetDescriptionDto implements AssetDescription {
@ApiProperty()
city!: string | null;
@ApiProperty()
country!: string | null;
}
export class TimeBucketAssetResponseDto implements TimeBucketAssets {
@ApiProperty({ type: [String] })
id: string[] = [];
@@ -154,6 +161,9 @@ export class TimeBucketAssetResponseDto implements TimeBucketAssets {
},
})
livePhotoVideoId: (string | number)[] = [];
@ApiProperty()
description: TimelineAssetDescriptionDto[] = [];
}
export class TimeBucketsResponseDto {

View File

@@ -701,7 +701,14 @@ export class AssetRepository {
'livePhotoVideoId',
])
.leftJoin('exif', 'assets.id', 'exif.assetId')
.select(['exif.exifImageHeight as height', 'exifImageWidth as width', 'exif.orientation', 'exif.projectionType'])
.select([
'exif.exifImageHeight as height',
'exifImageWidth as width',
'exif.orientation',
'exif.projectionType',
'exif.city as city',
'exif.country as country',
])
.$if(!!options.albumId, (qb) =>
qb
.innerJoin('albums_assets_assets', 'albums_assets_assets.assetsId', 'assets.id')

View File

@@ -58,6 +58,7 @@ export class TimelineService extends BaseService {
duration: [],
projectionType: [],
livePhotoVideoId: [],
description: [],
};
for (const item of items) {
let width = item.width!;
@@ -82,6 +83,10 @@ export class TimelineService extends BaseService {
bucketAssets.livePhotoVideoId.push(item.livePhotoVideoId || 0);
bucketAssets.isImage.push(item.type === AssetType.IMAGE ? 1 : 0);
bucketAssets.isVideo.push(item.type === AssetType.VIDEO ? 1 : 0);
bucketAssets.description.push({
city: item.city,
country: item.country,
});
}
return {

View File

@@ -4,6 +4,11 @@ export type TimelineStack = {
assetCount: number;
};
export type AssetDescription = {
city: string | null;
country: string | null;
};
export type TimeBucketAssets = {
id: string[];
ownerId: string[];
@@ -19,4 +24,5 @@ export type TimeBucketAssets = {
duration: (string | number)[];
projectionType: (string | number)[];
livePhotoVideoId: (string | number)[];
description: AssetDescription[];
};