You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ss...@apache.org on 2013/12/23 19:14:29 UTC

[1/2] git commit: Paginated tasks on framework pages.

Updated Branches:
  refs/heads/master 1f27c9670 -> b181accf4


Paginated tasks on framework pages.

Review: http://reviews.apache.org/r/16396


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

Branch: refs/heads/master
Commit: b181accf40d5d322834cc7cd09387e53424ed7fe
Parents: 32e4d72
Author: Ross Allen <ro...@gmail.com>
Authored: Wed Dec 18 14:21:42 2013 -0800
Committer: Ross Allen <ro...@gmail.com>
Committed: Mon Dec 23 10:13:17 2013 -0800

----------------------------------------------------------------------
 src/webui/master/static/framework.html | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b181accf/src/webui/master/static/framework.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/framework.html b/src/webui/master/static/framework.html
index be76763..7dc6205 100644
--- a/src/webui/master/static/framework.html
+++ b/src/webui/master/static/framework.html
@@ -86,7 +86,7 @@
         </tr>
       </thead>
       <tbody>
-        <tr ng-repeat="task in framework.tasks | orderBy:tables['active_tasks'].selected_column:tables['active_tasks'].reverse">
+        <tr ng-repeat="task in framework.tasks | orderBy:tables['active_tasks'].selected_column:tables['active_tasks'].reverse | slice:((tables.active_tasks.page - 1) * itemsPerPage):(tables.active_tasks.page * itemsPerPage)">
           <td>
             <a href="#/slaves/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}">
               {{task.id}}
@@ -124,6 +124,11 @@
         </tr>
       </tbody>
     </table>
+    <pagination
+      data-ng-if="active_tasks.length > itemsPerPage"
+      max-size="5"
+      page="tables.active_tasks.page"
+      total-items="active_tasks.length"></pagination>
 
     <h3 id="frameworks">Completed Tasks</h3>
     <table class="table table-striped table-bordered table-condensed">
@@ -158,7 +163,7 @@
         </tr>
       </thead>
       <tbody>
-        <tr ng-repeat="task in framework.completed_tasks | orderBy:tables['completed_tasks'].selected_column:tables['completed_tasks'].reverse">
+        <tr ng-repeat="task in framework.completed_tasks | orderBy:tables.completed_tasks.selected_column:tables.completed_tasks.reverse | slice:((tables.completed_tasks.page - 1) * itemsPerPage):(tables.completed_tasks.page * itemsPerPage)">
           <td>{{task.id}}</td>
           <td>{{task.name}}</td>
           <td>{{task.state | truncateMesosState}}</td>
@@ -204,5 +209,11 @@
         </tr>
       </tbody>
     </table>
+    <pagination
+      data-ng-if="completed_tasks.length > itemsPerPage"
+      max-size="5"
+      page="tables.completed_tasks.page"
+      total-items="completed_tasks.length"></pagination>
+
   </div>
 </div>


[2/2] git commit: Moved control of navbar tabs to MainController

Posted by ss...@apache.org.
Moved control of navbar tabs to MainController

This removes another dependency on jQuery and lets the MainController
control its tabs. `setNavbarActiveTab` was a global function that was
accessing the global DOM, which meant the controllers were editing
things they didn't control.

The MainController now sets the tab based on the path.

We are almost to zero jQuery...

Review: http://reviews.apache.org/r/16395


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

Branch: refs/heads/master
Commit: 32e4d7249b6f018e83933b8e808ff4b4f87dfc0c
Parents: 1f27c96
Author: Ross Allen <ro...@gmail.com>
Authored: Wed Dec 18 10:51:57 2013 -0800
Committer: Ross Allen <ro...@gmail.com>
Committed: Mon Dec 23 10:13:17 2013 -0800

----------------------------------------------------------------------
 src/webui/master/static/index.html        | 12 +++--
 src/webui/master/static/js/controllers.js | 64 +++++++++++++++-----------
 2 files changed, 46 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/32e4d724/src/webui/master/static/index.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/index.html b/src/webui/master/static/index.html
index 1ac7c9d..a5833f6 100644
--- a/src/webui/master/static/index.html
+++ b/src/webui/master/static/index.html
@@ -32,9 +32,15 @@
             <a class="brand" href="#/">Mesos</a>
             <div class="nav-collapse" data-collapse="!navbarExpanded">
               <ul class="nav">
-                <li data-tabname="frameworks"><a href="#/frameworks">Frameworks</a></li>
-                <li data-tabname="slaves"><a href="#/slaves">Slaves</a></li>
-                <li data-tabname="offers"><a href="#/offers">Offers</a></li>
+                <li data-ng-class="{active: (navbarActiveTab === 'frameworks')}">
+                  <a href="#/frameworks">Frameworks</a>
+                </li>
+                <li data-ng-class="{active: (navbarActiveTab === 'slaves')}">
+                  <a href="#/slaves">Slaves</a>
+                </li>
+                <li data-ng-class="{active: (navbarActiveTab === 'offers')}">
+                  <a href="#/offers">Offers</a>
+                </li>
               </ul>
               <ul class="nav pull-right">
                 <li>

