Explorar o código

HUE-1393 [hbase] Routing to tableview does not clear query

Kevin Wang %!s(int64=12) %!d(string=hai) anos
pai
achega
bc36d4d5cf

+ 2 - 5
apps/hbase/src/hbase/templates/app.mako

@@ -120,7 +120,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
   <!-- Page Header -->
   <h1>
     <a href="/hbase/">HBase Browser</a> - <a data-bind="text: app.cluster(), attr: { href: '#' + app.cluster() }"></a>
-    <span data-bind="visible: app.station() == 'table'">/ <a data-bind="text: app.views.tabledata.name()"></a></span>
+    <span data-bind="visible: app.station() == 'table'">/ <a data-bind="text: app.views.tabledata.name(), attr: { href: '#' + app.cluster() + '/' + app.views.tabledata.name()}"></a></span>
     <span class="pull-right">
       <span class="dropdown">
         <a class="dropdown-toggle btn" id="dLabel" data-toggle="dropdown">
@@ -134,9 +134,6 @@ ${ commonheader(None, "hbase", user) | n,unicode }
     </span>
   </h1>
 
-  <!-- breadcrumbs -->
-  <ul id="hbase-breadcrumbs" class="nav nav-pills hueBreadcrumbBar" data-bind="visible: false"></ul>
-
   <!-- Application Pages -->
   <div id="main"></div>
 
@@ -199,6 +196,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
           <div id="searchbar-main" class="span5" data-bind="click: search.clickTagBar">
             <div id="search-tags" contenteditable="true" data-bind="editableText: search.cur_input, hasfocus: search.focused, css: { 'active': search.cur_input() != '' }, event: { 'keydown': search.onKeyDown, click: search.updateMenu.bind(null) }" data-placeholder="${_('row_key, row_key_prefix* + scan_length, row_key [family:col1, family2:col2, family3:]')}">
             </div>
+            <a class="search-remove" data-bind="visible: search.cur_input() != '', click: function(){ app.search.cur_input(''); }"><i class="icon-remove-sign"></i></a>
           </div>
           <ul id="search-typeahead" data-bind="visible: search.focused() && !search.submitted()">
             <!-- ko if: search.mode() != 'idle' -->
@@ -209,7 +207,6 @@ ${ commonheader(None, "hbase", user) | n,unicode }
             <!-- /ko -->
           </ul>
           <button class="btn btn-primary add-on" data-bind="enabled: !search.submitted(), click: search.evaluate.bind(null)"><i class="icon-search"></i></button>
-          <a class="search-remove" data-bind="click: function(){ app.search.cur_input(''); }"><i class="icon-remove-sign"></i></a>
           <span id="column-family-selectors">
             <!-- ko foreach: views.tabledata.columnFamilies() -->
               <span class="label" data-bind="text: $data.name, style: {'backgroundColor': ($data.enabled()) ? stringHashColor($data.name.split(':')[0]) : '#ccc' ,'cursor':'pointer'}, click: $data.toggle"></span>

+ 3 - 3
apps/hbase/static/css/hbase.css

@@ -565,9 +565,9 @@ textarea {
 
 .search-remove
 {
-	position: relative;
-	left: -65px;
-	top: 2px;
+	position: absolute;
+	right: 10px;
+	top: 5px;
 	text-decoration: none;
 	cursor: pointer;
 	color: #ccc;

+ 10 - 9
apps/hbase/static/js/app.js

@@ -41,7 +41,7 @@ var AppViewModel = function() {
           callback();
       });
     }}),
