2021-11-18 12:44:04 +00:00
|
|
|
import React from "react";
|
2021-09-30 14:05:28 +00:00
|
|
|
import { useStatus } from "../../src/core/hooks";
|
2021-11-18 12:44:04 +00:00
|
|
|
import { Heading, Text, Flex, Spacer, chakra, Spinner } from "@chakra-ui/react";
|
|
|
|
import { getLayout } from "../../src/layouts/InfoPageLayout";
|
2021-09-30 14:05:28 +00:00
|
|
|
|
|
|
|
const Status = () => {
|
2021-10-04 19:04:38 +00:00
|
|
|
const healthyStatusText = "Available";
|
|
|
|
const downStatusText = "Unavailable";
|
|
|
|
const healthyStatusColor = "green.900";
|
|
|
|
const downStatusColor = "red.600";
|
2021-09-30 14:05:28 +00:00
|
|
|
|
2021-10-04 19:04:38 +00:00
|
|
|
const shortTimestamp = (rawTimestamp) => {
|
|
|
|
return rawTimestamp.replace(/^.+T/, "").replace(/\..+/, "");
|
|
|
|
};
|
2021-10-01 19:07:44 +00:00
|
|
|
|
2021-10-04 19:04:38 +00:00
|
|
|
const {
|
2021-10-06 14:40:31 +00:00
|
|
|
apiServerStatusCache,
|
|
|
|
ethereumClusterServerStatusCache,
|
|
|
|
gethStatusCache,
|
|
|
|
crawlersStatusCache,
|
|
|
|
dbServerStatusCache,
|
|
|
|
latestBlockDBStatusCache,
|
2021-10-04 19:04:38 +00:00
|
|
|
} = useStatus();
|
2021-09-30 14:05:28 +00:00
|
|
|
|
2021-11-18 12:44:04 +00:00
|
|
|
const StatusRow = (props) => {
|
|
|
|
console.log(props.cache.data);
|
|
|
|
return (
|
|
|
|
<Flex mb={3}>
|
|
|
|
<Text>{props.title}</Text>
|
|
|
|
<Spacer />
|
|
|
|
{!props.cache.isLoading && props.children}
|
|
|
|
{props.cache.isLoading && <Spinner m={0} p={0} size="sm" />}
|
|
|
|
</Flex>
|
|
|
|
);
|
|
|
|
};
|
2021-10-04 19:04:38 +00:00
|
|
|
return (
|
2021-11-18 12:44:04 +00:00
|
|
|
<>
|
|
|
|
<Heading
|
|
|
|
as="h2"
|
|
|
|
size="md"
|
|
|
|
placeSelf="center"
|
|
|
|
px={12}
|
|
|
|
py={2}
|
|
|
|
borderTopRadius="xl"
|
|
|
|
>
|
|
|
|
{`Status page`}
|
|
|
|
</Heading>
|
|
|
|
<chakra.span pl={2} px={12} py={2} width="400px">
|
|
|
|
<StatusRow title="Backend server" cache={apiServerStatusCache}>
|
|
|
|
<Text
|
|
|
|
color={
|
2021-10-06 14:40:31 +00:00
|
|
|
apiServerStatusCache?.data?.status == "ok"
|
2021-11-18 12:44:04 +00:00
|
|
|
? healthyStatusColor
|
|
|
|
: downStatusColor
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{apiServerStatusCache?.data?.status == "ok"
|
|
|
|
? healthyStatusText
|
|
|
|
: downStatusText}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
<br />
|
|
|
|
<StatusRow
|
|
|
|
title="Crawlers server"
|
|
|
|
cache={ethereumClusterServerStatusCache}
|
|
|
|
>
|
|
|
|
<Text
|
|
|
|
color={
|
|
|
|
ethereumClusterServerStatusCache?.data?.status == "ok"
|
|
|
|
? healthyStatusColor
|
|
|
|
: downStatusColor
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{ethereumClusterServerStatusCache?.data
|
|
|
|
? healthyStatusText
|
|
|
|
: downStatusText}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
<StatusRow title="Latest block in Geth" cache={gethStatusCache}>
|
|
|
|
<Text>
|
|
|
|
{gethStatusCache?.data?.current_block
|
|
|
|
? gethStatusCache.data.current_block
|
|
|
|
: 0}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
<StatusRow title="Txpool latest record ts" cache={crawlersStatusCache}>
|
|
|
|
<Text>
|
|
|
|
{crawlersStatusCache?.data?.ethereum_txpool_timestamp
|
|
|
|
? shortTimestamp(
|
|
|
|
crawlersStatusCache?.data?.ethereum_txpool_timestamp
|
|
|
|
)
|
|
|
|
: downStatusText}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
<StatusRow
|
|
|
|
title="Trending latest record ts"
|
|
|
|
cache={crawlersStatusCache}
|
|
|
|
>
|
|
|
|
<Text>
|
|
|
|
{crawlersStatusCache?.data?.ethereum_trending_timestamp
|
|
|
|
? shortTimestamp(
|
|
|
|
crawlersStatusCache?.data?.ethereum_trending_timestamp
|
|
|
|
)
|
|
|
|
: downStatusText}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<StatusRow title="Database server" cache={dbServerStatusCache}>
|
|
|
|
<Text
|
|
|
|
color={
|
2021-10-06 14:40:31 +00:00
|
|
|
dbServerStatusCache?.data?.status == "ok"
|
2021-11-18 12:44:04 +00:00
|
|
|
? healthyStatusColor
|
|
|
|
: downStatusColor
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{dbServerStatusCache?.data?.status == "ok"
|
|
|
|
? healthyStatusText
|
|
|
|
: downStatusText}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
<StatusRow
|
|
|
|
title="Latest block in Database"
|
|
|
|
cache={latestBlockDBStatusCache}
|
|
|
|
>
|
|
|
|
<Text>
|
|
|
|
{latestBlockDBStatusCache?.data?.block_number
|
|
|
|
? latestBlockDBStatusCache.data.block_number
|
|
|
|
: 0}
|
|
|
|
</Text>
|
|
|
|
</StatusRow>
|
|
|
|
</chakra.span>
|
|
|
|
</>
|
2021-10-04 19:04:38 +00:00
|
|
|
);
|
2021-10-01 19:07:44 +00:00
|
|
|
};
|
2021-09-30 14:05:28 +00:00
|
|
|
|
2021-11-18 12:44:04 +00:00
|
|
|
Status.getLayout = getLayout;
|
2021-10-01 19:07:44 +00:00
|
|
|
export default Status;
|