http://git-wip-us.apache.org/repos/asf/mesos/blob/32e4d724/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js
index c7042ca..1ba84f1 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -14,12 +14,6 @@
   }
 
 
-  function setNavbarActiveTab(tab_name) {
-    $('#navbar li').removeClass('active');
-    $('#navbar li[data-tabname='+tab_name+']').addClass('active');
-  }
-
-
   function hasSelectedText() {
     if (window.getSelection) {  // All browsers except IE before version 9.
       var range = window.getSelection();
@@ -266,8 +260,9 @@
   // In addition, the MainCntl encapsulates the "view", allowing the
   // active controller/view to easily access anything in scope (e.g.,
   // the state).
-  mesosApp.controller('MainCntl',
-      function($scope, $http, $route, $routeParams, $location, $timeout, $modal, paginationConfig) {
+  mesosApp.controller('MainCntl', [
+      '$scope', '$http', '$location', '$timeout', '$modal', 'paginationConfig',
+      function($scope, $http, $location, $timeout, $modal, paginationConfig) {
     $scope.doneLoading = true;
 
     // Adding bindings into scope so that they can be used from within
@@ -298,6 +293,39 @@
     // slices of collections for pagination in views.
     $scope.itemsPerPage = paginationConfig.itemsPerPage;
 
+    // Ordered Array of path => activeTab mappings. On successful route changes,
+    // the `pathRegexp` values are matched against the current route. The first
+    // match will be used to set the active navbar tab.
+    var NAVBAR_PATHS = [
+      {
+        pathRegexp: /^\/slaves/,
+        tab: 'slaves'
+      },
+      {
+        pathRegexp: /^\/frameworks/,
+        tab: 'frameworks'
+      },
+      {
+        pathRegexp: /^\/offers/,
+        tab: 'offers'
+      }
+    ];
+
+    // Set the active tab on route changes according to NAVBAR_PATHS.
+    $scope.$on('$routeChangeSuccess', function(event, current) {
+      var path = current.$$route.originalPath;
+
+      // Use _.some so the loop can exit on the first `pathRegexp` match.
+      var matched = _.some(NAVBAR_PATHS, function(nav) {
+        if (path.match(nav.pathRegexp)) {
+          $scope.navbarActiveTab = nav.tab;
+          return true;
+        }
+      });
+
+      if (!matched) $scope.navbarActiveTab = null;
+    });
+
     var poll = function() {
       $http.get('master/state.json',
                 {transformResponse: function(data) { return data; }})
@@ -358,12 +386,10 @@
     };
 
     poll();
-  });
+  }]);
 
 
   mesosApp.controller('HomeCtrl', function($dialog, $scope) {
-    setNavbarActiveTab('home');
-
     $scope.tables = {
       active_tasks: new Table('start_time'),
       completed_tasks: new Table('finish_time')
@@ -389,8 +415,6 @@
 
 
   mesosApp.controller('FrameworksCtrl', function($scope) {
-    setNavbarActiveTab('frameworks');
-
     $scope.tables = {};
     $scope.tables['frameworks'] = new Table('id');
     $scope.tables['completed_frameworks'] = new Table('id');
@@ -401,8 +425,6 @@
 
 
   mesosApp.controller('OffersCtrl', function($scope) {
-    setNavbarActiveTab('offers');
-
     $scope.tables = {};
     $scope.tables['offers'] = new Table('id');
 
@@ -411,8 +433,6 @@
   });
 
   mesosApp.controller('FrameworkCtrl', function($scope, $routeParams) {
-    setNavbarActiveTab('frameworks');
-
     $scope.tables = {};
     $scope.tables['active_tasks'] = new Table('id');
     $scope.tables['completed_tasks'] = new Table('id');
@@ -447,8 +467,6 @@
 
 
   mesosApp.controller('SlavesCtrl', function($scope) {
-    setNavbarActiveTab('slaves');
-
     $scope.tables = {};
     $scope.tables['slaves'] = new Table('id');
 
@@ -458,8 +476,6 @@
 
 
   mesosApp.controller('SlaveCtrl', function($dialog, $scope, $routeParams, $http, $q) {
-    setNavbarActiveTab('slaves');
-
     $scope.slave_id = $routeParams.slave_id;
 
     $scope.tables = {};
@@ -557,8 +573,6 @@
 
 
   mesosApp.controller('SlaveFrameworkCtrl', function($scope, $routeParams, $http, $q) {
-    setNavbarActiveTab('slaves');
-
     $scope.slave_id = $routeParams.slave_id;
     $scope.framework_id = $routeParams.framework_id;
 
@@ -661,8 +675,6 @@
 
 
   mesosApp.controller('SlaveExecutorCtrl', function($scope, $routeParams, $http, $q) {
-    setNavbarActiveTab('slaves');
-
     $scope.slave_id = $routeParams.slave_id;
     $scope.framework_id = $routeParams.framework_id;
     $scope.executor_id = $routeParams.executor_id;
@@ -871,8 +883,6 @@
 
 
   mesosApp.controller('BrowseCtrl', function($scope, $routeParams, $http) {
-    setNavbarActiveTab('slaves');
-
     var update = function() {
       if ($routeParams.slave_id in $scope.slaves && $routeParams.path) {
         $scope.slave_id = $routeParams.slave_id;