aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Refactoring resources table to show dedicated.
Date Wed, 09 Sep 2015 21:12:51 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 01e611ad4 -> a5ac5b964


Refactoring resources table to show dedicated.

Bugs closed: AURORA-1461

Reviewed at https://reviews.apache.org/r/38169/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/a5ac5b96
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/a5ac5b96
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/a5ac5b96

Branch: refs/heads/master
Commit: a5ac5b96424ad747bf79b0d7a60325c06b1f04f1
Parents: 01e611a
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Sep 9 14:12:28 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Sep 9 14:12:28 2015 -0700

----------------------------------------------------------------------
 .../scheduler/assets/js/controllers.js          | 66 +++++++++++---------
 src/main/resources/scheduler/assets/role.html   |  4 +-
 2 files changed, 40 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/a5ac5b96/src/main/resources/scheduler/assets/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/js/controllers.js b/src/main/resources/scheduler/assets/js/controllers.js
index 9436e9b..9ac62c8 100644
--- a/src/main/resources/scheduler/assets/js/controllers.js
+++ b/src/main/resources/scheduler/assets/js/controllers.js
@@ -158,18 +158,31 @@
     function ($scope, $filter, auroraClient) {
       $scope.error = '';
 
-      $scope.resourcesTableColumns = [
-        {label: 'Resource', map: 'resource'},
-        {label: 'Production Consumption', map: 'prodSharedConsumption'},
-        {label: 'Quota', map: 'quota'},
-        {label: 'Non-Production Consumption', map: 'nonProdSharedConsumption'}
-      ];
-
       $scope.resourcesTableConfig = summaryTableConfig;
 
 
       auroraClient.getQuota($scope.role).then(function (quotaResponse) {
         $scope.resources = getQuota(quotaResponse);
+
+        var consumption = quotaResponse.quota;
+        var columns = [
+          {label: 'Resource', map: 'resource'},
+          {label: 'Quota', map: 'quota'},
+          {label: 'Quota Consumption', map: 'prodSharedConsumption'},
+          {label: 'Production Dedicated Consumption', map: 'prodDedicatedConsumption'},
+          {label: 'Non-Production Consumption', map: 'nonProdSharedConsumption'},
+          {label: 'Non-Production Dedicated Consumption', map: 'nonProdDedicatedConsumption'}
+        ];
+
+        columns = _.filter(columns, function (column) {
+          var vector = consumption[column.map];
+          return !vector || vector.numCpus > 0 || vector.ramMb > 0 || vector.diskMb
> 0;
+        });
+        $scope.resourcesTableColumns = columns;
+
+        // Assuming the max column count of 6. Revisit this approach if that's no longer
the case.
+        $scope.resourceClass = 'col-md-' + (columns.length * 2);
+
       });
 
       function getQuota(quotaResponse) {
@@ -179,28 +192,25 @@
           return [];
         }
 
-        var consumption = quotaResponse.quota;
-        return [
-          {
-            resource: 'CPU',
-            prodSharedConsumption: $filter('toCores')(consumption.prodSharedConsumption.numCpus),
-            quota: $filter('toCores')(consumption.quota.numCpus),
+        function addResourceVector(name, filterSpec, vector) {
+          var consumption = quotaResponse.quota;
+          return {
+            resource: name,
+            quota: $filter(filterSpec)(consumption.quota[vector]),
+            prodSharedConsumption: $filter(filterSpec)(consumption.prodSharedConsumption[vector]),
+            prodDedicatedConsumption:
+              $filter(filterSpec)(consumption.prodDedicatedConsumption[vector]),
             nonProdSharedConsumption:
-              $filter('toCores')(consumption.nonProdSharedConsumption.numCpus)
-          },
-          {
-            resource: 'RAM',
-            prodSharedConsumption: $filter('scaleMb')(consumption.prodSharedConsumption.ramMb),
-            quota: $filter('scaleMb')(consumption.quota.ramMb),
-            nonProdSharedConsumption: $filter('scaleMb')(consumption.nonProdSharedConsumption.ramMb)
-          },
-          {
-            resource: 'Disk',
-            prodSharedConsumption: $filter('scaleMb')(consumption.prodSharedConsumption.diskMb),
-            quota: $filter('scaleMb')(consumption.quota.diskMb),
-            nonProdSharedConsumption:
-              $filter('scaleMb')(consumption.nonProdSharedConsumption.diskMb)
-          }
+              $filter(filterSpec)(consumption.nonProdSharedConsumption[vector]),
+            nonProdDedicatedConsumption:
+              $filter(filterSpec)(consumption.nonProdDedicatedConsumption[vector])
+          };
+        }
+
+        return [
+          addResourceVector('CPU', 'toCores', 'numCpus'),
+          addResourceVector('RAM', 'scaleMb', 'ramMb'),
+          addResourceVector('Disk', 'scaleMb', 'diskMb')
         ];
       }
     }

http://git-wip-us.apache.org/repos/asf/aurora/blob/a5ac5b96/src/main/resources/scheduler/assets/role.html
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/role.html b/src/main/resources/scheduler/assets/role.html
index 2572c4b..3072ae3 100644
--- a/src/main/resources/scheduler/assets/role.html
+++ b/src/main/resources/scheduler/assets/role.html
@@ -31,8 +31,8 @@
     </div>
 
     <div class='row' ng-show='!environment'>
-      <div class='col-md-8'>
-        <div ng-controller="QuotaController">
+      <div ng-controller="QuotaController">
+        <div class={{resourceClass}}>
           <div>
             <h4>Resource consumption</h4>
             <smart-table config='resourcesTableConfig'


Mime
View raw message