Skip to content

Commit 2140499

Browse files
committed
Dynamically show multiple byte formats
1 parent 362e4c2 commit 2140499

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

redisinsight/ui/src/components/database-overview/components/OverviewMetrics/OverviewMetrics.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,21 @@ export const getOverviewMetrics = ({ theme, items, db = 0 }: Props): Array<IMetr
119119
},
120120
}
121121

122-
const networkInKbpsItem = {
122+
let [networkIn, networkInUnit] = formatBytes(networkInKbps, 3, true)
123+
networkInUnit = `${networkInUnit.toLowerCase()}/s`
124+
let [networkOut, networkOutUnit] = formatBytes(networkOutKbps, 3, true)
125+
networkOutUnit = `${networkOutUnit.toLowerCase()}/s`
126+
127+
const networkInItem = {
123128
id: 'network-input',
124129
groupId: opsPerSecItem.id,
125130
title: 'Network Input',
126131
icon: theme === Theme.Dark ? InputDarkIcon : InputLightIcon,
127-
value: networkInKbps,
132+
value: networkIn,
128133
content: (
129134
<>
130-
<b>{networkInKbps}</b>
131-
&nbsp;kb/s
135+
<b>{networkIn}</b>
136+
&nbsp;{networkInUnit}
132137
</>
133138
),
134139
unavailableText: 'Network Input is not available',
@@ -137,23 +142,23 @@ export const getOverviewMetrics = ({ theme, items, db = 0 }: Props): Array<IMetr
137142
icon: theme === Theme.Dark ? InputDarkIcon : InputLightIcon,
138143
content: (
139144
<>
140-
<b>{networkInKbps}</b>
141-
&nbsp;kb/s
145+
<b>{networkIn}</b>
146+
&nbsp;{networkInUnit}
142147
</>
143148
),
144149
},
145150
}
146151

147-
const networkOutKbpsItem = {
152+
const networkOutItem = {
148153
id: 'network-output-tip',
149154
groupId: opsPerSecItem.id,
150155
title: 'Network Output',
151156
icon: theme === Theme.Dark ? OutputDarkIcon : OutputLightIcon,
152-
value: networkOutKbps,
157+
value: networkOut,
153158
content: (
154159
<>
155-
<b>{networkOutKbps}</b>
156-
&nbsp;kb/s
160+
<b>{networkOut}</b>
161+
&nbsp;{networkOutUnit}
157162
</>
158163
),
159164
unavailableText: 'Network Output is not available',
@@ -162,8 +167,8 @@ export const getOverviewMetrics = ({ theme, items, db = 0 }: Props): Array<IMetr
162167
icon: theme === Theme.Dark ? OutputDarkIcon : OutputLightIcon,
163168
content: (
164169
<>
165-
<b>{networkOutKbps}</b>
166-
&nbsp;kb/s
170+
<b>{networkOut}</b>
171+
&nbsp;{networkOutUnit}
167172
</>
168173
),
169174
},
@@ -179,8 +184,8 @@ export const getOverviewMetrics = ({ theme, items, db = 0 }: Props): Array<IMetr
179184
content: opsPerSecond,
180185
unavailableText: 'Commands/s are not available',
181186
},
182-
networkInKbpsItem,
183-
networkOutKbpsItem
187+
networkInItem,
188+
networkOutItem
184189
]
185190
}
186191

0 commit comments

Comments
 (0)