Skip to content
Snippets Groups Projects
Commit 8d7ef0dc authored by GyDi's avatar GyDi
Browse files

feat: remove sec field

parent f736951f
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ const Traffic = () => {
color={+up > 0 ? "primary" : "disabled"}
/>
<Typography {...valStyle}>{up}</Typography>
<Typography {...unitStyle}>{upUnit}</Typography>
<Typography {...unitStyle}>{upUnit}/s</Typography>
</Box>
<Box display="flex" alignItems="center" whiteSpace="nowrap">
......@@ -63,7 +63,7 @@ const Traffic = () => {
color={+down > 0 ? "primary" : "disabled"}
/>
<Typography {...valStyle}>{down}</Typography>
<Typography {...unitStyle}>{downUnit}</Typography>
<Typography {...unitStyle}>{downUnit}/s</Typography>
</Box>
</Box>
);
......
/**
* parse the traffic to
* xxx B
* xxx KB
* xxx MB
* xxx GB
*/
const parseTraffic = (num: number) => {
const gb = 1024 ** 3;
const mb = 1024 ** 2;
......@@ -5,7 +12,7 @@ const parseTraffic = (num: number) => {
let t = num;
let u = "B";
if (num < 1000) return [`${Math.round(t)}`, "B/s"];
if (num < 1000) return [`${Math.round(t)}`, "B"];
if (num <= mb) {
t = num / kb;
u = "KB";
......@@ -16,8 +23,8 @@ const parseTraffic = (num: number) => {
t = num / gb;
u = "GB";
}
if (t >= 100) return [`${Math.round(t)}`, `${u}/s`];
return [`${Math.round(t * 10) / 10}`, `${u}/s`];
if (t >= 100) return [`${Math.round(t)}`, u];
return [`${Math.round(t * 10) / 10}`, u];
};
export default parseTraffic;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment