Преглед изворни кода

HUE-1430 [hbase] Disable and drop options

Kevin Wang пре 12 година
родитељ
комит
bee992946d

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

@@ -148,7 +148,7 @@ ${ commonheader(None, "hbase", user) | n,unicode }
               <i class="icon-check-empty"></i> ${_('Disable')}
             </button>
           </span>
-          <button class="btn" data-bind="enable: views.tables.canDrop, click: views.tables.dropSelected"><i class="icon-trash"></i> ${_('Drop')}</button>
+          <button class="btn" data-bind="enable: views.tables.selected().length > 0, click: views.tables.dropSelected"><i class="icon-trash"></i> ${_('Drop')}</button>
         % endif
         <span class="pull-right">
           <a href="#new_table_modal" role="button" data-bind="click: function(){app.focusModel(app.views.tables);}" class="btn" data-toggle="modal"><i class='icon-plus-sign'></i> ${_('New Table')}</a>

+ 15 - 4
apps/hbase/static/js/base.js

@@ -68,10 +68,13 @@ var ListViewModel = function(options) {
           self.isLoading(false);
         }
       };
-      if(call != null && 'complete' in call)
+      if(call === true) {
+        callback();
+      } else if (call != null && 'complete' in call) {
         call.complete(callback);
-      else
+      } else {
         self.isLoading(false);
+      }
     }
   };
   self.batchSelectedAlias = function(actionAlias) {
@@ -92,9 +95,17 @@ var ListViewModel = function(options) {
     });
   };
   self.dropSelected = function() {
-    confirm("Confirm Delete", "Are you sure you want to delete the selected items? (WARNING: This cannot be undone!)", function() {
+    confirm("Confirm Delete", "Are you sure you want to drop the selected items? (WARNING: This cannot be undone!)", function() {
       self.batchSelected(function() {
-        return this.drop(true);
+        var s = this;
+        if(s.enabled()) {
+          self.isLoading(true);
+          return s.disable(function() {
+            s.drop(true);
+          });
+        } else {
+          return s.drop(true);
+        }
       });
     });
   };

+ 2 - 1
apps/hbase/static/js/controls.js

@@ -507,9 +507,10 @@ var TableDataRow = function(options) {
       self.enabled(true);
     });
   };
-  self.disable = function(el) {
+  self.disable = function(callback) {
     return API.queryCluster('disableTable',self.name).complete(function() {
       self.enabled(false);
+      if($.isFunction(callback)) callback();
     });
   };
   self.drop = function(el) {