瀏覽代碼

HUE-5499 [responsive] Embeddable oozie coordinator editor

Enrico Berti 9 年之前
父節點
當前提交
7d4ac88

+ 15 - 11
apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

@@ -102,18 +102,22 @@ var CoordinatorEditorViewModel = (function () {
 
         // Append the new variables, reuse past variables in case of rename
         prev_variables = self.variables.slice();
-        $.each(data.parameters, function (index, param) {
-          if (prev_variables.filter(function(variable) { return param['name'] == variable.workflow_variable(); }).length == 0) {
-            var newVar;
-            if (removed_variables.length > 0) {
-              newVar = removed_variables.shift();
-              self.variables.push(newVar);
-            } else {
-              newVar = self.addVariable();
+        if (data.parameters) {
+          $.each(data.parameters, function (index, param) {
+            if (prev_variables.filter(function (variable) {
+                return param['name'] == variable.workflow_variable();
+              }).length == 0) {
+              var newVar;
+              if (removed_variables.length > 0) {
+                newVar = removed_variables.shift();
+                self.variables.push(newVar);
+              } else {
+                newVar = self.addVariable();
+              }
+              newVar.workflow_variable(param['name']);
             }
-            newVar.workflow_variable(param['name']);
-          }
-        });
+          });
+        }
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);
       });

+ 11 - 1
apps/oozie/src/oozie/templates/editor2/common_scheduler.inc.mako

@@ -387,9 +387,17 @@ from django.utils.translation import ugettext as _
 
 <%def name="import_modals()">
 
-<div id="chooseWorkflowDemiModal" class="demi-modal fade" data-backdrop="false">
+<div id="chooseWorkflowDemiModal" class="${ is_embeddable and 'modal' or 'demi-modal' } fade" data-backdrop="false">
+  %if is_embeddable:
+  <div class="modal-header" style="padding-bottom: 2px">
+    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+    <h3>${ _('Choose a workflow') }</h3>
+  </div>
+  %endif
   <div class="modal-body">
+    %if not is_embeddable:
     <a href="javascript: void(0)" data-dismiss="modal" class="pull-right"><i class="fa fa-times"></i></a>
+    %endif
     <div style="float: left; margin-right: 10px;text-align: center">
       <input type="text" data-bind="clearable: $root.workflowModalFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter workflows')}" class="input" style="float: left" /><br/>
     </div>
@@ -410,7 +418,9 @@ from django.utils.translation import ugettext as _
       </div>
     </div>
   </div>
+  %if not is_embeddable:
   <div><a class="pointer demi-modal-chevron" data-dismiss="modal"><i class="fa fa-chevron-up"></i></a></div>
+  %endif
 </div>
 
 <div id="settingsModal" class="modal hide fade">

+ 6 - 10
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -24,9 +24,11 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="../navigation-bar.mako" />
 <%namespace name="scheduler" file="common_scheduler.inc.mako" />
 
+%if not is_embeddable:
 ${ commonheader(_("Coordinator Editor"), "Oozie", user, request) | n,unicode }
+%endif
 
-<div id="editor">
+<div id="oozie_coordinatorComponents">
 
 <%def name="buttons()">
   <div class="pull-right" style="padding-right: 10px">
@@ -39,20 +41,14 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user, request) | n,unicode }
       <i class="fa fa-play"></i>
     </a>
 
-    &nbsp;&nbsp;&nbsp;
-
     <a title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}, visible: canEdit">
       <i class="fa fa-pencil"></i>
     </a>
 
-    &nbsp;&nbsp;&nbsp;
-
     <a title="${ _('Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#settingsModal" data-bind="css: {'btn': true}, visible: canEdit">
       <i class="fa fa-cog"></i>
     </a>
 
-    &nbsp;&nbsp;&nbsp;
-
     <a title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }"
         data-bind="click: $root.save, css: {'btn': true, 'disabled': $root.isSaving()}, visible: coordinator.properties.workflow() && canEdit">
       <i class="fa fa-save"></i>
