mirror of https://github.com/immich-app/immich.git
chore: minor admin pages refactorings (#24160)
parent
2801a6e672
commit
939d2c8b27
@ -1,35 +1,33 @@
|
||||
<script lang="ts">
|
||||
import AdminPageLayout from '$lib/components/layouts/AdminPageLayout.svelte';
|
||||
import ServerStatisticsPanel from '$lib/components/server-statistics/ServerStatisticsPanel.svelte';
|
||||
import { asyncTimeout } from '$lib/utils';
|
||||
import { getServerStatistics } from '@immich/sdk';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
interface Props {
|
||||
type Props = {
|
||||
data: PageData;
|
||||
}
|
||||
};
|
||||
|
||||
let { data = $bindable() }: Props = $props();
|
||||
const { data }: Props = $props();
|
||||
|
||||
let running = true;
|
||||
let stats = $state(data.stats);
|
||||
|
||||
onMount(async () => {
|
||||
while (running) {
|
||||
data.stats = await getServerStatistics();
|
||||
await asyncTimeout(5000);
|
||||
}
|
||||
});
|
||||
const updateStatistics = async () => {
|
||||
stats = await getServerStatistics();
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
const interval = setInterval(() => void updateStatistics(), 5000);
|
||||
|
||||
onDestroy(() => {
|
||||
running = false;
|
||||
return () => clearInterval(interval);
|
||||
});
|
||||
</script>
|
||||
|
||||
<AdminPageLayout title={data.meta.title}>
|
||||
<section id="setting-content" class="flex place-content-center sm:mx-4">
|
||||
<section class="w-full pb-28 sm:w-5/6 md:w-212.5">
|
||||
<ServerStatisticsPanel stats={data.stats} />
|
||||
<ServerStatisticsPanel {stats} />
|
||||
</section>
|
||||
</section>
|
||||
</AdminPageLayout>
|
||||
|
||||
Loading…
Reference in New Issue