mirror of
https://github.com/immich-app/immich.git
synced 2025-01-09 13:26:47 +01:00
Add selection of favorites
This commit is contained in:
parent
05e851ef44
commit
026ffbe133
4 changed files with 70 additions and 64 deletions
|
@ -24,6 +24,7 @@
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||||
import DownloadAction from '../photos-page/actions/download-action.svelte';
|
import DownloadAction from '../photos-page/actions/download-action.svelte';
|
||||||
|
import SelectAllAssets from '../photos-page/actions/select-all-assets.svelte';
|
||||||
import RemoveFromAlbum from '../photos-page/actions/remove-from-album.svelte';
|
import RemoveFromAlbum from '../photos-page/actions/remove-from-album.svelte';
|
||||||
import AssetSelectControlBar from '../photos-page/asset-select-control-bar.svelte';
|
import AssetSelectControlBar from '../photos-page/asset-select-control-bar.svelte';
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
@ -341,6 +342,7 @@
|
||||||
assets={multiSelectAsset}
|
assets={multiSelectAsset}
|
||||||
clearSelect={() => (multiSelectAsset = new Set())}
|
clearSelect={() => (multiSelectAsset = new Set())}
|
||||||
>
|
>
|
||||||
|
<SelectAllAssets/>
|
||||||
<DownloadAction filename={album.albumName} sharedLinkKey={sharedLink?.key} />
|
<DownloadAction filename={album.albumName} sharedLinkKey={sharedLink?.key} />
|
||||||
{#if isOwned}
|
{#if isOwned}
|
||||||
<RemoveFromAlbum bind:album />
|
<RemoveFromAlbum bind:album />
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import {api, AssetResponseDto} from '@api';
|
import {api, AssetResponseDto} from '@api';
|
||||||
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
||||||
import TimerSand from 'svelte-material-icons/TimerSand.svelte';
|
import TimerSand from 'svelte-material-icons/TimerSand.svelte';
|
||||||
import {OnSelectAll, getAssetControlContext} from '../asset-select-control-bar.svelte';
|
import {getAssetControlContext} from '../asset-select-control-bar.svelte';
|
||||||
import {
|
import {
|
||||||
assetInteractionStore,
|
assetInteractionStore,
|
||||||
selectedAssets
|
selectedAssets
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
import {AssetGridState} from "$lib/models/asset-grid-state";
|
import {AssetGridState} from "$lib/models/asset-grid-state";
|
||||||
import {sumBy} from "lodash-es";
|
import {sumBy} from "lodash-es";
|
||||||
|
|
||||||
export let onSelectAll: OnSelectAll;
|
|
||||||
|
|
||||||
let selecting = false;
|
let selecting = false;
|
||||||
|
|
||||||
const handleSelectAll = async () => {
|
const handleSelectAll = async () => {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { createContext } from '$lib/utils/context';
|
import { createContext } from '$lib/utils/context';
|
||||||
|
|
||||||
export type OnAssetDelete = (assetId: string) => void;
|
export type OnAssetDelete = (assetId: string) => void;
|
||||||
export type OnSelectAll = (assetId: string) => void;
|
|
||||||
export type OnAssetArchive = (asset: AssetResponseDto, archived: boolean) => void;
|
export type OnAssetArchive = (asset: AssetResponseDto, archived: boolean) => void;
|
||||||
export type OnAssetFavorite = (asset: AssetResponseDto, favorite: boolean) => void;
|
export type OnAssetFavorite = (asset: AssetResponseDto, favorite: boolean) => void;
|
||||||
|
|
||||||
|
|
|
@ -1,75 +1,82 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
|
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
|
||||||
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
|
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
|
||||||
import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte';
|
import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte';
|
||||||
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
||||||
import DownloadAction from '$lib/components/photos-page/actions/download-action.svelte';
|
import DownloadAction from '$lib/components/photos-page/actions/download-action.svelte';
|
||||||
import FavoriteAction from '$lib/components/photos-page/actions/favorite-action.svelte';
|
import FavoriteAction from '$lib/components/photos-page/actions/favorite-action.svelte';
|
||||||
import AssetSelectContextMenu from '$lib/components/photos-page/asset-select-context-menu.svelte';
|
import AssetSelectContextMenu from '$lib/components/photos-page/asset-select-context-menu.svelte';
|
||||||
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
|
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
|
||||||
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
||||||
import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
|
import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
import { api, AssetResponseDto } from '@api';
|
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
||||||
import { onMount } from 'svelte';
|
import TimerSand from 'svelte-material-icons/TimerSand.svelte';
|
||||||
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
|
import {handleError} from '$lib/utils/handle-error';
|
||||||
import Plus from 'svelte-material-icons/Plus.svelte';
|
import {api, AssetResponseDto} from '@api';
|
||||||
import Error from '../../+error.svelte';
|
import {onMount} from 'svelte';
|
||||||
import type { PageData } from './$types';
|
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
|
||||||
|
import Plus from 'svelte-material-icons/Plus.svelte';
|
||||||
|
import Error from '../../+error.svelte';
|
||||||
|
import type {PageData} from './$types';
|
||||||
|
|
||||||
let favorites: AssetResponseDto[] = [];
|
let favorites: AssetResponseDto[] = [];
|
||||||
let selectedAssets: Set<AssetResponseDto> = new Set();
|
let selectedAssets: Set<AssetResponseDto> = new Set();
|
||||||
|
export let data: PageData;
|
||||||
|
|
||||||
export let data: PageData;
|
$: isMultiSelectionMode = selectedAssets.size > 0;
|
||||||
|
$: isAllArchive = Array.from(selectedAssets).every((asset) => asset.isArchived);
|
||||||
|
|
||||||
$: isMultiSelectionMode = selectedAssets.size > 0;
|
onMount(async () => {
|
||||||
$: isAllArchive = Array.from(selectedAssets).every((asset) => asset.isArchived);
|
try {
|
||||||
|
const {data: assets} = await api.assetApi.getAllAssets({
|
||||||
|
isFavorite: true,
|
||||||
|
withoutThumbs: true
|
||||||
|
});
|
||||||
|
favorites = assets;
|
||||||
|
} catch {
|
||||||
|
handleError(Error, 'Unable to load favorites');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onMount(async () => {
|
const handleSelectAll = () => {
|
||||||
try {
|
selectedAssets = new Set(favorites);
|
||||||
const { data: assets } = await api.assetApi.getAllAssets({
|
};
|
||||||
isFavorite: true,
|
|
||||||
withoutThumbs: true
|
|
||||||
});
|
|
||||||
favorites = assets;
|
|
||||||
} catch {
|
|
||||||
handleError(Error, 'Unable to load favorites');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const onAssetDelete = (assetId: string) => {
|
const onAssetDelete = (assetId: string) => {
|
||||||
favorites = favorites.filter((a) => a.id !== assetId);
|
favorites = favorites.filter((a) => a.id !== assetId);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Multiselection mode app bar -->
|
<!-- Multiselection mode app bar -->
|
||||||
{#if isMultiSelectionMode}
|
{#if isMultiSelectionMode}
|
||||||
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
|
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
|
||||||
<FavoriteAction removeFavorite onAssetFavorite={(asset) => onAssetDelete(asset.id)} />
|
<FavoriteAction removeFavorite onAssetFavorite={(asset) => onAssetDelete(asset.id)}/>
|
||||||
<CreateSharedLink />
|
<CreateSharedLink/>
|
||||||
<AssetSelectContextMenu icon={Plus} title="Add">
|
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/>
|
||||||
<AddToAlbum />
|
<AssetSelectContextMenu icon={Plus} title="Add">
|
||||||
<AddToAlbum shared />
|
<AddToAlbum/>
|
||||||
</AssetSelectContextMenu>
|
<AddToAlbum shared/>
|
||||||
<DeleteAssets {onAssetDelete} />
|
</AssetSelectContextMenu>
|
||||||
<AssetSelectContextMenu icon={DotsVertical} title="Menu">
|
<DeleteAssets {onAssetDelete}/>
|
||||||
<DownloadAction menuItem />
|
<AssetSelectContextMenu icon={DotsVertical} title="Menu">
|
||||||
<ArchiveAction menuItem unarchive={isAllArchive} />
|
<DownloadAction menuItem/>
|
||||||
</AssetSelectContextMenu>
|
<ArchiveAction menuItem unarchive={isAllArchive}/>
|
||||||
</AssetSelectControlBar>
|
</AssetSelectContextMenu>
|
||||||
|
</AssetSelectControlBar>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<UserPageLayout user={data.user} hideNavbar={isMultiSelectionMode} title={data.meta.title}>
|
<UserPageLayout user={data.user} hideNavbar={isMultiSelectionMode} title={data.meta.title}>
|
||||||
<section>
|
<section>
|
||||||
<!-- Empty Message -->
|
<!-- Empty Message -->
|
||||||
{#if favorites.length === 0}
|
{#if favorites.length === 0}
|
||||||
<EmptyPlaceholder
|
<EmptyPlaceholder
|
||||||
text="Add favorites to quickly find your best pictures and videos"
|
text="Add favorites to quickly find your best pictures and videos"
|
||||||
alt="Empty favorites"
|
alt="Empty favorites"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<GalleryViewer assets={favorites} bind:selectedAssets viewFrom="favorites-page" />
|
<GalleryViewer assets={favorites} bind:selectedAssets viewFrom="favorites-page"/>
|
||||||
</section>
|
</section>
|
||||||
</UserPageLayout>
|
</UserPageLayout>
|
||||||
|
|
Loading…
Reference in a new issue