You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2016/05/25 17:09:40 UTC

aurora git commit: Updating scheduler UI to use new resource objects

Repository: aurora
Updated Branches:
  refs/heads/master 9f6a6606c -> 3cf6e4e2b


Updating scheduler UI to use new resource objects

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


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

Branch: refs/heads/master
Commit: 3cf6e4e2b2585426702fef0828be54f0cfad870c
Parents: 9f6a660
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Wed May 25 10:09:31 2016 -0700
Committer: Maxim Khutornenko <ma...@apache.org>
Committed: Wed May 25 10:09:31 2016 -0700

----------------------------------------------------------------------
 .../scheduler/assets/configSummary.html         |  6 ++--
 .../scheduler/assets/js/controllers.js          | 12 +++----
 .../resources/scheduler/assets/js/filters.js    | 34 ++++++++++++++----
 .../resources/scheduler/assets/js/services.js   |  4 +--
 .../scheduler/assets/schedulingDetail.html      | 36 --------------------
 5 files changed, 37 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3cf6e4e2/src/main/resources/scheduler/assets/configSummary.html
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/configSummary.html b/src/main/resources/scheduler/assets/configSummary.html
index 1af7511..97104de 100644
--- a/src/main/resources/scheduler/assets/configSummary.html
+++ b/src/main/resources/scheduler/assets/configSummary.html
@@ -19,15 +19,15 @@
   <tr>
     <td class="cellLabel" rowspan="3">resources</td>
     <td>cpu</td>
-    <td>{{group.summary.schedulingDetail.numCpus | toCores}}</td>
+    <td>{{group.summary.schedulingDetail.resources | toResourceValue:'CPUS'}}</td>
   </tr>
   <tr>
     <td>ram</td>
-    <td>{{group.summary.schedulingDetail.ramMb | scaleMb}}</td>
+    <td>{{group.summary.schedulingDetail.resources | toResourceValue:'RAM'}}</td>
   </tr>
   <tr>
     <td>disk</td>
-    <td>{{group.summary.schedulingDetail.diskMb | scaleMb}}</td>
+    <td>{{group.summary.schedulingDetail.resources | toResourceValue:'Disk'}}</td>
   </tr>
   <tr>
     <td class="cellLabel">constraints</td>

http://git-wip-us.apache.org/repos/asf/aurora/blob/3cf6e4e2/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 84417eb..2131c42 100644
--- a/src/main/resources/scheduler/assets/js/controllers.js
+++ b/src/main/resources/scheduler/assets/js/controllers.js
@@ -163,9 +163,9 @@
         $scope.resources = getQuota(quotaResponse);
         $scope.resourcesTableColumns = [
           {label: '', map: 'resource'},
-          {label: 'CPU', map: 'numCpus'},
-          {label: 'RAM', map: 'ramMb'},
-          {label: 'Disk', map: 'diskMb'}
+          {label: 'CPU', map: 'cpus'},
+          {label: 'RAM', map: 'ram'},
+          {label: 'Disk', map: 'disk'}
         ];
       });
 
@@ -180,9 +180,9 @@
           var consumption = quotaResponse.quota;
           return {
             resource: name,
-            numCpus: $filter('toCores')(consumption[vector].numCpus),
-            ramMb: $filter('scaleMb')(consumption[vector].ramMb),
-            diskMb: $filter('scaleMb')(consumption[vector].diskMb)
+            cpus: $filter('toResourceValue')(consumption[vector].resources, 'CPUS'),
+            ram: $filter('toResourceValue')(consumption[vector].resources, 'RAM'),
+            disk: $filter('toResourceValue')(consumption[vector].resources, 'Disk')
           };
         }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/3cf6e4e2/src/main/resources/scheduler/assets/js/filters.js
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/js/filters.js b/src/main/resources/scheduler/assets/js/filters.js
index ac48c7f..34fc185 100644
--- a/src/main/resources/scheduler/assets/js/filters.js
+++ b/src/main/resources/scheduler/assets/js/filters.js
@@ -79,10 +79,10 @@
     };
   });
 
-  auroraUI.filter('scaleMb', function () {
+  auroraUI.filter('toResourceValue', function () {
     var SCALE = ['MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
 
-    return function (sizeInMb) {
+    function formatMem(sizeInMb) {
       var size = sizeInMb;
       var unit = 0;
       while (size >= 1024 && unit < SCALE.length) {
@@ -90,12 +90,32 @@
         unit++;
       }
       return size.toFixed(2).toString() + ' ' + SCALE[unit];
-    };
-  });
+    }
+
+    return function (resources, type) {
+      var RESOURCE_MAP = {
+        'CPUS': {
+          filter: function (e) { return e.numCpus !== null; },
+          format: function (v) { return v.numCpus + ' cores'; }
+        },
+        'RAM': {
+          filter: function (e) { return e.ramMb !== null; },
+          format: function (v) { return formatMem(v.ramMb); }
+        },
+        'Disk': {
+          filter: function (e) { return e.diskMb !== null; },
+          format: function (v) { return formatMem(v.diskMb); }
+        }
+      };
+
+      if (RESOURCE_MAP.hasOwnProperty(type)) {
+        var resource = _.find(resources, RESOURCE_MAP[type].filter);
+        if (resource) {
+          return RESOURCE_MAP[type].format(resource);
+        }
+      }
 
-  auroraUI.filter('toCores', function () {
-    return  function (count) {
-      return count + ' cores';
+      return '';
     };
   });
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/3cf6e4e2/src/main/resources/scheduler/assets/js/services.js
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/js/services.js b/src/main/resources/scheduler/assets/js/services.js
index d9ce520..a633396 100644
--- a/src/main/resources/scheduler/assets/js/services.js
+++ b/src/main/resources/scheduler/assets/js/services.js
@@ -432,9 +432,7 @@
           }
 
           return {
-            numCpus: task.numCpus,
-            ramMb: task.ramMb,
-            diskMb: task.diskMb,
+            resources: task.resources,
             isService: task.isService,
             production: task.production,
             contact: task.contactEmail || '',

http://git-wip-us.apache.org/repos/asf/aurora/blob/3cf6e4e2/src/main/resources/scheduler/assets/schedulingDetail.html
----------------------------------------------------------------------
diff --git a/src/main/resources/scheduler/assets/schedulingDetail.html b/src/main/resources/scheduler/assets/schedulingDetail.html
deleted file mode 100644
index eb88c1e..0000000
--- a/src/main/resources/scheduler/assets/schedulingDetail.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<div class='scheduling-detail'>
-  <!--
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-   -->
-  <ul class='unstyled'>
-    <li>resources:
-      cpu: {{dataRow.schedulingDetail.numCpus | toCores}},
-      ram: {{dataRow.schedulingDetail.ramMb | scaleMb}},
-      disk: {{dataRow.schedulingDetail.diskMb | scaleMb}}
-    </li>
-    <li ng-if='dataRow.schedulingDetail.constraints'>
-      constraints: {{dataRow.schedulingDetail.constraints}}
-    </li>
-    <li>production: {{dataRow.schedulingDetail.production}}</li>
-    <li>service: {{dataRow.schedulingDetail.isService}}</li>
-    <li ng-if='dataRow.schedulingDetail.ports'>
-      ports: {{dataRow.schedulingDetail.ports}}
-    </li>
-    <li ng-if='dataRow.schedulingDetail.metadata'>
-      metadata: {{dataRow.schedulingDetail.metadata}}
-    </li>
-    <li ng-if='dataRow.schedulingDetail.contact'>
-      contact: {{dataRow.schedulingDetail.contact}}
-    </li>
-  </ul>
-</div>