mirror of
https://github.com/immich-app/immich.git
synced 2025-01-09 05:16:47 +01:00
Add select all to photos
This commit is contained in:
parent
9a3a01ca78
commit
05e851ef44
4 changed files with 55 additions and 0 deletions
|
@ -0,0 +1,51 @@
|
|||
<script lang="ts">
|
||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||
import {
|
||||
NotificationType,
|
||||
notificationController
|
||||
} from '$lib/components/shared-components/notification/notification';
|
||||
import {api, AssetResponseDto} from '@api';
|
||||
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
||||
import TimerSand from 'svelte-material-icons/TimerSand.svelte';
|
||||
import {OnSelectAll, getAssetControlContext} from '../asset-select-control-bar.svelte';
|
||||
import {
|
||||
assetInteractionStore,
|
||||
selectedAssets
|
||||
} from '$lib/stores/asset-interaction.store';
|
||||
import {assetGridState, assetStore, loadingBucketState} from '$lib/stores/assets.store';
|
||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||
import {handleError} from '../../../utils/handle-error';
|
||||
import {AssetGridState} from "$lib/models/asset-grid-state";
|
||||
import {sumBy} from "lodash-es";
|
||||
|
||||
export let onSelectAll: OnSelectAll;
|
||||
|
||||
let selecting = false;
|
||||
|
||||
const handleSelectAll = async () => {
|
||||
try {
|
||||
selecting = true;
|
||||
let _assetGridState = new AssetGridState();
|
||||
assetGridState.subscribe((state) => {
|
||||
_assetGridState = state;
|
||||
});
|
||||
|
||||
for (let i = 0; i < _assetGridState.buckets.length; i++) {
|
||||
await assetStore.getAssetsByBucket(_assetGridState.buckets[i].bucketDate, i)
|
||||
for (const asset of _assetGridState.buckets[i].assets) {
|
||||
assetInteractionStore.addAssetToMultiselectGroup(asset)
|
||||
}
|
||||
}
|
||||
selecting = false;
|
||||
} catch (e) {
|
||||
handleError(e, 'Error selecting all assets');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
{#if selecting}
|
||||
<CircleIconButton title="Delete" logo={TimerSand}/>
|
||||
{/if}
|
||||
{#if !selecting}
|
||||
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/>
|
||||
{/if}
|
|
@ -2,6 +2,7 @@
|
|||
import { createContext } from '$lib/utils/context';
|
||||
|
||||
export type OnAssetDelete = (assetId: string) => void;
|
||||
export type OnSelectAll = (assetId: string) => void;
|
||||
export type OnAssetArchive = (asset: AssetResponseDto, archived: boolean) => void;
|
||||
export type OnAssetFavorite = (asset: AssetResponseDto, favorite: boolean) => void;
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ function createAssetStore() {
|
|||
userId
|
||||
});
|
||||
|
||||
console.log("Initial buckets: "+ data.buckets.length)
|
||||
// Update timeline height based on calculated bucket height
|
||||
assetGridState.update((state) => {
|
||||
state.timelineHeight = sumBy(state.buckets, (d) => d.bucketHeight);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
||||
import DownloadAction from '$lib/components/photos-page/actions/download-action.svelte';
|
||||
import FavoriteAction from '$lib/components/photos-page/actions/favorite-action.svelte';
|
||||
import SelectAllAssets from '$lib/components/photos-page/actions/select-all-assets.svelte';
|
||||
import AssetGrid from '$lib/components/photos-page/asset-grid.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';
|
||||
|
@ -37,6 +38,7 @@
|
|||
clearSelect={assetInteractionStore.clearMultiselect}
|
||||
>
|
||||
<CreateSharedLink />
|
||||
<SelectAllAssets/>
|
||||
<AssetSelectContextMenu icon={Plus} title="Add">
|
||||
<AddToAlbum />
|
||||
<AddToAlbum shared />
|
||||
|
|
Loading…
Reference in a new issue