2022-07-15 23:18:17 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { page } from '$app/stores';
|
2023-01-27 09:32:26 -05:00
|
|
|
import { api } from '@api';
|
|
|
|
|
import AccountMultipleOutline from 'svelte-material-icons/AccountMultipleOutline.svelte';
|
2022-07-15 23:18:17 -05:00
|
|
|
import ImageAlbum from 'svelte-material-icons/ImageAlbum.svelte';
|
|
|
|
|
import ImageOutline from 'svelte-material-icons/ImageOutline.svelte';
|
2023-04-12 18:37:52 +03:00
|
|
|
import ArchiveArrowDownOutline from 'svelte-material-icons/ArchiveArrowDownOutline.svelte';
|
2023-03-05 15:44:31 -05:00
|
|
|
import Magnify from 'svelte-material-icons/Magnify.svelte';
|
2023-01-27 09:32:26 -05:00
|
|
|
import StarOutline from 'svelte-material-icons/StarOutline.svelte';
|
2022-12-09 15:51:42 -05:00
|
|
|
import { AppRoute } from '../../../constants';
|
2023-01-27 09:32:26 -05:00
|
|
|
import LoadingSpinner from '../loading-spinner.svelte';
|
|
|
|
|
import StatusBox from '../status-box.svelte';
|
|
|
|
|
import SideBarButton from './side-bar-button.svelte';
|
2023-02-22 18:53:08 +01:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2023-04-15 03:41:52 +02:00
|
|
|
import SideBarSection from './side-bar-section.svelte';
|
|
|
|
|
|
|
|
|
|
let isCollapsed: boolean;
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-09-07 15:16:18 -05:00
|
|
|
const getAssetCount = async () => {
|
2023-04-12 18:37:52 +03:00
|
|
|
const { data: allAssetCount } = await api.assetApi.getAssetCountByUserId();
|
|
|
|
|
const { data: archivedCount } = await api.assetApi.getArchivedAssetCountByUserId();
|
2022-09-07 15:16:18 -05:00
|
|
|
|
|
|
|
|
return {
|
2023-04-12 18:37:52 +03:00
|
|
|
videos: allAssetCount.videos - archivedCount.videos,
|
|
|
|
|
photos: allAssetCount.photos - archivedCount.photos
|
2022-09-07 15:16:18 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-27 09:32:26 -05:00
|
|
|
const getFavoriteCount = async () => {
|
2023-04-13 10:22:06 -05:00
|
|
|
try {
|
|
|
|
|
const { data: assets } = await api.assetApi.getAllAssets(true, undefined);
|
2023-01-27 09:32:26 -05:00
|
|
|
|
2023-04-13 10:22:06 -05:00
|
|
|
return {
|
|
|
|
|
favorites: assets.length
|
|
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
favorites: 0
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-01-27 09:32:26 -05:00
|
|
|
};
|
|
|
|
|
|
2022-09-07 15:16:18 -05:00
|
|
|
const getAlbumCount = async () => {
|
2023-04-13 10:22:06 -05:00
|
|
|
try {
|
|
|
|
|
const { data: albumCount } = await api.albumApi.getAlbumCountByUserId();
|
|
|
|
|
return {
|
|
|
|
|
shared: albumCount.shared,
|
|
|
|
|
sharing: albumCount.sharing,
|
|
|
|
|
owned: albumCount.owned
|
|
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
shared: 0,
|
|
|
|
|
sharing: 0,
|
|
|
|
|
owned: 0
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-09-07 15:16:18 -05:00
|
|
|
};
|
2023-04-12 18:37:52 +03:00
|
|
|
|
|
|
|
|
const getArchivedAssetsCount = async () => {
|
2023-04-13 10:22:06 -05:00
|
|
|
try {
|
|
|
|
|
const { data: assetCount } = await api.assetApi.getArchivedAssetCountByUserId();
|
2023-04-12 18:37:52 +03:00
|
|
|
|
2023-04-13 10:22:06 -05:00
|
|
|
return {
|
|
|
|
|
videos: assetCount.videos,
|
|
|
|
|
photos: assetCount.photos
|
|
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
videos: 0,
|
|
|
|
|
photos: 0
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-04-12 18:37:52 +03:00
|
|
|
};
|
2022-07-15 23:18:17 -05:00
|
|
|
</script>
|
|
|
|
|
|
2023-04-15 03:41:52 +02:00
|
|
|
<SideBarSection bind:isCollapsed>
|
2022-09-07 15:16:18 -05:00
|
|
|
<a
|
2022-12-06 18:08:08 -06:00
|
|
|
data-sveltekit-preload-data="hover"
|
2022-09-16 23:13:22 -05:00
|
|
|
data-sveltekit-noscroll
|
2022-12-09 15:51:42 -05:00
|
|
|
href={AppRoute.PHOTOS}
|
2023-01-15 14:01:10 -06:00
|
|
|
draggable="false"
|
2022-09-07 15:16:18 -05:00
|
|
|
>
|
2022-07-15 23:18:17 -05:00
|
|
|
<SideBarButton
|
2023-02-21 13:42:22 +01:00
|
|
|
title="Photos"
|
2022-07-15 23:18:17 -05:00
|
|
|
logo={ImageOutline}
|
2023-02-27 04:23:43 +01:00
|
|
|
isSelected={$page.route.id === '/(user)/photos'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2022-09-07 15:16:18 -05:00
|
|
|
>
|
2023-02-21 13:42:22 +01:00
|
|
|
<svelte:fragment slot="moreInformation">
|
|
|
|
|
{#await getAssetCount()}
|
|
|
|
|
<LoadingSpinner />
|
|
|
|
|
{:then data}
|
|
|
|
|
<div>
|
2023-02-22 18:53:08 +01:00
|
|
|
<p>{data.videos.toLocaleString($locale)} Videos</p>
|
|
|
|
|
<p>{data.photos.toLocaleString($locale)} Photos</p>
|
2023-02-21 13:42:22 +01:00
|
|
|
</div>
|
|
|
|
|
{/await}
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
</SideBarButton>
|
2022-09-07 15:16:18 -05:00
|
|
|
</a>
|
2023-03-05 15:44:31 -05:00
|
|
|
<a
|
|
|
|
|
data-sveltekit-preload-data="hover"
|
|
|
|
|
data-sveltekit-noscroll
|
|
|
|
|
href={AppRoute.EXPLORE}
|
|
|
|
|
draggable="false"
|
|
|
|
|
>
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Explore"
|
|
|
|
|
logo={Magnify}
|
|
|
|
|
isSelected={$page.route.id === '/(user)/explore'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2023-03-05 15:44:31 -05:00
|
|
|
/>
|
|
|
|
|
</a>
|
2023-02-21 13:42:22 +01:00
|
|
|
<a data-sveltekit-preload-data="hover" href={AppRoute.SHARING} draggable="false">
|
2022-07-16 23:52:00 -05:00
|
|
|
<SideBarButton
|
|
|
|
|
title="Sharing"
|
|
|
|
|
logo={AccountMultipleOutline}
|
2023-02-27 04:23:43 +01:00
|
|
|
isSelected={$page.route.id === '/(user)/sharing'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2022-09-07 15:16:18 -05:00
|
|
|
>
|
2023-02-21 13:42:22 +01:00
|
|
|
<svelte:fragment slot="moreInformation">
|
|
|
|
|
{#await getAlbumCount()}
|
|
|
|
|
<LoadingSpinner />
|
|
|
|
|
{:then data}
|
|
|
|
|
<div>
|
2023-02-22 18:53:08 +01:00
|
|
|
<p>{(data.shared + data.sharing).toLocaleString($locale)} Albums</p>
|
2023-02-21 13:42:22 +01:00
|
|
|
</div>
|
|
|
|
|
{/await}
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
</SideBarButton>
|
2022-09-07 15:16:18 -05:00
|
|
|
</a>
|
2023-02-21 13:42:22 +01:00
|
|
|
|
2023-04-15 03:41:52 +02:00
|
|
|
<div
|
|
|
|
|
class="text-xs md:pb-2 md:p-5 p-6 pb-[1.2rem] dark:text-immich-dark-fg transition-all duration-200"
|
|
|
|
|
>
|
|
|
|
|
<p class={isCollapsed ? 'hidden' : 'block'}>LIBRARY</p>
|
|
|
|
|
<hr class={isCollapsed ? 'block mt-2 mb-[0.45rem]' : 'hidden'} />
|
2022-07-15 23:18:17 -05:00
|
|
|
</div>
|
2023-02-21 13:42:22 +01:00
|
|
|
<a data-sveltekit-preload-data="hover" href={AppRoute.FAVORITES} draggable="false">
|
2023-01-27 09:32:26 -05:00
|
|
|
<SideBarButton
|
|
|
|
|
title="Favorites"
|
|
|
|
|
logo={StarOutline}
|
2023-02-27 04:23:43 +01:00
|
|
|
isSelected={$page.route.id == '/(user)/favorites'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2023-01-27 09:32:26 -05:00
|
|
|
>
|
2023-02-21 13:42:22 +01:00
|
|
|
<svelte:fragment slot="moreInformation">
|
|
|
|
|
{#await getFavoriteCount()}
|
|
|
|
|
<LoadingSpinner />
|
|
|
|
|
{:then data}
|
|
|
|
|
<div>
|
|
|
|
|
<p>{data.favorites} Favorites</p>
|
|
|
|
|
</div>
|
|
|
|
|
{/await}
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
</SideBarButton>
|
2023-01-27 09:32:26 -05:00
|
|
|
</a>
|
2023-02-21 13:42:22 +01:00
|
|
|
<a data-sveltekit-preload-data="hover" href={AppRoute.ALBUMS} draggable="false">
|
2023-02-27 04:23:43 +01:00
|
|
|
<SideBarButton
|
|
|
|
|
title="Albums"
|
|
|
|
|
logo={ImageAlbum}
|
|
|
|
|
isSelected={$page.route.id === '/(user)/albums'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2023-02-27 04:23:43 +01:00
|
|
|
>
|
2023-02-21 13:42:22 +01:00
|
|
|
<svelte:fragment slot="moreInformation">
|
|
|
|
|
{#await getAlbumCount()}
|
|
|
|
|
<LoadingSpinner />
|
|
|
|
|
{:then data}
|
|
|
|
|
<div>
|
2023-02-22 18:53:08 +01:00
|
|
|
<p>{data.owned.toLocaleString($locale)} Albums</p>
|
2023-02-21 13:42:22 +01:00
|
|
|
</div>
|
|
|
|
|
{/await}
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
</SideBarButton>
|
2022-07-15 23:18:17 -05:00
|
|
|
</a>
|
2023-04-12 18:37:52 +03:00
|
|
|
<a data-sveltekit-preload-data="hover" href={AppRoute.ARCHIVE} draggable="false">
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Archive"
|
|
|
|
|
logo={ArchiveArrowDownOutline}
|
|
|
|
|
isSelected={$page.route.id === '/(user)/archive'}
|
2023-04-15 03:41:52 +02:00
|
|
|
{isCollapsed}
|
2023-04-12 18:37:52 +03:00
|
|
|
>
|
|
|
|
|
<svelte:fragment slot="moreInformation">
|
|
|
|
|
{#await getArchivedAssetsCount()}
|
|
|
|
|
<LoadingSpinner />
|
|
|
|
|
{:then data}
|
|
|
|
|
<div>
|
|
|
|
|
<p>{data.videos.toLocaleString($locale)} Videos</p>
|
|
|
|
|
<p>{data.photos.toLocaleString($locale)} Photos</p>
|
|
|
|
|
</div>
|
|
|
|
|
{/await}
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
</SideBarButton>
|
|
|
|
|
</a>
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-08-25 23:04:23 -07:00
|
|
|
<!-- Status Box -->
|
2022-07-15 23:18:17 -05:00
|
|
|
<div class="mb-6 mt-auto">
|
2023-04-15 03:41:52 +02:00
|
|
|
<StatusBox {isCollapsed} />
|
2022-07-15 23:18:17 -05:00
|
|
|
</div>
|
2023-04-15 03:41:52 +02:00
|
|
|
</SideBarSection>
|