mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
feat(web): shared link filters (#15948)
This commit is contained in:
parent
23014c263b
commit
c5360e78c5
22 changed files with 253 additions and 110 deletions
|
|
@ -436,6 +436,7 @@
|
||||||
"back_close_deselect": "Back, close, or deselect",
|
"back_close_deselect": "Back, close, or deselect",
|
||||||
"backward": "Backward",
|
"backward": "Backward",
|
||||||
"birthdate_saved": "Date of birth saved successfully",
|
"birthdate_saved": "Date of birth saved successfully",
|
||||||
|
"show_shared_links": "Show shared links",
|
||||||
"birthdate_set_description": "Date of birth is used to calculate the age of this person at the time of a photo.",
|
"birthdate_set_description": "Date of birth is used to calculate the age of this person at the time of a photo.",
|
||||||
"blurred_background": "Blurred background",
|
"blurred_background": "Blurred background",
|
||||||
"bugs_and_feature_requests": "Bugs & Feature Requests",
|
"bugs_and_feature_requests": "Bugs & Feature Requests",
|
||||||
|
|
@ -804,6 +805,7 @@
|
||||||
"include_shared_albums": "Include shared albums",
|
"include_shared_albums": "Include shared albums",
|
||||||
"include_shared_partner_assets": "Include shared partner assets",
|
"include_shared_partner_assets": "Include shared partner assets",
|
||||||
"individual_share": "Individual share",
|
"individual_share": "Individual share",
|
||||||
|
"individual_shares": "Individual shares",
|
||||||
"info": "Info",
|
"info": "Info",
|
||||||
"interval": {
|
"interval": {
|
||||||
"day_at_onepm": "Every day at 1pm",
|
"day_at_onepm": "Every day at 1pm",
|
||||||
|
|
@ -1172,6 +1174,7 @@
|
||||||
"shared_from_partner": "Photos from {partner}",
|
"shared_from_partner": "Photos from {partner}",
|
||||||
"shared_link_options": "Shared link options",
|
"shared_link_options": "Shared link options",
|
||||||
"shared_links": "Shared links",
|
"shared_links": "Shared links",
|
||||||
|
"shared_links_description": "Share photos and videos with a link",
|
||||||
"shared_photos_and_videos_count": "{assetCount, plural, other {# shared photos & videos.}}",
|
"shared_photos_and_videos_count": "{assetCount, plural, other {# shared photos & videos.}}",
|
||||||
"shared_with_partner": "Shared with {partner}",
|
"shared_with_partner": "Shared with {partner}",
|
||||||
"sharing": "Sharing",
|
"sharing": "Sharing",
|
||||||
|
|
|
||||||
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api.dart
generated
BIN
mobile/openapi/lib/api.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/api_client.dart
generated
BIN
mobile/openapi/lib/api_client.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/shared_links_response.dart
generated
Normal file
BIN
mobile/openapi/lib/model/shared_links_response.dart
generated
Normal file
Binary file not shown.
BIN
mobile/openapi/lib/model/shared_links_update.dart
generated
Normal file
BIN
mobile/openapi/lib/model/shared_links_update.dart
generated
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11514,6 +11514,34 @@
|
||||||
],
|
],
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"SharedLinksResponse": {
|
||||||
|
"properties": {
|
||||||
|
"enabled": {
|
||||||
|
"default": true,
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"sidebarWeb": {
|
||||||
|
"default": false,
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"enabled",
|
||||||
|
"sidebarWeb"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"SharedLinksUpdate": {
|
||||||
|
"properties": {
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"sidebarWeb": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"SignUpDto": {
|
"SignUpDto": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"email": {
|
"email": {
|
||||||
|
|
@ -13160,6 +13188,9 @@
|
||||||
"ratings": {
|
"ratings": {
|
||||||
"$ref": "#/components/schemas/RatingsResponse"
|
"$ref": "#/components/schemas/RatingsResponse"
|
||||||
},
|
},
|
||||||
|
"sharedLinks": {
|
||||||
|
"$ref": "#/components/schemas/SharedLinksResponse"
|
||||||
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"$ref": "#/components/schemas/TagsResponse"
|
"$ref": "#/components/schemas/TagsResponse"
|
||||||
}
|
}
|
||||||
|
|
@ -13173,6 +13204,7 @@
|
||||||
"people",
|
"people",
|
||||||
"purchase",
|
"purchase",
|
||||||
"ratings",
|
"ratings",
|
||||||
|
"sharedLinks",
|
||||||
"tags"
|
"tags"
|
||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
|
|
@ -13203,6 +13235,9 @@
|
||||||
"ratings": {
|
"ratings": {
|
||||||
"$ref": "#/components/schemas/RatingsUpdate"
|
"$ref": "#/components/schemas/RatingsUpdate"
|
||||||
},
|
},
|
||||||
|
"sharedLinks": {
|
||||||
|
"$ref": "#/components/schemas/SharedLinksUpdate"
|
||||||
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"$ref": "#/components/schemas/TagsUpdate"
|
"$ref": "#/components/schemas/TagsUpdate"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,10 @@ export type PurchaseResponse = {
|
||||||
export type RatingsResponse = {
|
export type RatingsResponse = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
};
|
};
|
||||||
|
export type SharedLinksResponse = {
|
||||||
|
enabled: boolean;
|
||||||
|
sidebarWeb: boolean;
|
||||||
|
};
|
||||||
export type TagsResponse = {
|
export type TagsResponse = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
sidebarWeb: boolean;
|
sidebarWeb: boolean;
|
||||||
|
|
@ -126,6 +130,7 @@ export type UserPreferencesResponseDto = {
|
||||||
people: PeopleResponse;
|
people: PeopleResponse;
|
||||||
purchase: PurchaseResponse;
|
purchase: PurchaseResponse;
|
||||||
ratings: RatingsResponse;
|
ratings: RatingsResponse;
|
||||||
|
sharedLinks: SharedLinksResponse;
|
||||||
tags: TagsResponse;
|
tags: TagsResponse;
|
||||||
};
|
};
|
||||||
export type AvatarUpdate = {
|
export type AvatarUpdate = {
|
||||||
|
|
@ -158,6 +163,10 @@ export type PurchaseUpdate = {
|
||||||
export type RatingsUpdate = {
|
export type RatingsUpdate = {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
};
|
};
|
||||||
|
export type SharedLinksUpdate = {
|
||||||
|
enabled?: boolean;
|
||||||
|
sidebarWeb?: boolean;
|
||||||
|
};
|
||||||
export type TagsUpdate = {
|
export type TagsUpdate = {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
sidebarWeb?: boolean;
|
sidebarWeb?: boolean;
|
||||||
|
|
@ -171,6 +180,7 @@ export type UserPreferencesUpdateDto = {
|
||||||
people?: PeopleUpdate;
|
people?: PeopleUpdate;
|
||||||
purchase?: PurchaseUpdate;
|
purchase?: PurchaseUpdate;
|
||||||
ratings?: RatingsUpdate;
|
ratings?: RatingsUpdate;
|
||||||
|
sharedLinks?: SharedLinksUpdate;
|
||||||
tags?: TagsUpdate;
|
tags?: TagsUpdate;
|
||||||
};
|
};
|
||||||
export type AlbumUserResponseDto = {
|
export type AlbumUserResponseDto = {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,14 @@ class PeopleUpdate {
|
||||||
sidebarWeb?: boolean;
|
sidebarWeb?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SharedLinksUpdate {
|
||||||
|
@ValidateBoolean({ optional: true })
|
||||||
|
enabled?: boolean;
|
||||||
|
|
||||||
|
@ValidateBoolean({ optional: true })
|
||||||
|
sidebarWeb?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
class TagsUpdate {
|
class TagsUpdate {
|
||||||
@ValidateBoolean({ optional: true })
|
@ValidateBoolean({ optional: true })
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
|
@ -98,6 +106,11 @@ export class UserPreferencesUpdateDto {
|
||||||
@Type(() => RatingsUpdate)
|
@Type(() => RatingsUpdate)
|
||||||
ratings?: RatingsUpdate;
|
ratings?: RatingsUpdate;
|
||||||
|
|
||||||
|
@Optional()
|
||||||
|
@ValidateNested()
|
||||||
|
@Type(() => SharedLinksUpdate)
|
||||||
|
sharedLinks?: SharedLinksUpdate;
|
||||||
|
|
||||||
@Optional()
|
@Optional()
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
@Type(() => TagsUpdate)
|
@Type(() => TagsUpdate)
|
||||||
|
|
@ -152,6 +165,11 @@ class TagsResponse {
|
||||||
sidebarWeb: boolean = true;
|
sidebarWeb: boolean = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SharedLinksResponse {
|
||||||
|
enabled: boolean = true;
|
||||||
|
sidebarWeb: boolean = false;
|
||||||
|
}
|
||||||
|
|
||||||
class EmailNotificationsResponse {
|
class EmailNotificationsResponse {
|
||||||
enabled!: boolean;
|
enabled!: boolean;
|
||||||
albumInvite!: boolean;
|
albumInvite!: boolean;
|
||||||
|
|
@ -175,6 +193,7 @@ export class UserPreferencesResponseDto implements UserPreferences {
|
||||||
memories!: MemoriesResponse;
|
memories!: MemoriesResponse;
|
||||||
people!: PeopleResponse;
|
people!: PeopleResponse;
|
||||||
ratings!: RatingsResponse;
|
ratings!: RatingsResponse;
|
||||||
|
sharedLinks!: SharedLinksResponse;
|
||||||
tags!: TagsResponse;
|
tags!: TagsResponse;
|
||||||
avatar!: AvatarResponse;
|
avatar!: AvatarResponse;
|
||||||
emailNotifications!: EmailNotificationsResponse;
|
emailNotifications!: EmailNotificationsResponse;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ export interface UserPreferences {
|
||||||
ratings: {
|
ratings: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
};
|
};
|
||||||
|
sharedLinks: {
|
||||||
|
enabled: boolean;
|
||||||
|
sidebarWeb: boolean;
|
||||||
|
};
|
||||||
tags: {
|
tags: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
sidebarWeb: boolean;
|
sidebarWeb: boolean;
|
||||||
|
|
@ -74,6 +78,10 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
|
||||||
enabled: true,
|
enabled: true,
|
||||||
sidebarWeb: false,
|
sidebarWeb: false,
|
||||||
},
|
},
|
||||||
|
sharedLinks: {
|
||||||
|
enabled: true,
|
||||||
|
sidebarWeb: false,
|
||||||
|
},
|
||||||
ratings: {
|
ratings: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
filters: string[];
|
filters: string[];
|
||||||
|
labels?: string[];
|
||||||
selected: string;
|
selected: string;
|
||||||
label: string;
|
label: string;
|
||||||
onSelect: (selected: string) => void;
|
onSelect: (selected: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { filters, selected, label, onSelect }: Props = $props();
|
let { filters, selected, label, labels, onSelect }: Props = $props();
|
||||||
|
|
||||||
const id = `group-tab-${generateId()}`;
|
const id = `group-tab-${generateId()}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -32,7 +33,7 @@
|
||||||
for="{id}-{index}"
|
for="{id}-{index}"
|
||||||
class="flex h-full cursor-pointer items-center px-4 text-sm hover:bg-gray-300 group-first-of-type:rounded-s-2xl group-last-of-type:rounded-e-2xl peer-checked:bg-gray-300 dark:hover:bg-gray-800 peer-checked:dark:bg-gray-700"
|
class="flex h-full cursor-pointer items-center px-4 text-sm hover:bg-gray-300 group-first-of-type:rounded-s-2xl group-last-of-type:rounded-e-2xl peer-checked:bg-gray-300 dark:hover:bg-gray-800 peer-checked:dark:bg-gray-700"
|
||||||
>
|
>
|
||||||
{filter}
|
{labels?.[index] ?? filter}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
mdiToolboxOutline,
|
mdiToolboxOutline,
|
||||||
mdiFolderOutline,
|
mdiFolderOutline,
|
||||||
mdiTagMultipleOutline,
|
mdiTagMultipleOutline,
|
||||||
|
mdiLink,
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
import SideBarSection from './side-bar-section.svelte';
|
import SideBarSection from './side-bar-section.svelte';
|
||||||
import SideBarLink from './side-bar-link.svelte';
|
import SideBarLink from './side-bar-link.svelte';
|
||||||
|
|
@ -72,6 +73,10 @@
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if $preferences.sharedLinks.enabled && $preferences.sharedLinks.sidebarWeb}
|
||||||
|
<SideBarLink title={$t('shared_links')} routeId="/(user)/shared-links" icon={mdiLink} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
<SideBarLink
|
<SideBarLink
|
||||||
title={$t('sharing')}
|
title={$t('sharing')}
|
||||||
routeId="/(user)/sharing"
|
routeId="/(user)/sharing"
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,22 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import type { SharedLinkResponseDto } from '@immich/sdk';
|
||||||
import { mdiCircleEditOutline } from '@mdi/js';
|
import { mdiCircleEditOutline } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
menuItem?: boolean;
|
menuItem?: boolean;
|
||||||
onEdit: () => void;
|
sharedLink: SharedLinkResponseDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { menuItem = false, onEdit }: Props = $props();
|
let { sharedLink, menuItem = false }: Props = $props();
|
||||||
|
|
||||||
|
const onEdit = async () => {
|
||||||
|
await goto(`${AppRoute.SHARED_LINKS}/${sharedLink.id}`);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if menuItem}
|
{#if menuItem}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,9 @@
|
||||||
interface Props {
|
interface Props {
|
||||||
link: SharedLinkResponseDto;
|
link: SharedLinkResponseDto;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onEdit: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { link, onDelete, onEdit }: Props = $props();
|
let { link, onDelete }: Props = $props();
|
||||||
|
|
||||||
let now = DateTime.now();
|
let now = DateTime.now();
|
||||||
let expiresAt = $derived(link.expiresAt ? DateTime.fromISO(link.expiresAt) : undefined);
|
let expiresAt = $derived(link.expiresAt ? DateTime.fromISO(link.expiresAt) : undefined);
|
||||||
|
|
@ -95,10 +94,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
|
|
||||||
<div class="flex flex-auto flex-col place-content-center place-items-end text-end ms-4">
|
<div class="flex flex-auto flex-col place-content-center place-items-end text-end ms-4">
|
||||||
<div class="sm:flex hidden">
|
<div class="sm:flex hidden">
|
||||||
<SharedLinkEdit {onEdit} />
|
<SharedLinkEdit sharedLink={link} />
|
||||||
<SharedLinkCopy {link} />
|
<SharedLinkCopy {link} />
|
||||||
<SharedLinkDelete {onDelete} />
|
<SharedLinkDelete {onDelete} />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -112,7 +110,7 @@
|
||||||
padding="3"
|
padding="3"
|
||||||
hideContent
|
hideContent
|
||||||
>
|
>
|
||||||
<SharedLinkEdit menuItem {onEdit} />
|
<SharedLinkEdit menuItem sharedLink={link} />
|
||||||
<SharedLinkCopy menuItem {link} />
|
<SharedLinkCopy menuItem {link} />
|
||||||
<SharedLinkDelete menuItem {onDelete} />
|
<SharedLinkDelete menuItem {onDelete} />
|
||||||
</ButtonContextMenu>
|
</ButtonContextMenu>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
// Ratings
|
// Ratings
|
||||||
let ratingsEnabled = $state($preferences?.ratings?.enabled ?? false);
|
let ratingsEnabled = $state($preferences?.ratings?.enabled ?? false);
|
||||||
|
|
||||||
|
// Shared links
|
||||||
|
let sharedLinksEnabled = $state($preferences?.sharedLinks?.enabled ?? true);
|
||||||
|
let sharedLinkSidebar = $state($preferences?.sharedLinks?.sidebarWeb ?? false);
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
let tagsEnabled = $state($preferences?.tags?.enabled ?? false);
|
let tagsEnabled = $state($preferences?.tags?.enabled ?? false);
|
||||||
let tagsSidebar = $state($preferences?.tags?.sidebarWeb ?? false);
|
let tagsSidebar = $state($preferences?.tags?.sidebarWeb ?? false);
|
||||||
|
|
@ -39,6 +43,7 @@
|
||||||
memories: { enabled: memoriesEnabled },
|
memories: { enabled: memoriesEnabled },
|
||||||
people: { enabled: peopleEnabled, sidebarWeb: peopleSidebar },
|
people: { enabled: peopleEnabled, sidebarWeb: peopleSidebar },
|
||||||
ratings: { enabled: ratingsEnabled },
|
ratings: { enabled: ratingsEnabled },
|
||||||
|
sharedLinks: { enabled: sharedLinksEnabled, sidebarWeb: sharedLinkSidebar },
|
||||||
tags: { enabled: tagsEnabled, sidebarWeb: tagsSidebar },
|
tags: { enabled: tagsEnabled, sidebarWeb: tagsSidebar },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -104,6 +109,21 @@
|
||||||
</div>
|
</div>
|
||||||
</SettingAccordion>
|
</SettingAccordion>
|
||||||
|
|
||||||
|
<SettingAccordion key="shared-links" title={$t('shared_links')} subtitle={$t('shared_links_description')}>
|
||||||
|
<div class="ml-4 mt-6">
|
||||||
|
<SettingSwitch title={$t('enable')} bind:checked={sharedLinksEnabled} />
|
||||||
|
</div>
|
||||||
|
{#if sharedLinksEnabled}
|
||||||
|
<div class="ml-4 mt-6">
|
||||||
|
<SettingSwitch
|
||||||
|
title={$t('sidebar')}
|
||||||
|
subtitle={$t('sidebar_display_description')}
|
||||||
|
bind:checked={sharedLinkSidebar}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</SettingAccordion>
|
||||||
|
|
||||||
<SettingAccordion key="tags" title={$t('tags')} subtitle={$t('tag_feature_description')}>
|
<SettingAccordion key="tags" title={$t('tags')} subtitle={$t('tag_feature_description')}>
|
||||||
<div class="ml-4 mt-6">
|
<div class="ml-4 mt-6">
|
||||||
<SettingSwitch title={$t('enable')} bind:checked={tagsEnabled} />
|
<SettingSwitch title={$t('enable')} bind:checked={tagsEnabled} />
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export enum AppRoute {
|
||||||
EXPLORE = '/explore',
|
EXPLORE = '/explore',
|
||||||
SHARE = '/share',
|
SHARE = '/share',
|
||||||
SHARING = '/sharing',
|
SHARING = '/sharing',
|
||||||
SHARED_LINKS = '/sharing/sharedlinks',
|
SHARED_LINKS = '/shared-links',
|
||||||
SEARCH = '/search',
|
SEARCH = '/search',
|
||||||
MAP = '/map',
|
MAP = '/map',
|
||||||
USER_SETTINGS = '/user-settings',
|
USER_SETTINGS = '/user-settings',
|
||||||
|
|
|
||||||
119
web/src/routes/(user)/shared-links/[[id=id]]/+page.svelte
Normal file
119
web/src/routes/(user)/shared-links/[[id=id]]/+page.svelte
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { page } from '$app/state';
|
||||||
|
import GroupTab from '$lib/components/elements/group-tab.svelte';
|
||||||
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
|
import CreateSharedLinkModal from '$lib/components/shared-components/create-share-link-modal/create-shared-link-modal.svelte';
|
||||||
|
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
|
||||||
|
import {
|
||||||
|
notificationController,
|
||||||
|
NotificationType,
|
||||||
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
|
import SharedLinkCard from '$lib/components/sharedlinks-page/shared-link-card.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { getAllSharedLinks, removeSharedLink, SharedLinkType, type SharedLinkResponseDto } from '@immich/sdk';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { t } from 'svelte-i18n';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
data: PageData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data }: Props = $props();
|
||||||
|
|
||||||
|
let sharedLinks: SharedLinkResponseDto[] = $state([]);
|
||||||
|
let sharedLink = $derived(sharedLinks.find(({ id }) => id === page.params.id));
|
||||||
|
|
||||||
|
const refresh = async () => {
|
||||||
|
sharedLinks = await getAllSharedLinks();
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleDeleteLink = async (id: string) => {
|
||||||
|
const isConfirmed = await dialogController.show({
|
||||||
|
title: $t('delete_shared_link'),
|
||||||
|
prompt: $t('confirm_delete_shared_link'),
|
||||||
|
confirmText: $t('delete'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isConfirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await removeSharedLink({ id });
|
||||||
|
notificationController.show({ message: $t('deleted_shared_link'), type: NotificationType.Info });
|
||||||
|
await refresh();
|
||||||
|
} catch (error) {
|
||||||
|
handleError(error, $t('errors.unable_to_delete_shared_link'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEditDone = async () => {
|
||||||
|
await refresh();
|
||||||
|
await goto(AppRoute.SHARED_LINKS);
|
||||||
|
};
|
||||||
|
|
||||||
|
type Filter = 'all' | 'album' | 'individual';
|
||||||
|
|
||||||
|
const filterMap: Record<Filter, string> = {
|
||||||
|
all: $t('all'),
|
||||||
|
album: $t('albums'),
|
||||||
|
individual: $t('individual_shares'),
|
||||||
|
};
|
||||||
|
|
||||||
|
let filters = Object.keys(filterMap);
|
||||||
|
let labels = Object.values(filterMap);
|
||||||
|
|
||||||
|
const getActiveTab = (url: URL) => {
|
||||||
|
const filter = url.searchParams.get('filter');
|
||||||
|
return filter && filters.includes(filter) ? filter : 'all';
|
||||||
|
};
|
||||||
|
|
||||||
|
let selectedTab = $derived(getActiveTab(page.url));
|
||||||
|
const handleSelectTab = async (value: string) => {
|
||||||
|
await goto(`${AppRoute.SHARED_LINKS}?filter=${value}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
let filteredSharedLinks = $derived(
|
||||||
|
sharedLinks.filter(
|
||||||
|
({ type }) =>
|
||||||
|
selectedTab === 'all' ||
|
||||||
|
(type === SharedLinkType.Album && selectedTab === 'album') ||
|
||||||
|
(type === SharedLinkType.Individual && selectedTab === 'individual'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<UserPageLayout title={data.meta.title}>
|
||||||
|
{#snippet buttons()}
|
||||||
|
<div class="hidden xl:block h-10">
|
||||||
|
<GroupTab label={$t('show_shared_links')} {filters} {labels} selected={selectedTab} onSelect={handleSelectTab} />
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{#if sharedLinks.length === 0}
|
||||||
|
<div
|
||||||
|
class="flex place-content-center place-items-center rounded-lg bg-gray-100 dark:bg-immich-dark-gray dark:text-immich-gray p-12"
|
||||||
|
>
|
||||||
|
<p>{$t('you_dont_have_any_shared_links')}</p>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
{#each filteredSharedLinks as link (link.id)}
|
||||||
|
<SharedLinkCard {link} onDelete={() => handleDeleteLink(link.id)} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if sharedLink}
|
||||||
|
<CreateSharedLinkModal editingLink={sharedLink} onClose={handleEditDone} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</UserPageLayout>
|
||||||
14
web/src/routes/(user)/shared-links/[[id=id]]/+page.ts
Normal file
14
web/src/routes/(user)/shared-links/[[id=id]]/+page.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { authenticate } from '$lib/utils/auth';
|
||||||
|
import { getFormatter } from '$lib/utils/i18n';
|
||||||
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
export const load = (async () => {
|
||||||
|
await authenticate();
|
||||||
|
const $t = await getFormatter();
|
||||||
|
|
||||||
|
return {
|
||||||
|
meta: {
|
||||||
|
title: $t('shared_links'),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}) satisfies PageLoad;
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import { goto, afterNavigate } from '$app/navigation';
|
|
||||||
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
|
|
||||||
import CreateSharedLinkModal from '$lib/components/shared-components/create-share-link-modal/create-shared-link-modal.svelte';
|
|
||||||
import {
|
|
||||||
notificationController,
|
|
||||||
NotificationType,
|
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
|
||||||
import SharedLinkCard from '$lib/components/sharedlinks-page/shared-link-card.svelte';
|
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import { getAllSharedLinks, removeSharedLink, type SharedLinkResponseDto } from '@immich/sdk';
|
|
||||||
import { mdiArrowLeft } from '@mdi/js';
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
|
|
||||||
import { t } from 'svelte-i18n';
|
|
||||||
|
|
||||||
let sharedLinks: SharedLinkResponseDto[] = $state([]);
|
|
||||||
let editSharedLink: SharedLinkResponseDto | null = $state(null);
|
|
||||||
|
|
||||||
const refresh = async () => {
|
|
||||||
sharedLinks = await getAllSharedLinks();
|
|
||||||
};
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
await refresh();
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDeleteLink = async (id: string) => {
|
|
||||||
const isConfirmed = await dialogController.show({
|
|
||||||
title: $t('delete_shared_link'),
|
|
||||||
prompt: $t('confirm_delete_shared_link'),
|
|
||||||
confirmText: $t('delete'),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!isConfirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await removeSharedLink({ id });
|
|
||||||
notificationController.show({ message: $t('deleted_shared_link'), type: NotificationType.Info });
|
|
||||||
await refresh();
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, $t('errors.unable_to_delete_shared_link'));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEditDone = async () => {
|
|
||||||
await refresh();
|
|
||||||
editSharedLink = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
let backUrl: string = AppRoute.SHARING;
|
|
||||||
|
|
||||||
afterNavigate(({ from }) => {
|
|
||||||
let url: string | undefined = from?.url?.pathname;
|
|
||||||
backUrl = url || AppRoute.SHARING;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<ControlAppBar backIcon={mdiArrowLeft} onClose={() => goto(backUrl)}>
|
|
||||||
{#snippet leading()}
|
|
||||||
{$t('shared_links')}
|
|
||||||
{/snippet}
|
|
||||||
</ControlAppBar>
|
|
||||||
|
|
||||||
<section class="mt-[120px] flex flex-col pb-[120px] container max-w-screen-lg mx-auto px-3">
|
|
||||||
<div class="mb-4 dark:text-immich-gray">
|
|
||||||
<p>{$t('manage_shared_links')}</p>
|
|
||||||
</div>
|
|
||||||
{#if sharedLinks.length === 0}
|
|
||||||
<div
|
|
||||||
class="flex place-content-center place-items-center rounded-lg bg-gray-100 dark:bg-immich-dark-gray dark:text-immich-gray p-12"
|
|
||||||
>
|
|
||||||
<p>{$t('you_dont_have_any_shared_links')}</p>
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div class="flex flex-col">
|
|
||||||
{#each sharedLinks as link (link.id)}
|
|
||||||
<SharedLinkCard {link} onDelete={() => handleDeleteLink(link.id)} onEdit={() => (editSharedLink = link)} />
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{#if editSharedLink}
|
|
||||||
<CreateSharedLinkModal editingLink={editSharedLink} onClose={handleEditDone} />
|
|
||||||
{/if}
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
import { authenticate } from '$lib/utils/auth';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { getFormatter } from '$lib/utils/i18n';
|
import { redirect } from '@sveltejs/kit';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (() => {
|
||||||
await authenticate();
|
redirect(307, AppRoute.SHARED_LINKS);
|
||||||
const $t = await getFormatter();
|
|
||||||
|
|
||||||
return {
|
|
||||||
meta: {
|
|
||||||
title: $t('shared_links'),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}) satisfies PageLoad;
|
}) satisfies PageLoad;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue