2022-05-21 02:23:55 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { afterNavigate, beforeNavigate } from '$app/navigation';
|
2024-12-20 15:18:22 -07:00
|
|
|
import { page } from '$app/state';
|
2025-09-30 12:39:24 +00:00
|
|
|
import { shortcut } from '$lib/actions/shortcut.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte';
|
2025-03-13 18:04:21 -04:00
|
|
|
import ErrorLayout from '$lib/components/layouts/ErrorLayout.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import AppleHeader from '$lib/components/shared-components/apple-header.svelte';
|
|
|
|
|
import NavigationLoadingBar from '$lib/components/shared-components/navigation-loading-bar.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import NotificationList from '$lib/components/shared-components/notification/notification-list.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import UploadPanel from '$lib/components/shared-components/upload-panel.svelte';
|
2025-04-28 14:48:33 -04:00
|
|
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
2025-06-23 04:56:41 +02:00
|
|
|
import VersionAnnouncementModal from '$lib/modals/VersionAnnouncementModal.svelte';
|
2024-08-25 18:34:08 -04:00
|
|
|
import { serverConfig } from '$lib/stores/server-config.store';
|
2023-12-12 17:35:28 +01:00
|
|
|
import { user } from '$lib/stores/user.store';
|
2025-06-23 04:56:41 +02:00
|
|
|
import {
|
|
|
|
|
closeWebsocketConnection,
|
|
|
|
|
openWebsocketConnection,
|
|
|
|
|
websocketStore,
|
|
|
|
|
type ReleaseEvent,
|
|
|
|
|
} from '$lib/stores/websocket';
|
2025-10-06 12:00:37 -05:00
|
|
|
import { copyToClipboard, getReleaseType } from '$lib/utils';
|
2025-04-28 14:48:33 -04:00
|
|
|
import { isAssetViewerRoute } from '$lib/utils/navigation';
|
2025-06-23 04:56:41 +02:00
|
|
|
import type { ServerVersionResponseDto } from '@immich/sdk';
|
2025-07-23 23:27:09 +02:00
|
|
|
import { modalManager, setTranslations } from '@immich/ui';
|
2025-04-29 17:44:09 -04:00
|
|
|
import { onMount, type Snippet } from 'svelte';
|
2025-03-13 18:04:21 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2025-01-14 09:14:28 -05:00
|
|
|
import { run } from 'svelte/legacy';
|
2024-02-14 08:09:49 -05:00
|
|
|
import '../app.css';
|
2025-01-14 09:14:28 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
children?: Snippet;
|
|
|
|
|
}
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2025-01-14 14:53:33 -05:00
|
|
|
$effect(() => {
|
|
|
|
|
setTranslations({
|
|
|
|
|
close: $t('close'),
|
2025-07-01 03:33:47 +08:00
|
|
|
show_password: $t('show_password'),
|
|
|
|
|
hide_password: $t('hide_password'),
|
2025-08-27 22:00:50 -05:00
|
|
|
confirm: $t('confirm'),
|
|
|
|
|
cancel: $t('cancel'),
|
2025-01-14 14:53:33 -05:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let { children }: Props = $props();
|
2024-01-07 01:15:25 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let showNavigationLoadingBar = $state(false);
|
2024-02-20 15:20:09 +01:00
|
|
|
|
2024-08-24 01:03:36 +02:00
|
|
|
const getMyImmichLink = () => {
|
2024-12-20 15:18:22 -07:00
|
|
|
return new URL(page.url.pathname + page.url.search, 'https://my.immich.app');
|
2024-08-24 01:03:36 +02:00
|
|
|
};
|
|
|
|
|
|
2024-01-07 01:15:25 +01:00
|
|
|
onMount(() => {
|
2024-08-25 18:34:08 -04:00
|
|
|
const element = document.querySelector('#stencil');
|
|
|
|
|
element?.remove();
|
2024-01-07 01:15:25 +01:00
|
|
|
// if the browser theme changes, changes the Immich theme too
|
|
|
|
|
});
|
2024-01-03 23:28:32 -06:00
|
|
|
|
2025-04-28 14:48:33 -04:00
|
|
|
eventManager.emit('app.init');
|
2023-08-25 00:03:28 -04:00
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
beforeNavigate(({ from, to }) => {
|
|
|
|
|
if (isAssetViewerRoute(from) && isAssetViewerRoute(to)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-01 00:50:47 -04:00
|
|
|
showNavigationLoadingBar = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterNavigate(() => {
|
|
|
|
|
showNavigationLoadingBar = false;
|
|
|
|
|
});
|
2024-11-14 08:43:25 -06:00
|
|
|
run(() => {
|
|
|
|
|
if ($user) {
|
|
|
|
|
openWebsocketConnection();
|
|
|
|
|
} else {
|
|
|
|
|
closeWebsocketConnection();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-06-23 04:56:41 +02:00
|
|
|
|
|
|
|
|
const semverToName = ({ major, minor, patch }: ServerVersionResponseDto) => `v${major}.${minor}.${patch}`;
|
|
|
|
|
const { release } = websocketStore;
|
|
|
|
|
|
2025-06-23 20:13:08 +08:00
|
|
|
const handleRelease = async (release?: ReleaseEvent) => {
|
|
|
|
|
if (!release?.isAvailable || !$user.isAdmin) {
|
2025-06-23 04:56:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const releaseVersion = semverToName(release.releaseVersion);
|
|
|
|
|
const serverVersion = semverToName(release.serverVersion);
|
2025-10-06 12:00:37 -05:00
|
|
|
const type = getReleaseType(release.serverVersion, release.releaseVersion);
|
2025-06-23 04:56:41 +02:00
|
|
|
|
2025-10-06 12:00:37 -05:00
|
|
|
if (type === 'none' || type === 'patch' || localStorage.getItem('appVersion') === releaseVersion) {
|
2025-06-23 04:56:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await modalManager.show(VersionAnnouncementModal, { serverVersion, releaseVersion });
|
|
|
|
|
|
|
|
|
|
localStorage.setItem('appVersion', releaseVersion);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error [VersionAnnouncementBox]:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$effect(() => void handleRelease($release));
|
2022-05-21 02:23:55 -05:00
|
|
|
</script>
|
|
|
|
|
|
2023-01-10 22:36:50 -05:00
|
|
|
<svelte:head>
|
2024-12-20 15:18:22 -07:00
|
|
|
<title>{page.data.meta?.title || 'Web'} - Immich</title>
|
2024-10-23 21:53:23 -04:00
|
|
|
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
|
2023-07-01 00:50:47 -04:00
|
|
|
<meta name="theme-color" content="currentColor" />
|
|
|
|
|
<AppleHeader />
|
|
|
|
|
|
2024-12-20 15:18:22 -07:00
|
|
|
{#if page.data.meta}
|
|
|
|
|
<meta name="description" content={page.data.meta.description} />
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
|
<!-- Facebook Meta Tags -->
|
|
|
|
|
<meta property="og:type" content="website" />
|
2024-12-20 15:18:22 -07:00
|
|
|
<meta property="og:title" content={page.data.meta.title} />
|
|
|
|
|
<meta property="og:description" content={page.data.meta.description} />
|
|
|
|
|
{#if page.data.meta.imageUrl}
|
2024-07-29 14:38:47 -07:00
|
|
|
<meta
|
|
|
|
|
property="og:image"
|
2024-12-20 15:18:22 -07:00
|
|
|
content={new URL(page.data.meta.imageUrl, $serverConfig.externalDomain || globalThis.location.origin).href}
|
2024-07-29 14:38:47 -07:00
|
|
|
/>
|
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
|
<!-- Twitter Meta Tags -->
|
|
|
|
|
<meta name="twitter:card" content="summary_large_image" />
|
2024-12-20 15:18:22 -07:00
|
|
|
<meta name="twitter:title" content={page.data.meta.title} />
|
|
|
|
|
<meta name="twitter:description" content={page.data.meta.description} />
|
|
|
|
|
{#if page.data.meta.imageUrl}
|
2024-07-29 14:38:47 -07:00
|
|
|
<meta
|
|
|
|
|
name="twitter:image"
|
2024-12-20 15:18:22 -07:00
|
|
|
content={new URL(page.data.meta.imageUrl, $serverConfig.externalDomain || globalThis.location.origin).href}
|
2024-07-29 14:38:47 -07:00
|
|
|
/>
|
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
2023-01-10 22:36:50 -05:00
|
|
|
</svelte:head>
|
|
|
|
|
|
2025-05-21 18:12:00 +02:00
|
|
|
<svelte:document
|
2025-09-30 12:39:24 +00:00
|
|
|
{@attach shortcut({ key: 'm', ctrl: true, shift: true }, $t('get_my_immich_link'), () =>
|
|
|
|
|
copyToClipboard(getMyImmichLink().toString()),
|
|
|
|
|
)}
|
2024-08-24 01:03:36 +02:00
|
|
|
/>
|
2024-08-25 18:34:08 -04:00
|
|
|
|
2024-12-20 15:18:22 -07:00
|
|
|
{#if page.data.error}
|
2025-03-13 18:04:21 -04:00
|
|
|
<ErrorLayout error={page.data.error}></ErrorLayout>
|
2024-08-25 18:34:08 -04:00
|
|
|
{:else}
|
2024-11-14 08:43:25 -06:00
|
|
|
{@render children?.()}
|
2024-08-25 18:34:08 -04:00
|
|
|
{/if}
|
2023-11-17 21:31:34 -05:00
|
|
|
|
2023-02-27 04:23:43 +01:00
|
|
|
{#if showNavigationLoadingBar}
|
2023-07-01 00:50:47 -04:00
|
|
|
<NavigationLoadingBar />
|
2023-02-27 04:23:43 +01:00
|
|
|
{/if}
|
2023-02-22 18:53:08 +01:00
|
|
|
|
2023-02-27 04:23:43 +01:00
|
|
|
<DownloadPanel />
|
|
|
|
|
<UploadPanel />
|
|
|
|
|
<NotificationList />
|