Explorar o código

HUE-2142 [editor] Convert saving result to a table in Hue 4

Romain Rigaux %!s(int64=8) %!d(string=hai) anos
pai
achega
d035c29

+ 1 - 1
desktop/core/src/desktop/templates/common_notebook_ko_components.mako

@@ -215,7 +215,7 @@ except ImportError, e:
         <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
         <h2 class="modal-title">${_('Save query result in a')}</h2>
       </div>
-      <div class="modal-body" style="padding: 4px">
+      <div class="modal-body" style="padding-left: 30px">
         <form id="saveResultsForm" method="POST" class="form form-inline">
           ${ csrf_token(request) | n,unicode }
           <fieldset>

+ 1 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -102,7 +102,7 @@ ${ hueIcons.symbols() }
           <span class="hamburger-box"><span class="hamburger-inner"></span></span>
         </a>
 
-        <a class="brand" data-bind="click: function () { page('/home') }" href="javascript: void(0);" title="${_('Homepage')}">
+        <a class="brand" data-bind="click: function () { page('/home') }" href="javascript: void(0);" title="${_('Documents')}">
           <svg style="height: 24px; width: 120px;"><use xlink:href="#hue-logo"></use></svg>
         </a>
 

+ 2 - 2
desktop/core/src/desktop/templates/ko_components.mako

@@ -331,7 +331,7 @@ from desktop.views import _ko
                     if (notebook.onSuccessUrl() == 'assist.db.refresh') { // TODO: Similar if in in FB directory, also refresh FB dir
                       huePubSub.publish('assist.db.refresh', { sourceType: 'hive' });
                     } else {
-                      huePubSub.publish('open.link', notebook.onSuccessUrl()); // TODO support FB
+                      huePubSub.publish('page.route', notebook.onSuccessUrl());
                     }
                   }
                 } else { // Perform last DROP statement execute
@@ -345,7 +345,7 @@ from desktop.views import _ko
             notebook.history.unshift(
                 notebook._makeHistoryRecord(
                     notebook.onSuccessUrl(),
-                    notebook.snippets()[0].result.handle().statement || '',
+                    notebook.description(),
                     notebook.snippets()[0].lastExecuted(),
                     notebook.snippets()[0].status(),
                     notebook.name(),

+ 19 - 4
desktop/libs/notebook/src/notebook/api.py

@@ -637,15 +637,30 @@ def export_result(request):
     response['watch_url'] = api.export_data_as_hdfs_file(snippet, destination, overwrite)
     response['status'] = 0
   elif data_format == 'hive-table':
-    notebook_id = notebook['id'] or request.GET.get('editor', request.GET.get('notebook'))
-    response['watch_url'] = reverse('notebook:execute_and_watch') + '?action=save_as_table&notebook=' + str(notebook_id) + '&snippet=0&destination=' + destination
-    response['status'] = 0
+    if is_embedded:
+      sql, success_url = api.export_data_as_table(notebook, snippet, destination)
+
+      task = make_notebook(
+        name=_('Export %s query to table %s') % (snippet['type'], destination),
+        description=_('Query %s to %s') % (_get_snippet_name(notebook), success_url),
+        editor_type=snippet['type'],
+        statement=sql,
+        status='ready-execute',
+        database=snippet['database'],
+        on_success_url=success_url,
+        is_task=True
+      )
+      response = task.execute(request)
+    else:
+      notebook_id = notebook['id'] or request.GET.get('editor', request.GET.get('notebook'))
+      response['watch_url'] = reverse('notebook:execute_and_watch') + '?action=save_as_table&notebook=' + str(notebook_id) + '&snippet=0&destination=' + destination
+      response['status'] = 0
   elif data_format == 'hdfs-directory':
     if is_embedded:
       sql, success_url = api.export_large_data_to_hdfs(notebook, snippet, destination)
 
       task = make_notebook(
-        name=_('Export %s to directory') % snippet['type'],
+        name=_('Export %s query to directory') % snippet['type'],
         description=_('Query %s to %s') % (_get_snippet_name(notebook), success_url),
         editor_type=snippet['type'],
         statement=sql,

+ 1 - 1
desktop/libs/notebook/src/notebook/views.py

@@ -159,7 +159,7 @@ def browse(request, database, table, partition_spec=None):
         'editor_type': editor_type,
     })
 
-
+# Deprecated from Hue 4
 @check_document_access_permission()
 def execute_and_watch(request):
   notebook_id = request.GET.get('editor', request.GET.get('notebook'))