@@ -65,8 +61,6 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user, request) | n,unicode }
       <i class="fa fa-users"></i>
     </a>
 
-    &nbsp;&nbsp;&nbsp;
-
     <a class="btn" href="${ url('oozie:new_coordinator') }" title="${ _('New') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
       <i class="fa fa-file-o"></i>
     </a>
@@ -144,7 +138,7 @@ ${ scheduler.import_sla_cron(coordinator_json) }
 
   var viewModel = new CoordinatorEditorViewModel(${ coordinator_json | n,unicode }, ${ credentials_json | n,unicode }, ${ workflows_json | n,unicode }, ${ can_edit_json | n,unicode });
 
-  ko.applyBindings(viewModel, $("#editor")[0]);
+  ko.applyBindings(viewModel, $("#oozie_coordinatorComponents")[0]);
 
   viewModel.coordinator.properties.cron_advanced.valueHasMutated(); // Update jsCron enabled status
   viewModel.coordinator.tracker().markCurrentStateAsClean();
@@ -184,4 +178,6 @@ ${ scheduler.import_sla_cron(coordinator_json) }
   });
 </script>
 
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
+%endif

+ 4 - 4
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -27,9 +27,9 @@ from oozie.conf import ENABLE_DOCUMENT_ACTION
 <%namespace name="workflow" file="common_workflow.mako" />
 <%namespace name="layout" file="../navigation-bar.mako" />
 
-% if not is_embeddable:
+%if not is_embeddable:
 ${ commonheader(_("Workflow Editor"), "Oozie", user, request, "40px") | n,unicode }
-% endif
+%endif
 
 <div id="oozie_workflowComponents">
 
@@ -799,6 +799,6 @@ ${ dashboard.import_bindings() }
 
 </script>
 
-% if not is_embeddable:
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
-% endif
+%endif

+ 2 - 0
apps/oozie/src/oozie/views/editor2.py

@@ -525,6 +525,7 @@ def edit_coordinator(request):
       'credentials': credentials.credentials.keys(),
       'workflows': workflows,
       'doc_uuid': doc.uuid if doc else '',
+      'is_embeddable': request.GET.get('is_embeddable', False),
       'can_edit': doc is None or doc.doc.get().is_editable(request.user),
       'layout': django_mako.render_to_string('editor2/common_scheduler.mako', {'coordinator_json': coordinator.to_json_for_html()})
     })
@@ -534,6 +535,7 @@ def edit_coordinator(request):
       'credentials_json': json.dumps(credentials.credentials.keys(), cls=JSONEncoderForHTML),
       'workflows_json': json.dumps(workflows, cls=JSONEncoderForHTML),
       'doc_uuid': doc.uuid if doc else '',
+      'is_embeddable': request.GET.get('is_embeddable', False),
       'can_edit_json': json.dumps(doc is None or doc.doc.get().is_editable(request.user))
   })
 

+ 2 - 0
desktop/core/src/desktop/templates/responsive.mako

@@ -359,6 +359,7 @@ ${ hueIcons.symbols() }
       <div id="embeddable_metastore" class="embeddable"></div>
       <div id="embeddable_search" class="embeddable"></div>
       <div id="embeddable_oozie_workflow" class="embeddable"></div>
+      <div id="embeddable_oozie_coordinator" class="embeddable"></div>
       <div id="embeddable_jobbrowser" class="embeddable"></div>
       <div id="embeddable_filebrowser" class="embeddable"></div>
       <div id="embeddable_filebrowser_s3" class="embeddable"></div>
@@ -480,6 +481,7 @@ ${ assist.assistPanel() }
           metastore: '/metastore/tables/?is_embeddable=true',
           search: '/search/embeddable/new_search',
           oozie_workflow: '/oozie/editor/workflow/new/?is_embeddable=true',
+          oozie_coordinator: '/oozie/editor/coordinator/new/?is_embeddable=true',
           jobbrowser: '/jobbrowser/apps?is_embeddable=true',
           filebrowser: '/filebrowser/?is_embeddable=true',
           filebrowser_s3: '/filebrowser/view=S3A://?is_embeddable=true',