Skip to content

Commit

Permalink
feat(server/web): album description (immich-app#3558)
Browse files Browse the repository at this point in the history
* feat(server): add album description

* chore: open api

* fix: tests

* show and edit description on the web

* fix test

* remove unused code

* type event

* format fix

---------

Co-authored-by: Alex Tran <[email protected]>
  • Loading branch information
jrasm91 and alextran1502 authored Aug 6, 2023
1 parent deaf81e commit 2f26a7e
Show file tree
Hide file tree
Showing 28 changed files with 287 additions and 41 deletions.
18 changes: 18 additions & 0 deletions cli/src/api/open-api/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/openapi/doc/AlbumResponseDto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/openapi/doc/CreateAlbumDto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/openapi/doc/UpdateAlbumDto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion mobile/openapi/lib/model/album_response_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion mobile/openapi/lib/model/create_album_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions mobile/openapi/lib/model/update_album_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions mobile/openapi/test/album_response_dto_test.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions mobile/openapi/test/create_album_dto_test.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions mobile/openapi/test/update_album_dto_test.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions server/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4754,6 +4754,9 @@
"format": "date-time",
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string"
},
Expand Down Expand Up @@ -4786,6 +4789,7 @@
"id",
"ownerId",
"albumName",
"description",
"createdAt",
"updatedAt",
"albumThumbnailAssetId",
Expand Down Expand Up @@ -5264,6 +5268,9 @@
},
"type": "array"
},
"description": {
"type": "string"
},
"sharedWithUserIds": {
"items": {
"format": "uuid",
Expand Down Expand Up @@ -6903,6 +6910,9 @@
"albumThumbnailAssetId": {
"format": "uuid",
"type": "string"
},
"description": {
"type": "string"
}
},
"type": "object"
Expand Down
32 changes: 7 additions & 25 deletions server/src/domain/album/album-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class AlbumResponseDto {
id!: string;
ownerId!: string;
albumName!: string;
description!: string;
createdAt!: Date;
updatedAt!: Date;
albumThumbnailAssetId!: string | null;
Expand All @@ -19,7 +20,7 @@ export class AlbumResponseDto {
lastModifiedAssetTimestamp?: Date;
}

export function mapAlbum(entity: AlbumEntity): AlbumResponseDto {
const _map = (entity: AlbumEntity, withAssets: boolean): AlbumResponseDto => {
const sharedUsers: UserResponseDto[] = [];

entity.sharedUsers?.forEach((user) => {
Expand All @@ -29,6 +30,7 @@ export function mapAlbum(entity: AlbumEntity): AlbumResponseDto {

return {
albumName: entity.albumName,
description: entity.description,
albumThumbnailAssetId: entity.albumThumbnailAssetId,
createdAt: entity.createdAt,
updatedAt: entity.updatedAt,
Expand All @@ -37,33 +39,13 @@ export function mapAlbum(entity: AlbumEntity): AlbumResponseDto {
owner: mapUser(entity.owner),
sharedUsers,
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
assets: entity.assets?.map((asset) => mapAsset(asset)) || [],
assets: withAssets ? entity.assets?.map((asset) => mapAsset(asset)) || [] : [],
assetCount: entity.assets?.length || 0,
};
}

export function mapAlbumExcludeAssetInfo(entity: AlbumEntity): AlbumResponseDto {
const sharedUsers: UserResponseDto[] = [];
};

entity.sharedUsers?.forEach((user) => {
const userDto = mapUser(user);
sharedUsers.push(userDto);
});

return {
albumName: entity.albumName,
albumThumbnailAssetId: entity.albumThumbnailAssetId,
createdAt: entity.createdAt,
updatedAt: entity.updatedAt,
id: entity.id,
ownerId: entity.ownerId,
owner: mapUser(entity.owner),
sharedUsers,
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
assets: [],
assetCount: entity.assets?.length || 0,
};
}
export const mapAlbum = (entity: AlbumEntity) => _map(entity, true);
export const mapAlbumExcludeAssetInfo = (entity: AlbumEntity) => _map(entity, false);

export class AlbumCountResponseDto {
@ApiProperty({ type: 'integer' })
Expand Down
1 change: 1 addition & 0 deletions server/src/domain/album/album.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ describe(AlbumService.name, () => {

await expect(sut.create(authStub.admin, { albumName: 'Empty album' })).resolves.toEqual({
albumName: 'Empty album',
description: '',
albumThumbnailAssetId: null,
assetCount: 0,
assets: [],
Expand Down
Loading

0 comments on commit 2f26a7e

Please sign in to comment.