mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(web): manual stacking asset (#4650)
Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
72dcde9e0f
commit
8b5b6d0821
22 changed files with 437 additions and 82 deletions
|
|
@ -1841,6 +1841,14 @@
|
|||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "withStacked",
|
||||
"required": false,
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timeBucket",
|
||||
"required": true,
|
||||
|
|
@ -1961,6 +1969,14 @@
|
|||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "withStacked",
|
||||
"required": false,
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "key",
|
||||
"required": false,
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ export class AssetService {
|
|||
await this.timeBucketChecks(authUser, dto);
|
||||
const assets = await this.assetRepository.getByTimeBucket(dto.timeBucket, dto);
|
||||
if (authUser.isShowMetadata) {
|
||||
return assets.map((asset) => mapAsset(asset));
|
||||
return assets.map((asset) => mapAsset(asset, { withStack: true }));
|
||||
} else {
|
||||
return assets.map((asset) => mapAsset(asset, { stripMetadata: true }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ export class TimeBucketDto {
|
|||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
isTrashed?: boolean;
|
||||
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
withStacked?: boolean;
|
||||
}
|
||||
|
||||
export class TimeBucketAssetDto extends TimeBucketDto {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export interface TimeBucketOptions {
|
|||
albumId?: string;
|
||||
personId?: string;
|
||||
userId?: string;
|
||||
withStacked?: boolean;
|
||||
}
|
||||
|
||||
export interface TimeBucketItem {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ const truncateMap: Record<TimeBucketSize, string> = {
|
|||
};
|
||||
|
||||
const dateTrunc = (options: TimeBucketOptions) =>
|
||||
`(date_trunc('${truncateMap[options.size]}', ("localDateTime" at time zone 'UTC')) at time zone 'UTC')::timestamptz`;
|
||||
`(date_trunc('${
|
||||
truncateMap[options.size]
|
||||
}', (asset."localDateTime" at time zone 'UTC')) at time zone 'UTC')::timestamptz`;
|
||||
|
||||
@Injectable()
|
||||
export class AssetRepository implements IAssetRepository {
|
||||
|
|
@ -505,13 +507,14 @@ export class AssetRepository implements IAssetRepository {
|
|||
}
|
||||
|
||||
private getBuilder(options: TimeBucketOptions) {
|
||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userId } = options;
|
||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userId, withStacked } = options;
|
||||
|
||||
let builder = this.repository
|
||||
.createQueryBuilder('asset')
|
||||
.where('asset.isVisible = true')
|
||||
.andWhere('asset.fileCreatedAt < NOW()')
|
||||
.leftJoinAndSelect('asset.exifInfo', 'exifInfo');
|
||||
.leftJoinAndSelect('asset.exifInfo', 'exifInfo')
|
||||
.leftJoinAndSelect('asset.stack', 'stack');
|
||||
|
||||
if (albumId) {
|
||||
builder = builder.leftJoin('asset.albums', 'album').andWhere('album.id = :albumId', { albumId });
|
||||
|
|
@ -540,11 +543,9 @@ export class AssetRepository implements IAssetRepository {
|
|||
.andWhere('person.id = :personId', { personId });
|
||||
}
|
||||
|
||||
// Hide stack children only in main timeline
|
||||
// Uncomment after adding support for stacked assets in web client
|
||||
// if (!isArchived && !isFavorite && !personId && !albumId && !isTrashed) {
|
||||
// builder = builder.andWhere('asset.stackParent IS NULL');
|
||||
// }
|
||||
if (withStacked) {
|
||||
builder = builder.andWhere('asset.stackParentId IS NULL');
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue