diff --git a/web/src/lib/components/asset-viewer/album-list-item.svelte b/web/src/lib/components/asset-viewer/album-list-item.svelte new file mode 100644 index 0000000000..9ab281b740 --- /dev/null +++ b/web/src/lib/components/asset-viewer/album-list-item.svelte @@ -0,0 +1,39 @@ + + + diff --git a/web/src/lib/components/asset-viewer/album-selection-modal.svelte b/web/src/lib/components/asset-viewer/album-selection-modal.svelte new file mode 100644 index 0000000000..86f5effb1f --- /dev/null +++ b/web/src/lib/components/asset-viewer/album-selection-modal.svelte @@ -0,0 +1,95 @@ + + + dispatch('close')}> + + +

+ Add to {#if shared}shared {/if} +

+
+
+ +
+
+ {#if loading} + {#each { length: 3 } as _} +
+
+
+ +
+ + +
+
+
+ {/each} + {:else} + + {#if albums.length > 0} +

RECENT

+ {#each recentAlbums as album} + {#key album.id} + handleSelect(album)} /> + {/key} + {/each} + +

ALL ALBUMS

+ {#each albums as album} + {#key album.id} + handleSelect(album)} /> + {/key} + {/each} + {:else} +

It looks like you do not have any albums yet.

+ {/if} + {/if} +
+
+ diff --git a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte index 1cd4e6da23..a5a3ad1d5f 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte @@ -4,9 +4,30 @@ import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte'; import CloudDownloadOutline from 'svelte-material-icons/CloudDownloadOutline.svelte'; import InformationOutline from 'svelte-material-icons/InformationOutline.svelte'; + import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; import DeleteOutline from 'svelte-material-icons/DeleteOutline.svelte'; import CircleIconButton from '../shared-components/circle-icon-button.svelte'; + import ContextMenu from '../shared-components/context-menu/context-menu.svelte'; + import MenuOption from '../shared-components/context-menu/menu-option.svelte'; + const dispatch = createEventDispatcher(); + + let contextMenuPosition = { x: 0, y: 0 }; + let isShowAssetOptions = false; + + const showOptionsMenu = (event: CustomEvent) => { + contextMenuPosition = { + x: event.detail.mouseEvent.x, + y: event.detail.mouseEvent.y + }; + + isShowAssetOptions = !isShowAssetOptions; + }; + + const onMenuClick = (eventName: string) => { + isShowAssetOptions = false; + dispatch(eventName); + };
dispatch('download')} /> dispatch('delete')} /> dispatch('showDetail')} /> + showOptionsMenu(event)} />
+ +{#if isShowAssetOptions} + (isShowAssetOptions = false)}> +
+ onMenuClick('addToAlbum')} text="Add to Album" /> + onMenuClick('addToSharedAlbum')} text="Add to Shared Album" /> +
+
+{/if} diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte index 9cad61119b..fd1fb70f5f 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte @@ -6,9 +6,17 @@ import ChevronLeft from 'svelte-material-icons/ChevronLeft.svelte'; import PhotoViewer from './photo-viewer.svelte'; import DetailPanel from './detail-panel.svelte'; + import { goto } from '$app/navigation'; import { downloadAssets } from '$lib/stores/download'; import VideoViewer from './video-viewer.svelte'; - import { api, AssetResponseDto, AssetTypeEnum, AlbumResponseDto } from '@api'; + import AlbumSelectionModal from './album-selection-modal.svelte'; + import { + api, + AddAssetsResponseDto, + AssetResponseDto, + AssetTypeEnum, + AlbumResponseDto + } from '@api'; import { notificationController, NotificationType @@ -29,6 +37,8 @@ let halfRightHover = false; let isShowDetail = false; let appearsInAlbums: AlbumResponseDto[] = []; + let isShowAlbumPicker = false; + let addToSharedAlbum = true; const onKeyboardPress = (keyInfo: KeyboardEvent) => handleKeyboardPress(keyInfo.key); @@ -167,6 +177,39 @@ console.error('Error deleteSelectedAssetHandler', e); } }; + + const openAlbumPicker = (shared: boolean) => { + isShowAlbumPicker = true; + addToSharedAlbum = shared; + }; + + const showAddNotification = (dto: AddAssetsResponseDto) => { + notificationController.show({ + message: `Added ${dto.successfullyAdded} to ${dto.album?.albumName}`, + type: NotificationType.Info + }); + + if (dto.successfullyAdded === 1 && dto.album) { + appearsInAlbums = [...appearsInAlbums, dto.album]; + } + }; + + const handleAddToNewAlbum = () => { + isShowAlbumPicker = false; + api.albumApi.createAlbum({ albumName: 'Untitled', assetIds: [asset.id] }).then((response) => { + const album = response.data; + goto('/albums/' + album.id); + }); + }; + + const handleAddToAlbum = async (event: CustomEvent<{ album: AlbumResponseDto }>) => { + isShowAlbumPicker = false; + const album = event.detail.album; + + api.albumApi + .addAssetsToAlbum(album.id, { assetIds: [asset.id] }) + .then((response) => showAddNotification(response.data)); + };
openAlbumPicker(false)} + on:addToSharedAlbum={() => openAlbumPicker(true)} /> @@ -246,6 +291,17 @@ (isShowDetail = false)} /> {/if} + + {#if isShowAlbumPicker} + (isShowAlbumPicker = false)} + /> +
Hello
+ {/if}