You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/08/09 20:09:40 UTC
svn commit: r1371352 - in /incubator/mesos/trunk/src/webui/master/static:
controllers.js dashboard.html framework.html frameworks.html home.html
slaves.html
Author: benh
Date: Thu Aug 9 18:09:39 2012
New Revision: 1371352
URL: http://svn.apache.org/viewvc?rev=1371352&view=rev
Log:
Some webui improvements (contributed by Ben Mahler,
https://reviews.apache.org/r/6472).
Modified:
incubator/mesos/trunk/src/webui/master/static/controllers.js
incubator/mesos/trunk/src/webui/master/static/dashboard.html
incubator/mesos/trunk/src/webui/master/static/framework.html
incubator/mesos/trunk/src/webui/master/static/frameworks.html
incubator/mesos/trunk/src/webui/master/static/home.html
incubator/mesos/trunk/src/webui/master/static/slaves.html
Modified: incubator/mesos/trunk/src/webui/master/static/controllers.js
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/controllers.js?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/controllers.js (original)
+++ incubator/mesos/trunk/src/webui/master/static/controllers.js Thu Aug 9 18:09:39 2012
@@ -1,5 +1,13 @@
'use strict';
+function hasSelectedText () {
+ if (window.getSelection) { // All browsers except IE before version 9.
+ var range = window.getSelection();
+ return range.toString().length > 0;
+ }
+ return false;
+}
+
// Update the outermost scope with the new state.
function update($scope, $defer, data) {
@@ -8,7 +16,6 @@ function update($scope, $defer, data) {
return true; // Continue polling.
}
- $scope.data = data;
$scope.state = $.parseJSON(data);
// Determine if there is a leader (and redirect if not the leader).
@@ -37,6 +44,41 @@ function update($scope, $defer, data) {
}
}
+ // Check for selected text, and allow up to 20 seconds to pass before
+ // potentially wiping the user highlighted text.
+ // TODO(bmahler): This is to avoid the annoying loss of highlighting when
+ // the tables update. Once we can have tighter granularity control on the
+ // angular.js dynamic table updates, we should remove this hack.
+ $scope.time_since_update += $scope.delay;
+
+ if (hasSelectedText() && $scope.time_since_update < 20000) {
+ return true;
+ }
+
+ $scope.data = data;
+
+ // Update the maps.
+ $scope.slaves = {};
+ $scope.frameworks = {};
+ $scope.offers = {};
+ $scope.completed_frameworks = {};
+
+ _.each($scope.state.slaves, function(slave) {
+ $scope.slaves[slave.id] = slave;
+ });
+
+ _.each($scope.state.frameworks, function(framework) {
+ $scope.frameworks[framework.id] = framework;
+ _.each(framework.offers, function(offer) {
+ $scope.offers[offer.id] = offer;
+ });
+ });
+
+ _.each($scope.state.completed_frameworks, function(framework) {
+ $scope.completed_frameworks[framework.id] = framework;
+ });
+
+ // Update the stats.
$scope.total_cpus = 0;
$scope.total_mem = 0;
$scope.used_cpus = 0;
@@ -44,48 +86,31 @@ function update($scope, $defer, data) {
$scope.offered_cpus = 0;
$scope.offered_mem = 0;
- $scope.slaves = {};
-
- _.each($scope.state.slaves, function(slave) {
+ _.each($scope.slaves, function(slave) {
$scope.total_cpus += slave.resources.cpus;
$scope.total_mem += slave.resources.mem;
-
- $scope.slaves[slave.id] = slave;
});
- $scope.frameworks = {};
- $scope.offers = {};
-
- _.each($scope.state.frameworks, function(framework) {
+ _.each($scope.frameworks, function(framework) {
$scope.used_cpus += framework.resources.cpus;
$scope.used_mem += framework.resources.mem;
- _.each(framework.offers, function(offer) {
- $scope.offered_cpus = offer.resources.cpus;
- $scope.offered_mem = offer.resources.mem;
-
- $scope.offers[offer.id] = offer;
- });
-
- $scope.frameworks[framework.id] = framework;
-
+ framework.cpus_share = 0;
if ($scope.total_cpus > 0) {
- $scope.frameworks[framework.id].cpus_share =
- framework.resources.cpus / $scope.total_cpus;
- } else {
- $scope.frameworks[framework.id].cpus_share = 0;
+ framework.cpus_share = framework.resources.cpus / $scope.total_cpus;
}
+ framework.mem_share = 0;
if ($scope.total_mem > 0) {
- $scope.frameworks[framework.id].mem_share =
- framework.resources.mem / $scope.total_mem;
- } else {
- $scope.frameworks[framework.id].mem_share = 0;
+ framework.mem_share = framework.resources.mem / $scope.total_mem;
}
- $scope.frameworks[framework.id].max_share =
- Math.max($scope.frameworks[framework.id].cpus_share,
- $scope.frameworks[framework.id].mem_share);
+ framework.max_share = Math.max(framework.cpus_share, framework.mem_share);
+ });
+
+ _.each($scope.offers, function(offer) {
+ $scope.offered_cpus += offer.resources.cpus;
+ $scope.offered_mem += offer.resources.mem;
});
$scope.used_cpus -= $scope.offered_cpus;
@@ -94,17 +119,13 @@ function update($scope, $defer, data) {
$scope.idle_cpus = $scope.total_cpus - ($scope.offered_cpus + $scope.used_cpus);
$scope.idle_mem = $scope.total_mem - ($scope.offered_mem + $scope.used_mem);
- $scope.completed_frameworks = {};
-
- _.each($scope.state.completed_frameworks, function(framework) {
- $scope.completed_frameworks[framework.id] = framework;
- });
-
+ $scope.time_since_update = 0;
$.event.trigger('state_updated');
return true; // Continue polling.
}
+
// Main controller that can be used to handle "global" events. E.g.,:
// $scope.$on('$afterRouteChange', function() { ...; });
//
@@ -123,6 +144,7 @@ function MainCntl($scope, $http, $route,
$scope.$location = $location;
$scope.delay = 2000;
$scope.retry = 0;
+ $scope.time_since_update = 0;
var poll = function() {
$http.get('master/state.json',
Modified: incubator/mesos/trunk/src/webui/master/static/dashboard.html
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/dashboard.html?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/dashboard.html (original)
+++ incubator/mesos/trunk/src/webui/master/static/dashboard.html Thu Aug 9 18:09:39 2012
@@ -4,6 +4,11 @@
via <strong>shift+click</strong>.
</div>
+<div class="alert">
+ <button class="close" data-dismiss="alert">Ã</button>
+ P.S. This is <strong>FAKE</strong> data.
+</div>
+
<!-- <div class="well" id="graph"></div> -->
<div id="graphs"></div>
Modified: incubator/mesos/trunk/src/webui/master/static/framework.html
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/framework.html?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/framework.html (original)
+++ incubator/mesos/trunk/src/webui/master/static/framework.html Thu Aug 9 18:09:39 2012
@@ -52,11 +52,11 @@
<dt>CPUs:</dt>
<dd>{{framework.resources.cpus}}</dd>
<dt>Mem:</dt>
- <dd>{{framework.resources.mem / 1024}} GB</dd>
+ <dd>{{framework.resources.mem / 1024 | number:2}} GB</dd>
</dl>
</div>
</div>
-
+
<div class="span9">
<h2 id="frameworks">Active Tasks</h2>
<table class="table table-striped table-bordered table-condensed">
Modified: incubator/mesos/trunk/src/webui/master/static/frameworks.html
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/frameworks.html?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/frameworks.html (original)
+++ incubator/mesos/trunk/src/webui/master/static/frameworks.html Thu Aug 9 18:09:39 2012
@@ -35,8 +35,8 @@
<td><a href="{{'#/framework/' + framework.id}}">{{framework.name}}</a></td>
<td>{{framework.tasks.length}}</td>
<td>{{framework.resources.cpus}}</td>
- <td>{{framework.resources.mem / 1024}} GB</td>
- <td>{{framework.max_share * 100}}%</td>
+ <td>{{framework.resources.mem / 1024 | number:2}} GB</td>
+ <td>{{framework.max_share * 100 | number:2}}%</td>
<td>
<a href="" rel="popover" ng-click="popover($event, 'bottom')" data-content="{{framework.registered_time * 1000 | mesosDate}}" data-original-title="Registered">
{{framework.registered_time * 1000 | relativeDate}}
Modified: incubator/mesos/trunk/src/webui/master/static/home.html
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/home.html?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/home.html (original)
+++ incubator/mesos/trunk/src/webui/master/static/home.html Thu Aug 9 18:09:39 2012
@@ -51,22 +51,22 @@
<tr>
<th>Total</th>
<td>{{total_cpus}}</td>
- <td>{{total_mem / 1024}} GB</td>
+ <td>{{total_mem / 1024 | number:2}} GB</td>
</tr>
<tr>
<th>Used</th>
<td>{{used_cpus}}</td>
- <td>{{used_mem / 1024}} GB</td>
+ <td>{{used_mem / 1024 | number:2}} GB</td>
</tr>
<tr>
<th>Offered</th>
<td>{{offered_cpus}}</td>
- <td>{{offered_mem / 1024}} GB</td>
+ <td>{{offered_mem / 1024 | number:2}} GB</td>
</tr>
<tr>
<th>Idle</th>
<td>{{idle_cpus}}</td>
- <td>{{idle_mem / 1024}} GB</td>
+ <td>{{idle_mem / 1024 | number:2}} GB</td>
</tr>
</tbody>
</table>
@@ -103,8 +103,8 @@
<td><a href="{{'#/framework/' + framework.id}}">{{framework.name}}</a></td>
<td>{{framework.tasks.length}}</td>
<td>{{framework.resources.cpus}}</td>
- <td>{{framework.resources.mem / 1024}} GB</td>
- <td>{{framework.max_share * 100}}%</td>
+ <td>{{framework.resources.mem / 1024 | number:2}} GB</td>
+ <td>{{framework.max_share * 100 | number:2}}%</td>
<td>
<a href="" rel="popover" ng-click="popover($event, 'bottom')" data-content="{{framework.registered_time * 1000 | mesosDate}}" data-original-title="Registered">
{{framework.registered_time * 1000 | relativeDate}}
@@ -142,7 +142,7 @@
</td>
<td><a href="#/slave/{{slave.id}}">{{slave.hostname}}</a></td>
<td>{{slave.resources.cpus}}</td>
- <td>{{slave.resources.mem / 1024}} GB</td>
+ <td>{{slave.resources.mem / 1024 | number:2}} GB</td>
<td>
<a href="" rel="popover" ng-click="popover($event, 'bottom')" data-content="{{slave.registered_time * 1000 | mesosDate}}" data-original-title="Registered">
{{slave.registered_time * 1000 | relativeDate}}
@@ -158,7 +158,8 @@
<th>ID</th>
<th>Framework</th>
<th>Host</th>
- <th>Resources</th>
+ <th>CPUs</th>
+ <th>Mem</th>
</tr>
</thead>
<tbody>
@@ -172,7 +173,8 @@
{{slaves[offer.slave_id].hostname}}
</a>
</td>
- <td>{{offer.resources}}</td>
+ <td>{{offer.resources.cpus}}</td>
+ <td>{{offer.resources.mem / 1024 | number:2}} GB</td>
</tr>
</tbody>
</table>
Modified: incubator/mesos/trunk/src/webui/master/static/slaves.html
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/static/slaves.html?rev=1371352&r1=1371351&r2=1371352&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/static/slaves.html (original)
+++ incubator/mesos/trunk/src/webui/master/static/slaves.html Thu Aug 9 18:09:39 2012
@@ -26,7 +26,7 @@
</td>
<td><a href="#/slave/{{slave.id}}">{{slave.hostname}}</a></td>
<td>{{slave.resources.cpus}}</td>
- <td>{{slave.resources.mem / 1024}} GB</td>
+ <td>{{slave.resources.mem / 1024 | number:2}} GB</td>
<td>
<a href="" rel="popover" ng-click="popover($event, 'bottom')" data-content="{{slave.registered_time * 1000 | mesosDate}}" data-original-title="Registered">
{{slave.registered_time * 1000 | relativeDate}}