Skip to content

Commit ae3f05b

Browse files
committed
Always show the resource graph boxes
1 parent 976ad74 commit ae3f05b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

resources/scripts/components/server/ServerConsole.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default () => {
7373
return () => {
7474
instance.removeListener('stats', statsListener);
7575
};
76-
}, [ connected ]);
76+
}, [ instance, connected ]);
7777

7878
return (
7979
<div className={'my-10 flex'}>
@@ -135,7 +135,7 @@ export default () => {
135135
<div className={'flex-1 mx-4 mr-4'}>
136136
<SuspenseSpinner>
137137
<ChunkedConsole/>
138-
{status !== 'offline' && <ChunkedStatGraphs/>}
138+
<ChunkedStatGraphs/>
139139
</SuspenseSpinner>
140140
</div>
141141
</div>

resources/scripts/components/server/StatGraphs.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const createDefaultChart = (ctx: CanvasRenderingContext2D, options?: ChartConfig
7272
});
7373

7474
export default () => {
75-
const { limits } = ServerContext.useStoreState(state => state.server.data!);
75+
const status = ServerContext.useStoreState(state => state.status.value);
76+
const limits = ServerContext.useStoreState(state => state.server.data!.limits);
7677
const { connected, instance } = ServerContext.useStoreState(state => state.socket);
7778

7879
const [ memory, setMemory ] = useState<Chart>();
@@ -152,15 +153,28 @@ export default () => {
152153
return () => {
153154
instance.removeListener('stats', statsListener);
154155
};
155-
}, [ connected, memory, cpu ]);
156+
// eslint-disable-next-line react-hooks/exhaustive-deps
157+
}, [ instance, connected, memory, cpu ]);
156158

157159
return (
158160
<div className={'flex mt-4'}>
159161
<TitledGreyBox title={'Memory usage'} icon={faMemory} className={'flex-1 mr-2'}>
160-
<canvas id={'memory_chart'} ref={memoryRef} aria-label={'Server Memory Usage Graph'} role={'img'}/>
162+
{status !== 'offline' ?
163+
<canvas id={'memory_chart'} ref={memoryRef} aria-label={'Server Memory Usage Graph'} role={'img'}/>
164+
:
165+
<p className={'text-xs text-neutral-400 text-center p-3'}>
166+
Server is offline.
167+
</p>
168+
}
161169
</TitledGreyBox>
162170
<TitledGreyBox title={'CPU usage'} icon={faMicrochip} className={'flex-1 ml-2'}>
163-
<canvas id={'cpu_chart'} ref={cpuRef} aria-label={'Server CPU Usage Graph'} role={'img'}/>
171+
{status !== 'offline' ?
172+
<canvas id={'cpu_chart'} ref={cpuRef} aria-label={'Server CPU Usage Graph'} role={'img'}/>
173+
:
174+
<p className={'text-xs text-neutral-400 text-center p-3'}>
175+
Server is offline.
176+
</p>
177+
}
164178
</TitledGreyBox>
165179
</div>
166180
);

0 commit comments

Comments
 (0)