2024-07-18 10:56:27 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
import ServerAboutModal from '$lib/components/shared-components/server-about-modal.svelte';
|
|
|
|
|
import { websocketStore } from '$lib/stores/websocket';
|
|
|
|
|
import { requestServerInfo } from '$lib/utils/auth';
|
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
2024-10-01 13:33:58 -04:00
|
|
|
import {
|
|
|
|
|
getAboutInfo,
|
|
|
|
|
getVersionHistory,
|
|
|
|
|
type ServerAboutResponseDto,
|
|
|
|
|
type ServerVersionHistoryResponseDto,
|
|
|
|
|
} from '@immich/sdk';
|
2024-10-17 14:36:52 +02:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
|
|
|
|
import { mdiAlert } from '@mdi/js';
|
2024-07-18 10:56:27 -05:00
|
|
|
|
|
|
|
|
const { serverVersion, connected } = websocketStore;
|
|
|
|
|
|
|
|
|
|
let isOpen = false;
|
|
|
|
|
|
2024-10-17 14:36:52 +02:00
|
|
|
$: isMain = info?.sourceRef === 'main' && info.repository === 'immich-app/immich';
|
2024-07-18 10:56:27 -05:00
|
|
|
$: version = $serverVersion ? `v${$serverVersion.major}.${$serverVersion.minor}.${$serverVersion.patch}` : null;
|
|
|
|
|
|
2024-10-01 13:33:58 -04:00
|
|
|
let info: ServerAboutResponseDto;
|
|
|
|
|
let versions: ServerVersionHistoryResponseDto[] = [];
|
2024-07-18 10:56:27 -05:00
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
await requestServerInfo();
|
2024-10-01 13:33:58 -04:00
|
|
|
[info, versions] = await Promise.all([getAboutInfo(), getVersionHistory()]);
|
2024-07-18 10:56:27 -05:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if isOpen}
|
2024-10-01 13:33:58 -04:00
|
|
|
<ServerAboutModal onClose={() => (isOpen = false)} {info} {versions} />
|
2024-07-18 10:56:27 -05:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="text-sm hidden group-hover:sm:flex md:flex pl-5 pr-1 place-items-center place-content-center justify-between"
|
|
|
|
|
>
|
|
|
|
|
{#if $connected}
|
|
|
|
|
<div class="flex gap-2 place-items-center place-content-center">
|
|
|
|
|
<div class="w-[7px] h-[7px] bg-green-500 rounded-full" />
|
|
|
|
|
<p class="dark:text-immich-gray">{$t('server_online')}</p>
|
|
|
|
|
</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="flex gap-2 place-items-center place-content-center">
|
|
|
|
|
<div class="w-[7px] h-[7px] bg-red-500 rounded-full" />
|
|
|
|
|
<p class="text-red-500">{$t('server_offline')}</p>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-between justify-items-center">
|
|
|
|
|
{#if $connected && version}
|
2024-10-17 14:36:52 +02:00
|
|
|
<button type="button" on:click={() => (isOpen = true)} class="dark:text-immich-gray flex gap-1">
|
|
|
|
|
{#if isMain}
|
|
|
|
|
<Icon path={mdiAlert} size="1.5em" color="#ffcc4d" /> {info.sourceRef}
|
|
|
|
|
{:else}
|
|
|
|
|
{version}
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
2024-07-18 10:56:27 -05:00
|
|
|
{:else}
|
|
|
|
|
<p class="text-red-500">{$t('unknown')}</p>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|