瀏覽代碼

HUE-2006 [hbase] UX bug fixes for HBase 0.98

- Need to wait for clusters to be loaded before checking if cluster
  is available.
- Missing icons are now fa-compress and fa-expand.
- Empty query is because routiejs doesn't undertand empty parameters.
- Added new deselectAllVisible method.
- Make columnQuery dynamically filter row columns by updating
  the row view models searchQuery member.
Abraham Elmahrek 11 年之前
父節點
當前提交
fb0a60a617
共有 4 個文件被更改,包括 43 次插入24 次删除
  1. 2 2
      apps/hbase/src/hbase/templates/app.mako
  2. 24 16
      apps/hbase/static/js/app.js
  3. 16 5
      apps/hbase/static/js/controls.js
  4. 1 1
      apps/hbase/static/js/utils.js

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

@@ -82,7 +82,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
           % endif
         </span>
         <span class="smartview-row-controls pull-right">
-          <button class="btn" data-bind="click: $data.toggleSelectedCollapse, enable: $data.selected().length > 0, clickBubble: false" data-toggle="tooltip" title="${_('Toggle Collapse Selected')}"><i data-bind="css: { 'fa': true, 'fa-resize-small': !$data.isCollapsed(), 'fa-resize-full': $data.isCollapsed() }"></i></button>
+          <button class="btn" data-bind="click: $data.toggleSelectedCollapse, enable: $data.selected().length > 0, clickBubble: false" data-toggle="tooltip" title="${_('Toggle Collapse Selected')}"><i data-bind="css: { 'fa': true, 'fa-compress': !$data.isCollapsed(), 'fa-expand': $data.isCollapsed() }"></i></button>
           <button class="btn" data-bind="click: $data.toggleSelectAllVisible, enable: $data.displayedItems().length > 0, clickBubble: false" data-toggle="tooltip" title="${_('Select All Visible')}"><i class="fa fa-check-square-o"></i></button>
           <input type="text" placeholder="${('Filter Column Names/Family')}" data-bind="value: $data.searchQuery, valueUpdate: $data.items().length < 100 ? 'afterkeydown' : 'change', clickBubble: false"/>
           ${sortBtn('$data.sortDropDown')}
@@ -244,7 +244,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
               ${sortBtn('views.tabledata.sortDropDown')}
             </span>
             <span class="smartview-row-controls pull-right" data-bind="if: views.tabledata.items().length > 0 && views.tabledata.selected().length > 0">
-              <button class="btn" data-bind="click: views.tabledata.batchSelectedAlias.bind(null, 'toggleSelectedCollapse'), clickBubble: false" data-toggle="tooltip" title="${_('Toggle Collapse Selected')}"><i class="fa fa-resize-small"></i></button>
+              <button class="btn" data-bind="click: views.tabledata.batchSelectedAlias.bind(null, 'toggleSelectedCollapse'), clickBubble: false" data-toggle="tooltip" title="${_('Toggle Collapse Selected')}"><i class="fa fa-compress"></i></button>
               <button class="btn" data-bind="click: views.tabledata.batchSelectedAlias.bind(null, 'toggleSelectAllVisible'), clickBubble: false" data-toggle="tooltip" title="${_('Select All Visible')}"><i class="fa fa-check-square-o"></i></button>
               % if user.is_superuser:
                 <button class="btn" data-bind="enable: views.tabledata.items()[0].selected().length > 0, click: views.tabledata.items()[0].dropSelected, clickBubble: false"><i class="fa fa-trash-o"></i> ${_('Drop Columns')}</button>

+ 24 - 16
apps/hbase/static/js/app.js

@@ -102,7 +102,10 @@ ko.applyBindings(app);
 
 routed = false;
 routie({
-  ':cluster/:table/query/:query': function(cluster, table, query) {
+    ':cluster/:table/query': function(cluster, table) {
+      routie(cluster + '/' + table);
+    },
+    ':cluster/:table/query/:query': function(cluster, table, query) {
       logGA('query_table');
       $.totalStorage('hbase_cluster', cluster);
       app.station('table');
@@ -127,21 +130,26 @@ routie({
       routed = true;
     },
     ':cluster': function(cluster) {
-      if ($.inArray(cluster, app.clusterNames()) == -1) {
-        routie('');
-      } else {
-        logGA('view_cluster');
-        $.totalStorage('hbase_cluster', cluster);
-        app.station('cluster');
-        app.cluster(cluster);
-        app.pageTitle(cluster);
-        Views.render('clusterview');
-        resetSearch();
-        resetElements();
-        app.views.tabledata.name('');
-        app.views.tables.reload();
-        routed = true;
-      }
+      var redirect = app.clusters.subscribe(function(data) {
+        if ($.inArray(cluster, app.clusterNames()) == -1) {
+          routie('');
+        } else {
+          logGA('view_cluster');
+          $.totalStorage('hbase_cluster', cluster);
+          app.station('cluster');
+          app.cluster(cluster);
+          app.pageTitle(cluster);
+          Views.render('clusterview');
+          resetSearch();
+          resetElements();
+          app.views.tabledata.name('');
+          app.views.tables.reload();
+          routed = true;
+        }
+        redirect.dispose();
+      });
+      resetElements();
+      routed = true;
     },
     'error': function() {
       logGA('error');

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

@@ -175,7 +175,7 @@ var SmartViewModel = function(options) {
 
   self.lastReloadTime = ko.observable(1);
 
-  self.searchQuery.subscribe(function goToRow(value) //make this as nice as the renderfucnction and split into two, also fire not down on keyup events
+  self.searchQuery.subscribe(function(value) //make this as nice as the render function and split into two, also fire not down on keyup events
   {
     if(app.station() != 'table')
       return;
@@ -269,9 +269,14 @@ var SmartViewModel = function(options) {
 
   self.columnQuery = ko.observable("");
   self.columnQuery.subscribe(function(query) {
-    $(self.items()).each(function() {
-      table_search(query);
-    });
+    var dataRowFilter = function(index, data_row) {
+      data_row.searchQuery(query);
+    };
+    if (self.selected().length > 0) {
+      $.each(self.selected(), dataRowFilter);
+    } else {
+      $.each(self.items(), dataRowFilter);
+    }
   });
 
   self.rows = ko.computed(function() {
@@ -518,10 +523,16 @@ var SmartViewDataRow = function(options) {
     return self;
   };
 
+  self.deselectAllVisible = function(){
+    for(t=0; t<self.displayedItems().length; t++)
+      self.displayedItems()[t].isSelected(false);
+    return self;
+  };
+
   self.toggleSelectAllVisible = function() {
     if(self.selected().length != self.displayedItems().length)
       return self.selectAllVisible();
-    return self.deselectAll();
+    return self.deselectAllVisible();
   };
 
   self.push = function(item) {

+ 1 - 1
apps/hbase/static/js/utils.js

@@ -258,7 +258,7 @@ function logGA(postfix) {
 
 function table_search(value) {
   routie(app.cluster() + '/' + app.views.tabledata.name() +'/query/' + value);
-};
+}
 
 function getEditablePosition(contentEditable, trimWhitespaceNodes) {
   var el = contentEditable;