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-01-14 09:14:28 -05:00
|
|
|
import { shortcut } from '$lib/actions/shortcut';
|
2023-07-01 00:50:47 -04:00
|
|
|
import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte';
|
2025-01-14 09:14:28 -05:00
|
|
|
import Error from '$lib/components/error.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import AppleHeader from '$lib/components/shared-components/apple-header.svelte';
|
2025-01-14 09:14:28 -05:00
|
|
|
import DialogWrapper from '$lib/components/shared-components/dialog/dialog-wrapper.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
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';
|
2023-07-01 00:50:47 -04:00
|
|
|
import VersionAnnouncementBox from '$lib/components/shared-components/version-announcement-box.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { Theme } from '$lib/constants';
|
|
|
|
|
import { colorTheme, handleToggleTheme, type ThemeSetting } from '$lib/stores/preferences.store';
|
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';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { closeWebsocketConnection, openWebsocketConnection } from '$lib/stores/websocket';
|
2024-08-24 01:03:36 +02:00
|
|
|
import { copyToClipboard, setKey } from '$lib/utils';
|
2025-01-14 09:14:28 -05:00
|
|
|
import { isAssetViewerRoute, isSharedLinkRoute } from '$lib/utils/navigation';
|
2024-11-14 08:43:25 -06:00
|
|
|
import { onDestroy, onMount, type Snippet } from 'svelte';
|
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
|
|
|
|
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-01-07 01:15:25 +01:00
|
|
|
const changeTheme = (theme: ThemeSetting) => {
|
|
|
|
|
if (theme.system) {
|
2024-12-18 15:19:48 +01:00
|
|
|
theme.value = globalThis.matchMedia('(prefers-color-scheme: dark)').matches ? Theme.DARK : Theme.LIGHT;
|
2024-01-03 23:28:32 -06:00
|
|
|
}
|
2024-01-07 01:15:25 +01:00
|
|
|
|
|
|
|
|
if (theme.value === Theme.LIGHT) {
|
|
|
|
|
document.documentElement.classList.remove('dark');
|
|
|
|
|
} else {
|
|
|
|
|
document.documentElement.classList.add('dark');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleChangeTheme = () => {
|
|
|
|
|
if ($colorTheme.system) {
|
|
|
|
|
handleToggleTheme();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
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-12-18 15:19:48 +01:00
|
|
|
globalThis.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', handleChangeTheme);
|
2024-01-07 01:15:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onDestroy(() => {
|
|
|
|
|
document.removeEventListener('change', handleChangeTheme);
|
|
|
|
|
});
|
2024-01-03 23:28:32 -06:00
|
|
|
|
2024-12-20 15:18:22 -07:00
|
|
|
if (isSharedLinkRoute(page.route?.id)) {
|
|
|
|
|
setKey(page.params.key);
|
2023-08-25 00:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
beforeNavigate(({ from, to }) => {
|
2024-09-06 15:15:48 +02:00
|
|
|
setKey(isSharedLinkRoute(to?.route.id) ? to?.params?.key : undefined);
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
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(() => {
|
|
|
|
|
changeTheme($colorTheme);
|
|
|
|
|
});
|
|
|
|
|
run(() => {
|
|
|
|
|
if ($user) {
|
|
|
|
|
openWebsocketConnection();
|
|
|
|
|
} else {
|
|
|
|
|
closeWebsocketConnection();
|
|
|
|
|
}
|
|
|
|
|
});
|
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>
|
|
|
|
|
|
2024-08-24 01:03:36 +02:00
|
|
|
<svelte:window
|
|
|
|
|
use:shortcut={{
|
|
|
|
|
shortcut: { ctrl: true, shift: true, key: 'm' },
|
|
|
|
|
onShortcut: () => copyToClipboard(getMyImmichLink().toString()),
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-08-25 18:34:08 -04:00
|
|
|
|
2024-12-20 15:18:22 -07:00
|
|
|
{#if page.data.error}
|
|
|
|
|
<Error error={page.data.error}></Error>
|
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 />
|
2024-05-28 09:10:43 +07:00
|
|
|
<DialogWrapper />
|
2023-02-28 00:13:39 +01:00
|
|
|
|
2023-12-12 17:35:28 +01:00
|
|
|
{#if $user?.isAdmin}
|
2023-10-24 17:05:42 +02:00
|
|
|
<VersionAnnouncementBox />
|
2023-02-28 00:13:39 +01:00
|
|
|
{/if}
|