aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [22/50] [abbrv] git commit: Moved common functions into filters.
Date Sat, 05 Apr 2014 00:05:08 GMT
Moved common functions into filters.


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

Branch: refs/heads/mansu/job_page
Commit: d9a3f222d96249534266af8f96fe92ef5d85cb7c
Parents: 09972aa
Author: Suman Karumuri <skarumuri@twitter.com>
Authored: Sat Mar 29 00:52:53 2014 -0700
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Sat Mar 29 00:52:53 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/http/ui/js/controllers.js  | 36 ++++--------
 .../aurora/scheduler/http/ui/js/filters.js      | 62 +++++++++++++-------
 2 files changed, 51 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d9a3f222/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
index 1a4a828..f7df538 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
@@ -210,7 +210,7 @@ auroraUIControllers.controller('JobSummaryController',
   });
 
 auroraUIControllers.controller('QuotaController',
-  function ($scope, auroraClient) {
+  function ($scope, $filter, auroraClient) {
     $scope.error = false;
 
     $scope.resourcesTableColumns = [
@@ -240,39 +240,25 @@ auroraUIControllers.controller('QuotaController',
       return [
         {
           resource: 'CPU',
-          prodConsumption: toCores(consumption.prodConsumption.numCpus),
-          quota: toCores(consumption.quota.numCpus),
-          nonProdConsumption: toCores(consumption.nonProdConsumption.numCpus)
+          prodConsumption: $filter('toCores')(consumption.prodConsumption.numCpus),
+          quota: $filter('toCores')(consumption.quota.numCpus),
+          nonProdConsumption: $filter('toCores')(consumption.nonProdConsumption.numCpus)
         },
         {
           resource: 'RAM',
-          prodConsumption: scaleMb(consumption.prodConsumption.ramMb),
-          quota: scaleMb(consumption.quota.ramMb),
-          nonProdConsumption: scaleMb(consumption.nonProdConsumption.ramMb)
+          prodConsumption: $filter('scaleMb')(consumption.prodConsumption.ramMb),
+          quota: $filter('scaleMb')(consumption.quota.ramMb),
+          nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.ramMb)
         },
         {
           resource: 'Disk',
-          prodConsumption: scaleMb(consumption.prodConsumption.diskMb),
-          quota: scaleMb(consumption.quota.diskMb),
-          nonProdConsumption: scaleMb(consumption.nonProdConsumption.diskMb)
+          prodConsumption: $filter('scaleMb')(consumption.prodConsumption.diskMb),
+          quota: $filter('scaleMb')(consumption.quota.diskMb),
+          nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.diskMb)
         }
       ];
     }
 
-    function toCores(count) {
-      return count + ' cores';
-    }
-
-    function scaleMb(sizeInMb) {
-      var size = sizeInMb;
-      var SCALE = ['MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
-      var unit = 0;
-      while (size >= 1024 && unit < SCALE.length) {
-        size = size / 1024;
-        unit++;
-      }
-      return size.toFixed(2).toString() + ' ' + SCALE[unit];
-    }
   }
 );
 
@@ -308,7 +294,7 @@ auroraUIControllers.controller('JobController',
     $scope.summaryButtonText = showSummary;
     $scope.showSummary = false;
 
-    $scope.toggleSummaryVisibility = function() {
+    $scope.toggleSummaryVisibility = function () {
       $scope.showSummary = !$scope.showSummary;
       $scope.summaryButtonText = $scope.showSummary ? hideSummary : showSummary;
     };

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/d9a3f222/src/main/resources/org/apache/aurora/scheduler/http/ui/js/filters.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/filters.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/filters.js
index ac7e2a5..931b9ee 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/filters.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/filters.js
@@ -1,29 +1,47 @@
 'use strict';
 
-auroraUI.filter('scheduleStatusTooltip',
-  function () {
-    return function (value) {
-      var states = {
-        PENDING: 'The scheduler is searching for a machine that satisfies the resources and
'
-          + 'constraints for this task.',
+auroraUI.filter('scheduleStatusTooltip', function () {
+  return function (value) {
+    var states = {
+      PENDING: 'The scheduler is searching for a machine that satisfies the resources and
'
+        + 'constraints for this task.',
 
-        THROTTLED: 'The task will be rescheduled, but is being throttled for restarting too
' +
-          'frequently.',
+      THROTTLED: 'The task will be rescheduled, but is being throttled for restarting too
' +
+        'frequently.',
 
-        ASSIGNED: 'The scheduler has selected a machine to run the task and is instructing
the '
-          + 'slave to launch it.',
+      ASSIGNED: 'The scheduler has selected a machine to run the task and is instructing
the '
+        + 'slave to launch it.',
 
-        STARTING: 'The executor is preparing to launch the task.',
-        RUNNING: 'The user process(es) are running.',
-        FAILED: 'The task ran, but did not exit indicating success.',
-        FINISHED: 'The task ran and exited successfully.',
-        KILLED: 'A user or cron invocation terminated the task.',
-        PREEMPTING: 'This task is being killed to make resources available for a production
task.',
-        KILLING: 'A user request or cron invocation has requested the task be killed.',
-        LOST: 'The task cannot be accounted for, usually a result of slave process or machine
' +
-          'failure.'
-      };
+      STARTING: 'The executor is preparing to launch the task.',
+      RUNNING: 'The user process(es) are running.',
+      FAILED: 'The task ran, but did not exit indicating success.',
+      FINISHED: 'The task ran and exited successfully.',
+      KILLED: 'A user or cron invocation terminated the task.',
+      PREEMPTING: 'This task is being killed to make resources available for a production
task.',
+      KILLING: 'A user request or cron invocation has requested the task be killed.',
+      LOST: 'The task cannot be accounted for, usually a result of slave process or machine
' +
+        'failure.'
+    };
 
-      return states[value] ? states[value] : value;
+    return states[value] ? states[value] : value;
+  };
+});
+
+auroraUI.filter('scaleMb', function () {
+  return function (sizeInMb) {
+    var size = sizeInMb;
+    var SCALE = ['MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
+    var unit = 0;
+    while (size >= 1024 && unit < SCALE.length) {
+      size = size / 1024;
+      unit++;
     }
-  });
\ No newline at end of file
+    return size.toFixed(2).toString() + ' ' + SCALE[unit];
+  };
+});
+
+auroraUI.filter('toCores', function () {
+  return  function (count) {
+    return count + ' cores';
+  }
+});
\ No newline at end of file


Mime
View raw message