Browse Source

HUE-1176 [fb] Submit and monitor HDFS archive extraction and offer to open destination

Romain Rigaux 9 years ago
parent
commit
bc36557

+ 3 - 1
desktop/core/src/desktop/lib/tasks/extract_archive/extract_utils.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext as _
 
 from desktop.conf import DEFAULT_USER
@@ -27,10 +28,11 @@ def extract_archive_in_hdfs(request, upload_path, file_name):
   _upload_extract_archive_script_to_hdfs(request.fs)
 
   output_path = upload_path + '/' + file_name.split('.')[0]
+
   shell_notebook = Notebook(
       description=_('HDFS Extraction of %(upload_path)s/%(file_name)s') % {'upload_path': upload_path, 'file_name': file_name},
       isManaged=True,
-      onSuccessUrl=upload_path
+      onSuccessUrl=reverse('filebrowser.views.view', kwargs={'path': output_path})
   )
 
   shell_notebook.add_shell_snippet(

+ 24 - 24
desktop/core/src/desktop/templates/responsive.mako

@@ -210,16 +210,16 @@ ${ hueIcons.symbols() }
               <span data-bind="text: uuid"></span>
               <a href="javascript:void(0)" data-bind="attr: { href: onSuccessUrl() }, text: onSuccessUrl" target="_blank"></a>
               <!-- ko if: selectedSnippet() -->
-              <div>
-                Progress
-                <span data-bind="text: selectedSnippet().progress"></span>
-              </div>
-              <!-- ko if: selectedSnippet().result -->
-              <div>
-                Logs
-                <span data-bind="text: selectedSnippet().result.logs"></span>
-              </div>
-              <!-- /ko -->
+                <div>
+                  Progress
+                  <span data-bind="text: selectedSnippet().progress"></span>
+                </div>
+                <!-- ko if: selectedSnippet().result -->
+                <div>
+                  Logs
+                  <span data-bind="text: selectedSnippet().result.logs"></span>
+                </div>
+                <!-- /ko -->
               <!-- /ko -->
             </div>
             <hr>
@@ -872,7 +872,8 @@ ${ assist.assistPanel() }
               var snippet = notebook.snippets()[0];
               if (! snippet.result.handle().has_more_statements) {
                 if (notebook.onSuccessUrl()) {
-                  window.location.href = notebook.onSuccessUrl(); // Show notification. If still on initial spinner redirect automatically
+                  // TODO: If we are in FB directory, also refresh FB dir
+                  window.location.href = notebook.onSuccessUrl(); // TODO: Show finish notification or if still on initial spinner redirect automatically
                 }
               } else { // Perform last DROP statement execute
                 snippet.execute();
@@ -880,21 +881,20 @@ ${ assist.assistPanel() }
             }
           });
           notebook.snippets()[0].checkStatus();
+          
+          // Add to history
+          notebook.history.unshift(
+            notebook._makeHistoryRecord(
+              notebook.onSuccessUrl(),
+              notebook.snippets()[0].result.handle().statement || '',
+              notebook.snippets()[0].lastExecuted(),
+              notebook.snippets()[0].status(),
+              notebook.name(),
+              notebook.uuid()
+            )
+          );
         });
 
-        // Add to history
-        var notebook = self.editorVM.selectedNotebook();
-        notebook.history.unshift(
-          notebook._makeHistoryRecord(
-            notebook.onSuccessUrl(),
-            notebook.snippets()[0].result.handle().statement || '',
-            notebook.snippets()[0].lastExecuted(),
-            notebook.snippets()[0].status(),
-            notebook.name(),
-            notebook.uuid()
-          )
-        );
-
         topNavViewModel.historyPanelVisible(true);
       });