From 6673f1eb2441ac6d93f6de888f41a45e21591a5e Mon Sep 17 00:00:00 2001 From: Dan Taylor Date: Fri, 1 Dec 2023 18:26:48 -0800 Subject: [PATCH] fix(web): status box rendering (#5410) * fix(web): status box rendering * Syntax improvement for api import Co-authored-by: martin <74269598+martabal@users.noreply.github.com> --------- Co-authored-by: Daniel Taylor Co-authored-by: martin <74269598+martabal@users.noreply.github.com> --- .../shared-components/status-box.svelte | 15 +++++++-------- web/src/lib/stores/server-info.store.ts | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 web/src/lib/stores/server-info.store.ts diff --git a/web/src/lib/components/shared-components/status-box.svelte b/web/src/lib/components/shared-components/status-box.svelte index 31201dd4e..1d769829c 100644 --- a/web/src/lib/components/shared-components/status-box.svelte +++ b/web/src/lib/components/shared-components/status-box.svelte @@ -2,19 +2,18 @@ import { browser } from '$app/environment'; import { locale } from '$lib/stores/preferences.store'; import { websocketStore } from '$lib/stores/websocket'; - import { ServerInfoResponseDto, api } from '@api'; + import { api } from '@api'; import { onDestroy, onMount } from 'svelte'; import Icon from '$lib/components/elements/icon.svelte'; import { asByteUnitString } from '../../utils/byte-units'; import LoadingSpinner from './loading-spinner.svelte'; import { mdiCloud, mdiDns } from '@mdi/js'; + import { serverInfoStore } from '$lib/stores/server-info.store'; const { serverVersion, connected } = websocketStore; - let serverInfo: ServerInfoResponseDto; - $: version = $serverVersion ? `v${$serverVersion.major}.${$serverVersion.minor}.${$serverVersion.patch}` : null; - $: usedPercentage = Math.round((serverInfo?.diskUseRaw / serverInfo?.diskSizeRaw) * 100); + $: usedPercentage = Math.round(($serverInfoStore?.diskUseRaw / $serverInfoStore?.diskSizeRaw) * 100); onMount(async () => { await refresh(); @@ -23,7 +22,7 @@ const refresh = async () => { try { const { data } = await api.serverInfoApi.getServerInfo(); - serverInfo = data; + $serverInfoStore = data; } catch (e) { console.log('Error [StatusBox] [onMount]'); } @@ -44,7 +43,7 @@