aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [09/50] [abbrv] git commit: Merge branch 'mansu/aurora-39_list_jobs_per_role2' into mansu/aurora-281_job_page
Date Sat, 05 Apr 2014 00:04:55 GMT
Merge branch 'mansu/aurora-39_list_jobs_per_role2' into mansu/aurora-281_job_page

Conflicts:
	src/main/resources/org/apache/aurora/scheduler/http/ui/index.html
	src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js


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

Branch: refs/heads/mansu/job_page
Commit: 8886db1217226a7320cb6e2a336895b3ab89bc06
Parents: cd3f950 b6aca8d
Author: Suman Karumuri <skarumuri@twitter.com>
Authored: Thu Mar 27 00:25:04 2014 -0700
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Thu Mar 27 00:25:04 2014 -0700

----------------------------------------------------------------------
 .../apache/aurora/scheduler/http/ui/css/app.css |  14 ++
 .../apache/aurora/scheduler/http/ui/error.html  |   2 +-
 .../apache/aurora/scheduler/http/ui/home.html   |   4 +-
 .../apache/aurora/scheduler/http/ui/index.html  |   6 +-
 .../aurora/scheduler/http/ui/js/controllers.js  |  23 ++--
 .../aurora/scheduler/http/ui/js/services.js     | 130 ++++++++++---------
 .../apache/aurora/scheduler/http/ui/role.html   |  12 +-
 7 files changed, 104 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/8886db12/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html
----------------------------------------------------------------------
diff --cc src/main/resources/org/apache/aurora/scheduler/http/ui/index.html
index f7c3d6e,009919d..f6399c3
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html
@@@ -30,25 -29,14 +29,28 @@@
  <script src='/js/jquery.min.js'></script>
  <script src='/js/bootstrap.min.js'></script>
  <link href='/css/bootstrap.min.css' rel='stylesheet'>
 +<link href='/img/glyphicons-halflings.png' rel='stylesheet'>
  
 -<!--smart table-->
 +<!-- smart table -->
  <script src='/js/smartTable.js'></script>
  
 -<!--underscore-->
 +<!-- underscore -->
  <script src='/js/underscore.js'></script>
  
 +<!-- moment.js -->
 +<script src='/js/moment.js'></script>
 +
 +<!-- Intitalize bootstrap tooltips -->
 +<script>
 +  var options = {
 +    placement: 'right',
 +    trigger: 'hover'
 +  };
 +
 +  $('.task-status-tooltip').tooltip(options);
 +</script>
