Browse Source

HUE-6293 [oozie] Submit a workflow should not open Hue 3

Clean-up job rounting
Romain Rigaux 8 years ago
parent
commit
7c3af858b4

+ 26 - 22
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1887,6 +1887,31 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       }
       }
 
 
       self.resetBreadcrumbs();
       self.resetBreadcrumbs();
+
+      self.load = function() {
+        var h = window.location.hash;
+
+        h = h.indexOf('#!') === 0 ? h.substr(2) : '';
+        switch (h) {
+          case '':
+            h = 'jobs';
+          case 'slas':
+          case 'oozie-info':
+          case 'jobs':
+          case 'workflows':
+          case 'schedules':
+          case 'bundles':
+            self.selectInterface(h);
+            break;
+          default:
+            if (h.indexOf('id=') === 0 && ! self.isMini()){
+              new Job(viewModel, {id: h.substr(3)}).fetchJob();
+            }
+            else {
+              self.selectInterface('reset');
+            }
+        }
+      }
     };
     };
 
 
     var viewModel;
     var viewModel;
@@ -1912,28 +1937,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
 
       var loadHash = function () {
       var loadHash = function () {
         if (window.location.pathname.indexOf('jobbrowser') > -1) {
         if (window.location.pathname.indexOf('jobbrowser') > -1) {
-          var h = window.location.hash;
-
-          h = h.indexOf('#!') === 0 ? h.substr(2) : '';
-          switch (h) {
-            case '':
-              h = 'jobs';
-            case 'slas':
-            case 'oozie-info':
-            case 'jobs':
-            case 'workflows':
-            case 'schedules':
-            case 'bundles':
-              viewModel.selectInterface(h);
-              break;
-            default:
-              if (h.indexOf('id=') === 0 && !viewModel.isMini()){
-                new Job(viewModel, {id: h.substr(3)}).fetchJob();
-              }
-              else {
-                viewModel.selectInterface('reset');
-              }
-          }
+          viewModel.load();
         }
         }
       };
       };
 
 

+ 7 - 4
apps/jobbrowser/src/jobbrowser/views.py

