2022-05-21 02:23:55 -05:00
|
|
|
<script lang="ts">
|
2024-12-20 15:18:22 -07:00
|
|
|
import { page } from '$app/state';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { clickOutside } from '$lib/actions/click-outside';
|
|
|
|
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
2024-02-18 03:34:27 +00:00
|
|
|
import SkipLink from '$lib/components/elements/buttons/skip-link.svelte';
|
2025-01-16 11:03:04 -05:00
|
|
|
import HelpAndFeedbackModal from '$lib/components/shared-components/help-and-feedback-modal.svelte';
|
|
|
|
|
import ImmichLogo from '$lib/components/shared-components/immich-logo.svelte';
|
|
|
|
|
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
|
|
|
|
|
import { AppRoute } from '$lib/constants';
|
2024-02-13 17:07:37 -05:00
|
|
|
import { featureFlags } from '$lib/stores/server-config.store';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { user } from '$lib/stores/user.store';
|
2024-12-16 15:45:01 +01:00
|
|
|
import { userInteraction } from '$lib/stores/user.svelte';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { handleLogout } from '$lib/utils/auth';
|
2024-10-01 11:15:31 +01:00
|
|
|
import { getAboutInfo, logout, type ServerAboutResponseDto } from '@immich/sdk';
|
2025-01-16 11:03:04 -05:00
|
|
|
import { Button, IconButton } from '@immich/ui';
|
2024-10-01 11:15:31 +01:00
|
|
|
import { mdiHelpCircleOutline, mdiMagnify, mdiTrayArrowUp } from '@mdi/js';
|
2025-01-16 11:03:04 -05:00
|
|
|
import { onMount } from 'svelte';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-09-09 10:29:23 -04:00
|
|
|
import { fade } from 'svelte/transition';
|
2024-02-13 17:07:37 -05:00
|
|
|
import ThemeButton from '../theme-button.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import UserAvatar from '../user-avatar.svelte';
|
2024-02-13 17:07:37 -05:00
|
|
|
import AccountInfoPanel from './account-info-panel.svelte';
|
2023-12-12 17:35:28 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
showUploadButton?: boolean;
|
|
|
|
|
onUploadClick: () => void;
|
|
|
|
|
}
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let { showUploadButton = true, onUploadClick }: Props = $props();
|
|
|
|
|
|
|
|
|
|
let shouldShowAccountInfo = $state(false);
|
|
|
|
|
let shouldShowAccountInfoPanel = $state(false);
|
|
|
|
|
let shouldShowHelpPanel = $state(false);
|
|
|
|
|
let innerWidth: number = $state(0);
|
2022-05-28 22:35:45 -05:00
|
|
|
|
2024-09-07 13:21:05 -04:00
|
|
|
const onLogout = async () => {
|
2024-02-13 17:07:37 -05:00
|
|
|
const { redirectUri } = await logout();
|
2024-09-07 13:21:05 -04:00
|
|
|
await handleLogout(redirectUri);
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2024-10-01 11:15:31 +01:00
|
|
|
|
2024-12-16 15:45:01 +01:00
|
|
|
let info: ServerAboutResponseDto | undefined = $state();
|
2024-10-01 11:15:31 +01:00
|
|
|
|
|
|
|
|
onMount(async () => {
|
2024-12-16 15:45:01 +01:00
|
|
|
info = userInteraction.aboutInfo ?? (await getAboutInfo());
|
2024-10-01 11:15:31 +01:00
|
|
|
});
|
2022-05-21 02:23:55 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-13 12:14:45 -05:00
|
|
|
<svelte:window bind:innerWidth />
|
|
|
|
|
|
2024-12-16 15:45:01 +01:00
|
|
|
{#if shouldShowHelpPanel && info}
|
|
|
|
|
<HelpAndFeedbackModal onClose={() => (shouldShowHelpPanel = false)} {info} />
|
2024-10-01 11:15:31 +01:00
|
|
|
{/if}
|
|
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<section id="dashboard-navbar" class="fixed z-[900] h-[var(--navbar-height)] w-screen text-sm">
|
2024-09-05 09:24:24 -04:00
|
|
|
<SkipLink text={$t('skip_to_content')} />
|
2023-07-01 00:50:47 -04:00
|
|
|
<div
|
2023-07-18 13:19:39 -05:00
|
|
|
class="grid h-full grid-cols-[theme(spacing.18)_auto] items-center border-b bg-immich-bg py-2 dark:border-b-immich-dark-gray dark:bg-immich-dark-bg md:grid-cols-[theme(spacing.64)_auto]"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2024-03-13 12:14:45 -05:00
|
|
|
<a data-sveltekit-preload-data="hover" class="ml-4" href={AppRoute.PHOTOS}>
|
|
|
|
|
<ImmichLogo width="55%" noText={innerWidth < 768} />
|
2023-07-01 00:50:47 -04:00
|
|
|
</a>
|
2024-09-09 10:29:23 -04:00
|
|
|
<div class="flex justify-between gap-4 lg:gap-8 pr-6">
|
|
|
|
|
<div class="hidden w-full max-w-5xl flex-1 tall:pl-0 sm:block">
|
2023-08-18 00:55:26 -04:00
|
|
|
{#if $featureFlags.search}
|
|
|
|
|
<SearchBar grayTheme={true} />
|
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2022-10-26 11:10:48 -05:00
|
|
|
|
2024-10-01 11:15:31 +01:00
|
|
|
<section class="flex place-items-center justify-end gap-1 md:gap-2 w-full sm:w-auto">
|
2023-08-18 00:55:26 -04:00
|
|
|
{#if $featureFlags.search}
|
2024-07-29 16:36:10 +02:00
|
|
|
<CircleIconButton
|
|
|
|
|
href={AppRoute.SEARCH}
|
|
|
|
|
id="search-button"
|
2024-09-09 10:29:23 -04:00
|
|
|
class="sm:hidden"
|
2024-07-29 16:36:10 +02:00
|
|
|
title={$t('go_to_search')}
|
|
|
|
|
icon={mdiMagnify}
|
2024-09-09 10:29:23 -04:00
|
|
|
padding="2"
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={() => {}}
|
2024-07-29 16:36:10 +02:00
|
|
|
/>
|
2023-08-18 00:55:26 -04:00
|
|
|
{/if}
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2024-09-09 10:29:23 -04:00
|
|
|
<ThemeButton padding="2" />
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2024-10-01 11:15:31 +01:00
|
|
|
<div
|
|
|
|
|
use:clickOutside={{
|
|
|
|
|
onEscape: () => (shouldShowHelpPanel = false),
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-01-16 11:03:04 -05:00
|
|
|
<IconButton
|
|
|
|
|
shape="round"
|
|
|
|
|
color="secondary"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="large"
|
2024-10-01 11:15:31 +01:00
|
|
|
title={$t('support_and_feedback')}
|
|
|
|
|
icon={mdiHelpCircleOutline}
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={() => (shouldShowHelpPanel = !shouldShowHelpPanel)}
|
2024-10-01 11:15:31 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-12-20 15:18:22 -07:00
|
|
|
{#if !page.url.pathname.includes('/admin') && showUploadButton}
|
2025-01-22 16:44:59 -05:00
|
|
|
<Button
|
|
|
|
|
leadingIcon={mdiTrayArrowUp}
|
|
|
|
|
onclick={onUploadClick}
|
|
|
|
|
class="hidden lg:flex"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
color="secondary"
|
|
|
|
|
>{$t('upload')}
|
2025-01-16 11:03:04 -05:00
|
|
|
</Button>
|
2024-09-09 10:29:23 -04:00
|
|
|
<CircleIconButton
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={onUploadClick}
|
2024-09-09 10:29:23 -04:00
|
|
|
title={$t('upload')}
|
|
|
|
|
icon={mdiTrayArrowUp}
|
|
|
|
|
class="lg:hidden"
|
|
|
|
|
padding="2"
|
|
|
|
|
/>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2023-09-26 04:53:26 +02:00
|
|
|
<div
|
2024-06-02 14:20:11 +02:00
|
|
|
use:clickOutside={{
|
|
|
|
|
onOutclick: () => (shouldShowAccountInfoPanel = false),
|
|
|
|
|
onEscape: () => (shouldShowAccountInfoPanel = false),
|
|
|
|
|
}}
|
2023-09-26 04:53:26 +02:00
|
|
|
>
|
2023-07-01 00:50:47 -04:00
|
|
|
<button
|
2024-05-27 09:06:15 +02:00
|
|
|
type="button"
|
2024-10-01 11:15:31 +01:00
|
|
|
class="flex pl-2"
|
2024-11-14 08:43:25 -06:00
|
|
|
onmouseover={() => (shouldShowAccountInfo = true)}
|
|
|
|
|
onfocus={() => (shouldShowAccountInfo = true)}
|
|
|
|
|
onblur={() => (shouldShowAccountInfo = false)}
|
|
|
|
|
onmouseleave={() => (shouldShowAccountInfo = false)}
|
|
|
|
|
onclick={() => (shouldShowAccountInfoPanel = !shouldShowAccountInfoPanel)}
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2023-12-12 17:35:28 +01:00
|
|
|
{#key $user}
|
2024-09-09 10:29:23 -04:00
|
|
|
<UserAvatar user={$user} size="md" showTitle={false} interactive />
|
2023-11-14 04:10:35 +01:00
|
|
|
{/key}
|
2023-07-01 00:50:47 -04:00
|
|
|
</button>
|
2023-03-06 15:31:58 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if shouldShowAccountInfo && !shouldShowAccountInfoPanel}
|
|
|
|
|
<div
|
|
|
|
|
in:fade={{ delay: 500, duration: 150 }}
|
|
|
|
|
out:fade={{ delay: 200, duration: 150 }}
|
2023-07-18 13:19:39 -05:00
|
|
|
class="absolute -bottom-12 right-5 rounded-md border bg-gray-500 p-2 text-[12px] text-gray-100 shadow-md dark:border-immich-dark-gray dark:bg-immich-dark-gray"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2023-12-12 17:35:28 +01:00
|
|
|
<p>{$user.name}</p>
|
|
|
|
|
<p>{$user.email}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-04-18 17:02:51 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if shouldShowAccountInfoPanel}
|
2024-09-20 23:02:58 +02:00
|
|
|
<AccountInfoPanel {onLogout} />
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-05-21 02:23:55 -05:00
|
|
|
</section>
|