Browse Source

HUE-3024 [oozie] Add Generic action to the workflow editor

Romain Rigaux 10 years ago
parent
commit
37df771ec0

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

@@ -1485,6 +1485,23 @@ class JoinAction(Action):
     return []
 
 
+class GenericAction(Action):
+  TYPE = 'generic'
+  FIELDS = {
+     'xml': {
+          'name': 'xml',
+          'label': _('XML of the action'),
+          'value': '<my_action>\n</my_action>',
+          'help_text': _('Insert verbatim the XML of the action to insert into the workflow.'),
+          'type': 'textarea'
+     }
+  }
+
+  @classmethod
+  def get_mandatory_fields(cls):
+    return [cls.FIELDS['xml']]
+
+
 class ForkNode(Action):
   TYPE = 'fork'
   FIELDS = {}
@@ -1523,7 +1540,8 @@ NODES = {
   'join-widget': JoinAction,
   'fork-widget': ForkNode,
   'decision-widget': DecisionNode,
-  'spark-widget': SparkAction
+  'spark-widget': SparkAction,
+  'generic-widget': GenericAction
 }
 
 

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

@@ -1226,6 +1226,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.draggableStreamingAction = ko.observable(bareWidgetBuilder("Streaming", "streaming-widget"));
   self.draggableDistCpAction = ko.observable(bareWidgetBuilder("Distcp", "distcp-widget"));
   self.draggableSparkAction = ko.observable(bareWidgetBuilder("Spark", "spark-widget"));
+  self.draggableGenericAction = ko.observable(bareWidgetBuilder("Generic", "generic-widget"));
 
   self.draggableKillNode = ko.observable(bareWidgetBuilder("Kill", "kill-widget"));
 };

+ 48 - 0
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -209,6 +209,10 @@
       <img src="${ static('oozie/art/icon_spark_48.png') }" class="widget-icon">
       <!-- /ko -->
 
+      <!-- ko if: widgetType() == 'generic-widget' -->
+      <a class="widget-icon"><i class="fa fa-code"></i></a>
+      <!-- /ko -->
+
       <!-- ko if: widgetType() == 'kill-widget' -->
       <a class="widget-icon"><i class="fa fa-stop"></i></a>
       <!-- /ko -->
@@ -851,6 +855,50 @@
 </script>
 
 
+<script type="text/html" id="generic-widget">
+  <!-- ko if: $root.workflow.getNodeById(id()) -->
+  <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="padding: 10px">
+
+    <div data-bind="visible: ! $root.isEditing()">
+      <span data-bind="template: { name: 'logs-icon' }"></span>
+    </div>
+
+    <div data-bind="visible: $root.isEditing">
+      <div data-bind="visible: ! $parent.ooziePropertiesExpanded()" class="nowrap">
+
+        <div class="airy">
+          <span class="widget-label" data-bind="text: $root.workflow_properties.xml.label"></span>
+          <textarea class="input-xlarge seventy" style="resize:both" data-bind="value: properties.xml, attr: { placeholder: $root.workflow_properties.xml.help_text }"></textarea>
+        </div>
+
+      </div>
+    </div>
+
+    <div data-bind="visible: $parent.ooziePropertiesExpanded">
+      <ul class="nav nav-tabs">
+        <li class="active"><a data-bind="attr: { href: '#sla-' + id()}" href="#sla" data-toggle="tab">${ _('SLA') }</a></li>
+        <li><a data-bind="attr: { href: '#credentials-' + id()}" data-toggle="tab">${ _('Credentials') }</a></li>
+        <li><a data-bind="attr: { href: '#transitions-' + id()}" data-toggle="tab">${ _('Transitions') }</a></li>
+      </ul>
+      <div class="tab-content">
+        <div class="tab-pane active" data-bind="attr: { id: 'sla-' + id() }">
+          <span data-bind="template: { name: 'common-action-sla' }"></span>
+        </div>
+
+        <div class="tab-pane" data-bind="attr: { id: 'credentials-' + id() }">
+          <span data-bind="template: { name: 'common-action-credentials' }"></span>
+        </div>
+
+        <div class="tab-pane" data-bind="attr: { id: 'transitions-' + id() }">
+          <span data-bind="template: { name: 'common-action-transition' }"></span>
+        </div>
+      </div>
+    </div>
+  </div>
+  <!-- /ko -->
+</script>
+
+
 <script type="text/html" id="java-widget">
   <!-- ko if: $root.workflow.getNodeById(id()) -->
   <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="padding: 10px">

+ 5 - 4
apps/oozie/src/oozie/templates/editor2/gen/workflow-generic.xml.mako

@@ -17,8 +17,9 @@
 
 <%namespace name="common" file="workflow-common.xml.mako" />
 
-    <action name="${ node }"${ common.credentials(node.credentials) }>
-        ${ node.xml | n,unicode }
-        <ok to="${ node.get_oozie_child('ok') }"/>
-        <error to="${ node.get_oozie_child('error') }"/>
+    <action name="${ node['name'] }"${ common.credentials(node['properties']['credentials']) }${ common.retry_max(node['properties']['retry_max']) }${ common.retry_interval(node['properties']['retry_interval']) }>
+        ${ node['properties']['xml'] | n,unicode }
+        <ok to="${ node_mapping[node['children'][0]['to']].name }"/>
+        <error to="${ node_mapping[node['children'][1]['error']].name }"/>
+        ${ common.sla(node) }
     </action>

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

@@ -205,6 +205,13 @@ ${ layout.menubar(section='workflows', is_editor=True, pullright=buttons) }
          <a class="draggable-icon"><i class="fa fa-files-o"></i></a>
     </div>
 
+    <div data-bind="css: { 'draggable-widget': true },
+                    draggable: {data: draggableGenericAction(), isEnabled: true,
+                    options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableGenericAction());}}}"
+         title="${_('Generic')}" rel="tooltip" data-placement="top">
+         <a class="draggable-icon"><i class="fa fa-code"></i></a>
+    </div>
+
     <div data-bind="css: { 'draggable-widget': true },
                     draggable: {data: draggableKillNode(), isEnabled: true,
                     options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableKillNode());}}}"

File diff suppressed because it is too large
+ 1 - 0
apps/oozie/src/oozie/tests2.py


Some files were not shown because too many files changed in this diff