mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(server/web): album description (#3558)
* 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 <alex.tran1502@gmail.com>
This commit is contained in:
parent
deaf81e2a4
commit
2f26a7edae
28 changed files with 287 additions and 41 deletions
|
|
@ -44,6 +44,7 @@
|
|||
import { handleError } from '../../utils/handle-error';
|
||||
import { downloadArchive } from '../../utils/asset-utils';
|
||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||
import EditDescriptionModal from './edit-description-modal.svelte';
|
||||
|
||||
export let album: AlbumResponseDto;
|
||||
export let sharedLink: SharedLinkResponseDto | undefined = undefined;
|
||||
|
|
@ -73,6 +74,7 @@
|
|||
let isShowAlbumOptions = false;
|
||||
let isShowThumbnailSelection = false;
|
||||
let isShowDeleteConfirmation = false;
|
||||
let isEditingDescription = false;
|
||||
|
||||
let backUrl = '/albums';
|
||||
let currentAlbumName = '';
|
||||
|
|
@ -298,6 +300,27 @@
|
|||
const handleSelectAll = () => {
|
||||
multiSelectAsset = new Set(album.assets);
|
||||
};
|
||||
|
||||
const descriptionUpdatedHandler = (description: string) => {
|
||||
try {
|
||||
api.albumApi.updateAlbumInfo({
|
||||
id: album.id,
|
||||
updateAlbumDto: {
|
||||
description,
|
||||
},
|
||||
});
|
||||
|
||||
album.description = description;
|
||||
} catch (e) {
|
||||
console.error('Error [descriptionUpdatedHandler] ', e);
|
||||
notificationController.show({
|
||||
type: NotificationType.Error,
|
||||
message: 'Error setting album description, check console for more details',
|
||||
});
|
||||
}
|
||||
|
||||
isEditingDescription = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
<section class="bg-immich-bg dark:bg-immich-dark-bg" class:hidden={isShowThumbnailSelection}>
|
||||
|
|
@ -405,6 +428,7 @@
|
|||
{/if}
|
||||
|
||||
<section class="my-[160px] flex flex-col px-6 sm:px-12 md:px-24 lg:px-40">
|
||||
<!-- ALBUM TITLE -->
|
||||
<input
|
||||
on:keydown={(e) => {
|
||||
if (e.key == 'Enter') {
|
||||
|
|
@ -421,8 +445,10 @@
|
|||
bind:value={album.albumName}
|
||||
disabled={!isOwned}
|
||||
bind:this={titleInput}
|
||||
title="Edit Title"
|
||||
/>
|
||||
|
||||
<!-- ALBUM SUMMARY -->
|
||||
{#if album.assetCount > 0}
|
||||
<span class="my-4 flex gap-2 text-sm font-medium text-gray-500" data-testid="album-details">
|
||||
<p class="">{getDateRange()}</p>
|
||||
|
|
@ -448,6 +474,17 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- ALBUM DESCRIPTION -->
|
||||
<button
|
||||
class="mb-12 mt-6 w-full border-b-2 border-transparent pb-2 text-left text-lg font-medium transition-colors hover:border-b-2 dark:text-gray-300"
|
||||
on:click={() => (isEditingDescription = true)}
|
||||
class:hover:border-gray-400={isOwned}
|
||||
disabled={!isOwned}
|
||||
title="Edit description"
|
||||
>
|
||||
{album.description || 'Add description'}
|
||||
</button>
|
||||
|
||||
{#if album.assetCount > 0 && !isShowAssetSelection}
|
||||
<GalleryViewer assets={album.assets} {sharedLink} bind:selectedAssets={multiSelectAsset} />
|
||||
{:else}
|
||||
|
|
@ -490,6 +527,7 @@
|
|||
{#if isShowShareLinkModal}
|
||||
<CreateSharedLinkModal on:close={() => (isShowShareLinkModal = false)} shareType={SharedLinkType.Album} {album} />
|
||||
{/if}
|
||||
|
||||
{#if isShowShareInfoModal}
|
||||
<ShareInfoModal on:close={() => (isShowShareInfoModal = false)} {album} on:user-deleted={sharedUserDeletedHandler} />
|
||||
{/if}
|
||||
|
|
@ -515,3 +553,11 @@
|
|||
</svelte:fragment>
|
||||
</ConfirmDialogue>
|
||||
{/if}
|
||||
|
||||
{#if isEditingDescription}
|
||||
<EditDescriptionModal
|
||||
{album}
|
||||
on:close={() => (isEditingDescription = false)}
|
||||
on:updated={({ detail: description }) => descriptionUpdatedHandler(description)}
|
||||
/>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import type { AlbumResponseDto } from '@api';
|
||||
import FullScreenModal from '../shared-components/full-screen-modal.svelte';
|
||||
import Button from '../elements/buttons/button.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
close: void;
|
||||
updated: string;
|
||||
}>();
|
||||
export let album: AlbumResponseDto;
|
||||
|
||||
let description = album.description;
|
||||
|
||||
const handleSave = () => {
|
||||
dispatch('updated', description);
|
||||
};
|
||||
</script>
|
||||
|
||||
<FullScreenModal on:clickOutside={() => dispatch('close')}>
|
||||
<div
|
||||
class="w-[500px] max-w-[95vw] rounded-3xl border bg-immich-bg p-4 py-8 shadow-sm dark:border-immich-dark-gray dark:bg-immich-dark-gray dark:text-immich-dark-fg"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col place-content-center place-items-center gap-4 px-4 text-immich-primary dark:text-immich-dark-primary"
|
||||
>
|
||||
<h1 class="text-2xl font-medium text-immich-primary dark:text-immich-dark-primary">Edit description</h1>
|
||||
</div>
|
||||
|
||||
<form on:submit|preventDefault={handleSave} autocomplete="off">
|
||||
<div class="m-4 flex flex-col gap-2">
|
||||
<label class="immich-form-label" for="email">Description</label>
|
||||
<!-- svelte-ignore a11y-autofocus -->
|
||||
<input class="immich-form-input" id="name" name="name" type="text" bind:value={description} autofocus />
|
||||
</div>
|
||||
|
||||
<div class="mt-8 flex w-full gap-4 px-4">
|
||||
<Button color="gray" fullwidth on:click={() => dispatch('close')}>Cancel</Button>
|
||||
<Button type="submit" fullwidth>Ok</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</FullScreenModal>
|
||||
Loading…
Add table
Add a link
Reference in a new issue