fix(striker-ui): make node summary update periodically

main
Tsu-ba-me 9 months ago
parent 4d5d698a9c
commit ba9c65addc
  1. 15
      striker-ui/components/Anvils/AnvilSummary.tsx
  2. 13
      striker-ui/components/Anvils/AnvilSummaryList.tsx
  3. 6
      striker-ui/types/AnvilSummary.d.ts
  4. 5
      striker-ui/types/AnvilSummaryList.d.ts

@ -30,10 +30,13 @@ const MAP_TO_HOST_STATE_COLOUR: Record<string, string> = {
};
const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
const { anvilUuid } = props;
const { anvilUuid, refreshInterval = 5000 } = props;
const { data: rAnvil, loading: loadingAnvil } = useFetch<AnvilListItem>(
`/anvil/${anvilUuid}`,
{
refreshInterval,
},
);
const anvil = useMemo<APIAnvilDetail | undefined>(
@ -43,6 +46,9 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
const { data: cpu, loading: loadingCpu } = useFetch<AnvilCPU>(
`/anvil/${anvilUuid}/cpu`,
{
refreshInterval,
},
);
const cpuSubnodes = useMemo<AnvilCPU['hosts'][string][] | undefined>(
@ -52,6 +58,9 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
const { data: rMemory, loading: loadingMemory } = useFetch<AnvilMemory>(
`/anvil/${anvilUuid}/memory`,
{
refreshInterval,
},
);
const memory = useMemo<AnvilMemoryCalcable | undefined>(
@ -60,7 +69,9 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
);
const { data: rStorages, loading: loadingStorages } =
useFetch<AnvilSharedStorage>(`/anvil/${anvilUuid}/store`);
useFetch<AnvilSharedStorage>(`/anvil/${anvilUuid}/store`, {
refreshInterval,
});
const storages = useMemo<APIAnvilSharedStorageOverview | undefined>(
() => rStorages && toAnvilSharedStorageOverview(rStorages),

@ -15,9 +15,11 @@ import Spinner from '../Spinner';
import { BodyText, HeaderText } from '../Text';
import useFetch from '../../hooks/useFetch';
const AnvilSummaryList: FC = () => {
const AnvilSummaryList: FC<AnvilSummaryListProps> = (props) => {
const { refreshInterval = 5000 } = props;
const { data: rawAnvils, loading: loadingAnvils } =
useFetch<APIAnvilOverviewArray>('/anvil', { refreshInterval: 5000 });
useFetch<APIAnvilOverviewArray>('/anvil', { refreshInterval });
const anvils = useMemo<APIAnvilOverviewList | undefined>(
() => rawAnvils && toAnvilOverviewList(rawAnvils),
@ -48,7 +50,10 @@ const AnvilSummaryList: FC = () => {
</BodyText>
</InnerPanelHeader>
<InnerPanelBody>
<AnvilSummary anvilUuid={uuid} />
<AnvilSummary
anvilUuid={uuid}
refreshInterval={refreshInterval}
/>
</InnerPanelBody>
</InnerPanel>
),
@ -68,7 +73,7 @@ const AnvilSummaryList: FC = () => {
}}
/>
),
[anvils],
[anvils, refreshInterval],
);
return (

@ -1,3 +1,7 @@
type AnvilSummaryProps = {
type AnvilSummaryOptionalProps = {
refreshInterval?: number;
};
type AnvilSummaryProps = AnvilSummaryOptionalProps & {
anvilUuid: string;
};

@ -0,0 +1,5 @@
type AnvilSummaryListOptionalProps = {
refreshInterval?: number;
};
type AnvilSummaryListProps = AnvilSummaryListOptionalProps;
Loading…
Cancel
Save