From 32920739efbfcd3117ca0a50f2fb51e54c92ab50 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 27 Sep 2017 15:56:36 -0400 Subject: [PATCH 1/2] fix instance group percentage --- .../instance-groups/capacity-bar/capacity-bar.directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js b/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js index 872e2ac0be..e4f34063ce 100644 --- a/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js +++ b/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js @@ -23,10 +23,10 @@ export default ['templateUrl', 'ComponentsStrings', scope.$watch('capacity', function() { if (scope.totalCapacity !== 0) { scope.CapacityStyle = { - 'flex-grow': scope.capacity * 0.01 + 'flex-grow': scope.capacity / scope.totalCapacity * 0.01 }; - scope.consumedCapacity = `${scope.capacity}%`; + scope.consumedCapacity = `${Math.round(scope.capacity / scope.totalCapacity * 10) / 10}%`; } else { scope.CapacityStyle = { 'flex-grow': 1 From b05925cc0e3221a32935722bc9b78854582e89ee Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 27 Sep 2017 16:53:31 -0400 Subject: [PATCH 2/2] move percentage capacitty to variable --- .../instance-groups/capacity-bar/capacity-bar.directive.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js b/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js index e4f34063ce..73f6510466 100644 --- a/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js +++ b/awx/ui/client/src/instance-groups/capacity-bar/capacity-bar.directive.js @@ -22,11 +22,14 @@ export default ['templateUrl', 'ComponentsStrings', scope.$watch('capacity', function() { if (scope.totalCapacity !== 0) { + var percentageCapacity = Math + .round(scope.capacity / scope.totalCapacity * 10) / 10 * 100; + scope.CapacityStyle = { - 'flex-grow': scope.capacity / scope.totalCapacity * 0.01 + 'flex-grow': percentageCapacity * 0.01 }; - scope.consumedCapacity = `${Math.round(scope.capacity / scope.totalCapacity * 10) / 10}%`; + scope.consumedCapacity = `${percentageCapacity}%`; } else { scope.CapacityStyle = { 'flex-grow': 1