Skip to content

Commit

Permalink
feat: Adds synchronizing status to nodes page
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed Feb 9, 2022
1 parent dd409c2 commit 7fa8259
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/pages/nodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const Nodes = () => {

return {
network,
online: Date.now() - new Date(timestamp).getTime() < settings.node_monitor.max_delay,
online: true,
synchronizing: Date.now() - new Date(timestamp).getTime() > settings.node_monitor.max_delay,
timestamp,
level,
version,
Expand All @@ -40,8 +41,9 @@ const Nodes = () => {
.catch((e) => {
console.debug(e);
return {
network: network.toUpperCase(),
network: network,
online: false,
synchronizing: false,
};
});
}),
Expand Down
19 changes: 14 additions & 5 deletions src/pages/nodes/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ export interface NodeStatus {
level?: number;
timestamp?: string;
online: boolean;
synchronizing: boolean;
}

const ShowStatus = ({ online }: { online: boolean }) =>
online ? <p className="text-green-600">Online</p> : <p className="text-red-600">Offline</p>;
const ShowStatus = ({ online, synchronizing }: { online: boolean; synchronizing: boolean }) =>
online ? (
synchronizing ? (
<p className="text-yellow-600">Synchronizing</p>
) : (
<p className="text-green-600">Online</p>
)
) : (
<p className="text-red-600">Offline</p>
);

interface NodesViewProps {
nodes: NodeStatus[];
Expand All @@ -30,7 +39,7 @@ interface NodesViewProps {
const NodesView: React.FC<NodesViewProps> = ({ nodes }) => {
return (
<div className="flex-1 flex flex-row justify-center items-center p-2 flex-wrap">
{nodes.map(({ network, historyMode, online, level, version, timestamp }) => (
{nodes.map(({ network, historyMode, online, level, version, timestamp, synchronizing }) => (
<div
key={network}
className="basis-full md:basis-[40%] border-2 border-black dark:border-white rounded-lg p-2 m-1 shadow-xl "
Expand All @@ -46,14 +55,14 @@ const NodesView: React.FC<NodesViewProps> = ({ nodes }) => {
<tr>
<td className="text-base font-bold">Status</td>
<td className={`text-base text-${online ? 'online' : 'offline'} font-bold`}>
<ShowStatus online={online} />
<ShowStatus online={online} synchronizing={synchronizing} />
</td>
</tr>

<tr>
<td className="text-base font-bold">Node Version</td>
<td>
{version?.version.major}.{version?.version.minor}
{version?.version?.major}.{version?.version?.minor}
</td>
</tr>
<tr>
Expand Down

0 comments on commit 7fa8259

Please sign in to comment.