Skip to content

Commit 00f276f

Browse files
axel7083vrothberg
authored andcommitted
fix: refresh issue for inference servers
Signed-off-by: axel7083 <[email protected]>
1 parent 885fce5 commit 00f276f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

packages/frontend/src/lib/table/service/ServiceStatus.svelte

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ function navigateToContainer() {
1010
studioClient.navigateToContainer(object.container.containerId);
1111
}
1212
13+
let status: string;
14+
let loading: boolean;
15+
$: {
16+
status = getStatus();
17+
loading = object.health === undefined && object.status !== 'stopped';
18+
}
19+
1320
function getStatus(): 'RUNNING' | 'STARTING' | 'DEGRADED' | '' {
1421
if (object.status === 'stopped') {
1522
return '';
@@ -28,12 +35,10 @@ function getStatus(): 'RUNNING' | 'STARTING' | 'DEGRADED' | '' {
2835
}
2936
</script>
3037

31-
{#key object.status}
32-
{#if object.health === undefined && object.status !== 'stopped'}
33-
<Spinner />
34-
{:else}
35-
<button on:click="{navigateToContainer}">
36-
<StatusIcon status="{getStatus()}" icon="{ContainerIcon}" />
37-
</button>
38-
{/if}
39-
{/key}
38+
{#if loading}
39+
<Spinner />
40+
{:else}
41+
<button on:click="{navigateToContainer}">
42+
<StatusIcon status="{status}" icon="{ContainerIcon}" />
43+
</button>
44+
{/if}

packages/frontend/src/pages/InferenceServers.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Button from '/@/lib/button/Button.svelte';
1212
import { faTrash } from '@fortawesome/free-solid-svg-icons';
1313
import { studioClient } from '/@/utils/client';
1414
import { router } from 'tinro';
15+
import { onMount } from 'svelte';
1516
1617
const columns: Column<InferenceServer>[] = [
1718
new Column<InferenceServer>('Status', { width: '70px', renderer: ServiceStatus, align: 'center' }),
@@ -22,7 +23,12 @@ const columns: Column<InferenceServer>[] = [
2223
const row = new Row<InferenceServer>({ selectable: _service => true });
2324
2425
let data: (InferenceServer & { selected?: boolean })[];
25-
$: data = $inferenceServers;
26+
27+
onMount(() => {
28+
return inferenceServers.subscribe(items => {
29+
data = items;
30+
});
31+
});
2632
2733
let selectedItemsNumber: number;
2834
@@ -53,7 +59,7 @@ function createNewService() {
5359
<div slot="content" class="flex flex-col min-w-full min-h-full">
5460
<div class="min-w-full min-h-full flex-1">
5561
<div class="mt-4 px-5 space-y-5">
56-
{#if data.length > 0}
62+
{#if data?.length > 0}
5763
<Table
5864
kind="service"
5965
data="{data}"

0 commit comments

Comments
 (0)