@@ -95,6 +95,14 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
95
95
vm . today = new Date ( )
96
96
vm . presentDate = new Date ( )
97
97
vm . lastWeekDay = new Date ( vm . presentDate . setDate ( vm . presentDate . getDate ( ) - 7 ) )
98
+ vm . tlOptions = {
99
+ start : new Date ( vm . lastWeekDay ) ,
100
+ end : new Date ( vm . today ) ,
101
+ eventClick : tlTooltip ,
102
+ eventGrouping : 60000 ,
103
+ minScale : 0.234 ,
104
+ maxScale : 1440
105
+ }
98
106
resolveData ( )
99
107
}
100
108
@@ -198,14 +206,17 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
198
206
capture_interval : 'hourly'
199
207
} ) . then ( ( response ) => {
200
208
vm . metrics = response
201
- const lastHour = response . resources [ 1 ]
202
-
203
- vm . cpuUtil = UsageGraphsService . getChartConfig ( {
204
- 'units' : __ ( '%' ) ,
205
- 'chartId' : 'cpuChart' ,
206
- 'label' : __ ( 'used' )
207
- } , ( lastHour . cpu_usage_rate_average ) . toPrecision ( 3 ) , 100 )
209
+ const lastHour = response . resources . find ( ( item ) => {
210
+ return new Date ( item . timestamp ) . getUTCHours ( ) === ( vm . today . getUTCHours ( ) - 1 )
211
+ } )
208
212
213
+ if ( lastHour . cpu_usage_rate_average ) {
214
+ vm . cpuUtil = UsageGraphsService . getChartConfig ( {
215
+ 'units' : __ ( '%' ) ,
216
+ 'chartId' : 'cpuChart' ,
217
+ 'label' : __ ( 'used' )
218
+ } , ( lastHour . cpu_usage_rate_average ) . toPrecision ( 3 ) , 100 )
219
+ }
209
220
vm . memUtil = UsageGraphsService . getChartConfig ( {
210
221
'units' : __ ( 'GB' ) ,
211
222
'chartId' : 'memoryChart' ,
@@ -266,9 +277,10 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
266
277
: `${ retirementDate . getFullYear ( ) } -${ retirementDate . toString ( ) . split ( ' ' ) [ 1 ] } -${ retirementDate . getDate ( ) } `
267
278
vm . retirement . notifications [ 0 ] . iconClass = angular . isUndefined ( response . retires_on ) ? ''
268
279
: `fa fa-clock-o`
269
- vm . compliance . notifications [ 0 ] . count = angular . isUndefined ( response . last_compliance_status ) ? `Never Verified` : response . last_compliance_status
280
+ vm . compliance . notifications [ 0 ] . count = angular . isUndefined ( response . last_compliance_status ) ? `Never Verified`
281
+ : lodash . capitalize ( response . last_compliance_status )
270
282
vm . compliance . notifications [ 0 ] . iconClass = angular . isUndefined ( response . last_compliance_status ) ? ''
271
- : response . last_compliance_status === 'compliant' ? 'pficon pficon-error-circle-o ' : 'pficon pficon-ok '
283
+ : response . last_compliance_status ? 'pficon pficon-ok ' : 'pficon pficon-error-circle-o '
272
284
vm . vmDetails . complianceHistory = ( vm . vmDetails . compliances . length > 0 ? vm . availableText : vm . notAvailable )
273
285
274
286
getListActions ( )
@@ -449,13 +461,13 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
449
461
const fontSize = 12 // in pixels
450
462
const tooltipWidth = 9 // in rem
451
463
const tooltip = d3
452
- . select ( 'body' )
453
- . append ( 'div' )
454
- . attr ( 'class' , 'popover fade bottom in' )
455
- . attr ( 'role' , 'tooltip' )
456
- . on ( 'mouseleave' , ( ) => {
457
- d3 . select ( 'body' ) . selectAll ( '.popover' ) . remove ( )
458
- } )
464
+ . select ( 'body' )
465
+ . append ( 'div' )
466
+ . attr ( 'class' , 'popover fade bottom in' )
467
+ . attr ( 'role' , 'tooltip' )
468
+ . on ( 'mouseleave' , ( ) => {
469
+ d3 . select ( 'body' ) . selectAll ( '.popover' ) . remove ( )
470
+ } )
459
471
const rightOrLeftLimit = fontSize * tooltipWidth
460
472
const direction = d3 . event . pageX > rightOrLeftLimit ? 'right' : 'left'
461
473
const left = direction === 'right' ? d3 . event . pageX - rightOrLeftLimit : d3 . event . pageX
@@ -487,8 +499,8 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
487
499
`
488
500
)
489
501
tooltip
490
- . style ( 'left' , `${ left } px` )
491
- . style ( 'top' , `${ d3 . event . pageY + 8 } px` )
492
- . style ( 'display' , 'block' )
502
+ . style ( 'left' , `${ left } px` )
503
+ . style ( 'top' , `${ d3 . event . pageY + 8 } px` )
504
+ . style ( 'display' , 'block' )
493
505
}
494
506
}
0 commit comments