++
+ <!-- Load our css at the end so we can override bootstrap css properties as needed -->
+ <link rel='stylesheet' href='/css/app.css'/>
  </body>
  </html>

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/8886db12/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
----------------------------------------------------------------------
diff --cc src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
index fc01d06,848d136..764374d
--- 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
@@@ -280,135 -275,3 +275,135 @@@ auroraUIControllers.controller('QuotaCo
      }
    }
  );
 +
 +auroraUIControllers.controller('JobController',
 +  function ($scope, $routeParams, auroraClient) {
 +    $scope.error = false;
 +    $scope.errorMsg = '';
 +
 +    $scope.role = $routeParams.role;
 +    $scope.environment = $routeParams.environment;
 +    $scope.job = $routeParams.job;
 +
 +    $scope.activeTasksTableConfig = globalTableConfig;
 +    $scope.completedTasksTableConfig = globalTableConfig;
 +
 +    var taskColumns = [
 +      {label: 'Instance', map: 'instanceId'},
 +      {label: 'Status', map: 'status', cellTemplateUrl: '/taskStatus.html'},
 +      {label: 'Last Active', map: 'latestActivity',
 +        formatFunction: function (date) {
 +          return fromNow(date);
 +        }},
 +      {label: 'Host', map: 'host', cellTemplateUrl: '/taskSandbox.html'},
 +      {label: '', map: 'taskId', cellTemplateUrl: '/taskLink.html'}
 +    ];
 +
 +    $scope.activeTasksTableColumns = taskColumns;
 +
 +    $scope.completedTasksTableColumns = _.union(
 +      _.first(taskColumns, 2),
 +      [
 +        {label: 'Running duration', map: 'duration',
 +          formatFunction: function (duration) {
 +            return fromNow(moment().subtract(duration), true);
 +          }}
 +      ],
 +      _.last(taskColumns, taskColumns.length - 3)
 +    );
 +
 +    $scope.completedTasks = [];
 +
 +    $scope.activeTasks = getTasksForJob($scope.role, $scope.environment, $scope.job);
 +
 +    function getTasksForJob(role, environment, job) {
 +      var response = auroraClient.getTasks(role, environment, job);
 +
 +      $scope.error = response.error;
 +      $scope.errorMsg = response.errorMsg;
 +
 +      if (response.error) {
 +        return [];
 +      }
 +
 +      console.log(response);
 +
 +      var tasks = _.chain(response.tasks)
 +        .map(function (task) {
 +          var isActive = isActiveTask(task);
 +
 +          // TODO: Clean this logic.
 +
 +          var sortedTaskEvents = _.sortBy(task.taskEvents, function (taskEvent) {
 +            return taskEvent.timestamp;
 +          });
 +
 +          console.log(sortedTaskEvents);
 +
 +          var lastTaskTimestamp = sortedTaskEvents.length !== 0
 +            ? _.last(sortedTaskEvents).timestamp
 +            : 0;
 +
 +          var runningTaskEvent = sortedTaskEvents.length === 0 ? undefined : getRunningTaskEvent(task);
 +
 +          return {
 +            instanceId: task.assignedTask.instanceId,
 +            status: _.invert(ScheduleStatus)[task.status],
 +            host: task.assignedTask.slaveHost || '',
 +            latestActivity: lastTaskTimestamp,
 +            duration: isActive || _.isUndefined(runningTaskEvent)
 +              ? 0
 +              : lastTaskTimestamp - runningTaskEvent.timestamp,
 +            isActive: isActive,
 +            taskId: task.assignedTask.taskId,
 +            taskEvents: toTaskEvents(sortedTaskEvents)
 +          };
 +        })
 +        .value();
 +
 +      console.log(tasks);
 +
 +      var activeTaskPredicate = function (task) {
 +        return task.isActive;
 +      };
 +
 +      $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();
 +    }
 +
 +    function isActiveTask(task) {
 +      return _.contains(ACTIVE_STATES, task.status);
 +    }
 +
 +    function getRunningTaskEvent(task) {
 +      return _.find(task.taskEvents, function (taskEvent) {
 +        return taskEvent.status === ScheduleStatus['RUNNING'];
 +      });
 +    }
 +
 +    function fromNow(date, dropSuffix) {
 +      return moment(date).fromNow(dropSuffix);
 +    }
 +
 +    function toTaskEvents(taskEvents) {
 +      return _.map(taskEvents, function (taskEvent) {
 +        return {
 +          date: moment(taskEvent.timestamp).format('MM DD h:mm:ss z'),
 +          status: _.invert(ScheduleStatus)[taskEvent.status],
 +          message: taskEvent.message
 +        };
 +      });
 +    }
 +  }
- );
++);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/8886db12/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
----------------------------------------------------------------------
diff --cc src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
index 37c4222,82758d5..fcde29c
--- 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
@@@ -2,71 -2,64 +2,77 @@@
  
  auroraUI.factory(
    'auroraClient',
-   function () {
-     return {
-       getRoleSummary: function () {
-         var response = this.getSchedulerClient().getRoleSummary();
-         return {
-           error: response.responseCode !== 1,
-           errorMsg: response.message,
-           summaries: response.result !== null ? response.result.roleSummaryResult.summaries
: [],
-           pageTitle: this.getPageTitle(response.serverInfo)
-         }
-       },
+   ['$window',
+     function ($window) {
+       return {
+         getRoleSummary: function () {
+           var response = this.getSchedulerClient().getRoleSummary();
+           var result = this.processResponse(response);
+           result.summaries = response.result !== null
+             ? response.result.roleSummaryResult.summaries : [];
+           return result;
+         },
  
-       getJobSummary: function (role) {
-         var response = this.getSchedulerClient().getJobSummary(role);
-         return {
-           error: response.responseCode !== 1,
-           errorMsg: response.message,
-           jobs: response.result !== null ? response.result.jobSummaryResult.summaries :
[]
-         };
-       },
+         getJobSummary: function (role) {
+           var response = this.getSchedulerClient().getJobSummary(role);
+           var result = this.processResponse(response);
+           result.jobs = response.result !== null ? response.result.jobSummaryResult.summaries
: [];
+           return result;
+         },
  
-       getQuota: function (role) {
-         var response = this.getSchedulerClient().getQuota(role);
-         return {
-           error: response.responseCode !== 1,
-           errorMsg: response.message,
-           quota: response.result !== null ? response.result.getQuotaResult : []
-         }
-       },
+         getQuota: function (role) {
+           var response = this.getSchedulerClient().getQuota(role);
+           var result = this.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.identity = id;
-         taskQuery.environment = environment;
-         taskQuery.jobName = jobName;
-         var response = this.getSchedulerClient().getTasksStatus(taskQuery);
-         return {
-           error: response.responseCode !== 1,
-           errorMsg: response.message,
-           tasks: response.result !== null ? response.result.scheduleStatusResult.tasks :
[]
-         };
-       },
++        getTasks: function (role, environment, jobName) {
++          var id = new Identity();
++          id.role = role;
++          var taskQuery = new TaskQuery();
++          taskQuery.identity = id;
++          taskQuery.environment = environment;
++          taskQuery.jobName = jobName;
++          var response = this.getSchedulerClient().getTasksStatus(taskQuery);
++          var result = this.processResponse(response);
++          result.tasks = response.result !== null ? response.result.scheduleStatusResult.tasks
: [];
++          return result;
++        },
 +
-       // TODO(Suman Karumuri): Make schedulerClient a service
-       schedulerClient: null,
+         // TODO(Suman Karumuri): Make schedulerClient a service
+         schedulerClient: null,
  
-       getSchedulerClient: function () {
-         if (!this.schedulerClient) {
-           var transport = new Thrift.Transport("/api/");
-           var protocol = new Thrift.Protocol(transport);
-           this.schedulerClient = new ReadOnlySchedulerClient(protocol);
-           return this.schedulerClient;
-         } else {
-           return this.schedulerClient;
-         }
-       },
+         getSchedulerClient: function () {
+           if (!this.schedulerClient) {
+             var transport = new Thrift.Transport("/api/");
+             var protocol = new Thrift.Protocol(transport);
+             this.schedulerClient = new ReadOnlySchedulerClient(protocol);
+             return this.schedulerClient;
+           } else {
+             return this.schedulerClient;
+           }
+         },
  
-       getPageTitle: function (info) {
-         var title = "Aurora UI";
-         return _.isNull(info) || info.error || typeof info.clusterName === "undefined"
-           ? title
-           : info.clusterName + " " + title;
-       }
-     };
-   }
- );
+         processResponse: function (response) {
+           this.setPageTitle(response.serverInfo);
+           return {
+             error: response.responseCode !== 1,
+             errorMsg: response.message
+           }
+         },
+ 
+         getPageTitle: function (info) {
+           var title = "Aurora UI";
+           return _.isNull(info) || info.error || typeof info.clusterName === "undefined"
+             ? title
+             : info.clusterName + " " + title;
+         },
+ 
+         // Not the best way to set the page title, but this works on all browsers.
+         setPageTitle: function (serverInfo) {
+           $window.document.title = this.getPageTitle(serverInfo);
+         }
+       };
+     }
+   ]);


Mime
View raw message