Add B to bytesToUnits to make clear that they are bytes (#5170)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-04-06 11:48:42 -04:00
1 parent 1a29759bff
commit 7c34ba36a6
7 files changed
+157 -24

No files matched your search

@@ -73,7 +73,7 @@ const NonInjectedClusterMetrics = observer(({ clusterOverviewStore: { metricType
label: ({ index }, data) => {
const value = data.datasets[0].data[index] as ChartPoint;
return bytesToUnits(parseInt(value.y as string), 3);
return bytesToUnits(parseInt(value.y as string), { precision: 3 });
},
},
},
+2 -2
View File
@@ -127,7 +127,7 @@ export class NodesRoute extends React.Component {
metricNames: ["workloadMemoryUsage", "memoryAllocatableCapacity"],
formatters: [
([usage, capacity]) => `${(usage * 100 / capacity).toFixed(2)}%`,
([usage]) => bytesToUnits(usage, 3),
([usage]) => bytesToUnits(usage, { precision: 3 }),
],
});
}
@@ -139,7 +139,7 @@ export class NodesRoute extends React.Component {
metricNames: ["fsUsage", "fsSize"],
formatters: [
([usage, capacity]) => `${(usage * 100 / capacity).toFixed(2)}%`,
([usage]) => bytesToUnits(usage, 3),
([usage]) => bytesToUnits(usage, { precision: 3 }),
],
});
}
@@ -75,7 +75,7 @@ export class PodDetailsList extends React.Component<PodDetailsListProps> {
renderMemoryUsage(id: string, usage: number) {
const { maxMemory } = this.props;
const tooltip = (
<p>Memory: {Math.ceil(usage * 100 / maxMemory)}%<br/>{bytesToUnits(usage, 3)}</p>
<p>Memory: {Math.ceil(usage * 100 / maxMemory)}%<br/>{bytesToUnits(usage, { precision: 3 })}</p>
);
if (!maxMemory) return usage ? bytesToUnits(usage) : 0;
+1 -1
View File
@@ -195,7 +195,7 @@ export const memoryOptions: ChartOptions = {
const { label, data } = datasets[datasetIndex];
const value = data[index] as ChartPoint;
return `${label}: ${bytesToUnits(parseInt(value.y.toString()), 3)}`;
return `${label}: ${bytesToUnits(parseInt(value.y.toString()), { precision: 3 })}`;
},
},
},