Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,7 @@
"stack_selected_photos": "Stack selected photos",
"stacked_assets_count": "Stacked {count, plural, one {# asset} other {# assets}}",
"stacktrace": "Stacktrace",
"star_rating_set_1_5_0": "Set rating to 1, 2, 3, 4, 5 or 0 star(s)",
"start": "Start",
"start_date": "Start date",
"state": "State",
Expand Down Expand Up @@ -1967,5 +1968,8 @@
"yes": "Yes",
"you_dont_have_any_shared_links": "You don't have any shared links",
"your_wifi_name": "Your Wi-Fi name",
"zoom_image": "Zoom Image"
"zoom_image": "Zoom Image",
"sort_by": "Sort by",
"sort_by_created_at": "Created date",
"sort_by_deleted_at": "Deleted date"
}
6 changes: 5 additions & 1 deletion i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@
"stack_selected_photos": "Empiler les photos sélectionnées",
"stacked_assets_count": "{count, plural, one {# média empilé} other {# médias empilés}}",
"stacktrace": "Trace de la pile",
"star_rating_set_1_5_0": "Définir la note à 1, 2, 3, 4, 5 ou 0 étoile(s)",
"start": "Commencer",
"start_date": "Date de début",
"state": "Région",
Expand Down Expand Up @@ -1955,5 +1956,8 @@
"yes": "Oui",
"you_dont_have_any_shared_links": "Vous n'avez aucun lien partagé",
"your_wifi_name": "Nom du réseau wifi",
"zoom_image": "Zoomer"
"zoom_image": "Zoomer",
"sort_by": "Trier par",
"sort_by_created_at": "Date de création",
"sort_by_deleted_at": "Date d'effacement"
}
25 changes: 25 additions & 0 deletions open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7686,6 +7686,15 @@
"type": "string"
}
},
{
"name": "sortBy",
"required": false,
"in": "query",
"description": "Permet de choisir le champ de tri/groupe pour les buckets (createdAt ou deletedAt)",
"schema": {
"$ref": "#/components/schemas/TimeBucketSortBy"
}
},
{
"name": "tagId",
"required": false,
Expand Down Expand Up @@ -7831,6 +7840,15 @@
"type": "string"
}
},
{
"name": "sortBy",
"required": false,
"in": "query",
"description": "Permet de choisir le champ de tri/groupe pour les buckets (createdAt ou deletedAt)",
"schema": {
"$ref": "#/components/schemas/TimeBucketSortBy"
}
},
{
"name": "tagId",
"required": false,
Expand Down Expand Up @@ -15457,6 +15475,13 @@
],
"type": "object"
},
"TimeBucketSortBy": {
"enum": [
"createdAt",
"deletedAt"
],
"type": "string"
},
"TimeBucketsResponseDto": {
"properties": {
"count": {
Expand Down
10 changes: 10 additions & 0 deletions server/src/dtos/time-bucket.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ export class TimeBucketDto {
})
order?: AssetOrder;

@ApiProperty({
enum: ['createdAt', 'deletedAt'],
enumName: 'TimeBucketSortBy',
required: false,
description: 'Permet de choisir le champ de tri/groupe pour les buckets (createdAt ou deletedAt)',
example: 'deletedAt',
})
@Optional()
sortBy?: 'createdAt' | 'deletedAt';

@ValidateAssetVisibility({
optional: true,
description: 'Filter by asset visibility status (ARCHIVE, TIMELINE, HIDDEN, LOCKED)',
Expand Down
6 changes: 5 additions & 1 deletion server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ interface AssetBuilderOptions {

export interface TimeBucketOptions extends AssetBuilderOptions {
order?: AssetOrder;
/** Ajouté pour permettre le tri/groupe par createdAt ou deletedAt */
sortBy?: 'createdAt' | 'deletedAt';
}

export interface TimeBucketItem {
Expand Down Expand Up @@ -491,11 +493,13 @@ export class AssetRepository {

@GenerateSql({ params: [{}] })
async getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]> {
// Par défaut, on groupe/ordonne par fileCreatedAt, sinon par deletedAt si demandé
const groupField = options.sortBy === 'deletedAt' ? 'deletedAt' : 'fileCreatedAt';
return this.db
.with('assets', (qb) =>
qb
.selectFrom('assets')
.select(truncatedDate<Date>().as('timeBucket'))
.select(sql.raw<string>(`date_trunc('day', assets."${groupField}")`).as('timeBucket'))
.$if(!!options.isTrashed, (qb) => qb.where('assets.status', '!=', AssetStatus.DELETED))
.where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null)
.$if(options.visibility === undefined, withDefaultVisibility)
Expand Down
6 changes: 5 additions & 1 deletion server/src/services/timeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
async getTimeBuckets(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketsResponseDto[]> {
await this.timeBucketChecks(auth, dto);
const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);
if (dto.sortBy) {
(timeBucketOptions as any).sortBy = dto.sortBy;
}
return await this.assetRepository.getTimeBuckets(timeBucketOptions);
}

Expand All @@ -26,7 +29,7 @@
}

private async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketOptions> {
const { userId, ...options } = dto;
const { userId, sortBy, ...options } = dto;

Check warning on line 32 in server/src/services/timeline.service.ts

View workflow job for this annotation

GitHub Actions / Test & Lint Server

'sortBy' is assigned a value but never used. Allowed unused vars must match /^_/u
let userIds: string[] | undefined = undefined;

if (userId) {
Expand All @@ -41,6 +44,7 @@
}
}

// sortBy est propagé plus haut
return { ...options, userIds };
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { shortcuts } from '$lib/actions/shortcut';
import StarRating from '$lib/components/shared-components/star-rating.svelte';
import { authManager } from '$lib/managers/auth-manager.svelte';
import { preferences } from '$lib/stores/user.store';
Expand All @@ -23,8 +24,29 @@
handleError(error, $t('errors.cant_apply_changes'));
}
};

function handleShortcutRating(key: string) {
if (!isOwner || authManager.key || !$preferences?.ratings.enabled) return;

Check failure on line 29 in web/src/lib/components/asset-viewer/detail-panel-star-rating.svelte

View workflow job for this annotation

GitHub Actions / Lint Web

Expected { after 'if' condition
if (['1', '2', '3', '4', '5'].includes(key)) {
handlePromiseError(handleChangeRating(Number(key)));
}
if (key === '0') {
handlePromiseError(handleChangeRating(0));
}
}
</script>

<svelte:document
use:shortcuts={[
{ shortcut: { key: '1' }, onShortcut: () => handleShortcutRating('1') },
{ shortcut: { key: '2' }, onShortcut: () => handleShortcutRating('2') },
{ shortcut: { key: '3' }, onShortcut: () => handleShortcutRating('3') },
{ shortcut: { key: '4' }, onShortcut: () => handleShortcutRating('4') },
{ shortcut: { key: '5' }, onShortcut: () => handleShortcutRating('5') },
{ shortcut: { key: '0' }, onShortcut: () => handleShortcutRating('0') },
]}
/>

{#if !authManager.key && $preferences?.ratings.enabled}
<section class="px-4 pt-2">
<StarRating {rating} readOnly={!isOwner} onRating={(rating) => handlePromiseError(handleChangeRating(rating))} />
Expand Down
1 change: 1 addition & 0 deletions web/src/lib/managers/timeline-manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type AssetApiGetTimeBucketsRequest = Parameters<typeof import('@immich/sd
export type TimelineManagerOptions = Omit<AssetApiGetTimeBucketsRequest, 'size'> & {
timelineAlbumId?: string;
deferInit?: boolean;
sortBy?: 'createdAt' | 'deletedAt';
};

export type AssetDescriptor = { id: string };
Expand Down
1 change: 1 addition & 0 deletions web/src/lib/modals/ShortcutsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
{ key: ['⇧', 'd'], action: $t('download') },
{ key: ['Space'], action: $t('play_or_pause_video') },
{ key: ['Del'], action: $t('trash_delete_asset'), info: $t('shift_to_permanent_delete') },
{ key: ['1', '2', '3', '4', '5', '0'], action: $t('star_rating_set_1_5_0') },
],
},
}: Props = $props();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@
}

const timelineManager = new TimelineManager();
void timelineManager.updateOptions({ isTrashed: true });
let sortBy = $state<'createdAt' | 'deletedAt'>('createdAt');
void timelineManager.updateOptions({ isTrashed: true, sortBy: 'createdAt' });

function handleSortChange(event: Event) {
const value = (event.target as HTMLSelectElement).value as 'createdAt' | 'deletedAt';
sortBy = value;
void timelineManager.updateOptions({ isTrashed: true, sortBy });
}
onDestroy(() => timelineManager.destroy());

const assetInteraction = new AssetInteraction();
Expand Down Expand Up @@ -92,7 +99,7 @@

{#if $featureFlags.loaded && $featureFlags.trash}
<UserPageLayout hideNavbar={assetInteraction.selectionActive} title={data.meta.title} scrollbar={false}>
{#snippet buttons()}
<div class="flex flex-row items-center gap-4 mb-2">
<HStack gap={0}>
<Button
leadingIcon={mdiHistory}
Expand All @@ -115,8 +122,14 @@
<Text class="hidden md:block">{$t('empty_trash')}</Text>
</Button>
</HStack>
{/snippet}

<div class="ml-auto">
<label for="sortBy" class="mr-2">{$t('sort_by')}</label>
<select id="sortBy" bind:value={sortBy} onchange={handleSortChange} class="border rounded px-2 py-1">
<option value="createdAt">{$t('sort_by_created_at', { default: 'Date de création' })}</option>
<option value="deletedAt">{$t('sort_by_deleted_at', { default: "Date d'effacement" })}</option>
</select>
</div>
</div>
<AssetGrid enableRouting={true} {timelineManager} {assetInteraction} onEscape={handleEscape}>
<p class="font-medium text-gray-500/60 dark:text-gray-300/60 p-4">
{$t('trashed_items_will_be_permanently_deleted_after', { values: { days: $serverConfig.trashDays } })}
Expand Down
Loading