@@ -320,11 +320,14 @@ def job_attempt_logs_json(request, job, attempt_index=0, name='syslog', offset=L
     if app['applicationType'] == 'MAPREDUCE':
     if app['applicationType'] == 'MAPREDUCE':
       if app['finalStatus'] in ('SUCCEEDED', 'FAILED', 'KILLED'):
       if app['finalStatus'] in ('SUCCEEDED', 'FAILED', 'KILLED'):
         attempt_index = int(attempt_index)
         attempt_index = int(attempt_index)
-        attempt = job.job_attempts['jobAttempt'][attempt_index]
+        if not job.job_attempts['jobAttempt']:
+          response = {'status': 0, 'log': _('Job has not tasks')}
+        else:
+          attempt = job.job_attempts['jobAttempt'][attempt_index]
 
 
-        log_link = attempt['logsLink']
-        # Reformat log link to use YARN RM, replace node addr with node ID addr
-        log_link = log_link.replace(attempt['nodeHttpAddress'], attempt['nodeId'])
+          log_link = attempt['logsLink']
+          # Reformat log link to use YARN RM, replace node addr with node ID addr
+          log_link = log_link.replace(attempt['nodeHttpAddress'], attempt['nodeId'])
       elif app['state'] == 'RUNNING':
       elif app['state'] == 'RUNNING':
         log_link = app['amContainerLogs']
         log_link = app['amContainerLogs']
   except (KeyError, RestException), e:
   except (KeyError, RestException), e:

+ 6 - 1
apps/oozie/src/oozie/models2.py

@@ -391,7 +391,12 @@ class Workflow(Job):
           if param['value'] and '=' in param['value']:
           if param['value'] and '=' in param['value']:
             name, val = param['value'].split('=', 1)
             name, val = param['value'].split('=', 1)
             parameters[name] = val
             parameters[name] = val
-        extra = find_parameters(node, fields=['key_tab_path', 'user_principal'])
+        extra_fields = []
+        if node.data['properties'].get('key_tab_path'):
+          extra_fields.append('key_tab_path')
+        if node.data['properties'].get('user_principal'):
+          extra_fields.append('user_principal')
+        extra = find_parameters(node, fields=extra_fields)
       else:
       else:
         extra = node.find_parameters()
         extra = node.find_parameters()
 
 

+ 2 - 0
apps/oozie/src/oozie/static/oozie/js/workflow-editor.ko.js

@@ -1222,6 +1222,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.showSubmitPopup = function () {
   self.showSubmitPopup = function () {
     $(".jHueNotify").hide();
     $(".jHueNotify").hide();
     $.get("/oozie/editor/workflow/submit/" + self.workflow.id(), {
     $.get("/oozie/editor/workflow/submit/" + self.workflow.id(), {
+      format: IS_HUE_4 ? 'json' : 'html'
     }, function (data) {
     }, function (data) {
       $(document).trigger("showSubmitPopup", data);
       $(document).trigger("showSubmitPopup", data);
     }).fail(function (xhr, textStatus, errorThrown) {
     }).fail(function (xhr, textStatus, errorThrown) {
@@ -1232,6 +1233,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.showSubmitActionPopup = function (w) {
   self.showSubmitActionPopup = function (w) {
     $(".jHueNotify").hide();
     $(".jHueNotify").hide();
     $.get("/oozie/editor/workflow/submit_single_action/" + self.workflow.id() + "/" + self.workflow.getNodeById(w.id()).id(), {
     $.get("/oozie/editor/workflow/submit_single_action/" + self.workflow.id() + "/" + self.workflow.getNodeById(w.id()).id(), {
+      format: IS_HUE_4 ? 'json' : 'html'
     }, function (data) {
     }, function (data) {
       $(document).trigger("showSubmitPopup", data);
       $(document).trigger("showSubmitPopup", data);
     }).fail(function (xhr, textStatus, errorThrown) {
     }).fail(function (xhr, textStatus, errorThrown) {

+ 1 - 1
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -670,7 +670,7 @@
 
 
 <script type="text/html" id="param-fs-link">
 <script type="text/html" id="param-fs-link">
   <!-- ko if: path.split('=', 2)[1] && path.split('=', 2)[1].charAt(0) == '/' -->
   <!-- ko if: path.split('=', 2)[1] && path.split('=', 2)[1].charAt(0) == '/' -->
-    <a data-bind="attr: {href: '/filebrowser/view=' + $data.path.split('=', 2)[1] }" target="_blank" title="${ _('Open') }">
+    <a data-bind="attr: { href: '/filebrowser/view=' + $data.path.split('=', 2)[1] }" target="_blank" title="${ _('Open') }">
       <i class="fa fa-external-link-square"></i>
       <i class="fa fa-external-link-square"></i>
     </a>
     </a>
   <!-- /ko -->
   <!-- /ko -->

+ 6 - 0
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -878,6 +878,12 @@ ${ dashboard.import_bindings() }
       }, 200);
       }, 200);
     });
     });
 
 
+    huePubSub.subscribe('submit.popup.return', function (data) {
+      $.jHueNotify.info('${_('Workflow submitted.')}');
+      huePubSub.publish('open.link', '/jobbrowser/#!id=' + data.job_id);
+      $('.submit-modal').modal('hide');
+    }, 'oozie');
+
     huePubSub.subscribe('oozie.draggable.section.change', function(val){
     huePubSub.subscribe('oozie.draggable.section.change', function(val){
       apiHelper.setInTotalStorage('oozie', 'draggable_section', val);
       apiHelper.setInTotalStorage('oozie', 'draggable_section', val);
       if (val === 'actions'){
       if (val === 'actions'){

+ 1 - 1
apps/oozie/src/oozie/templates/navigation-bar.mako

@@ -64,7 +64,7 @@
                   <img src="${ static('oozie/art/icon_oozie_dashboard_48.png') }" class="app-icon" alt="${ _('Oozie dashboard icon') }" /> ${ _('Oozie Dashboard') }
                   <img src="${ static('oozie/art/icon_oozie_dashboard_48.png') }" class="app-icon" alt="${ _('Oozie dashboard icon') }" /> ${ _('Oozie Dashboard') }
                 </a>
                 </a>
                 % else:
                 % else:
-                <a title="${ _('Switch to the dashboard') }" href="${ is_embeddable and '/hue/jobbrowser/workflows' or getURL(section, dashboard, ENABLE_V2.get())}">
+                <a title="${ _('Switch to the dashboard') }" href="${ is_embeddable and '/hue/jobbrowser/#!workflows' or getURL(section, dashboard, ENABLE_V2.get())}">
                   <svg class="svg-app-icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#hi-oozie"></use></svg> ${ _('Oozie Editor') }
                   <svg class="svg-app-icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#hi-oozie"></use></svg> ${ _('Oozie Editor') }
                 </a>
                 </a>
                 % endif
                 % endif

+ 8 - 3
apps/oozie/src/oozie/views/editor2.py

@@ -409,8 +409,12 @@ def _submit_workflow_helper(request, workflow, submit_action):
         job_id = _submit_workflow(request.user, request.fs, request.jt, workflow, mapping)
         job_id = _submit_workflow(request.user, request.fs, request.jt, workflow, mapping)
       except Exception, e:
       except Exception, e:
         raise PopupException(_('Workflow submission failed'), detail=smart_str(e))
         raise PopupException(_('Workflow submission failed'), detail=smart_str(e))
-      request.info(_('Workflow submitted'))
-      return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
+      jsonify = request.POST.get('format') == 'json'
+      if jsonify:
+        return JsonResponse({'status': 0, 'job_id': job_id}, safe=False)
+      else:
+        request.info(_('Workflow submitted'))
+        return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
     else:
     else:
       request.error(_('Invalid submission form: %s' % params_form.errors))
       request.error(_('Invalid submission form: %s' % params_form.errors))
   else:
   else:
@@ -425,7 +429,8 @@ def _submit_workflow_helper(request, workflow, submit_action):
                      'action': submit_action,
                      'action': submit_action,
                      'show_dryrun': True,
                      'show_dryrun': True,
                      'email_id': request.user.email,
                      'email_id': request.user.email,
-                     'is_oozie_mail_enabled': _is_oozie_mail_enabled(request.user)
+                     'is_oozie_mail_enabled': _is_oozie_mail_enabled(request.user),
+                     'return_json': request.GET.get('format') == 'json'
                    }, force_template=True).content
                    }, force_template=True).content
     return JsonResponse(popup, safe=False)
     return JsonResponse(popup, safe=False)
 
 

+ 0 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -2028,7 +2028,6 @@ from notebook.conf import get_ordered_interpreters
           <!-- /ko -->
           <!-- /ko -->
           <!-- ko if: schedulerViewModelIsLoaded() && viewSchedulerId()-->
           <!-- ko if: schedulerViewModelIsLoaded() && viewSchedulerId()-->
           <a data-bind="click: function() { huePubSub.publish('show.jobs.panel'); huePubSub.publish('mini.jb.navigate', 'schedules') }" href="javascript: void(0);">${ _('View') }</a>
           <a data-bind="click: function() { huePubSub.publish('show.jobs.panel'); huePubSub.publish('mini.jb.navigate', 'schedules') }" href="javascript: void(0);">${ _('View') }</a>
-          ##<a data-bind="click: showSubmitPopup">${ _('Synchronize') }</a>
           <!-- /ko -->
           <!-- /ko -->
           <br>
           <br>
           <br>
           <br>

+ 11 - 6
desktop/core/src/desktop/templates/hue.mako

@@ -757,7 +757,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
             self.getActiveAppViewModel(function (viewModel) {
             self.getActiveAppViewModel(function (viewModel) {
               var arguments = ctx.path.match(/\/indexer\/importer\/prefill\/?([^/]+)\/?([^/]+)\/?([^/]+)?/);
               var arguments = ctx.path.match(/\/indexer\/importer\/prefill\/?([^/]+)\/?([^/]+)\/?([^/]+)?/);
               if (! arguments) {
               if (! arguments) {
-                console.warn('Could not match ' + href)
+                console.warn('Could not match ' + href);
               }
               }
               hueUtils.waitForVariable(viewModel.createWizard, function(){
               hueUtils.waitForVariable(viewModel.createWizard, function(){
                 hueUtils.waitForVariable(viewModel.createWizard.prefill, function(){
                 hueUtils.waitForVariable(viewModel.createWizard.prefill, function(){
@@ -768,14 +768,19 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
               });
               });
             })
             })
           }},
           }},
-          { url: '/jobbrowser/', app: 'jobbrowser' },
           { url: '/jobbrowser/jobs/job_*', app: function (ctx) {
           { url: '/jobbrowser/jobs/job_*', app: function (ctx) {
-            page.redirect('/jobbrowser/jobs/#!id=application_' + _.trimRight(ctx.params[0], '/'));
+            page.redirect('/jobbrowser#!id=application_' + _.trimRight(ctx.params[0], '/'));
           }},
           }},
-          { url: '/jobbrowser/workflows', app: function () {
-            page.redirect('/jobbrowser/#!workflows');
+          { url: '/jobbrowser*', app: function (ctx) {
+            self.loadApp('jobbrowser');
+            self.getActiveAppViewModel(function (viewModel) {
+              hueUtils.waitForVariable(viewModel.selectInterface, function(){
+                hueUtils.waitForVariable(viewModel.selectInterface, function(){
+                  viewModel.load();
+                });
+              });
+            });
           }},
           }},
-          { url: '/jobbrowser/jobs', app: 'jobbrowser' },
           { url: '/logs', app: 'logs' },
           { url: '/logs', app: 'logs' },
           { url: '/metastore', app: function () {
           { url: '/metastore', app: function () {
             page('/metastore/tables');
             page('/metastore/tables');