Skip to content

Commit 2d0f11e

Browse files
committed
Fix static aria-valuenow in utilization bar charts
The utilization bar charts are rendering `aria-value` now attributes, but they contain static (therefore mostly wrong) values. This patch makes them dynamic, introduces missing ones in the default layout and adds tests.
1 parent b0e8a96 commit 2d0f11e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/charts/utilization-bar/utilization-bar-chart.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<span ng-if="!layout || layout.type === 'regular'">
33
<div ng-if="chartTitle" class="progress-description">{{chartTitle}}</div>
44
<div class="progress progress-label-top-right" ng-if="chartData.dataAvailable !== false">
5-
<div class="progress-bar" role="progressbar" ng-class="{'animate': animate,
5+
<div class="progress-bar" role="progressbar" aria-valuenow="{{chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100" ng-class="{'animate': animate,
66
'progress-bar-success': isOk, 'progress-bar-danger': isError, 'progress-bar-warning': isWarn}"
77
ng-style="{width:chartData.percentageUsed + '%'}" tooltip="{{chartData.percentageUsed}}% Used" >
88
<span ng-if="chartFooter" ng-bind-html="chartFooter"></span>
99
<span ng-if="!chartFooter && (!footerLabelFormat || footerLabelFormat === 'actual')"><strong>{{chartData.used}} of {{chartData.total}} {{units}}</strong> Used</span>
1010
<span ng-if="!chartFooter && footerLabelFormat === 'percent'"><strong>{{chartData.percentageUsed}}%</strong> Used</span>
1111
</div>
12-
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="5" aria-valuemin="0" aria-valuemax="100"
12+
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="{{100 - chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100"
1313
ng-style="{width:(100 - chartData.percentageUsed) + '%'}" tooltip="{{100 - chartData.percentageUsed}}% Available">
1414
</div>
1515
</div>
@@ -19,14 +19,14 @@
1919
ng-style="{'padding-left':layout.titleLabelWidth, 'padding-right':layout.footerLabelWidth}">
2020
<div ng-if="chartTitle" class="progress-description" ng-style="{'max-width':layout.titleLabelWidth}">{{chartTitle}}</div>
2121
<div class="progress" ng-if="chartData.dataAvailable !== false">
22-
<div class="progress-bar" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"
22+
<div class="progress-bar" role="progressbar" aria-valuenow="{{chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100"
2323
ng-class="{'animate': animate, 'progress-bar-success': isOk, 'progress-bar-danger': isError, 'progress-bar-warning': isWarn}"
2424
ng-style="{width:chartData.percentageUsed + '%'}" tooltip="{{chartData.percentageUsed}}% Used">
2525
<span ng-if="chartFooter" ng-bind-html="chartFooter"></span>
2626
<span ng-if="(!chartFooter) && (!footerLabelFormat || footerLabelFormat === 'actual')" ng-style="{'max-width':layout.footerLabelWidth}"><strong>{{chartData.used}} {{units}}</strong> Used</span>
2727
<span ng-if="(!chartFooter) && footerLabelFormat === 'percent'" ng-style="{'max-width':layout.footerLabelWidth}"><strong>{{chartData.percentageUsed}}%</strong> Used</span>
2828
</div>
29-
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"
29+
<div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="{{100 - chartData.percentageUsed}}" aria-valuemin="0" aria-valuemax="100"
3030
ng-style="{width:(100 - chartData.percentageUsed) + '%'}" tooltip="{{100 - chartData.percentageUsed}}% Available">
3131
</div>
3232
</div>

test/charts/utilization-bar/utilization-bar.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ describe('Directive: pfUtilizationBarChart', function() {
3838
expect(utilizationBar).toBe("80%");
3939
});
4040

41+
it("should set aria-valuenow values", function() {
42+
remaining = angular.element(element).find('.progress-bar-remaining');
43+
used = angular.element(element).find('.progress-bar').not('.progress-bar-remaining');
44+
expect(remaining.attr('aria-valuenow')).toBe("20");
45+
expect(used.attr('aria-valuenow')).toBe("80");
46+
});
47+
4148
it("should set the charts title and usage label", function() {
4249
title = angular.element(element).find('.progress-description').html();
4350
expect(title).toBe("CPU Usage");

0 commit comments

Comments
 (0)