feat: 支持获取和查看板子连接的情况。

This commit is contained in:
2023-04-30 18:44:26 +08:00
parent 11045f27d8
commit 6c90a5e655
6 changed files with 193 additions and 58 deletions

View File

@ -0,0 +1,49 @@
import { Component, ParentComponent, createMemo } from 'solid-js';
import { BoardInfo } from '../../models/board-info.model';
type ItemProps = {
label: string;
};
const Item: ParentComponent<ItemProps> = (props) => {
return (
<dl class="flex">
<dt class="w-20">{props.label}</dt>
<dd class="flex-auto">{props.children}</dd>
</dl>
);
};
export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
const ttl = createMemo(() => {
if (!props.board.is_online) {
return '--';
}
if (props.board.ttl == null) {
return 'timeout';
}
return (
<>
<span class="font-mono">{props.board.ttl.toFixed(0)}</span> ms
</>
);
});
return (
<section class="p-2 rounded shadow">
<Item label="Host">{props.board.host}</Item>
<Item label="Ip Addr">
<span class="font-mono">{props.board.address}</span>
</Item>
<Item label="Port">
<span class="font-mono">{props.board.port}</span>
</Item>
<Item label="Status">
<span class="font-mono">{props.board.is_online ? 'Online' : 'Offline'}</span>
</Item>
<Item label="TTL">{ttl()}</Item>
</section>
);
};