Skip to content

Commit

Permalink
Replace toTeraOrGiga w formatResourceSize & remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary committed Dec 24, 2023
1 parent 393b38d commit 37a495d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ import { VDataTableServer } from "vuetify/labs/VDataTable";
import { gridProxyClient } from "@/clients";
import { useProfileManager } from "@/stores";
import formatResourceSize from "@/utils/format_resource_size";
import { convert } from "@/utils/get_nodes";
import { getGrid } from "@/utils/grid";
import { toGigaBytes } from "@/utils/helpers";
import toTeraOrGigaOrPeta from "@/utils/toTeraOrGegaOrPeta";
const headers: VDataTable["headers"] = [
{ title: "Node ID", key: "nodeId", sortable: false },
Expand All @@ -115,19 +115,19 @@ const headers: VDataTable["headers"] = [
{
title: "RAM",
key: "total_resources.mru",
value: item => toTeraOrGigaOrPeta(item.total_resources.mru),
value: item => formatResourceSize(item.total_resources.mru),
sortable: false,
},
{
title: "SSD",
key: "total_resources.sru",
value: item => toTeraOrGigaOrPeta(item.total_resources.sru),
value: item => formatResourceSize(item.total_resources.sru),
sortable: false,
},
{
title: "HDD",
key: "total_resources.hru",
value: item => toTeraOrGigaOrPeta(item.total_resources.hru),
value: item => formatResourceSize(item.total_resources.hru),
sortable: false,
},
{ title: "GPU", key: "num_gpu", sortable: false },
Expand Down
8 changes: 4 additions & 4 deletions packages/playground/src/dashboard/components/node_details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ import { onMounted, type PropType, ref } from "vue";
import { gridProxyClient } from "@/clients";
import type { NodeDetailsCard } from "@/types";
import { nodeInitializer } from "@/types";
import formatResourceSize from "@/utils/format_resource_size";
import { getNode } from "@/utils/get_nodes";
import toTeraOrGigaOrPeta from "@/utils/toTeraOrGegaOrPeta";
const dNodeError = ref(false);
const dNodeLoading = ref(true);
Expand Down Expand Up @@ -190,9 +190,9 @@ const getCountryResourceCard = (): NodeDetailsCard[] => {
const getNodeResourceCard = (): NodeDetailsCard[] => {
return [
{ name: "CPU", value: props.node.total_resources.cru.toString() + " CPU" },
{ name: "Memory", value: toTeraOrGigaOrPeta(props.node.total_resources.mru.toString()) },
{ name: "Disk(SSD)", value: toTeraOrGigaOrPeta(props.node.total_resources.sru.toString()) },
{ name: "Disk(HDD)", value: toTeraOrGigaOrPeta(props.node.total_resources.hru.toString()) },
{ name: "Memory", value: formatResourceSize(props.node.total_resources.mru) },
{ name: "Disk(SSD)", value: formatResourceSize(props.node.total_resources.sru) },
{ name: "Disk(HDD)", value: formatResourceSize(props.node.total_resources.hru) },
];
};
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/utils/format_resource_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
export default function formatResourceSize(sizeInBytes?: number): string {
if (sizeInBytes === undefined || sizeInBytes === null || isNaN(sizeInBytes) || sizeInBytes === 0) {
return "0 Bytes";
return "0";
}

const giga = 1024 ** 3; // One gigabyte in bytes
Expand Down
25 changes: 0 additions & 25 deletions packages/playground/src/utils/toTeraOrGegaOrPeta.ts

This file was deleted.

9 changes: 5 additions & 4 deletions packages/playground/src/views/stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
import { NodeStatus, type Stats as GridProxyStats } from "@threefold/gridproxy_client";
import { onMounted, ref } from "vue";
import formatResourceSize from "@/utils/format_resource_size";
import { gridProxyClient } from "../clients";
import StatisticsCard from "../components/statistics_card.vue";
import type { IStatistics as IStatistics } from "../types";
import toTeraOrGigaOrPeta from "../utils/toTeraOrGegaOrPeta";
type Stats = GridProxyStats & { gpus: number };
Expand Down Expand Up @@ -96,9 +97,9 @@ const fetchData = async () => {
{ data: stats!.farms, title: "Farms", icon: "mdi-tractor" },
{ data: stats!.countries, title: "Countries", icon: "mdi-earth" },
{ data: stats!.totalCru, title: "CPUs", icon: "mdi-cpu-64-bit" },
{ data: toTeraOrGigaOrPeta(stats!.totalSru.toString()), title: "SSD Storage", icon: "mdi-nas" },
{ data: toTeraOrGigaOrPeta(stats!.totalHru.toString()), title: "HDD Storage", icon: "mdi-harddisk" },
{ data: toTeraOrGigaOrPeta(stats!.totalMru.toString()), title: "RAM", icon: "mdi-memory" },
{ data: formatResourceSize(stats!.totalSru), title: "SSD Storage", icon: "mdi-nas" },
{ data: formatResourceSize(stats!.totalHru), title: "HDD Storage", icon: "mdi-harddisk" },
{ data: formatResourceSize(stats!.totalMru), title: "RAM", icon: "mdi-memory" },
{ data: stats!.gpus, title: "GPUs", icon: "mdi-memory" },
{ data: stats!.accessNodes, title: "Access Nodes", icon: "mdi-gate" },
{ data: stats!.gateways, title: "Gateways", icon: "mdi-boom-gate-outline" },
Expand Down

0 comments on commit 37a495d

Please sign in to comment.