@@ -8,7 +8,19 @@ import DiskList from './DiskList'
8
8
import HostActions from './HostActions'
9
9
import InstanceManagerComponent from './components/InstanceManagerComponent'
10
10
import { nodeStatusColorMap } from '../../utils/status'
11
- import { byteToGi , getStorageProgressStatus } from './helper/index'
11
+ import {
12
+ byteToGi ,
13
+ getStorageProgressStatus ,
14
+ computeTotalAllocated ,
15
+ computeAllocated ,
16
+ computeBackingImageAllocated ,
17
+ computeReplicaAllocated ,
18
+ computeUsagePercentage ,
19
+ computeTotalUsed ,
20
+ computeUsed ,
21
+ computeSize ,
22
+ computeReserved
23
+ } from './helper/index'
12
24
import { formatMib } from '../../utils/formatter'
13
25
import { pagination } from '../../utils/page'
14
26
import { ModalBlur } from '../../components'
@@ -195,26 +207,6 @@ class List extends React.Component {
195
207
deleteHost,
196
208
}
197
209
198
- const computeTotalAllocated = ( record ) => {
199
- const max = Object . values ( record . disks ) . reduce ( ( total , item ) => total + item . storageMaximum , 0 )
200
- const reserved = Object . values ( record . disks ) . reduce ( ( total , item ) => total + item . storageReserved , 0 )
201
- return ( ( max - reserved ) * storageOverProvisioningPercentage ) / 100
202
- }
203
- const computeAllocated = ( record ) => {
204
- return Object . values ( record . disks ) . reduce ( ( total , item ) => total + item . storageScheduled , 0 )
205
- }
206
- const coumputeTotalUsed = ( record ) => {
207
- return Object . values ( record . disks ) . reduce ( ( total , item ) => total + item . storageMaximum , 0 )
208
- }
209
- const computeUsed = ( record ) => {
210
- return Object . values ( record . disks ) . reduce ( ( total , item ) => total + ( item . storageMaximum - item . storageAvailable ) , 0 )
211
- }
212
- const computeSize = ( record ) => {
213
- return Object . values ( record . disks ) . reduce ( ( total , item ) => total + ( item . storageMaximum - item . storageReserved ) , 0 )
214
- }
215
- const computeReserved = ( record ) => {
216
- return Object . values ( record . disks ) . reduce ( ( total , item ) => total + item . storageReserved , 0 )
217
- }
218
210
const columns = [
219
211
{
220
212
title : < span style = { { display : 'inline-block' , padding : '0 0 0 30px' } } > Status</ span > ,
@@ -289,13 +281,34 @@ class List extends React.Component {
289
281
sorter : ( a , b ) => computeAllocated ( a ) - computeAllocated ( b ) ,
290
282
render : ( text , record ) => {
291
283
const allocated = computeAllocated ( record )
292
- const total = computeTotalAllocated ( record )
293
- const p = total === 0 ? 0 : Math . round ( ( allocated / total ) * 100 )
284
+ const total = computeTotalAllocated ( record , storageOverProvisioningPercentage )
285
+ const backingImageAllocated = computeBackingImageAllocated ( record )
286
+ const replicaAllocated = computeReplicaAllocated ( record )
287
+ const percent = computeUsagePercentage ( allocated , total )
288
+ const backingImagePercent = computeUsagePercentage ( backingImageAllocated , total )
289
+ const status = getStorageProgressStatus ( minimalSchedulingQuotaWarning , percent )
290
+
291
+ const renderTooltipContent = ( ) => (
292
+ < div className = { styles . allocatedTooltip } >
293
+ < span > Replica Size: { byteToGi ( replicaAllocated ) } Gi</ span >
294
+ < span > Backing Image Size: { byteToGi ( backingImageAllocated ) } Gi</ span >
295
+ < span > Total Usage: { percent } %</ span >
296
+ </ div >
297
+ )
298
+ const tooltipContent = renderTooltipContent ( )
299
+
294
300
return (
295
301
< div >
296
302
< div >
297
- < Tooltip title = { `${ p } %` } >
298
- < Progress strokeWidth = { 14 } status = { getStorageProgressStatus ( minimalSchedulingQuotaWarning , p ) } percent = { p > 100 ? 100 : p } showInfo = { false } />
303
+ < Tooltip title = { tooltipContent } >
304
+ < Progress
305
+ strokeWidth = { 14 }
306
+ status = { status }
307
+ percent = { percent }
308
+ successPercent = { backingImagePercent }
309
+ showInfo = { false }
310
+ className = { styles . progress }
311
+ />
299
312
</ Tooltip >
300
313
</ div >
301
314
< div className = { styles . secondLabel } >
@@ -312,12 +325,13 @@ class List extends React.Component {
312
325
sorter : ( a , b ) => computeUsed ( a ) - computeUsed ( b ) ,
313
326
render : ( text , record ) => {
314
327
const used = computeUsed ( record )
315
- const total = coumputeTotalUsed ( record )
316
- const p = total === 0 ? 0 : Math . round ( ( used / total ) * 100 )
328
+ const total = computeTotalUsed ( record )
329
+ const p = computeUsagePercentage ( used , total )
330
+
317
331
return (
318
332
< div >
319
333
< div >
320
- < Tooltip title = { `${ p } %` } >
334
+ < Tooltip title = { `Total usage: ${ p } %` } >
321
335
< Progress strokeWidth = { 14 } status = { getStorageProgressStatus ( minimalSchedulingQuotaWarning , p ) } percent = { p > 100 ? 100 : p } showInfo = { false } />
322
336
</ Tooltip >
323
337
</ div >
0 commit comments