mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Album view option for cover or list view
This commit is contained in:
@@ -41,8 +41,10 @@ export const isShowDetail = persisted<boolean>('info-opened', false, {});
|
|||||||
|
|
||||||
export interface AlbumViewSettings {
|
export interface AlbumViewSettings {
|
||||||
sortBy: string;
|
sortBy: string;
|
||||||
|
view: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const albumViewSettings = persisted<AlbumViewSettings>('album-view-settings', {
|
export const albumViewSettings = persisted<AlbumViewSettings>('album-view-settings', {
|
||||||
sortBy: 'Most recent photo',
|
sortBy: 'Most recent photo',
|
||||||
|
view: 'Cover'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
import Dropdown from '$lib/components/elements/dropdown.svelte';
|
import Dropdown from '$lib/components/elements/dropdown.svelte';
|
||||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||||
|
import { dateFormats } from '$lib/constants';
|
||||||
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import {
|
import {
|
||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
@@ -24,6 +26,15 @@
|
|||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
const sortByOptions = ['Most recent photo', 'Last modified', 'Album title'];
|
const sortByOptions = ['Most recent photo', 'Last modified', 'Album title'];
|
||||||
|
const viewOptions = [{
|
||||||
|
name: 'Cover',
|
||||||
|
icon: ViewGridOutline
|
||||||
|
}, {
|
||||||
|
name: 'List',
|
||||||
|
icon: FormatListBulletedSquare
|
||||||
|
}]
|
||||||
|
const viewOptionNames = viewOptions.map(option => option.name)
|
||||||
|
const viewOptionIcons = viewOptions.map(option => option.icon)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
albums: unsortedAlbums,
|
albums: unsortedAlbums,
|
||||||
@@ -114,17 +125,49 @@
|
|||||||
</div>
|
</div>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
|
|
||||||
<Dropdown options={sortByOptions} bind:value={$albumViewSettings.sortBy} />
|
<Dropdown options={sortByOptions} bind:value={$albumViewSettings.sortBy} icons={[SwapVertical]} />
|
||||||
|
<Dropdown options={viewOptionNames} bind:value={$albumViewSettings.view} icons={viewOptionIcons} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Album Card -->
|
<!-- Album Card -->
|
||||||
<div class="grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]">
|
{#if $albumViewSettings.view === 'Cover'}
|
||||||
|
<div class="grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]">
|
||||||
|
{#each $albums as album (album.id)}
|
||||||
|
<a data-sveltekit-preload-data="hover" href={`albums/${album.id}`} animate:flip={{ duration: 200 }}>
|
||||||
|
<AlbumCard {album} on:showalbumcontextmenu={(e) => showAlbumContextMenu(e.detail, album)} user={data.user} />
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else if $albumViewSettings.view === 'List'}
|
||||||
|
<div class="grid grid-cols-4 text-white mb-2">
|
||||||
|
<span>Album title</span>
|
||||||
|
<span>Assets</span>
|
||||||
|
<span>Updated date</span>
|
||||||
|
<span>Created date</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#each $albums as album (album.id)}
|
{#each $albums as album (album.id)}
|
||||||
<a data-sveltekit-preload-data="hover" href={`albums/${album.id}`} animate:flip={{ duration: 200 }}>
|
<a class="grid grid-cols-4" data-sveltekit-preload-data="hover" href={`albums/${album.id}`}>
|
||||||
<AlbumCard {album} on:showalbumcontextmenu={(e) => showAlbumContextMenu(e.detail, album)} user={data.user} />
|
<span
|
||||||
|
class="w-full truncate text-xl font-semibold text-immich-primary dark:text-immich-dark-primary"
|
||||||
|
data-testid="album-name"
|
||||||
|
title={album.albumName}
|
||||||
|
>
|
||||||
|
{album.albumName}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span>
|
||||||
|
{album.assetCount}
|
||||||
|
{album.assetCount == 1 ? `item` : `items`}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span>{new Date(album.updatedAt).toLocaleDateString($locale, dateFormats.album)}</span>
|
||||||
|
<span>{new Date(album.createdAt).toLocaleDateString($locale, dateFormats.album)}</span>
|
||||||
|
|
||||||
|
<!-- <span>{album.startDate} - {album.endDate}</span> -->
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
{/if}
|
||||||
|
|
||||||
<!-- Empty Message -->
|
<!-- Empty Message -->
|
||||||
{#if $albums.length === 0}
|
{#if $albums.length === 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user