Skip to content

Commit cb8a02e

Browse files
committed
Display pooled resources in the Hero component
1 parent 50eb5be commit cb8a02e

File tree

7 files changed

+62
-8
lines changed

7 files changed

+62
-8
lines changed

app/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ export default async function HomePage(props: {
1919
[key: string]: types.NodeState;
2020
} = response.result.nodes;
2121

22+
// console.log(response);
23+
2224
const pagesCount: number = response.result.nodes_total_pages;
2325

2426
return (
2527
<>
26-
<Hero nodesTotalItems={response.result.nodes_total_items} />
28+
<Hero nodesTotalItems={response.result.nodes_total_items} resourcesTotal={response.result.resources_total} />
2729

2830
<Suspense fallback={<NodesListSkeleton />}>
2931
<List nodes={nodes} pagesCount={pagesCount} currentPage={currentPage} />

app/server-components/Nodes/Hero.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,56 @@
11
import HeroEpochCard from '@/components/Hero/HeroEpochCard';
2+
import * as types from '@/typedefs/blockchain';
23
import { Skeleton } from '@heroui/skeleton';
4+
import { round } from 'lodash';
35
import { Suspense } from 'react';
46
import R1MintedLastEpoch from '../R1MintedLastEpoch';
57
import { BorderedCard } from '../shared/cards/BorderedCard';
68
import { CardHorizontal } from '../shared/cards/CardHorizontal';
79
import R1TotalSupply from '../shared/R1TotalSupply';
810

9-
export default async function Hero({ nodesTotalItems }) {
11+
export default async function Hero({
12+
nodesTotalItems,
13+
resourcesTotal,
14+
}: {
15+
nodesTotalItems: number;
16+
resourcesTotal: types.ResourcesTotal;
17+
}) {
1018
return (
1119
<div className="w-full">
1220
<BorderedCard>
1321
<div className="card-title-big font-bold">Nodes</div>
1422

1523
<div className="flexible-row">
16-
<CardHorizontal label="Active Nodes" value={nodesTotalItems} isFlexible widthClasses="min-w-[192px]" />
24+
<CardHorizontal label="Active Nodes" value={nodesTotalItems} isFlexible widthClasses="min-w-[196px]" />
25+
26+
<CardHorizontal
27+
label="CPU Cores Available"
28+
value={round(resourcesTotal.cpu_cores_avail, 1)}
29+
isFlexible
30+
widthClasses="min-w-[274px]"
31+
/>
32+
33+
<CardHorizontal
34+
label="Memory Available"
35+
value={
36+
<div>
37+
{round(resourcesTotal.mem_avail, 1)} <span className="text-slate-500">GB</span>
38+
</div>
39+
}
40+
isFlexible
41+
widthClasses="min-w-[302px]"
42+
/>
43+
44+
<CardHorizontal
45+
label="Disk Available"
46+
value={
47+
<div>
48+
{round(resourcesTotal.disk_avail, 1)} <span className="text-slate-500">GB</span>
49+
</div>
50+
}
51+
isFlexible
52+
widthClasses="min-w-[282px]"
53+
/>
1754

1855
<CardHorizontal
1956
label={
@@ -35,7 +72,7 @@ export default async function Hero({ nodesTotalItems }) {
3572
}
3673
value={<R1MintedLastEpoch />}
3774
isFlexible
38-
widthClasses="min-w-[254px]"
75+
widthClasses="min-w-[300px]"
3976
/>
4077
</Suspense>
4178

app/server-components/Nodes/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default async function List({
2222
<div className="list-wrapper">
2323
<div className="list">
2424
<ListHeader>
25-
<div className="min-w-[200px] lg:min-w-[228px]">Alias</div>
25+
<div className="min-w-[200px]">Alias</div>
2626
<div className="min-w-[164px]">Addresses</div>
2727
<div className="min-w-[244px]">License</div>
2828
<div className="min-w-[112px]">Owner</div>

app/server-components/Nodes/NodeListNodeCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default async function NodeListNodeCard({
3434
return (
3535
<BorderedCard useCustomWrapper useFixedWidthLarge>
3636
<div className="row justify-between gap-3 py-2 md:py-3 lg:gap-6">
37-
<Link href={`${routePath.node}/${node.eth_addr}`} className="group min-w-[200px] py-3 lg:min-w-[228px]">
37+
<Link href={`${routePath.node}/${node.eth_addr}`} className="group min-w-[200px] py-3">
3838
<div className="row gap-1.5">
3939
<div className="overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium group-hover:text-primary lg:text-[15px]">
4040
{node.alias}

app/server-components/shared/R1TotalSupply.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default async function R1TotalSupply() {
77
return (
88
<div className="text-lg text-primary md:text-xl">
99
{R1TotalSupply !== undefined
10-
? `${parseFloat(Number(formatUnits(R1TotalSupply, 18)).toFixed(2)).toLocaleString()}`
10+
? `${parseFloat(Number(formatUnits(R1TotalSupply, 18)).toFixed(1)).toLocaleString()}`
1111
: '...'}
1212
</div>
1313
);

app/server-components/shared/cards/CardHorizontal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const CardHorizontal = ({
2121
}) => {
2222
return (
2323
<CardFlexible isFlexible={isFlexible} isDarker={isDarker} widthClasses={widthClasses}>
24-
<div className="row w-full justify-between gap-4 px-4 py-4 sm:gap-6 md:gap-12 lg:px-6 lg:py-6">
24+
<div className="row w-full justify-between gap-4 px-4 py-4 sm:gap-6 md:gap-10 lg:px-6 lg:py-6">
2525
<div className="text-[15px] font-medium text-slate-500">{label}</div>
2626
<div
2727
className={clsx('text-right font-semibold', {

typedefs/blockchain.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ type ServerInfo = {
9292
server_uptime: string;
9393
};
9494

95+
type ResourcesTotal = {
96+
cpu_cores: number;
97+
cpu_cores_avail: number;
98+
default_cuda: {
99+
cpu: number;
100+
'cuda:0': number;
101+
};
102+
disk_avail: number;
103+
disk_total: number;
104+
mem_avail: number;
105+
mem_total: number;
106+
};
107+
95108
type OraclesDefaultResult = {
96109
result: {
97110
nodes_total_items: number;
@@ -101,6 +114,7 @@ type OraclesDefaultResult = {
101114
nodes: {
102115
[key: R1Address | string]: NodeState;
103116
};
117+
resources_total: ResourcesTotal;
104118
server_alias: string;
105119
server_version: string;
106120
server_time: string;
@@ -126,5 +140,6 @@ export type {
126140
OraclesAvailabilityResult,
127141
OraclesDefaultResult,
128142
R1Address,
143+
ResourcesTotal,
129144
ServerInfo,
130145
};

0 commit comments

Comments
 (0)