mirror of
https://github.com/immich-app/immich.git
synced 2025-01-19 18:26:46 +01:00
feat(web): show original uploader in shared album photo details (#3977)
* feat(web): show original uploader in shared album photo details * feat: send owner in asset by id response * chore: open api * fix: linting * fix: change to Shared By * openapi * openapi * api * styling --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
b1467bd1da
commit
b4fa60d4fd
11 changed files with 63 additions and 42 deletions
6
cli/src/api/open-api/api.ts
generated
6
cli/src/api/open-api/api.ts
generated
|
@ -645,6 +645,12 @@ export interface AssetResponseDto {
|
||||||
* @memberof AssetResponseDto
|
* @memberof AssetResponseDto
|
||||||
*/
|
*/
|
||||||
'originalPath': string;
|
'originalPath': string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {UserResponseDto}
|
||||||
|
* @memberof AssetResponseDto
|
||||||
|
*/
|
||||||
|
'owner'?: UserResponseDto;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
|
BIN
mobile/openapi/doc/AssetResponseDto.md
generated
BIN
mobile/openapi/doc/AssetResponseDto.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/asset_response_dto.dart
generated
BIN
mobile/openapi/lib/model/asset_response_dto.dart
generated
Binary file not shown.
BIN
mobile/openapi/test/asset_response_dto_test.dart
generated
BIN
mobile/openapi/test/asset_response_dto_test.dart
generated
Binary file not shown.
|
@ -5208,6 +5208,9 @@
|
||||||
"originalPath": {
|
"originalPath": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"owner": {
|
||||||
|
"$ref": "#/components/schemas/UserResponseDto"
|
||||||
|
},
|
||||||
"ownerId": {
|
"ownerId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -5246,8 +5249,8 @@
|
||||||
"type",
|
"type",
|
||||||
"id",
|
"id",
|
||||||
"deviceAssetId",
|
"deviceAssetId",
|
||||||
"ownerId",
|
|
||||||
"deviceId",
|
"deviceId",
|
||||||
|
"ownerId",
|
||||||
"originalPath",
|
"originalPath",
|
||||||
"originalFileName",
|
"originalFileName",
|
||||||
"resized",
|
"resized",
|
||||||
|
|
|
@ -2,14 +2,16 @@ import { AssetEntity, AssetType } from '@app/infra/entities';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { PersonResponseDto, mapFace } from '../../person/person.dto';
|
import { PersonResponseDto, mapFace } from '../../person/person.dto';
|
||||||
import { TagResponseDto, mapTag } from '../../tag';
|
import { TagResponseDto, mapTag } from '../../tag';
|
||||||
|
import { UserResponseDto, mapUser } from '../../user/response-dto/user-response.dto';
|
||||||
import { ExifResponseDto, mapExif } from './exif-response.dto';
|
import { ExifResponseDto, mapExif } from './exif-response.dto';
|
||||||
import { SmartInfoResponseDto, mapSmartInfo } from './smart-info-response.dto';
|
import { SmartInfoResponseDto, mapSmartInfo } from './smart-info-response.dto';
|
||||||
|
|
||||||
export class AssetResponseDto {
|
export class AssetResponseDto {
|
||||||
id!: string;
|
id!: string;
|
||||||
deviceAssetId!: string;
|
deviceAssetId!: string;
|
||||||
ownerId!: string;
|
|
||||||
deviceId!: string;
|
deviceId!: string;
|
||||||
|
ownerId!: string;
|
||||||
|
owner?: UserResponseDto;
|
||||||
|
|
||||||
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
||||||
type!: AssetType;
|
type!: AssetType;
|
||||||
|
@ -33,11 +35,12 @@ export class AssetResponseDto {
|
||||||
checksum!: string;
|
checksum!: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
function _map(entity: AssetEntity, withExif: boolean): AssetResponseDto {
|
||||||
return {
|
return {
|
||||||
id: entity.id,
|
id: entity.id,
|
||||||
deviceAssetId: entity.deviceAssetId,
|
deviceAssetId: entity.deviceAssetId,
|
||||||
ownerId: entity.ownerId,
|
ownerId: entity.ownerId,
|
||||||
|
owner: entity.owner ? mapUser(entity.owner) : undefined,
|
||||||
deviceId: entity.deviceId,
|
deviceId: entity.deviceId,
|
||||||
type: entity.type,
|
type: entity.type,
|
||||||
originalPath: entity.originalPath,
|
originalPath: entity.originalPath,
|
||||||
|
@ -50,7 +53,7 @@ export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
||||||
isFavorite: entity.isFavorite,
|
isFavorite: entity.isFavorite,
|
||||||
isArchived: entity.isArchived,
|
isArchived: entity.isArchived,
|
||||||
duration: entity.duration ?? '0:00:00.00000',
|
duration: entity.duration ?? '0:00:00.00000',
|
||||||
exifInfo: entity.exifInfo ? mapExif(entity.exifInfo) : undefined,
|
exifInfo: withExif ? (entity.exifInfo ? mapExif(entity.exifInfo) : undefined) : undefined,
|
||||||
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
||||||
livePhotoVideoId: entity.livePhotoVideoId,
|
livePhotoVideoId: entity.livePhotoVideoId,
|
||||||
tags: entity.tags?.map(mapTag),
|
tags: entity.tags?.map(mapTag),
|
||||||
|
@ -59,30 +62,12 @@ export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
||||||
|
return _map(entity, true);
|
||||||
|
}
|
||||||
|
|
||||||
export function mapAssetWithoutExif(entity: AssetEntity): AssetResponseDto {
|
export function mapAssetWithoutExif(entity: AssetEntity): AssetResponseDto {
|
||||||
return {
|
return _map(entity, false);
|
||||||
id: entity.id,
|
|
||||||
deviceAssetId: entity.deviceAssetId,
|
|
||||||
ownerId: entity.ownerId,
|
|
||||||
deviceId: entity.deviceId,
|
|
||||||
type: entity.type,
|
|
||||||
originalPath: entity.originalPath,
|
|
||||||
originalFileName: entity.originalFileName,
|
|
||||||
resized: !!entity.resizePath,
|
|
||||||
thumbhash: entity.thumbhash?.toString('base64') || null,
|
|
||||||
fileCreatedAt: entity.fileCreatedAt,
|
|
||||||
fileModifiedAt: entity.fileModifiedAt,
|
|
||||||
updatedAt: entity.updatedAt,
|
|
||||||
isFavorite: entity.isFavorite,
|
|
||||||
isArchived: entity.isArchived,
|
|
||||||
duration: entity.duration ?? '0:00:00.00000',
|
|
||||||
exifInfo: undefined,
|
|
||||||
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
|
||||||
livePhotoVideoId: entity.livePhotoVideoId,
|
|
||||||
tags: entity.tags?.map(mapTag),
|
|
||||||
people: entity.faces?.map(mapFace),
|
|
||||||
checksum: entity.checksum.toString('base64'),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MemoryLaneResponseDto {
|
export class MemoryLaneResponseDto {
|
||||||
|
|
|
@ -107,6 +107,7 @@ export class AssetRepository implements IAssetRepository {
|
||||||
tags: true,
|
tags: true,
|
||||||
sharedLinks: true,
|
sharedLinks: true,
|
||||||
smartInfo: true,
|
smartInfo: true,
|
||||||
|
owner: true,
|
||||||
faces: {
|
faces: {
|
||||||
person: true,
|
person: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -199,6 +199,10 @@ export class AssetService {
|
||||||
data.people = [];
|
data.people = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (authUser.isPublicUser) {
|
||||||
|
delete data.owner;
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
server/test/fixtures/shared-link.stub.ts
vendored
4
server/test/fixtures/shared-link.stub.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
import { AlbumResponseDto, AssetResponseDto, ExifResponseDto, mapUser, SharedLinkResponseDto } from '@app/domain';
|
import { AlbumResponseDto, AssetResponseDto, ExifResponseDto, mapUser, SharedLinkResponseDto } from '@app/domain';
|
||||||
import { AssetType, SharedLinkEntity, SharedLinkType } from '@app/infra/entities';
|
import { AssetType, SharedLinkEntity, SharedLinkType, UserEntity } from '@app/infra/entities';
|
||||||
import { assetStub } from './asset.stub';
|
import { assetStub } from './asset.stub';
|
||||||
import { authStub } from './auth.stub';
|
import { authStub } from './auth.stub';
|
||||||
import { userStub } from './user.stub';
|
import { userStub } from './user.stub';
|
||||||
|
@ -158,7 +158,7 @@ export const sharedLinkStub = {
|
||||||
assets: [
|
assets: [
|
||||||
{
|
{
|
||||||
id: 'id_1',
|
id: 'id_1',
|
||||||
owner: userStub.user1,
|
owner: undefined as unknown as UserEntity,
|
||||||
ownerId: 'user_id_1',
|
ownerId: 'user_id_1',
|
||||||
deviceAssetId: 'device_asset_id_1',
|
deviceAssetId: 'device_asset_id_1',
|
||||||
deviceId: 'device_id_1',
|
deviceId: 'device_id_1',
|
||||||
|
|
6
web/src/api/open-api/api.ts
generated
6
web/src/api/open-api/api.ts
generated
|
@ -645,6 +645,12 @@ export interface AssetResponseDto {
|
||||||
* @memberof AssetResponseDto
|
* @memberof AssetResponseDto
|
||||||
*/
|
*/
|
||||||
'originalPath': string;
|
'originalPath': string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {UserResponseDto}
|
||||||
|
* @memberof AssetResponseDto
|
||||||
|
*/
|
||||||
|
'owner'?: UserResponseDto;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
import { asByteUnitString } from '../../utils/byte-units';
|
import { asByteUnitString } from '../../utils/byte-units';
|
||||||
import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
|
import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
|
||||||
import { getAssetFilename } from '$lib/utils/asset-utils';
|
import { getAssetFilename } from '$lib/utils/asset-utils';
|
||||||
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
|
||||||
export let asset: AssetResponseDto;
|
export let asset: AssetResponseDto;
|
||||||
export let albums: AlbumResponseDto[] = [];
|
export let albums: AlbumResponseDto[] = [];
|
||||||
|
@ -20,6 +21,8 @@
|
||||||
let textarea: HTMLTextAreaElement;
|
let textarea: HTMLTextAreaElement;
|
||||||
let description: string;
|
let description: string;
|
||||||
|
|
||||||
|
$: isOwner = $page?.data?.user?.id === asset.ownerId;
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
// Get latest description from server
|
// Get latest description from server
|
||||||
if (asset.id && !api.isSharedLink) {
|
if (asset.id && !api.isSharedLink) {
|
||||||
|
@ -93,20 +96,17 @@
|
||||||
<p class="text-lg text-immich-fg dark:text-immich-dark-fg">Info</p>
|
<p class="text-lg text-immich-fg dark:text-immich-dark-fg">Info</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section
|
<section class="mx-4 mt-10" style:display={!isOwner && textarea?.value == '' ? 'none' : 'block'}>
|
||||||
class="mx-4 mt-10"
|
|
||||||
style:display={$page?.data?.user?.id !== asset.ownerId && textarea?.value == '' ? 'none' : 'block'}
|
|
||||||
>
|
|
||||||
<textarea
|
<textarea
|
||||||
bind:this={textarea}
|
bind:this={textarea}
|
||||||
class="max-h-[500px]
|
class="max-h-[500px]
|
||||||
w-full resize-none overflow-hidden border-b border-gray-500 bg-transparent text-base text-black outline-none transition-all focus:border-b-2 focus:border-immich-primary disabled:border-none dark:text-white dark:focus:border-immich-dark-primary"
|
w-full resize-none overflow-hidden border-b border-gray-500 bg-transparent text-base text-black outline-none transition-all focus:border-b-2 focus:border-immich-primary disabled:border-none dark:text-white dark:focus:border-immich-dark-primary"
|
||||||
placeholder={$page?.data?.user?.id !== asset.ownerId ? '' : 'Add a description'}
|
placeholder={!isOwner ? '' : 'Add a description'}
|
||||||
on:focusin={handleFocusIn}
|
on:focusin={handleFocusIn}
|
||||||
on:focusout={handleFocusOut}
|
on:focusout={handleFocusOut}
|
||||||
on:input={autoGrowHeight}
|
on:input={autoGrowHeight}
|
||||||
bind:value={description}
|
bind:value={description}
|
||||||
disabled={$page?.data?.user?.id !== asset.ownerId}
|
disabled={!isOwner}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -291,11 +291,27 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<section class="p-2 dark:text-immich-dark-fg">
|
{#if asset.owner && !isOwner}
|
||||||
<div class="px-4 py-4">
|
<section class="px-6 pt-6 dark:text-immich-dark-fg">
|
||||||
{#if albums.length > 0}
|
<p class="text-sm">SHARED BY</p>
|
||||||
<p class="pb-4 text-sm">APPEARS IN</p>
|
<div class="flex gap-4 pt-4">
|
||||||
|
<div>
|
||||||
|
<UserAvatar user={asset.owner} size="md" autoColor />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-auto mt-auto">
|
||||||
|
<p>
|
||||||
|
{asset.owner.firstName}
|
||||||
|
{asset.owner.lastName}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if albums.length > 0}
|
||||||
|
<section class="p-6 dark:text-immich-dark-fg">
|
||||||
|
<p class="pb-4 text-sm">APPEARS IN</p>
|
||||||
{#each albums as album}
|
{#each albums as album}
|
||||||
<a data-sveltekit-preload-data="hover" href={`/albums/${album.id}`}>
|
<a data-sveltekit-preload-data="hover" href={`/albums/${album.id}`}>
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
@ -326,5 +342,5 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue