incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaven...@apache.org
Subject [7/8] git commit: fixed BLUR-368, improving the query list page
Date Tue, 09 Sep 2014 16:15:56 GMT
fixed BLUR-368, improving the query list page


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

Branch: refs/heads/master
Commit: 12e98789fa570d7ac12a60a8e93ccad8744c8900
Parents: 77a4f84
Author: Andrew Avenoso <andrew.va@gmail.com>
Authored: Tue Sep 9 12:12:44 2014 -0400
Committer: Andrew Avenoso <andrew.va@gmail.com>
Committed: Tue Sep 9 12:12:44 2014 -0400

----------------------------------------------------------------------
 .../org/apache/blur/console/util/QueryUtil.java |  8 ++++-
 .../src/main/webapp/js/blurconsole.b_utils.js   | 18 ++++++++++--
 .../src/main/webapp/js/blurconsole.fake.js      |  9 +++---
 .../src/main/webapp/js/blurconsole.model.js     | 31 ++++++++++++++++++--
 .../src/main/webapp/js/blurconsole.queries.js   | 16 +++++-----
 blur-console/src/main/webapp/public/index.html  |  2 +-
 ...rconsole.79e31ef1502d0a9a2b09a9f003068074.js | 27 -----------------
 ...rconsole.902358aa4c1d857be313b8095f5c215e.js | 27 +++++++++++++++++
 .../src/main/webapp/public/js/blurconsole.js    |  8 ++---
 ...sole.js.048af85f6ba8bfea2f94f056e1095f81.map |  1 -
 ...sole.js.b8dc3b9d945b90e6deed04b287315787.map |  1 +
 .../main/webapp/public/js/blurconsole.js.map    |  2 +-
 12 files changed, 99 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java b/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
index 9eae4b5..7799ff3 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
@@ -20,6 +20,7 @@ package org.apache.blur.console.util;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.BlurQueryStatus;
 import org.apache.blur.thrift.generated.Status;
+import org.apache.blur.thrift.generated.User;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -60,7 +61,12 @@ public class QueryUtil {
         if (Status.FOUND.equals(status.getStatus())) {
           Map<String, Object> info = new HashMap<String, Object>();
           info.put("uuid", id);
-          info.put("user", status.getQuery().getUserContext());
+          User user = status.getUser();
+          if(user != null && user.getUsername() != null) {
+            info.put("user", user.getUsername());
+          } else {
+            info.put("user", status.getQuery().getUserContext());
+          }
           info.put("query", status.getQuery().getQuery().getQuery());
           info.put("table", table);
           info.put("state", status.getState().getValue());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/webapp/js/blurconsole.b_utils.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.b_utils.js b/blur-console/src/main/webapp/js/blurconsole.b_utils.js
index 2cd2c0e..3f6804f 100644
--- a/blur-console/src/main/webapp/js/blurconsole.b_utils.js
+++ b/blur-console/src/main/webapp/js/blurconsole.b_utils.js
@@ -24,7 +24,17 @@ blurconsole.browserUtils = (function(){
   function table(def, data) {
     var tableMarkup;
 
-    tableMarkup = '<table class="table table-bordered table-condensed table-hover table-striped"><thead><tr>';
+    tableMarkup = '<table class="table table-bordered table-condensed table-hover table-striped">';
+
+    // Add ColGroup
+    if(def && def.length  > 0 && def[0].width) {
+      tableMarkup += '<colgroup>';
+      $.each(def, function(idx, colDef) {
+        tableMarkup += '<col width="' + colDef.width + '"/>';
+      });
+      tableMarkup += '</colgroup>';
+    }
+    tableMarkup += '<thead><tr>';
 
     // Add headers
     $.each(def, function(idx, colDef){
@@ -38,7 +48,11 @@ blurconsole.browserUtils = (function(){
       $.each(data, function(ir, row){
         tableMarkup += '<tr>';
         $.each(def, function(ic, col) {
-          tableMarkup += '<td>';
+          if(col.style) {
+            tableMarkup += '<td style="'+col.style+'">';
+          } else {
+            tableMarkup += '<td>';
+          }
           var val;
           if ($.isFunction(col.key)) {
             val = col.key(row);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/webapp/js/blurconsole.fake.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.fake.js b/blur-console/src/main/webapp/js/blurconsole.fake.js
index f591ec3..f5c71d8 100644
--- a/blur-console/src/main/webapp/js/blurconsole.fake.js
+++ b/blur-console/src/main/webapp/js/blurconsole.fake.js
@@ -38,11 +38,12 @@ blurconsole.fake = (function() {
     return _randomNumber(2) % 2 === 0;
   }
 
-  function _randomString() {
+  function _randomString(maxLength) {
+    maxLength = typeof maxLength !== 'undefined' ? maxLength : 30;
     var text = '';
-    var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+    var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ';
 
-    for( var i=0; i < Math.floor(Math.random() * 30 + 1); i++ ) {
+    for( var i=0; i < Math.floor(Math.random() * maxLength + 1); i++ ) {
       text += possible.charAt(Math.floor(Math.random() * possible.length));
     }
 
@@ -157,7 +158,7 @@ blurconsole.fake = (function() {
         randomQueries.push({
           uuid: _randomString(),
           user: 'user_' + _randomNumber(10, true),
-          query: _randomString(),
+          query: _randomString(500),
           table: 'testtable' + _randomNumber(5, true),
           state: _randomNumber(3, true),
           percent: _randomNumber(100, true),

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.model.js b/blur-console/src/main/webapp/js/blurconsole.model.js
index c4377e5..336cf5f 100644
--- a/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -385,7 +385,7 @@ blurconsole.model = (function() {
         if (sortDir === 'asc') {
           return a[sortField] > b[sortField];
         } else {
-          return b[sortField] > b[sortField];
+          return b[sortField] > a[sortField];
         }
       });
 
@@ -565,7 +565,34 @@ blurconsole.model = (function() {
 
   function _updateQueries(queries) {
     if (queries !== 'error' && !blurconsole.utils.equals(queries, stateMap.queries))
{
-      stateMap.queries = queries;
+      stateMap.queries.slowQueries = queries.slowQueries;
+      // age current queries
+      if(stateMap.queries.queries) {
+        $.each(stateMap.queries.queries, function(idx, query) {
+          query.age = (query.age || 0) + 1;
+        });
+      } else {
+        stateMap.queries.queries = [];
+      }
+      // update queries
+      $.each(queries.queries, function(idx, new_query){
+        var found = false;
+        $.each(stateMap.queries.queries, function(idx, old_query){
+          if(old_query.uuid === new_query.uuid) {
+            found = true;
+            old_query.age = 0;
+            old_query.state = new_query.state;
+            old_query.percent = new_query.percent;
+          }
+        });
+        if(!found) {
+          stateMap.queries.queries.push(new_query);
+        }
+      });
+      // remove old queries
+      stateMap.queries.queries = $.grep(stateMap.queries.queries, function(query){
+        return typeof query.age === 'undefined' || query.age < 5;
+      });
       $.gevent.publish('queries-updated');
     }
     setTimeout(_queryPoller, blurconsole.config.refreshtime);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/webapp/js/blurconsole.queries.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.queries.js b/blur-console/src/main/webapp/js/blurconsole.queries.js
index 7eeff87..e847b67 100644
--- a/blur-console/src/main/webapp/js/blurconsole.queries.js
+++ b/blur-console/src/main/webapp/js/blurconsole.queries.js
@@ -26,20 +26,20 @@ blurconsole.queries = (function() {
     view: 'views/queries.tpl.html',
     states: ['Running', 'Interrupted', 'Complete', 'Back Pressure Interrupted'],
     queryDef: [
-      { label: 'User', key: 'user' },
-      { label: 'Query', key: 'query' },
-      { label: 'Time Started', key: function(row) {
+      { label: 'User', key: 'user', width: '0%', style: 'white-space:nowrap' },
+      { label: 'Query', key: 'query', style: 'text-overflow:ellipsis; overflow: hidden; max-width:1px;',
width: '100%' },
+      { label: 'Time Started', width: '0%', style: 'white-space:nowrap', key: function(row)
{
         var start = new Date(row.startTime);
-        return start.toTimeString(); //start.getHours() + ':' + start.getMinutes() + ':'
+ start.getSeconds();
+        return start.toLocaleTimeString(); //start.getHours() + ':' + start.getMinutes()
+ ':' + start.getSeconds();
       } },
-      { label: 'State', key: function(row) {
+      { label: 'State', width: '0%', style: 'white-space:nowrap', key: function(row) {
         var stateInfo = configMap.states[row.state];
-        if(row.state === 0) {
-          stateInfo += ' <div class="badge badge-info">' + row.percent + '%</div>';
+        if(row.state === 0 && row.percent) {
+          stateInfo += ' <div class="badge badge-info">' + Math.round(row.percent)
+ '%</div>';
         }
         return stateInfo;
       } },
-      { label: 'Actions', key: function(row) {
+      { label: 'Actions', width: '0%', style: 'white-space:nowrap', key: function(row) {
         var actions = '';
         if(row.state === 0 && blurconsole.auth.hasRole('manager')) {
           actions += '<a href="#" class="cancelTrigger btn btn-danger" data-uuid="' +
row.uuid + '" data-query="' + row.query + '" data-table="' + row.table + '"><i class="glyphicon
glyphicon-ban-circle"></i> Cancel</a> ';

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/12e98789/blur-console/src/main/webapp/public/index.html
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/public/index.html b/blur-console/src/main/webapp/public/index.html
index e4276a1..6c304f3 100644
--- a/blur-console/src/main/webapp/public/index.html
+++ b/blur-console/src/main/webapp/public/index.html
@@ -64,7 +64,7 @@ under the License.
       </ul>
     </nav>
     <div id="blurconsole"></div>
-    <script src="js/blurconsole.79e31ef1502d0a9a2b09a9f003068074.js"></script>
+    <script src="js/blurconsole.902358aa4c1d857be313b8095f5c215e.js"></script>
     <script src="/service/config.js"></script>
     <script type="text/javascript">
       $(function () { blurconsole.initModule( $('#blurconsole') ); });


Mime
View raw message