Skip to content

Commit

Permalink
removed if testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Aug 31, 2023
1 parent 4d90cf8 commit 3f56a27
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 99 deletions.
63 changes: 29 additions & 34 deletions deploy-web/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { uaktToAKT } from "@src/utils/priceUtils";
import { BlockRow } from "../blockchain/BlockRow";
import { TransactionRow } from "../blockchain/TransactionRow";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

interface IDashboardProps {
dashboardData: DashboardData;
Expand Down Expand Up @@ -87,7 +86,7 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
const capacityMemoryDiff = bytesToShrink(dashboardData.networkCapacityStats.now.memory - dashboardData.networkCapacityStats.compare.memory);
const capacityStorageDiff = bytesToShrink(dashboardData.networkCapacityStats.now.storage - dashboardData.networkCapacityStats.compare.storage);
const selectedNetwork = useSelectedNetwork();
const statsGridWidth = selectedNetwork.id === testnetId ? 2.4 : 3;
const statsGridWidth = 2.4;

return (
<>
Expand Down Expand Up @@ -212,22 +211,20 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
/>
</Grid>

{selectedNetwork.id === testnetId && (
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.now.activeGPU} maximumFractionDigits={2} />
<small style={{ paddingLeft: "5px", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.graph(SnapshotsUrlParam.graphics)}
diffNumber={dashboardData.now.activeGPU - dashboardData.compare.activeGPU}
diffPercent={percIncrease(dashboardData.compare.activeGPU, dashboardData.now.activeGPU)}
/>
</Grid>
)}
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.now.activeGPU} maximumFractionDigits={2} />
<small style={{ paddingLeft: "5px", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.graph(SnapshotsUrlParam.graphics)}
diffNumber={dashboardData.now.activeGPU - dashboardData.compare.activeGPU}
diffPercent={percIncrease(dashboardData.compare.activeGPU, dashboardData.now.activeGPU)}
/>
</Grid>

<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
Expand Down Expand Up @@ -286,22 +283,20 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
/>
</Grid>

{selectedNetwork.id === testnetId && (
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.networkCapacity.totalGPU} maximumFractionDigits={0} />
<small style={{ paddingLeft: ".25rem", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.providerGraph(ProviderSnapshotsUrlParam.gpu)}
diffNumber={dashboardData.networkCapacityStats.now.gpu - dashboardData.networkCapacityStats.compare.gpu}
diffPercent={percIncrease(dashboardData.networkCapacityStats.compare.gpu, dashboardData.networkCapacityStats.now.gpu)}
/>
</Grid>
)}
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.networkCapacity.totalGPU} maximumFractionDigits={0} />
<small style={{ paddingLeft: ".25rem", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.providerGraph(ProviderSnapshotsUrlParam.gpu)}
diffNumber={dashboardData.networkCapacityStats.now.gpu - dashboardData.networkCapacityStats.compare.gpu}
diffPercent={percIncrease(dashboardData.networkCapacityStats.compare.gpu, dashboardData.networkCapacityStats.now.gpu)}
/>
</Grid>

<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
Expand Down
60 changes: 28 additions & 32 deletions deploy-web/src/components/providers/NetworkCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { bytesToShrink } from "@src/utils/unitUtils";
import { roundDecimal } from "@src/utils/mathHelpers";
import { useRouter } from "next/router";
import { useSelectedNetwork } from "@src/utils/networks";
import { mainnetId, testnetId } from "@src/utils/constants";

type Props = {
activeCPU: number;
Expand Down Expand Up @@ -52,8 +51,7 @@ const NetworkCapacity: React.FunctionComponent<Props> = ({
const memoryData = useData(activeMemoryBytes, availableMemoryBytes);
const storageData = useData(activeStorageBytes, availableStorageBytes);
const pieTheme = usePieTheme();
const selectedNetwork = useSelectedNetwork();
const flexBasis = selectedNetwork.id === mainnetId ? "33.3333%" : "25%";
const flexBasis = "25%";

const _getColor = bar => getColor(bar.id);

Expand Down Expand Up @@ -97,36 +95,34 @@ const NetworkCapacity: React.FunctionComponent<Props> = ({
</Box>
</Box>

{selectedNetwork.id === testnetId && (
<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
GPU
</Typography>
<Typography variant="caption" color="textSecondary">
{Math.round(activeGPU + pendingGPU)}&nbsp;GPU&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
<Box sx={{ height: "200px", width: "200px", display: "flex", alignItems: "center", justifyContent: "center" }}>
<ResponsivePie
data={gpuData}
margin={{ top: 15, right: 15, bottom: 15, left: 0 }}
innerRadius={0.3}
padAngle={2}
cornerRadius={4}
activeOuterRadiusOffset={8}
colors={_getColor}
borderWidth={0}
borderColor={{
from: "color",
modifiers: [["darker", 0.2]]
}}
valueFormat={value => `${roundDecimal(value, 2)} GPU`}
enableArcLinkLabels={false}
arcLabelsSkipAngle={10}
theme={pieTheme}
/>
</Box>
<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
GPU
</Typography>
<Typography variant="caption" color="textSecondary">
{Math.round(activeGPU + pendingGPU)}&nbsp;GPU&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
<Box sx={{ height: "200px", width: "200px", display: "flex", alignItems: "center", justifyContent: "center" }}>
<ResponsivePie
data={gpuData}
margin={{ top: 15, right: 15, bottom: 15, left: 0 }}
innerRadius={0.3}
padAngle={2}
cornerRadius={4}
activeOuterRadiusOffset={8}
colors={_getColor}
borderWidth={0}
borderColor={{
from: "color",
modifiers: [["darker", 0.2]]
}}
valueFormat={value => `${roundDecimal(value, 2)} GPU`}
enableArcLinkLabels={false}
arcLabelsSkipAngle={10}
theme={pieTheme}
/>
</Box>
)}
</Box>

<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
Expand Down
9 changes: 3 additions & 6 deletions deploy-web/src/components/providers/ProviderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MergedProvider } from "@src/types/provider";
import { CustomTableHeader } from "../shared/CustomTable";
import { ProviderListRow } from "./ProviderListRow";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

const useStyles = makeStyles()(theme => ({}));

Expand Down Expand Up @@ -36,11 +35,9 @@ export const ProviderList: React.FunctionComponent<Props> = ({ providers }) => {
<TableCell align="center" width="10%">
CPU
</TableCell>
{selectedNetwork.id === testnetId && (
<TableCell align="center" width="10%">
GPU
</TableCell>
)}
<TableCell align="center" width="10%">
GPU
</TableCell>
<TableCell align="center" width="10%">
Memory
</TableCell>
Expand Down
49 changes: 22 additions & 27 deletions deploy-web/src/components/providers/ProviderListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { UrlService } from "@src/utils/urlUtils";
import { FormattedNumber } from "react-intl";
import { Uptime } from "./Uptime";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

const useStyles = makeStyles()(theme => ({
root: {
Expand All @@ -38,16 +37,14 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) =>
const { classes } = useStyles();
const theme = useTheme();
const router = useRouter();
const selectedNetwork = useSelectedNetwork();
const { favoriteProviders, updateFavoriteProviders } = useLocalNotes();
const isFavorite = favoriteProviders.some(x => provider.owner === x);
const activeCPU = provider.isActive ? provider.activeStats.cpu / 1000 : 0;
const pendingCPU = provider.isActive ? provider.pendingStats.cpu / 1000 : 0;
const totalCPU = provider.isActive ? (provider.availableStats.cpu + provider.pendingStats.cpu + provider.activeStats.cpu) / 1000 : 0;
const activeGPU = provider.isActive && selectedNetwork.id === testnetId ? provider.activeStats.gpu : 0;
const pendingGPU = provider.isActive && selectedNetwork.id === testnetId ? provider.pendingStats.gpu : 0;
const totalGPU =
provider.isActive && selectedNetwork.id === testnetId ? provider.availableStats.gpu + provider.pendingStats.gpu + provider.activeStats.gpu : 0;
const activeGPU = provider.isActive && provider.activeStats.gpu;
const pendingGPU = provider.isActive && provider.pendingStats.gpu;
const totalGPU = provider.isActive && provider.availableStats.gpu + provider.pendingStats.gpu + provider.activeStats.gpu;
const _activeMemory = provider.isActive ? bytesToShrink(provider.activeStats.memory + provider.pendingStats.memory) : null;
const _totalMemory = provider.isActive ? bytesToShrink(provider.availableStats.memory + provider.pendingStats.memory + provider.activeStats.memory) : null;
const _activeStorage = provider.isActive ? bytesToShrink(provider.activeStats.storage + provider.pendingStats.storage) : null;
Expand Down Expand Up @@ -133,28 +130,26 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) =>
)}
</TableCell>

{selectedNetwork.id === testnetId && (
<TableCell align="center">
{provider.isActive && (
<CustomTooltip
title={
<Typography fontSize=".7rem" variant="caption">
{Math.round(activeGPU + pendingGPU)}&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
<TableCell align="center">
{provider.isActive && (
<CustomTooltip
title={
<Typography fontSize=".7rem" variant="caption">
{Math.round(activeGPU + pendingGPU)}&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
}
>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CapacityIcon value={(activeGPU + pendingGPU) / totalGPU} />
{totalGPU > 0 && (
<Typography variant="caption" color="textSecondary">
<FormattedNumber style="percent" maximumFractionDigits={2} value={roundDecimal((activeGPU + pendingGPU) / totalGPU, 2)} />
</Typography>
}
>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CapacityIcon value={(activeGPU + pendingGPU) / totalGPU} />
{totalGPU > 0 && (
<Typography variant="caption" color="textSecondary">
<FormattedNumber style="percent" maximumFractionDigits={2} value={roundDecimal((activeGPU + pendingGPU) / totalGPU, 2)} />
</Typography>
)}
</Box>
</CustomTooltip>
)}
</TableCell>
)}
)}
</Box>
</CustomTooltip>
)}
</TableCell>

<TableCell align="center">
{provider.isActive && (
Expand Down
1 change: 1 addition & 0 deletions deploy-web/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const auth0TokenNamespace = "https://cloudmos.io";
export const uAktDenom = "uakt";
// TODO Handle denom for mainnet/testnet/sandbox
export const usdcIbcDenom = "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84";
export const mainnetUsdcIdbDenom = "ibc/F8D2BEE806C3F969B256416B37FF6E7E0B927F372993114B8E0B9E57DC8CD327";

// Cloudmos fee
export const feePercent = 3;
Expand Down

0 comments on commit 3f56a27

Please sign in to comment.