Skip to content

Commit c60105b

Browse files
Merge pull request ManageIQ#1284 from AllenBW/bug/master/#1516807-update-resource-details
Ensure correct compliance icon, 7 day timeline, last hour utilization
2 parents 5f96bb1 + d97b933 commit c60105b

File tree

4 files changed

+407
-390
lines changed

4 files changed

+407
-390
lines changed

client/app/services/resource-details/resource-details.component.js

+31-19
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
9595
vm.today = new Date()
9696
vm.presentDate = new Date()
9797
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+
}
98106
resolveData()
99107
}
100108

@@ -198,14 +206,17 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
198206
capture_interval: 'hourly'
199207
}).then((response) => {
200208
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+
})
208212

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+
}
209220
vm.memUtil = UsageGraphsService.getChartConfig({
210221
'units': __('GB'),
211222
'chartId': 'memoryChart',
@@ -266,9 +277,10 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
266277
: `${retirementDate.getFullYear()}-${retirementDate.toString().split(' ')[1]}-${retirementDate.getDate()}`
267278
vm.retirement.notifications[0].iconClass = angular.isUndefined(response.retires_on) ? ''
268279
: `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)
270282
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'
272284
vm.vmDetails.complianceHistory = (vm.vmDetails.compliances.length > 0 ? vm.availableText : vm.notAvailable)
273285

274286
getListActions()
@@ -449,13 +461,13 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
449461
const fontSize = 12 // in pixels
450462
const tooltipWidth = 9 // in rem
451463
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+
})
459471
const rightOrLeftLimit = fontSize * tooltipWidth
460472
const direction = d3.event.pageX > rightOrLeftLimit ? 'right' : 'left'
461473
const left = direction === 'right' ? d3.event.pageX - rightOrLeftLimit : d3.event.pageX
@@ -487,8 +499,8 @@ function ComponentController ($state, $stateParams, VmsService, lodash, EventNot
487499
`
488500
)
489501
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')
493505
}
494506
}

client/app/services/usage-graphs/usage-graphs.component.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ describe('Component: usageGraphs', () => {
5454
})
5555
it('Chart availble values match', () => {
5656
const graphs = element[0].querySelectorAll('.metric-number')
57-
expect(graphs[0].innerHTML).to.eq('1000')
58-
expect(graphs[1].innerHTML).to.eq('6')
59-
expect(graphs[2].innerHTML).to.eq('38')
57+
expect(graphs[0].innerHTML).to.eq('1,000.000')
58+
expect(graphs[1].innerHTML).to.eq('6.000')
59+
expect(graphs[2].innerHTML).to.eq('38.000')
6060
})
6161
})
6262

client/app/services/usage-graphs/usage-graphs.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h2>{{ 'Utilization' | translate}}
77
<div class="metric-title" translate>CPU</div>
88
<div ng-if="vm.cpuDataExists">
99
<div class="metric-details-container">
10-
<span class="metric-number">{{vm.availableCPU}}</span>
10+
<span class="metric-number">{{vm.availableCPU | number:3}}</span>
1111
<span class="metric-details">
1212
<p>{{vm.cpuChart.config.units}} {{'Available' | translate}}</p>
1313
<p>{{'of' | translate }} {{vm.cpuChart.data.total}}{{vm.cpuChart.config.units}}</p>
@@ -23,7 +23,7 @@ <h2>{{ 'Utilization' | translate}}
2323
<div class="metric-title" translate>Memory</div>
2424
<div ng-if="vm.memoryDataExists">
2525
<div class="metric-details-container">
26-
<span class="metric-number">{{vm.availableMemory}}</span>
26+
<span class="metric-number">{{vm.availableMemory | number:3}}</span>
2727
<span class="metric-details">
2828
<p>{{vm.memoryChart.config.units}} {{'Available' | translate}}</p>
2929
<p>{{'of' | translate }} {{vm.memoryChart.data.total}}{{vm.memoryChart.config.units}}</p>
@@ -39,7 +39,7 @@ <h2>{{ 'Utilization' | translate}}
3939
<div class="metric-title" translate>Storage</div>
4040
<div ng-if="vm.storageDataExists">
4141
<div class="metric-details-container">
42-
<span class="metric-number">{{vm.availableStorage}}</span>
42+
<span class="metric-number">{{vm.availableStorage | number:3}}</span>
4343
<span class="metric-details">
4444
<p>{{vm.storageChart.config.units}} {{'Available' | translate}}</p>
4545
<p>{{'of' | translate }} {{vm.storageChart.data.total}}{{vm.storageChart.config.units}}</p>

0 commit comments

Comments
 (0)