chore(web) Add automatic server stats refetching (#1271)

This commit is contained in:
Krisjanis Lejejs
2023-01-09 22:40:54 +02:00
committed by GitHub
parent af2eac52a8
commit 5999af6c78
5 changed files with 71 additions and 42 deletions

View File

@@ -13,5 +13,5 @@ export const load: PageServerLoad = async ({ parent }) => {
const { data: allUsers } = await serverApi.userApi.getAllUsers(false);
return { user, allUsers };
return { allUsers };
};

View File

@@ -1,29 +1,12 @@
<script lang="ts">
import ServerStatsPanel from '$lib/components/admin-page/server-stats/server-stats-panel.svelte';
import { api, ServerStatsResponseDto } from '@api';
import { onMount } from 'svelte';
import { page } from '$app/stores';
let serverStat: ServerStatsResponseDto;
onMount(() => {
getServerStats();
});
const getServerStats = async () => {
try {
const res = await api.serverInfoApi.getStats();
serverStat = res.data;
} catch (e) {
console.log(e);
}
};
</script>
<svelte:head>
<title>Server Status - Immich</title>
</svelte:head>
{#if $page.data.allUsers && serverStat}
<ServerStatsPanel stats={serverStat} allUsers={$page.data.allUsers} />
{#if $page.data.allUsers}
<ServerStatsPanel allUsers={$page.data.allUsers} />
{/if}