Ver Fonte

[metastore] Refresh assist after table create

Enrico Berti há 9 anos atrás
pai
commit
e6b3c8f

+ 1 - 1
apps/beeswax/src/beeswax/templates/execute.mako

@@ -2804,7 +2804,7 @@ viewModel.design.fileResources.values.subscribe(function() {
     }
     else if (viewModel.design.results.errors().length == 0) {
       window.setTimeout(function(){
-        window.location.href = "${request.GET['on_success_url']}";
+        window.location.href = successUrl + (successUrl.indexOf("?") > -1 ? "&" : "?") + "refresh=true";
       }, 200);
     }
   });

+ 4 - 0
apps/metastore/src/metastore/templates/metastore.mako

@@ -798,6 +798,10 @@ ${ assist.assistPanel() }
 
       ko.applyBindings(viewModel);
 
+      if (location.getParameter('refresh') === 'true') {
+        huePubSub.publish('assist.refresh');
+      }
+
       // TODO: Use ko for this and the put the queries in the MetastoreTable
       $('a[data-toggle="tab"]').on('shown', function (e) {
         if ($(e.target).attr("href") == "#queries") {

+ 3 - 1
apps/metastore/src/metastore/views.py

@@ -321,15 +321,17 @@ def alter_column(request, database, table):
 @check_has_write_access_permission
 def drop_table(request, database):
   db = dbms.get(request.user)
+  print "drop table"
 
   if request.method == 'POST':
     tables = request.POST.getlist('table_selection')
+    print tables
     tables_objects = [db.get_table(database, table) for table in tables]
     try:
       # Can't be simpler without an important refactoring
       design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
       query_history = db.drop_tables(database, tables_objects, design)
-      url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:show_tables')
+      url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:show_tables', kwargs={'database': database})
       return redirect(url)
     except Exception, ex:
       error_message, log = dbms.expand_exception(ex, db)

+ 6 - 3
desktop/core/src/desktop/static/desktop/js/hue.utils.js

@@ -242,7 +242,7 @@ var huePubSub = (function () {
 
   return {
     subscribe: function (topic, listener) {
-      if(! hOP.call(topics, topic)) {
+      if (!hOP.call(topics, topic)) {
         topics[topic] = [];
       }
 
@@ -255,20 +255,23 @@ var huePubSub = (function () {
       };
     },
     subscribeOnce: function (topic, listener) {
-      var ephemeral = this.subscribe(topic, function(){
+      var ephemeral = this.subscribe(topic, function () {
         listener.apply(arguments);
         ephemeral.remove();
       });
 
     },
     publish: function (topic, info) {
-      if (! hOP.call(topics, topic)) {
+      if (!hOP.call(topics, topic)) {
         return;
       }
 
       topics[topic].forEach(function (item) {
         item(info);
       });
+    },
+    getTopics: function () {
+      return topics;
     }
   };
 })();