2025-04-01 22:12:04 -04:00
|
|
|
<script lang="ts" module>
|
|
|
|
|
export const menuButtonId = 'top-menu-button';
|
|
|
|
|
</script>
|
|
|
|
|
|
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';
|
2025-05-22 14:48:07 +02:00
|
|
|
import CastButton from '$lib/cast/cast-button.svelte';
|
2025-01-16 11:03:04 -05:00
|
|
|
import ImmichLogo from '$lib/components/shared-components/immich-logo.svelte';
|
2025-04-28 10:36:14 -04:00
|
|
|
import NotificationPanel from '$lib/components/shared-components/navigation-bar/notification-panel.svelte';
|
2025-01-16 11:03:04 -05:00
|
|
|
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
|
|
|
|
|
import { AppRoute } from '$lib/constants';
|
2025-09-16 14:31:22 -04:00
|
|
|
import SkipLink from '$lib/elements/SkipLink.svelte';
|
2025-04-28 16:56:04 +02:00
|
|
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
2025-04-25 08:36:31 -04:00
|
|
|
import { mobileDevice } from '$lib/stores/mobile-device.svelte';
|
2025-05-06 07:47:58 -05:00
|
|
|
import { notificationManager } from '$lib/stores/notification-manager.svelte';
|
2024-02-13 17:07:37 -05:00
|
|
|
import { featureFlags } from '$lib/stores/server-config.store';
|
2025-04-25 08:36:31 -04:00
|
|
|
import { sidebarStore } from '$lib/stores/sidebar.svelte';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { user } from '$lib/stores/user.store';
|
2025-01-16 11:03:04 -05:00
|
|
|
import { Button, IconButton } from '@immich/ui';
|
2025-05-27 09:26:40 -05:00
|
|
|
import { mdiBellBadge, mdiBellOutline, mdiMagnify, mdiMenu, mdiTrayArrowUp } from '@mdi/js';
|
2025-10-14 10:15:51 -05:00
|
|
|
import { onMount } from 'svelte';
|
2024-09-07 13:21:05 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
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;
|
2025-05-14 11:23:57 -04:00
|
|
|
onUploadClick?: () => void;
|
|
|
|
|
// TODO: remove once this is only used in <AppShellHeader>
|
|
|
|
|
noBorder?: boolean;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2025-05-14 11:23:57 -04:00
|
|
|
let { showUploadButton = true, onUploadClick, noBorder = false }: Props = $props();
|
2024-11-14 08:43:25 -06:00
|
|
|
|
|
|
|
|
let shouldShowAccountInfoPanel = $state(false);
|
2025-04-28 10:36:14 -04:00
|
|
|
let shouldShowNotificationPanel = $state(false);
|
2024-11-14 08:43:25 -06:00
|
|
|
let innerWidth: number = $state(0);
|
2025-04-28 10:36:14 -04:00
|
|
|
const hasUnreadNotifications = $derived(notificationManager.notifications.length > 0);
|
2025-10-14 10:15:51 -05:00
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
try {
|
|
|
|
|
await notificationManager.refresh();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to load notifications on mount', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-05-21 02:23:55 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-13 12:14:45 -05:00
|
|
|
<svelte:window bind:innerWidth />
|
|
|
|
|
|
2025-05-25 14:31:24 -05:00
|
|
|
<nav id="dashboard-navbar" class="max-md:h-(--navbar-height-md) h-(--navbar-height) w-dvw 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
|
2025-05-18 15:51:33 +02:00
|
|
|
class="grid h-full grid-cols-[--spacing(32)_auto] items-center py-2 sidebar:grid-cols-[--spacing(64)_auto] {noBorder
|
2025-05-14 11:23:57 -04:00
|
|
|
? ''
|
|
|
|
|
: 'border-b'}"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2025-04-01 22:12:04 -04:00
|
|
|
<div class="flex flex-row gap-1 mx-4 items-center">
|
2025-04-10 13:00:30 -04:00
|
|
|
<IconButton
|
|
|
|
|
id={menuButtonId}
|
|
|
|
|
shape="round"
|
|
|
|
|
color="secondary"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="medium"
|
|
|
|
|
aria-label={$t('main_menu')}
|
|
|
|
|
icon={mdiMenu}
|
|
|
|
|
onclick={() => {
|
|
|
|
|
sidebarStore.toggle();
|
|
|
|
|
}}
|
|
|
|
|
onmousedown={(event: MouseEvent) => {
|
|
|
|
|
if (sidebarStore.isOpen) {
|
|
|
|
|
// stops event from reaching the default handler when clicking outside of the sidebar
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
class="sidebar:hidden"
|
|
|
|
|
/>
|
2025-04-01 22:12:04 -04:00
|
|
|
<a data-sveltekit-preload-data="hover" href={AppRoute.PHOTOS}>
|
2025-04-10 13:00:30 -04:00
|
|
|
<ImmichLogo class="max-md:h-[48px] h-[50px]" noText={!mobileDevice.isFullSidebar} />
|
2025-04-01 22:12:04 -04:00
|
|
|
</a>
|
|
|
|
|
</div>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="flex justify-between gap-4 lg:gap-8 pe-6">
|
|
|
|
|
<div class="hidden w-full max-w-5xl flex-1 tall:ps-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}
|
2025-03-12 17:25:27 -04:00
|
|
|
<IconButton
|
|
|
|
|
color="secondary"
|
|
|
|
|
shape="round"
|
|
|
|
|
variant="ghost"
|
2025-03-24 17:36:36 -04:00
|
|
|
size="medium"
|
2025-03-12 17:25:27 -04:00
|
|
|
icon={mdiMagnify}
|
2024-07-29 16:36:10 +02:00
|
|
|
href={AppRoute.SEARCH}
|
|
|
|
|
id="search-button"
|
2024-09-09 10:29:23 -04:00
|
|
|
class="sm:hidden"
|
2025-03-12 17:25:27 -04:00
|
|
|
aria-label={$t('go_to_search')}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-05-14 11:23:57 -04:00
|
|
|
{#if !page.url.pathname.includes('/admin') && showUploadButton && onUploadClick}
|
2025-03-12 17:25:27 -04:00
|
|
|
<Button
|
|
|
|
|
leadingIcon={mdiTrayArrowUp}
|
|
|
|
|
onclick={onUploadClick}
|
|
|
|
|
class="hidden lg:flex"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="medium"
|
|
|
|
|
color="secondary"
|
|
|
|
|
>{$t('upload')}
|
|
|
|
|
</Button>
|
|
|
|
|
<IconButton
|
|
|
|
|
color="secondary"
|
|
|
|
|
shape="round"
|
|
|
|
|
variant="ghost"
|
2025-03-24 17:36:36 -04:00
|
|
|
size="medium"
|
2025-03-12 17:25:27 -04:00
|
|
|
onclick={onUploadClick}
|
|
|
|
|
title={$t('upload')}
|
|
|
|
|
aria-label={$t('upload')}
|
|
|
|
|
icon={mdiTrayArrowUp}
|
|
|
|
|
class="lg:hidden"
|
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
|
|
|
|
2025-06-02 09:47:23 -05:00
|
|
|
<ThemeButton />
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2025-04-28 10:36:14 -04:00
|
|
|
<div
|
|
|
|
|
use:clickOutside={{
|
|
|
|
|
onOutclick: () => (shouldShowNotificationPanel = false),
|
|
|
|
|
onEscape: () => (shouldShowNotificationPanel = false),
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-10-14 10:15:51 -05:00
|
|
|
<div class="relative">
|
|
|
|
|
<IconButton
|
|
|
|
|
shape="round"
|
|
|
|
|
color={hasUnreadNotifications ? 'primary' : 'secondary'}
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="medium"
|
|
|
|
|
icon={hasUnreadNotifications ? mdiBellBadge : mdiBellOutline}
|
|
|
|
|
onclick={() => (shouldShowNotificationPanel = !shouldShowNotificationPanel)}
|
|
|
|
|
aria-label={$t('notifications')}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{#if hasUnreadNotifications}
|
|
|
|
|
<div
|
|
|
|
|
class="pointer-events-none absolute border top-0 right-1 flex h-5 w-5 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-light"
|
|
|
|
|
>
|
|
|
|
|
{notificationManager.notifications.length}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2025-04-28 10:36:14 -04:00
|
|
|
|
|
|
|
|
{#if shouldShowNotificationPanel}
|
|
|
|
|
<NotificationPanel />
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-02 09:47:23 -05:00
|
|
|
<CastButton />
|
2025-05-20 16:08:23 -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"
|
2025-04-28 09:53:53 -04:00
|
|
|
class="flex ps-2"
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={() => (shouldShowAccountInfoPanel = !shouldShowAccountInfoPanel)}
|
2025-05-06 07:47:58 -05:00
|
|
|
title={`${$user.name} (${$user.email})`}
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2023-12-12 17:35:28 +01:00
|
|
|
{#key $user}
|
2025-06-11 15:08:11 -04:00
|
|
|
<UserAvatar user={$user} size="md" noTitle 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 shouldShowAccountInfoPanel}
|
2025-05-22 14:48:07 +02:00
|
|
|
<AccountInfoPanel
|
|
|
|
|
onLogout={() => authManager.logout()}
|
|
|
|
|
onClose={() => (shouldShowAccountInfoPanel = false)}
|
|
|
|
|
/>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-04-29 13:51:39 -04:00
|
|
|
</nav>
|