feat(web): theme/locale preferences and improve SSR (#1832)

This commit is contained in:
Michel Heusschen 2023-02-22 18:53:08 +01:00 committed by GitHub
parent a9a769d902
commit 10cb612fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 142 additions and 144 deletions

View file

@ -3,7 +3,7 @@
import SelectionSearch from 'svelte-material-icons/SelectionSearch.svelte';
import Play from 'svelte-material-icons/Play.svelte';
import AllInclusive from 'svelte-material-icons/AllInclusive.svelte';
import { locale } from '$lib/stores/preferences.store';
import { createEventDispatcher } from 'svelte';
import { JobCounts } from '@api';
@ -22,8 +22,6 @@
const run = (includeAllAssets: boolean) => {
dispatch('click', { includeAllAssets });
};
const locale = navigator.language;
</script>
<div class="flex justify-between rounded-3xl bg-gray-100 dark:bg-immich-dark-gray">
@ -45,7 +43,7 @@
<p>Active</p>
<p class="text-2xl">
{#if jobCounts.active !== undefined}
{jobCounts.active.toLocaleString(locale)}
{jobCounts.active.toLocaleString($locale)}
{:else}
<LoadingSpinner />
{/if}
@ -57,7 +55,7 @@
>
<p class="text-2xl">
{#if jobCounts.waiting !== undefined}
{jobCounts.waiting.toLocaleString(locale)}
{jobCounts.waiting.toLocaleString($locale)}
{:else}
<LoadingSpinner />
{/if}

View file

@ -7,6 +7,7 @@
import { getBytesWithUnit, asByteUnitString } from '../../../utils/byte-units';
import { onMount, onDestroy } from 'svelte';
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
import { locale } from '$lib/stores/preferences.store';
export let allUsers: Array<UserResponseDto>;
@ -37,8 +38,6 @@
// Stats are unavailable if data is not loaded yet
$: [spaceUsage, spaceUnit] = getBytesWithUnit(stats ? stats.usageRaw : 0);
const locale = navigator.language;
</script>
<div class="flex flex-col gap-5">
@ -83,8 +82,10 @@
}`}
>
<td class="text-sm px-2 w-1/4 text-ellipsis">{getFullName(user.userId)}</td>
<td class="text-sm px-2 w-1/4 text-ellipsis">{user.photos.toLocaleString(locale)}</td>
<td class="text-sm px-2 w-1/4 text-ellipsis">{user.videos.toLocaleString(locale)}</td>
<td class="text-sm px-2 w-1/4 text-ellipsis">{user.photos.toLocaleString($locale)}</td
>
<td class="text-sm px-2 w-1/4 text-ellipsis">{user.videos.toLocaleString($locale)}</td
>
<td class="text-sm px-2 w-1/4 text-ellipsis">{asByteUnitString(user.usageRaw)}</td>
</tr>
{/each}