-    tabledata: new SmartViewModel({el: 'views.tabledata', reload: function(callback) //move inside SmartViewModel class? 
+    tabledata: new SmartViewModel({el: 'views.tabledata', reload: function(callback) //move inside SmartViewModel class?
     {
       var t_self = this;
       function getColumnFamilies() {
@@ -96,23 +96,24 @@ routed = false;
 routie({
   ':cluster/:table/query/:query': function(cluster, table, query) {
       logGA('query_table');
+      app.station('table');
       Router.setTable(cluster, table);
       Views.render('dataview');
-      app.station('table');
       app.search.cur_input(query);
       app.search.evaluate();
+      app.views.tabledata.searchQuery(query);
       routed = true;
     },
     ':cluster/:table': function(cluster, table) {
-      //logGA('view_table'); taken care of in reload()
+      //logGA('view_table'); taken care of in reload()\
       Router.setTable(cluster, table);
+      resetSearch();
       app.station('table');
       Views.render('dataview');
       routed = true;
     },
     ':cluster': function(cluster) {
       logGA('view_cluster');
-      Breadcrumbs.render();
       app.station('cluster');
       app.cluster(cluster);
       app.pageTitle(cluster);
@@ -126,15 +127,15 @@ routie({
       routed = true;
     },
     '': function(){
-    var redirect = app.clusters.subscribe(function(data) {
-      routie(data[0].name);
-      redirect.dispose();
-    });
+      var redirect = app.clusters.subscribe(function(data) {
+        routie(data[0].name);
+        redirect.dispose();
+      });
+      resetElements();
       routed = true;
     },
     '*': function() {
       logGA();
-      resetElements();
       if(!routed)
         history.back();
       routed = false;

+ 9 - 5
apps/hbase/static/js/controls.js

@@ -156,16 +156,21 @@ var SmartViewModel = function(options) {
   self.columnFamilies = ko.observableArray();
   self.name = ko.observable(options.name);
   self.name.subscribe(function(){
-    self.querySet.removeAll();
     self._reloadcfs();
+    if(app.station() == 'table')
+      return;
+    self.querySet.removeAll();
     self.evaluateQuery();
   }); //fix and decouple
 
   self.lastReloadTime = ko.observable(1);
-  //self.columnFamilies.subscribe(function(){self.reload();});
 
   self.searchQuery.subscribe(function goToRow(value) //make this as nice as the renderfucnction and split into two, also fire not down on keyup events
   {
+    if(app.station() != 'table')
+      return;
+    if(value.replace(/\s/g, "") == '' || value == null)
+      routie(app.cluster() + '/' + app.views.tabledata.name());
     var inputs = value.match(searchRenderers['rowkey']['select']);
     self.querySet.removeAll();
     if(inputs) {
@@ -186,7 +191,6 @@ var SmartViewModel = function(options) {
         }
       }
     }
-    routie(app.cluster() + '/' + app.views.tabledata.name() +'/query/' + value);
     self.evaluateQuery();
   });
 
@@ -204,7 +208,7 @@ var SmartViewModel = function(options) {
   self.columnQuery = ko.observable("");
   self.columnQuery.subscribe(function(query) {
     $(self.items()).each(function() {
-      this.searchQuery(query);
+      table_search(query);
     });
   });
 
@@ -726,7 +730,7 @@ var tagsearch = function() {
   };
 
   self.evaluate = function() {
-    app.views.tabledata.searchQuery(self.cur_input());
+    table_search(self.cur_input());
     self.submitted(true);
     self.mode('idle');
   };

+ 0 - 28
apps/hbase/static/js/nav.js

@@ -27,35 +27,7 @@ var Router = {
     app.focusModel(app.views.tabledata);
   },
   setCluster: function(cluster) {
-    Router.set();
     app.cluster(cluster);
-  },
-  set: function() {
-      Breadcrumbs.render();
-  }
-}
-
-var Breadcrumbs = {
-  _selector_root:'#hbase-breadcrumbs',
-  //renders breadcrumbs automaticall
-  render:function(mutators) {
-    root = $(Breadcrumbs._selector_root).html('');
-    crumbs = ['/hbase'].concat(document.URL.split('/').splice(4));
-    biglink = "";
-    for(i=0;i<crumbs.length;i++) {
-      biglink += crumbs[i] + '/'
-      function clean_url(url) {
-        replacers = {'/': '', '#': '', '_': ' ', '^[a-z]': function(a) { return a.toUpperCase(); }};
-        keys = Object.keys(replacers);
-        for(q=0;q<keys.length;q++) {
-          url = url.replace(new RegExp(keys[q],'g'), replacers[keys[q]]);
-        }
-        return url;
-      }
-      if(crumbs[i]!="")
-        root.append('<li><a href="' + biglink + '">' + clean_url(crumbs[i]) + '</a></li><li><a href="' + biglink + '">/</a></li>');
-    }
-    return root.find('li:last-child').remove();
   }
 }
 

+ 8 - 0
apps/hbase/static/js/utils.js

@@ -188,6 +188,10 @@ function resetElements() {
       }
     });
   });
+  resetSearch();
+};
+
+function resetSearch() {
   app.views.tabledata.searchQuery('');
   app.search.cur_input('');
 };
@@ -207,6 +211,10 @@ function logGA(postfix) {
   }
 };
 
+function table_search(value) {
+  routie(app.cluster() + '/' + app.views.tabledata.name() +'/query/' + value);
+};
+
 function getEditablePosition(contentEditable, trimWhitespaceNodes) {
   var el = contentEditable;
   if(window.getSelection().getRangeAt(0).startContainer == el) //raw reference for FF fix