aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Make JS compliant with JSHint rules
Date Wed, 21 May 2014 23:17:45 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d2ab18213 -> 9fd8b5559


Make JS compliant with JSHint rules

Testing Done:
$ ./gradlew clean build

Bugs closed: AURORA-438

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


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

Branch: refs/heads/master
Commit: 9fd8b5559d89d0d682d008e8202c622eaa140972
Parents: d2ab182
Author: David McLaughlin <david@dmclaughlin.com>
Authored: Wed May 21 16:09:42 2014 -0700
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Wed May 21 16:09:42 2014 -0700

----------------------------------------------------------------------
 build.gradle                                    |   6 +-
 .../apache/aurora/scheduler/http/ui/js/app.js   |  37 +-
 .../aurora/scheduler/http/ui/js/controllers.js  | 671 ++++++++++---------
 .../aurora/scheduler/http/ui/js/directives.js   | 202 +++---
 .../aurora/scheduler/http/ui/js/filters.js      | 117 ++--
 .../aurora/scheduler/http/ui/js/services.js     | 452 +++++++------
 6 files changed, 755 insertions(+), 730 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 77fba33..d220385 100644
--- a/build.gradle
+++ b/build.gradle
@@ -293,7 +293,7 @@ task jsHint(type:com.eriwen.gradle.js.tasks.JsHintTask) {
   source = fileTree('src/main/resources/org/apache/aurora/scheduler/http/ui/js/')
   dest file("${buildDir}/jshint.out")
   // Set this to false once JS code complies with JSHint.
-  ignoreExitCode true
+  ignoreExitCode false
   outputToStdOut true
   jshint.options = [
     // See: http://www.jshint.com/docs/options/ for explanation.
@@ -302,10 +302,12 @@ task jsHint(type:com.eriwen.gradle.js.tasks.JsHintTask) {
     curly: true,
     eqeqeq: true,
     indent: 2,
+    maxlen: 100,
     quotmark: true,
     trailing: true,
     undef: true,
-    unused: true
+    unused: 'vars',
+    white: true
   ]
   jshint.predef = [
     '_': true,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js
index 1a61712..2a27a8c 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js
@@ -13,27 +13,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
+(function () {
+  'use strict';
 
-// Declare app level module which depends on filters, and services
-var auroraUI = angular.module('auroraUI', ['ngRoute', 'auroraUI.controllers', 'smartTable.table']);
+  // Declare app level module which depends on filters, and services
+  var auroraUI = angular.module('auroraUI',
+    ['ngRoute', 'auroraUI.controllers', 'smartTable.table']);
 
-auroraUI.config(function ($routeProvider, $locationProvider) {
-  $routeProvider.when("/scheduler",
-    {templateUrl: '/home.html', controller: 'RoleSummaryController'});
+  auroraUI.config(function ($routeProvider, $locationProvider) {
+    $routeProvider.when('/scheduler',
+      {templateUrl: '/home.html', controller: 'RoleSummaryController'});
 
-  $routeProvider.when("/scheduler/:role",
-    {templateUrl: '/role.html', controller: 'JobSummaryController'});
+    $routeProvider.when('/scheduler/:role',
+      {templateUrl: '/role.html', controller: 'JobSummaryController'});
 
-  $routeProvider.when("/scheduler/:role/:environment",
-    {templateUrl: '/role.html', controller: 'JobSummaryController'});
+    $routeProvider.when('/scheduler/:role/:environment',
+      {templateUrl: '/role.html', controller: 'JobSummaryController'});
 
-  $routeProvider.when("/scheduler/:role/:environment/:job",
-    {templateUrl: '/job.html', controller: 'JobController'});
+    $routeProvider.when('/scheduler/:role/:environment/:job',
+      {templateUrl: '/job.html', controller: 'JobController'});
 
-  $routeProvider.otherwise({redirectTo: function (location, path) {
-    window.location.href = path;
-  }});
+    $routeProvider.otherwise({redirectTo: function (location, path) {
+      window.location.href = path;
+    }});
 
-  $locationProvider.html5Mode(true);
-});
+    $locationProvider.html5Mode(true);
+  });
+})();

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/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 1fa1cea..87cdfb2 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
@@ -13,404 +13,407 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-
-/* Controllers */
-
-var auroraUIControllers = angular.module('auroraUI.controllers', []);
+(function () {
+  /* global ScheduleStatus:false */
+  'use strict';
+
+  /* Controllers */
+
+  var auroraUIControllers = angular.module('auroraUI.controllers', []);
+
+  var infoTableConfig = {
+    isGlobalSearchActivated: true,
+    isPaginationEnabled: true,
+    itemsByPage: 25,
+    maxSize: 8,
+    selectionMode: 'single'
+  };
+
+  var summaryTableConfig = {
+    isPaginationEnabled: false,
+    isGlobalSearchActivated: false,
+    selectionMode: 'none'
+  };
+
+  auroraUIControllers.controller('RoleSummaryController',
+    function ($scope, auroraClient) {
+      $scope.title = 'Scheduled Jobs Summary';
+
+      $scope.error = '';
+
+      $scope.roleSummaryColumns = [
+        {label: 'Role', map: 'role', cellTemplateUrl: 'roleLink.html'},
+        {label: 'Jobs', map: 'jobCount'},
+        {label: 'Cron Jobs', map: 'cronJobCount'}
+      ];
 
-var infoTableConfig = {
-  isGlobalSearchActivated: true,
-  isPaginationEnabled: true,
-  itemsByPage: 25,
-  maxSize: 8,
-  selectionMode: 'single'
-};
+      $scope.roleSummaries = parseResponse(auroraClient.getRoleSummary());
 
-var summaryTableConfig = {
-  isPaginationEnabled: false,
-  isGlobalSearchActivated: false,
-  selectionMode: 'none'
-};
+      function parseResponse(response) {
+        $scope.error = response.error ? 'Error requesting role summary: ' + response.error : '';
 
-auroraUIControllers.controller('RoleSummaryController',
-  function ($scope, auroraClient) {
-    $scope.title = 'Scheduled Jobs Summary';
+        if ($scope.error) {
+          return [];
+        }
 
-    $scope.error = '';
+        // TODO(Suman Karumuri): Replace sort with defaultSortColumn once it lands
+        // https://github.com/lorenzofox3/Smart-Table/pull/61
+        return response.summaries.sort(function (a, b) {
+          if (a.role.toLowerCase() > b.role.toLowerCase()) {
+            return 1;
+          }
+          if (a.role.toLowerCase() < b.role.toLowerCase()) {
+            return -1;
+          }
+          return 0;
+        });
+      }
 
-    $scope.roleSummaryColumns = [
-      {label: 'Role', map: 'role', cellTemplateUrl: 'roleLink.html'},
-      {label: 'Jobs', map: 'jobCount'},
-      {label: 'Cron Jobs', map: 'cronJobCount'}
-    ];
+      $scope.roleSummaryTableConfig = infoTableConfig;
+    });
+
+  auroraUIControllers.controller('JobSummaryController',
+    function ($scope, $routeParams, auroraClient) {
+      $scope.role = $routeParams.role;
+      $scope.environment = $routeParams.environment;
+
+      $scope.error = '';
+
+      $scope.jobsTableColumns = [
+        {label: 'Job Type', map: 'jobType'},
+        {label: 'Environment', map: 'environment', cellTemplateUrl: '/roleEnvLink.html'},
+        {label: 'Job', map: 'jobName', cellTemplateUrl: '/jobLink.html'},
+        {label: 'production', map: 'isProduction'},
+        {label: 'Pending Tasks', map: 'pendingTasks'},
+        {label: 'Active Tasks', map: 'activeTasks'},
+        {label: 'Finished Tasks', map: 'finishedTasks'},
+        {label: 'Failed Tasks', map: 'failedTasks'}
+      ];
 
-    $scope.roleSummaries = parseResponse(auroraClient.getRoleSummary());
+      $scope.jobsTableConfig = infoTableConfig;
 
-    function parseResponse(response) {
-      $scope.error = response.error ? 'Error requesting role summary: ' + response.error : '';
+      $scope.jobs = getJobs();
 
-      if ($scope.error) {
-        return [];
-      }
+      function getJobs() {
+        var summaries = auroraClient.getJobSummary($scope.role);
+        $scope.error = summaries.error ? 'Error fetching job summaries: ' + summaries.error : '';
 
-      // TODO(Suman Karumuri): Replace sort with defaultSortColumn once it lands
-      // https://github.com/lorenzofox3/Smart-Table/pull/61
-      return response.summaries.sort(function (a, b) {
-        if (a.role.toLowerCase() > b.role.toLowerCase()) {
-          return 1;
+        if ($scope.error) {
+          return [];
         }
-        if (a.role.toLowerCase() < b.role.toLowerCase()) {
-          return -1;
-        }
-        return 0;
-      });
-    }
-
-    $scope.roleSummaryTableConfig = infoTableConfig;
-  });
 
-auroraUIControllers.controller('JobSummaryController',
-  function ($scope, $routeParams, auroraClient) {
-    $scope.role = $routeParams.role;
-    $scope.environment = $routeParams.environment;
+        var jobSummaries = summaries.jobs;
 
-    $scope.error = '';
+        if ($scope.environment) {
+          jobSummaries = _.filter(jobSummaries, function (summary) {
+            return summary.job.key.environment === $scope.environment;
+          });
+        }
 
-    $scope.jobsTableColumns = [
-      {label: 'Job Type', map: 'jobType'},
-      {label: 'Environment', map: 'environment', cellTemplateUrl: '/roleEnvLink.html'},
-      {label: 'Job', map: 'jobName', cellTemplateUrl: '/jobLink.html'},
-      {label: 'production', map: 'isProduction'},
-      {label: 'Pending Tasks', map: 'pendingTasks'},
-      {label: 'Active Tasks', map: 'activeTasks'},
-      {label: 'Finished Tasks', map: 'finishedTasks'},
-      {label: 'Failed Tasks', map: 'failedTasks'}
-    ];
+        var byJobName = function (summary) {
+          return summary.jobName;
+        };
 
-    $scope.jobsTableConfig = infoTableConfig;
+        return _.chain(jobSummaries)
+          .map(function (summary) {
+            return {
+              role: $scope.role, // required for roleEnvLink directive
+              environment: summary.job.key.environment,
+              jobName: summary.job.taskConfig.jobName,
+              jobType: getJobType(summary.job),
+              isProduction: summary.job.taskConfig.production ? 'yes' : '',
+              pendingTasks: summary.stats.pendingTaskCount,
+              activeTasks: summary.stats.activeTaskCount,
+              finishedTasks: summary.stats.finishedTaskCount,
+              failedTasks: summary.stats.failedTaskCount
+            };
+          })
+          .sortBy(byJobName)
+          .value();
+      }
 
-    $scope.jobs = getJobs();
+      function getJobType(job) {
+        if (job.taskConfig.isService) {
+          return 'service';
+        }
 
-    function getJobs() {
-      var summaries = auroraClient.getJobSummary($scope.role);
-      $scope.error = summaries.error ? 'Error fetching job summaries: ' + summaries.error : '';
+        if (job.cronSchedule !== null) {
+          return 'cron';
+        }
 
-      if ($scope.error) {
-        return [];
+        return 'adhoc';
       }
+    });
 
-      var jobSummaries = summaries.jobs;
+  auroraUIControllers.controller('QuotaController',
+    function ($scope, $filter, auroraClient) {
+      $scope.error = '';
 
-      if ($scope.environment) {
-        jobSummaries = _.filter(jobSummaries, function (summary) {
-          return summary.job.key.environment === $scope.environment;
-        });
-      }
+      $scope.resourcesTableColumns = [
+        {label: 'Resource', map: 'resource'},
+        {label: 'Production Consumption', map: 'prodConsumption'},
+        {label: 'Quota', map: 'quota'},
+        {label: 'Non-Production Consumption', map: 'nonProdConsumption'}
+      ];
 
-      var byJobName = function (summary) {
-        return summary.jobName;
-      };
+      $scope.resourcesTableConfig = summaryTableConfig;
 
-      return _.chain(jobSummaries)
-        .map(function (summary) {
-          return {
-            role: $scope.role, // required for roleEnvLink directive
-            environment: summary.job.key.environment,
-            jobName: summary.job.taskConfig.jobName,
-            jobType: getJobType(summary.job),
-            isProduction: summary.job.taskConfig.production ? 'yes' : '',
-            pendingTasks: summary.stats.pendingTaskCount,
-            activeTasks: summary.stats.activeTaskCount,
-            finishedTasks: summary.stats.finishedTaskCount,
-            failedTasks: summary.stats.failedTaskCount
-          };
-        })
-        .sortBy(byJobName)
-        .value();
-    }
+      $scope.resources = getQuota();
 
-    function getJobType(job) {
-      if (job.taskConfig.isService) {
-        return 'service';
-      }
+      function getQuota() {
+        var quotaResponse = auroraClient.getQuota($scope.role);
+        $scope.error = quotaResponse.error ? 'Error fetching quota: ' + quotaResponse.error : '';
 
-      if (job.cronSchedule !== null) {
-        return 'cron';
-      }
+        if ($scope.error) {
+          return [];
+        }
 
-      return 'adhoc';
+        var consumption = quotaResponse.quota;
+        return [
+          {
+            resource: 'CPU',
+            prodConsumption: $filter('toCores')(consumption.prodConsumption.numCpus),
+            quota: $filter('toCores')(consumption.quota.numCpus),
+            nonProdConsumption: $filter('toCores')(consumption.nonProdConsumption.numCpus)
+          },
+          {
+            resource: 'RAM',
+            prodConsumption: $filter('scaleMb')(consumption.prodConsumption.ramMb),
+            quota: $filter('scaleMb')(consumption.quota.ramMb),
+            nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.ramMb)
+          },
+          {
+            resource: 'Disk',
+            prodConsumption: $filter('scaleMb')(consumption.prodConsumption.diskMb),
+            quota: $filter('scaleMb')(consumption.quota.diskMb),
+            nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.diskMb)
+          }
+        ];
+      }
     }
-  });
-
-auroraUIControllers.controller('QuotaController',
-  function ($scope, $filter, auroraClient) {
-    $scope.error = '';
+  );
+
+  auroraUIControllers.controller('CronJobSummaryController',
+    function ($scope, $filter, cronJobSummaryService) {
+      $scope.cronJobSummaryTableConfig = summaryTableConfig;
+
+      $scope.cronJobSummaryTableColumns = [
+        {label: 'Number of tasks', map: 'tasks', isSortable: false},
+        {label: 'Cron Schedule', map: 'schedule', isSortable: false},
+        {label: 'Next Cron Run', map: 'nextCronRun', isSortable: false},
+        {label: 'Collision Policy', map: 'collisionPolicy', isSortable: false},
+        {label: 'Metadata', map: 'metadata', isSortable: false}
+      ];
 
-    $scope.resourcesTableColumns = [
-      {label: 'Resource', map: 'resource'},
-      {label: 'Production Consumption', map: 'prodConsumption'},
-      {label: 'Quota', map: 'quota'},
-      {label: 'Non-Production Consumption', map: 'nonProdConsumption'}
-    ];
+      $scope.error = '';
+      $scope.cronJobSummary = [];
 
-    $scope.resourcesTableConfig = summaryTableConfig;
+      var cronJobSummary = cronJobSummaryService.getCronJobSummary($scope.role, $scope.environment,
+        $scope.job);
 
-    $scope.resources = getQuota();
+      if (cronJobSummary.error) {
+        $scope.error = 'Error fetching cron job summary: ' + cronJobSummary.error;
+        return [];
+      }
 
-    function getQuota() {
-      var quotaResponse = auroraClient.getQuota($scope.role);
-      $scope.error = quotaResponse.error ? 'Error fetching quota: ' + quotaResponse.error : '';
+      if (cronJobSummary.cronJobSummary) {
+        var nextCronRunTs = cronJobSummary.cronJobSummary.nextCronRun;
+        cronJobSummary.cronJobSummary.nextCronRun =
+          $filter('toLocalTime')(nextCronRunTs) + ', ' + $filter('toUtcTime')(nextCronRunTs);
 
-      if ($scope.error) {
-        return [];
+        $scope.cronJobSummary = [cronJobSummary.cronJobSummary];
       }
+    }
+  );
+
+  auroraUIControllers.controller('JobController',
+    function ($scope, $routeParams, auroraClient, taskUtil) {
+      $scope.error = '';
+
+      $scope.role = $routeParams.role;
+      $scope.environment = $routeParams.environment;
+      $scope.job = $routeParams.job;
+
+      var taskTableConfig = {
+        isGlobalSearchActivated: false,
+        isPaginationEnabled: true,
+        itemsByPage: 50,
+        maxSize: 8,
+        selectionMode: 'single'
+      };
 
-      var consumption = quotaResponse.quota;
-      return [
-        {
-          resource: 'CPU',
-          prodConsumption: $filter('toCores')(consumption.prodConsumption.numCpus),
-          quota: $filter('toCores')(consumption.quota.numCpus),
-          nonProdConsumption: $filter('toCores')(consumption.nonProdConsumption.numCpus)
-        },
-        {
-          resource: 'RAM',
-          prodConsumption: $filter('scaleMb')(consumption.prodConsumption.ramMb),
-          quota: $filter('scaleMb')(consumption.quota.ramMb),
-          nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.ramMb)
-        },
-        {
-          resource: 'Disk',
-          prodConsumption: $filter('scaleMb')(consumption.prodConsumption.diskMb),
-          quota: $filter('scaleMb')(consumption.quota.diskMb),
-          nonProdConsumption: $filter('scaleMb')(consumption.nonProdConsumption.diskMb)
-        }
+      $scope.activeTasksTableConfig = taskTableConfig;
+      $scope.completedTasksTableConfig = taskTableConfig;
+
+      var taskColumns = [
+        {label: 'Instance', map: 'instanceId'},
+        {label: 'Status', map: 'status', cellTemplateUrl: '/taskStatus.html'},
+        {label: 'Host', map: 'host', cellTemplateUrl: '/taskSandbox.html'}
       ];
-    }
-  }
-);
-
-auroraUIControllers.controller('CronJobSummaryController',
-  function ($scope, $filter, cronJobSummaryService) {
-    $scope.cronJobSummaryTableConfig = summaryTableConfig;
-
-    $scope.cronJobSummaryTableColumns = [
-      {label: 'Number of tasks', map: 'tasks', isSortable: false},
-      {label: 'Cron Schedule', map: 'schedule', isSortable: false},
-      {label: 'Next Cron Run', map: 'nextCronRun', isSortable: false},
-      {label: 'Collision Policy', map: 'collisionPolicy', isSortable: false},
-      {label: 'Metadata', map: 'metadata', isSortable: false}
-    ];
-
-    $scope.error = '';
-    $scope.cronJobSummary = [];
-
-    var cronJobSummary = cronJobSummaryService.getCronJobSummary($scope.role, $scope.environment,
-      $scope.job);
-
-    if (cronJobSummary.error) {
-      $scope.error = 'Error fetching cron job summary: ' + cronJobSummary.error;
-      return [];
-    }
 
-    if (cronJobSummary.cronJobSummary) {
-      var nextCronRunTs = cronJobSummary.cronJobSummary.nextCronRun;
-      cronJobSummary.cronJobSummary.nextCronRun =
-        $filter('toLocalTime')(nextCronRunTs) + ', ' + $filter('toUtcTime')(nextCronRunTs);
+      var completedTaskColumns = addColumn(2,
+        taskColumns,
+        {label: 'Running duration',
+          map: 'duration',
+          formatFunction: function (duration) {
+            return moment.duration(duration).humanize();
+          }
+        });
 
-      $scope.cronJobSummary = [cronJobSummary.cronJobSummary];
-    }
-  }
-);
-
-auroraUIControllers.controller('JobController',
-  function ($scope, $routeParams, auroraClient, taskUtil) {
-    $scope.error = '';
-
-    $scope.role = $routeParams.role;
-    $scope.environment = $routeParams.environment;
-    $scope.job = $routeParams.job;
-
-    var taskTableConfig = {
-      isGlobalSearchActivated: false,
-      isPaginationEnabled: true,
-      itemsByPage: 50,
-      maxSize: 8,
-      selectionMode: 'single'
-    };
-
-    $scope.activeTasksTableConfig = taskTableConfig;
-    $scope.completedTasksTableConfig = taskTableConfig;
-
-    var taskColumns = [
-      {label: 'Instance', map: 'instanceId'},
-      {label: 'Status', map: 'status', cellTemplateUrl: '/taskStatus.html'},
-      {label: 'Host', map: 'host', cellTemplateUrl: '/taskSandbox.html'}
-    ];
-
-    var completedTaskColumns = addColumn(2,
-      taskColumns,
-      {label: 'Running duration',
-        map: 'duration',
-        formatFunction: function (duration) {
-          return moment.duration(duration).humanize();
-        }
-      });
+      var taskIdColumn = {label: 'Task ID', map: 'taskId', cellTemplateUrl: '/taskLink.html'};
 
-    var taskIdColumn = {label: 'Task ID', map: 'taskId', cellTemplateUrl: '/taskLink.html'};
+      $scope.activeTasksTableColumns = taskColumns;
 
-    $scope.activeTasksTableColumns = taskColumns;
+      $scope.completedTasksTableColumns = completedTaskColumns;
 
-    $scope.completedTasksTableColumns = completedTaskColumns;
+      function addColumn(idxPosition, currentColumns, newColumn) {
+        return _.union(
+          _.first(currentColumns, idxPosition),
+          [newColumn],
+          _.last(currentColumns, currentColumns.length - idxPosition));
+      }
 
-    function addColumn(idxPosition, currentColumns, newColumn) {
-      return _.union(
-        _.first(currentColumns, idxPosition),
-        [newColumn],
-        _.last(currentColumns, currentColumns.length - idxPosition));
-    }
+      $scope.showTaskInfoLink = false;
 
-    $scope.showTaskInfoLink = false;
+      $scope.toggleTaskInfoLinkVisibility = function () {
+        $scope.showTaskInfoLink = !$scope.showTaskInfoLink;
 
-    $scope.toggleTaskInfoLinkVisibility = function () {
-      $scope.showTaskInfoLink = !$scope.showTaskInfoLink;
+        $scope.activeTasksTableColumns = $scope.showTaskInfoLink ?
+          addColumn(2, taskColumns, taskIdColumn) :
+          taskColumns;
 
-      $scope.activeTasksTableColumns = $scope.showTaskInfoLink
-        ? addColumn(2, taskColumns, taskIdColumn)
-        : taskColumns;
+        $scope.completedTasksTableColumns = $scope.showTaskInfoLink ?
+          addColumn(3, completedTaskColumns, taskIdColumn) :
+          completedTaskColumns;
+      };
 
-      $scope.completedTasksTableColumns = $scope.showTaskInfoLink
-        ? addColumn(3, completedTaskColumns, taskIdColumn) :
-        completedTaskColumns;
-    };
+      $scope.jobDashboardUrl = '';
 
-    $scope.jobDashboardUrl = '';
+      $scope.completedTasks = [];
 
-    $scope.completedTasks = [];
+      $scope.activeTasks = getTasksForJob($scope.role, $scope.environment, $scope.job);
 
-    $scope.activeTasks = getTasksForJob($scope.role, $scope.environment, $scope.job);
+      function buildGroupSummary($scope) {
+        var colors = [
+          'steelblue',
+          'indianred',
+          'darkseagreen',
+          'sandybrown',
+          'plum'
+        ];
 
-    function buildGroupSummary($scope) {
-      var colors = [
-        'steelblue',
-        'indianred',
-        'darkseagreen',
-        'sandybrown',
-        'plum'
-      ];
+        var total = _.reduce($scope.taskSummary, function (m, n) {
+          return m + ((n.range.end - n.range.start) + 1);
+        }, 0);
 
-      var total = _.reduce($scope.taskSummary, function(m, n) {
-        return m + ((n.range.end - n.range.start) + 1);
-      }, 0);
+        $scope.groupSummary = $scope.taskSummary.map(function (summary, i) {
+          var count = (summary.range.end - summary.range.start) + 1;
+          var percentage = (count / total) * 100;
 
-      $scope.groupSummary = $scope.taskSummary.map(function(summary, i) {
-        var count = (summary.range.end - summary.range.start) + 1;
-        var percentage = (count / total) * 100;
+          return {
+            label: summary.range.start + '-' + summary.range.end,
+            value: count,
+            percentage: percentage,
+            summary: summary,
+            color: colors[i % colors.length]
+          };
+        });
+      }
 
-        return {
-          label: summary.range.start + '-' + summary.range.end,
-          value: count,
-          percentage: percentage,
-          summary: summary,
-          color: colors[i % colors.length]
+      function getTasksForJob(role, environment, job) {
+        var response = auroraClient.getTasks(role, environment, job);
+
+        if (response.error) {
+          $scope.error = 'Error fetching tasks: ' + response.error;
+          return [];
         }
-      });
-    }
 
-    function getTasksForJob(role, environment, job) {
-      var response = auroraClient.getTasks(role, environment, job);
+        $scope.jobDashboardUrl = getJobDashboardUrl(response.statsUrlPrefix);
 
-      if (response.error) {
-        $scope.error = 'Error fetching tasks: ' + response.error;
-        return [];
-      }
+        $scope.taskSummary = taskUtil.summarizeActiveTaskConfigs(response.tasks);
+        buildGroupSummary($scope);
 
-      $scope.jobDashboardUrl = getJobDashboardUrl(response.statsUrlPrefix);
+        var tasks = _.map(response.tasks, function (task) {
+          return summarizeTask(task);
+        });
 
-      $scope.taskSummary = taskUtil.summarizeActiveTaskConfigs(response.tasks);
-      buildGroupSummary($scope);
+        var activeTaskPredicate = function (task) {
+          return task.isActive;
+        };
 
-      var tasks = _.map(response.tasks, function (task) {
-        return summarizeTask(task);
-      });
+        $scope.completedTasks = _.chain(tasks)
+          .reject(activeTaskPredicate)
+          .sortBy(function (task) {
+            return -task.latestActivity; //sort in descending order
+          })
+          .value();
+
+        return _.chain(tasks)
+          .filter(activeTaskPredicate)
+          .sortBy(function (task) {
+            return task.instanceId;
+          })
+          .value();
+      }
 
-      var activeTaskPredicate = function (task) {
-        return task.isActive;
-      };
+      function summarizeTask(task) {
+        var isActive = taskUtil.isActiveTask(task);
+        var sortedTaskEvents = _.sortBy(task.taskEvents, function (taskEvent) {
+          return taskEvent.timestamp;
+        });
 
-      $scope.completedTasks = _.chain(tasks)
-        .reject(activeTaskPredicate)
-        .sortBy(function (task) {
-          return -task.latestActivity; //sort in descending order
-        })
-        .value();
-
-      return _.chain(tasks)
-        .filter(activeTaskPredicate)
-        .sortBy(function (task) {
-          return task.instanceId;
-        })
-        .value();
-    }
+        // Since all task sandboxes are eventually garbage collected SANDBOX_DELETED doesn't
+        // indicate the state of the task, so use the previous task event to determine task status.
+        var latestTaskEvent = task.status === ScheduleStatus.SANDBOX_DELETED ?
+          _.chain(sortedTaskEvents).last(2).first().value() :
+          _.last(sortedTaskEvents);
 
-    function summarizeTask(task) {
-      var isActive = taskUtil.isActiveTask(task);
-      var sortedTaskEvents = _.sortBy(task.taskEvents, function (taskEvent) {
-        return taskEvent.timestamp;
-      });
-
-      // Since all task sandboxes are eventually garbage collected SANDBOX_DELETED doesn't indicate
-      // the state of the task, so use the previous task event to determine task status.
-      var latestTaskEvent = task.status === ScheduleStatus.SANDBOX_DELETED
-        ? _.chain(sortedTaskEvents).last(2).first().value()
-        : _.last(sortedTaskEvents);
-
-      return {
-        instanceId: task.assignedTask.instanceId,
-        status: _.invert(ScheduleStatus)[latestTaskEvent.status],
-        statusMessage: latestTaskEvent.message,
-        host: task.assignedTask.slaveHost || '',
-        latestActivity: _.isEmpty(sortedTaskEvents) ? 0 : latestTaskEvent.timestamp,
-        duration: getDuration(sortedTaskEvents),
-        isActive: isActive,
-        taskId: task.assignedTask.taskId,
-        taskEvents: summarizeTaskEvents(sortedTaskEvents),
-        showDetails: false,
-        sandboxExists: task.status !== ScheduleStatus.SANDBOX_DELETED
-      };
-    }
+        return {
+          instanceId: task.assignedTask.instanceId,
+          status: _.invert(ScheduleStatus)[latestTaskEvent.status],
+          statusMessage: latestTaskEvent.message,
+          host: task.assignedTask.slaveHost || '',
+          latestActivity: _.isEmpty(sortedTaskEvents) ? 0 : latestTaskEvent.timestamp,
+          duration: getDuration(sortedTaskEvents),
+          isActive: isActive,
+          taskId: task.assignedTask.taskId,
+          taskEvents: summarizeTaskEvents(sortedTaskEvents),
+          showDetails: false,
+          sandboxExists: task.status !== ScheduleStatus.SANDBOX_DELETED
+        };
+      }
 
-    function getDuration(sortedTaskEvents) {
-      var runningTaskEvent = _.find(sortedTaskEvents, function (taskEvent) {
-        return taskEvent.status === ScheduleStatus.RUNNING;
-      });
+      function getDuration(sortedTaskEvents) {
+        var runningTaskEvent = _.find(sortedTaskEvents, function (taskEvent) {
+          return taskEvent.status === ScheduleStatus.RUNNING;
+        });
 
-      if (runningTaskEvent) {
-        var nextEvent = sortedTaskEvents[_.indexOf(sortedTaskEvents, runningTaskEvent) + 1];
+        if (runningTaskEvent) {
+          var nextEvent = sortedTaskEvents[_.indexOf(sortedTaskEvents, runningTaskEvent) + 1];
 
-        return nextEvent
-          ? nextEvent.timestamp - runningTaskEvent.timestamp
-          : moment().valueOf() - runningTaskEvent.timestamp;
-      }
+          return nextEvent ?
+            nextEvent.timestamp - runningTaskEvent.timestamp :
+            moment().valueOf() - runningTaskEvent.timestamp;
+        }
 
-      return 0;
-    }
+        return 0;
+      }
 
-    function summarizeTaskEvents(taskEvents) {
-      return _.map(taskEvents, function (taskEvent) {
-        return {
-          date: moment(taskEvent.timestamp).format('MM/DD h:mm:ss'),
-          status: _.invert(ScheduleStatus)[taskEvent.status],
-          message: taskEvent.message
-        };
-      });
-    }
+      function summarizeTaskEvents(taskEvents) {
+        return _.map(taskEvents, function (taskEvent) {
+          return {
+            date: moment(taskEvent.timestamp).format('MM/DD h:mm:ss'),
+            status: _.invert(ScheduleStatus)[taskEvent.status],
+            message: taskEvent.message
+          };
+        });
+      }
 
-    function getJobDashboardUrl(statsUrlPrefix) {
-      return _.isEmpty(statsUrlPrefix)
-        ? ''
-        : statsUrlPrefix + $scope.role + '.' + $scope.environment + '.' + $scope.job;
+      function getJobDashboardUrl(statsUrlPrefix) {
+        return _.isEmpty(statsUrlPrefix) ?
+          '' :
+          statsUrlPrefix + $scope.role + '.' + $scope.environment + '.' + $scope.job;
+      }
     }
-  }
-);
+  );
+})();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js
index 890cb44..b186ae2 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js
@@ -13,117 +13,121 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
+(function () {
+  /*global auroraUI:false */
+  'use strict';
 
-auroraUI.directive('roleLink', function () {
-  return {
-    restrict: 'C',
-    template: '<a ng-href="/scheduler/{{formatedValue}}">{{formatedValue}}</a>'
-  };
-});
+  auroraUI.directive('roleLink', function () {
+    return {
+      restrict: 'C',
+      template: '<a ng-href="/scheduler/{{formatedValue}}">{{formatedValue}}</a>'
+    };
+  });
 
-auroraUI.directive('roleEnvLink', function () {
-  return {
-    restrict: 'C',
-    template: '<a ng-href="/scheduler/{{dataRow.role}}/{{formatedValue}}">{{formatedValue}}</a>'
-  };
-});
+  auroraUI.directive('roleEnvLink', function () {
+    return {
+      restrict: 'C',
+      template: '<a ng-href="/scheduler/{{dataRow.role}}/{{formatedValue}}">{{formatedValue}}</a>'
+    };
+  });
 
-auroraUI.directive('jobLink', function () {
-  return {
-    restrict: 'C',
-    template: '<a ng-href="/scheduler/{{dataRow.role}}/{{dataRow.environment}}/{{formatedValue}}">'
-      + '{{formatedValue}}</a>'
-  };
-});
+  auroraUI.directive('jobLink', function () {
+    return {
+      restrict: 'C',
+      template:
+        '<a ng-href="/scheduler/{{dataRow.role}}/{{dataRow.environment}}/{{formatedValue}}">' +
+        '{{formatedValue}}</a>'
+    };
+  });
 
-auroraUI.directive('breadcrumb', function () {
-  return {
-    restrict: 'E',
-    templateUrl: '/breadcrumb.html'
-  };
-});
+  auroraUI.directive('breadcrumb', function () {
+    return {
+      restrict: 'E',
+      templateUrl: '/breadcrumb.html'
+    };
+  });
 
-auroraUI.directive('error', function () {
-  return {
-    restrict: 'E',
-    templateUrl: '/error.html'
-  };
-});
+  auroraUI.directive('error', function () {
+    return {
+      restrict: 'E',
+      templateUrl: '/error.html'
+    };
+  });
 
-auroraUI.directive('taskSandboxLink', function () {
-  return {
-    restrict: 'E',
-    templateUrl: '/taskSandbox.html'
-  };
-});
+  auroraUI.directive('taskSandboxLink', function () {
+    return {
+      restrict: 'E',
+      templateUrl: '/taskSandbox.html'
+    };
+  });
 
-auroraUI.directive('taskStatus', function () {
-  return {
-    restrict: 'E',
-    replace: true,
-    link: function (scope, element, attrs, ctrl) {
-      element.on('click', function (e) {
-        scope.showDetails = !scope.showDetails;
-      });
-    }
-  };
-});
+  auroraUI.directive('taskStatus', function () {
+    return {
+      restrict: 'E',
+      replace: true,
+      link: function (scope, element, attrs, ctrl) {
+        element.on('click', function (e) {
+          scope.showDetails = !scope.showDetails;
+        });
+      }
+    };
+  });
 
-auroraUI.directive('taskLink', function () {
-  return {
-    restrict: 'C',
-    template: '<a class="span4" ng-href="/structdump/task/{{formatedValue}}" target="_self">' +
-      '{{formatedValue}}</a>'
-  };
-});
+  auroraUI.directive('taskLink', function () {
+    return {
+      restrict: 'C',
+      template: '<a class="span4" ng-href="/structdump/task/{{formatedValue}}" target="_self">' +
+        '{{formatedValue}}</a>'
+    };
+  });
 
-auroraUI.directive('schedulingDetail', function () {
-  return {
-    restrict: 'C'
-  };
-});
+  auroraUI.directive('schedulingDetail', function () {
+    return {
+      restrict: 'C'
+    };
+  });
 
-auroraUI.directive('groupSummary', function() {
-  return {
-    restrict: 'E',
-    templateUrl: '/groupSummary.html',
-    scope: {
-      'groups': '=',
-      'visibleGroups': '=?'
-    },
-    replace: true,
-    link: function(scope) {
-      scope.visibleGroups = scope.visibleGroups || [];
+  auroraUI.directive('groupSummary', function () {
+    return {
+      restrict: 'E',
+      templateUrl: '/groupSummary.html',
+      scope: {
+        'groups': '=',
+        'visibleGroups': '=?'
+      },
+      replace: true,
+      link: function (scope) {
+        scope.visibleGroups = scope.visibleGroups || [];
 
-      scope.toggleVisibleGroup = function(index) {
-        var i = _.indexOf(scope.visibleGroups, index, true);
-        if (i > -1) {
-          scope.visibleGroups.splice(i, 1);
-        } else {
-          scope.visibleGroups.push(index);
-          scope.visibleGroups.sort();
-        }
-      }
+        scope.toggleVisibleGroup = function (index) {
+          var i = _.indexOf(scope.visibleGroups, index, true);
+          if (i > -1) {
+            scope.visibleGroups.splice(i, 1);
+          } else {
+            scope.visibleGroups.push(index);
+            scope.visibleGroups.sort();
+          }
+        };
 
-      scope.showAllGroups = function() {
-        scope.visibleGroups = _.range(scope.groups.length);
-      }
+        scope.showAllGroups = function () {
+          scope.visibleGroups = _.range(scope.groups.length);
+        };
 
-      scope.hideAllGroups = function() {
-        scope.visibleGroups = [];
+        scope.hideAllGroups = function () {
+          scope.visibleGroups = [];
+        };
       }
-    }
-  };
-});
+    };
+  });
 
-auroraUI.directive('configSummary', function() {
-  return {
-    restrict: 'E',
-    scope: {
-      'group': '='
-    },
-    templateUrl: '/configSummary.html',
-    replace: true
-  }
-});
\ No newline at end of file
+  auroraUI.directive('configSummary', function () {
+    return {
+      restrict: 'E',
+      scope: {
+        'group': '='
+      },
+      templateUrl: '/configSummary.html',
+      replace: true
+    };
+  });
+})();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/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 a2aea4d..4c45ce1 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
@@ -13,71 +13,74 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
+(function () {
+  /* global auroraUI:false */
+  'use strict';
 
-auroraUI.filter('scheduleStatusTooltip', function () {
-  var STATES = {
-    PENDING: 'The scheduler is searching for a machine that satisfies the resources and '
-      + 'constraints for this task.',
+  auroraUI.filter('scheduleStatusTooltip', function () {
+    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.',
-    DRAINING: 'The task is being restarted since the host is undergoing scheduled maintenance.',
-    SANDBOX_DELETED: 'The task sandbox has been deleted by the executor.'
-  };
+      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.',
+      DRAINING: 'The task is being restarted since the host is undergoing scheduled maintenance.',
+      SANDBOX_DELETED: 'The task sandbox has been deleted by the executor.'
+    };
 
-  return function (value) {
-    return STATES[value] ? STATES[value] : value;
-  };
-});
+    return function (value) {
+      return STATES[value] ? STATES[value] : value;
+    };
+  });
 
-auroraUI.filter('scaleMb', function () {
-  var SCALE = ['MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
+  auroraUI.filter('scaleMb', function () {
+    var SCALE = ['MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
 
-  return function (sizeInMb) {
-    var size = sizeInMb;
-    var unit = 0;
-    while (size >= 1024 && unit < SCALE.length) {
-      size = size / 1024;
-      unit++;
-    }
-    return size.toFixed(2).toString() + ' ' + SCALE[unit];
-  };
-});
+    return function (sizeInMb) {
+      var size = sizeInMb;
+      var unit = 0;
+      while (size >= 1024 && unit < SCALE.length) {
+        size = size / 1024;
+        unit++;
+      }
+      return size.toFixed(2).toString() + ' ' + SCALE[unit];
+    };
+  });
 
-auroraUI.filter('toCores', function () {
-  return  function (count) {
-    return count + ' cores';
-  };
-});
+  auroraUI.filter('toCores', function () {
+    return  function (count) {
+      return count + ' cores';
+    };
+  });
 
-auroraUI.filter('toElapsedTime', function () {
-  return function (timestamp) {
-    return moment.duration(moment().valueOf() - timestamp).humanize();
-  };
-});
+  auroraUI.filter('toElapsedTime', function () {
+    return function (timestamp) {
+      return moment.duration(moment().valueOf() - timestamp).humanize();
+    };
+  });
 
-auroraUI.filter('toUtcTime', function () {
-  return function (timestamp, timezone) {
-    return moment(timestamp).utc().format('MM/DD h:mm:ss') + ' UTC';
-  };
-});
+  auroraUI.filter('toUtcTime', function () {
+    return function (timestamp, timezone) {
+      return moment(timestamp).utc().format('MM/DD h:mm:ss') + ' UTC';
+    };
+  });
 
-auroraUI.filter('toLocalTime', function () {
-  return function (timestamp, timezone) {
-    return moment(timestamp).format('MM/DD h:mm:ss') + ' LOCAL';
-  };
-});
\ No newline at end of file
+  auroraUI.filter('toLocalTime', function () {
+    return function (timestamp, timezone) {
+      return moment(timestamp).format('MM/DD h:mm:ss') + ' LOCAL';
+    };
+  });
+})();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fd8b555/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
index f984956..360f134 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
@@ -13,252 +13,262 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
+(function () {
+  /* global auroraUI:false, Identity:false, TaskQuery:false, ReadOnlySchedulerClient:false,
+            ACTIVE_STATES:false, CronCollisionPolicy: false */
+  'use strict';
 
-auroraUI.factory(
-  'auroraClient',
-  ['$window',
-    function ($window) {
-      var auroraClient = {
-        // Each of the functions below wrap an API call on the scheduler.
-        getRoleSummary: function () {
-          var response = auroraClient.getSchedulerClient().getRoleSummary();
-          var result = auroraClient.processResponse(response);
-          result.summaries = response.result !== null
-            ? response.result.roleSummaryResult.summaries : [];
-          return result;
-        },
+  auroraUI.factory(
+    'auroraClient',
+    ['$window',
+      function ($window) {
+        var auroraClient = {
+          // Each of the functions below wrap an API call on the scheduler.
+          getRoleSummary: function () {
+            var response = auroraClient.getSchedulerClient().getRoleSummary();
+            var result = auroraClient.processResponse(response);
+            result.summaries = response.result !== null ?
+              response.result.roleSummaryResult.summaries : [];
+            return result;
+          },
 
-        getJobSummary: function (role) {
-          var response = auroraClient.getSchedulerClient().getJobSummary(role);
-          var result = auroraClient.processResponse(response);
-          result.jobs = response.result !== null ? response.result.jobSummaryResult.summaries : [];
-          return result;
-        },
+          getJobSummary: function (role) {
+            var response = auroraClient.getSchedulerClient().getJobSummary(role);
+            var result = auroraClient.processResponse(response);
+            result.jobs = response.result !== null ?
+              response.result.jobSummaryResult.summaries : [];
+            return result;
+          },
 
-        getQuota: function (role) {
-          var response = auroraClient.getSchedulerClient().getQuota(role);
-          var result = auroraClient.processResponse(response);
-          result.quota = response.result !== null ? response.result.getQuotaResult : [];
-          return result;
-        },
+          getQuota: function (role) {
+            var response = auroraClient.getSchedulerClient().getQuota(role);
+            var result = auroraClient.processResponse(response);
+            result.quota = response.result !== null ? response.result.getQuotaResult : [];
+            return result;
+          },
 
-        getTasks: function (role, environment, jobName) {
-          var id = new Identity();
-          id.role = role;
-          var taskQuery = new TaskQuery();
-          taskQuery.owner = id;
-          taskQuery.environment = environment;
-          taskQuery.jobName = jobName;
-          var response = auroraClient.getSchedulerClient().getTasksStatus(taskQuery);
-          var result = auroraClient.processResponse(response);
-          result.tasks = response.result !== null ? response.result.scheduleStatusResult.tasks : [];
-          return result;
-        },
+          getTasks: function (role, environment, jobName) {
+            var id = new Identity();
+            id.role = role;
+            var taskQuery = new TaskQuery();
+            taskQuery.owner = id;
+            taskQuery.environment = environment;
+            taskQuery.jobName = jobName;
+            var response = auroraClient.getSchedulerClient().getTasksStatus(taskQuery);
+            var result = auroraClient.processResponse(response);
+            result.tasks = response.result !== null ?
+              response.result.scheduleStatusResult.tasks : [];
+            return result;
+          },
 
-        // Utility functions
-        // TODO(Suman Karumuri): Make schedulerClient a service
-        schedulerClient: null,
+          // Utility functions
+          // TODO(Suman Karumuri): Make schedulerClient a service
+          schedulerClient: null,
 
-        getSchedulerClient: function () {
-          if (!auroraClient.schedulerClient) {
-            var transport = new Thrift.Transport("/api");
-            var protocol = new Thrift.Protocol(transport);
-            auroraClient.schedulerClient = new ReadOnlySchedulerClient(protocol);
-            return auroraClient.schedulerClient;
-          } else {
-            return auroraClient.schedulerClient;
+          getSchedulerClient: function () {
+            if (!auroraClient.schedulerClient) {
+              var transport = new Thrift.Transport('/api');
+              var protocol = new Thrift.Protocol(transport);
+              auroraClient.schedulerClient = new ReadOnlySchedulerClient(protocol);
+              return auroraClient.schedulerClient;
+            } else {
+              return auroraClient.schedulerClient;
+            }
+          },
+
+          processResponse: function (response) {
+            auroraClient.setPageTitle(response.serverInfo);
+            var error = response.responseCode !== 1 ?
+                (response.message || 'No error message returned by the scheduler') : '',
+              statsUrlPrefix = response.serverInfo && response.serverInfo.statsUrlPrefix ?
+                response.serverInfo.statsUrlPrefix : '';
+
+            return {
+              error: error,
+              statsUrlPrefix: statsUrlPrefix
+            };
+          },
+
+          getPageTitle: function (info) {
+            var title = 'Aurora UI';
+            if (_.isNull(info) || info.error || typeof info.clusterName === 'undefined') {
+              return title;
+            } else {
+              return '[' + info.clusterName + '] ' + title;
+            }
+          },
+
+          setPageTitle: function (serverInfo) {
+            $window.document.title = auroraClient.getPageTitle(serverInfo);
           }
+        };
+        return auroraClient;
+      }
+    ]);
+
+  auroraUI.factory(
+    'taskUtil',
+    function () {
+      var taskUtil = {
+        // Given a list of tasks, group tasks with identical task configs and belonging to
+        // contiguous instance ids together.
+        summarizeActiveTaskConfigs: function (tasks) {
+          return _.chain(tasks)
+            .filter(taskUtil.isActiveTask)
+            .map(function (task) {
+              return {
+                instanceId: task.assignedTask.instanceId,
+                schedulingDetail: taskUtil.configToDetails(task.assignedTask.task)
+              };
+            })
+            .groupBy(function (task) {
+              return JSON.stringify(task.schedulingDetail);
+            })
+            .map(function (tasks) {
+              // Given a list of tasks with the same task config, group the tasks into ranges where
+              // each range consists of consecutive task ids along with their task config.
+              var schedulingDetail = _.first(tasks).schedulingDetail;
+              var ranges = taskUtil.toRanges(_.pluck(tasks, 'instanceId'));
+              return _.map(ranges, function (range) {
+                return {
+                  range: range,
+                  schedulingDetail: schedulingDetail
+                };
+              });
+            })
+            .flatten(true)
+            .sortBy(function (scheduleDetail) {
+              return scheduleDetail.range.start;
+            })
+            .value();
         },
 
-        processResponse: function (response) {
-          auroraClient.setPageTitle(response.serverInfo);
+        configToDetails: function (task) {
+          var constraints = _.chain(task.constraints)
+            .sortBy(function (constraint) {
+              return constraint.name;
+            })
+            .map(taskUtil.formatConstraint)
+            .value()
+            .join(', ');
+
+          var metadata = _.chain(task.metadata)
+            .sortBy(function (metadata) {
+              return metadata.key;
+            })
+            .map(function (metadata) {
+              return metadata.key + ':' + metadata.value;
+            })
+            .value()
+            .join(', ');
+
           return {
-            error: response.responseCode !== 1
-              ? (response.message || 'No error message returned by the scheduler')
-              : '',
-            statsUrlPrefix: response.serverInfo && response.serverInfo.statsUrlPrefix
-              ? response.serverInfo.statsUrlPrefix
-              : ''
+            numCpus: task.numCpus,
+            ramMb: task.ramMb,
+            diskMb: task.diskMb,
+            isService: task.isService,
+            production: task.production,
+            contact: task.contactEmail || '',
+            ports: _.sortBy(task.requestedPorts).join(', '),
+            constraints: constraints,
+            metadata: metadata
           };
         },
 
-        getPageTitle: function (info) {
-          var title = "Aurora UI";
-          return _.isNull(info) || info.error || typeof info.clusterName === "undefined"
-            ? title
-            : info.clusterName + " " + title;
+        // Given a list of instanceIds, group them into contiguous ranges.
+        toRanges: function (instanceIds) {
+          instanceIds = _.sortBy(instanceIds);
+          var ranges = [];
+          var i = 0;
+          var start = instanceIds[i];
+          while (i < instanceIds.length) {
+            if ((i + 1 === instanceIds.length) || (instanceIds[i] + 1 !== instanceIds[i + 1])) {
+              ranges.push({start: start, end: instanceIds[i]});
+              i++;
+              start = instanceIds[i];
+            } else {
+              i++;
+            }
+          }
+          return ranges;
         },
 
-        setPageTitle: function (serverInfo) {
-          $window.document.title = auroraClient.getPageTitle(serverInfo);
-        }
-      };
-      return auroraClient;
-    }
-  ]);
+        // A function that converts a task constraint into a string
+        formatConstraint: function (constraint) {
+          var taskConstraint = constraint.constraint;
 
-auroraUI.factory(
-  'taskUtil',
-  function () {
-    var taskUtil = {
-      // Given a list of tasks, group tasks with identical task configs and belonging to contiguous
-      // instance ids together.
-      summarizeActiveTaskConfigs: function (tasks) {
-        return _.chain(tasks)
-          .filter(taskUtil.isActiveTask)
-          .map(function (task) {
-            return {
-              instanceId: task.assignedTask.instanceId,
-              schedulingDetail: taskUtil.configToDetails(task.assignedTask.task)
-            };
-          })
-          .groupBy(function (task) {
-            return JSON.stringify(task.schedulingDetail);
-          })
-          .map(function (tasks) {
-            // Given a list of tasks with the same task config, group the tasks into ranges where
-            // each range consists of consecutive task ids along with their task config.
-            var schedulingDetail = _.first(tasks).schedulingDetail;
-            var ranges = taskUtil.toRanges(_.pluck(tasks, 'instanceId'));
-            return _.map(ranges, function (range) {
-              return {
-                range: range,
-                schedulingDetail: schedulingDetail
-              }
-            });
-          })
-          .flatten(true)
-          .sortBy(function (scheduleDetail) {
-            return scheduleDetail.range.start;
-          })
-          .value();
-      },
-
-      configToDetails: function (task) {
-        var constraints = _.chain(task.constraints)
-          .sortBy(function (constraint) {
-            return constraint.name;
-          })
-          .map(taskUtil.formatConstraint)
-          .value()
-          .join(', ');
-
-        var metadata = _.chain(task.metadata)
-          .sortBy(function (metadata) {
-            return metadata.key;
-          })
-          .map(function (metadata) {
-            return metadata.key + ':' + metadata.value;
-          })
-          .value()
-          .join(', ');
+          var valueConstraintStr = '';
+          var valueConstraint = taskConstraint.value;
+          if (valueConstraint && valueConstraint.values && _.isArray(valueConstraint.values)) {
+            var values = valueConstraint.values.join(',');
+            valueConstraintStr = valueConstraint.negated ? 'not ' + values : values;
+          }
 
-        return {
-          numCpus: task.numCpus,
-          ramMb: task.ramMb,
-          diskMb: task.diskMb,
-          isService: task.isService,
-          production: task.production,
-          contact: task.contactEmail || '',
-          ports: _.sortBy(task.requestedPorts).join(', '),
-          constraints: constraints,
-          metadata: metadata
-        };
-      },
+          var limitConstraintStr = taskConstraint.limit ? JSON.stringify(taskConstraint.limit) : '';
 
-      // Given a list of instanceIds, group them into contiguous ranges.
-      toRanges: function (instanceIds) {
-        instanceIds = _.sortBy(instanceIds);
-        var ranges = [];
-        var i = 0;
-        var start = instanceIds[i];
-        var end = instanceIds[i];
-        while (i < instanceIds.length) {
-          if ((i + 1 === instanceIds.length) || (instanceIds[i] + 1 !== instanceIds[i + 1])) {
-            ranges.push({start: start, end: instanceIds[i]});
-            i++;
-            start = instanceIds[i];
+          if (_.isEmpty(limitConstraintStr) && _.isEmpty(valueConstraintStr)) {
+            return '';
           } else {
-            i++;
+            return constraint.name + ':' +
+              (_.isEmpty(limitConstraintStr) ? valueConstraintStr : limitConstraintStr);
           }
-        }
-        return ranges;
-      },
-
-      // A function that converts a task constraint into a string
-      formatConstraint: function (constraint) {
-        var taskConstraint = constraint.constraint;
-
-        var valueConstraintStr = '';
-        var valueConstraint = taskConstraint.value;
-        if (valueConstraint && valueConstraint.values && _.isArray(valueConstraint.values)) {
-          var values = valueConstraint.values.join(',');
-          valueConstraintStr = valueConstraint.negated ? "not " + values : values;
-        }
-
-        var limitConstraintStr = taskConstraint.limit ? JSON.stringify(taskConstraint.limit) : '';
+        },
 
-        if (_.isEmpty(limitConstraintStr) && _.isEmpty(valueConstraintStr)) {
-          return '';
-        } else {
-          return constraint.name + ':' +
-            (_.isEmpty(limitConstraintStr) ? valueConstraintStr : limitConstraintStr);
+        isActiveTask: function (task) {
+          return _.contains(ACTIVE_STATES, task.status);
         }
-      },
-
-      isActiveTask: function (task) {
-        return _.contains(ACTIVE_STATES, task.status);
-      }
-    };
-    return taskUtil;
-  });
+      };
+      return taskUtil;
+    });
 
-auroraUI.factory(
-  'cronJobSummaryService',
-  [ 'auroraClient',
-    function (auroraClient) {
-      var cronJobSmrySvc = {
-        getCronJobSummary: function (role, env, jobName) {
-          var summaries = auroraClient.getJobSummary(role);
+  auroraUI.factory(
+    'cronJobSummaryService',
+    [ 'auroraClient',
+      function (auroraClient) {
+        var cronJobSmrySvc = {
+          getCronJobSummary: function (role, env, jobName) {
+            var summaries = auroraClient.getJobSummary(role);
 
-          if (summaries.error) {
-            return {error: 'Failed to fetch cron schedule from scheduler.'};
-          }
+            if (summaries.error) {
+              return {error: 'Failed to fetch cron schedule from scheduler.'};
+            }
 
-          var cronJobSummary = _.chain(summaries.jobs)
-            .filter(function (summary) {
-              // fetch the cron job with a matching name and env.
-              var job = summary.job;
-              return job.cronSchedule !== null
-                && job.key.environment === env
-                && job.taskConfig.jobName === jobName;
-            })
-            .map(function (summary) {
-              // summarize the cron job.
-              return {
-                tasks: summary.job.instanceCount,
-                schedule: summary.job.cronSchedule,
-                nextCronRun: summary.nextCronRunMs,
-                collisionPolicy: cronJobSmrySvc.getCronCollisionPolicy(summary.job.cronCollisionPolicy),
-                metadata: cronJobSmrySvc.getMetadata(summary.job.taskConfig.metadata)
-              };
-            })
-            .last() // there will always be 1 job in this list.
-            .value();
+            var cronJobSummary = _.chain(summaries.jobs)
+              .filter(function (summary) {
+                // fetch the cron job with a matching name and env.
+                var job = summary.job;
+                return job.cronSchedule !== null &&
+                  job.key.environment === env &&
+                  job.taskConfig.jobName === jobName;
+              })
+              .map(function (summary) {
+                var collisionPolicy =
+                  cronJobSmrySvc.getCronCollisionPolicy(summary.job.cronCollisionPolicy);
+                // summarize the cron job.
+                return {
+                  tasks: summary.job.instanceCount,
+                  schedule: summary.job.cronSchedule,
+                  nextCronRun: summary.nextCronRunMs,
+                  collisionPolicy: collisionPolicy,
+                  metadata: cronJobSmrySvc.getMetadata(summary.job.taskConfig.metadata)
+                };
+              })
+              .last() // there will always be 1 job in this list.
+              .value();
 
-          return {error: '', cronJobSummary: cronJobSummary}
-        },
+            return {error: '', cronJobSummary: cronJobSummary};
+          },
 
-        getMetadata: function (attributes) {
-          return _.map(attributes,function (attribute) {
-            return attribute.key + ': ' + attribute.value;
-          }).join(', ');
-        },
+          getMetadata: function (attributes) {
+            return _.map(attributes, function (attribute) {
+              return attribute.key + ': ' + attribute.value;
+            }).join(', ');
+          },
 
-        getCronCollisionPolicy: function (cronCollisionPolicy) {
-          return _.keys(CronCollisionPolicy)[cronCollisionPolicy ? cronCollisionPolicy : 0];
-        }
-      };
-      return cronJobSmrySvc;
-    }]);
+          getCronCollisionPolicy: function (cronCollisionPolicy) {
+            return _.keys(CronCollisionPolicy)[cronCollisionPolicy ? cronCollisionPolicy : 0];
+          }
+        };
+        return cronJobSmrySvc;
+      }]);
+})();
\ No newline at end of file


Mime
View raw message