浏览代码

HUE-910 [oozie] Display all actions in workflow editor and dashboard

Add uneditable node to workflow builder to represent start and end
nodes.

Add status and representation of decision, fork, join, start, and
end nodes.
Abraham Elmahrek 12 年之前
父节点
当前提交
6ca40cd

+ 7 - 2
apps/oozie/src/oozie/models.py

@@ -417,14 +417,16 @@ class Workflow(Job):
   def gen_status_graph(self, oozie_workflow):
   def gen_status_graph(self, oozie_workflow):
     from oozie.forms import NodeMetaForm  # Circular dependency
     from oozie.forms import NodeMetaForm  # Circular dependency
     actions = oozie_workflow.get_working_actions()
     actions = oozie_workflow.get_working_actions()
+    controls = oozie_workflow.get_control_flow_actions()
     WorkflowFormSet = inlineformset_factory(Workflow, Node, form=NodeMetaForm, max_num=0, can_order=False, can_delete=False)
     WorkflowFormSet = inlineformset_factory(Workflow, Node, form=NodeMetaForm, max_num=0, can_order=False, can_delete=False)
     forms = WorkflowFormSet(instance=self).forms
     forms = WorkflowFormSet(instance=self).forms
     template='editor/gen/workflow-graph-status.xml.mako'
     template='editor/gen/workflow-graph-status.xml.mako'
 
 
     index = dict([(form.instance.id, form) for form in forms])
     index = dict([(form.instance.id, form) for form in forms])
     actions_index = dict([(action.name, action) for action in actions])
     actions_index = dict([(action.name, action) for action in actions])
+    controls_index = dict([(control.name.strip(':'), control) for control in controls])
 
 
-    return django_mako.render_to_string(template, {'nodes': self.get_hierarchy(), 'index': index, 'actions': actions_index})
+    return django_mako.render_to_string(template, {'nodes': self.get_hierarchy(), 'index': index, 'actions': actions_index, 'controls': controls_index})
 
 
   @classmethod
   @classmethod
   def gen_status_graph_from_xml(cls, user, oozie_workflow):
   def gen_status_graph_from_xml(cls, user, oozie_workflow):
@@ -1043,7 +1045,7 @@ class ControlFlow(Node):
     return django_mako.render_to_string(self.get_template_name(), {})
     return django_mako.render_to_string(self.get_template_name(), {})
 
 
   def is_visible(self):
   def is_visible(self):
-    return False
+    return True
 
 
 
 
 # Could not make this abstract
 # Could not make this abstract
@@ -1070,6 +1072,9 @@ class Kill(ControlFlow):
   def add_node(self, child):
   def add_node(self, child):
     raise RuntimeError(_("Kill should not have any children."))
     raise RuntimeError(_("Kill should not have any children."))
 
 
+  def is_visible(self):
+    return False
+
 
 
 class Fork(ControlFlow):
 class Fork(ControlFlow):
   """
   """

+ 22 - 2
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -306,8 +306,28 @@ ${ controls.decision_form(node_form, link_form, default_link_form, 'decision', T
 
 
 <script type="text/html" id="emptyTemplate"></script>
 <script type="text/html" id="emptyTemplate"></script>
 
 
-<script type="text/html" id="startTemplate">
-  <div class="row-fluid" data-bind="template: { name: 'linkTemplate', foreach: links }"></div>
+<script type="text/html" id="disabledNodeTemplate">
+  <div class="node node-control row-fluid">
+    <div class="action span12">
+      <div class="row-fluid">
+        <div class="span12">
+          <h4 data-bind="text: (name()) ? name() : node_type() + '-' + id()"></h4>
+          <span data-bind="text: node_type" class="muted"></span>
+          <div class="node-description" data-bind="text: description"></div>
+        </div>
+      </div>
+
+      <div class="row-fluid node-action-bar">
+        <div class="span12" style="text-align:right">
+          &nbsp;
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <!-- ko if: links -->
+    <div class="row-fluid" data-bind="template: { name: 'linkTemplate', foreach: links }"></div>
+  <!-- /ko -->
 </script>
 </script>
 
 
 <script type="text/html" id="nodeTemplate">
 <script type="text/html" id="nodeTemplate">

+ 18 - 4
apps/oozie/src/oozie/templates/editor/gen/workflow-graph-status.xml.mako

@@ -27,7 +27,8 @@
     is_join = form.instance.get_full_node().node_type == 'join'
     is_join = form.instance.get_full_node().node_type == 'join'
     is_decision = form.instance.get_full_node().node_type == 'decision'
     is_decision = form.instance.get_full_node().node_type == 'decision'
     is_decision_end = form.instance.get_full_node().node_type == 'decisionend'
     is_decision_end = form.instance.get_full_node().node_type == 'decisionend'
-    action = actions.get(form.instance.__unicode__())
+    action = actions.get(unicode(form.instance))
+    control = controls.get(unicode(form.instance))
     box_class = ""
     box_class = ""
     if is_fork:
     if is_fork:
       box_class = "node-fork"
       box_class = "node-fork"
@@ -51,24 +52,37 @@
             <div class="node-description">${ form.instance.description }</div>
             <div class="node-description">${ form.instance.description }</div>
             % if action:
             % if action:
               ${ action.errorMessage or '' }
               ${ action.errorMessage or '' }
+            % elif control:
+              ${ control.errorMessage or '' }
             % endif
             % endif
           </div>
           </div>
         </div>
         </div>
         % if action and action.externalId:
         % if action and action.externalId:
         <div class="row-fluid node-action-bar">
         <div class="row-fluid node-action-bar">
           <div class="span2" style="text-align:left;padding-left: 6px">
           <div class="span2" style="text-align:left;padding-left: 6px">
-            % if not is_fork and action:
+            % if action:
               <span class="label ${ utils.get_status(action.status) }">${ action.status }</span>
               <span class="label ${ utils.get_status(action.status) }">${ action.status }</span>
             % endif
             % endif
           </div>
           </div>
           <div class="span10" style="text-align:right">
           <div class="span10" style="text-align:right">
-            % if not is_fork and action:
-            <a href="${ action.get_absolute_url() }" class="btn btn-mini" title="${ _('View workflow action') }" rel="tooltip"><i class="icon-eye-open"></i></a>
+            % if action:
+              <a href="${ action.get_absolute_url() }" class="btn btn-mini" title="${ _('View workflow action') }" rel="tooltip"><i class="icon-eye-open"></i></a>
             % endif
             % endif
             <a href="${ url('jobbrowser.views.job_single_logs', job=action.externalId) }" class="btn btn-mini" title="${ _('View the logs') }" rel="tooltip" data-row-selector-exclude="true" id="advanced-btn"><i class="icon-tasks"></i></a>
             <a href="${ url('jobbrowser.views.job_single_logs', job=action.externalId) }" class="btn btn-mini" title="${ _('View the logs') }" rel="tooltip" data-row-selector-exclude="true" id="advanced-btn"><i class="icon-tasks"></i></a>
             &nbsp;
             &nbsp;
           </div>
           </div>
         </div>
         </div>
+        % elif control:
+        <div class="row-fluid node-action-bar">
+          <div class="span2" style="text-align:left;padding-left: 6px">
+            % if control:
+              <span class="label ${ utils.get_status(control.status) }">${ control.status }</span>
+            % endif
+          </div>
+          <div class="span10" style="text-align:right">
+            &nbsp;
+          </div>
+        </div>
         % endif
         % endif
 
 
       </div>
       </div>

+ 2 - 2
apps/oozie/static/js/workflow.node.js

@@ -85,11 +85,11 @@ var NodeModule = function($, IdGeneratorTable, NodeFields) {
     self.edit_template = model.node_type + 'EditTemplate';
     self.edit_template = model.node_type + 'EditTemplate';
     switch(model.node_type) {
     switch(model.node_type) {
     case 'start':
     case 'start':
-      self.view_template = ko.observable('startTemplate');
+    case 'end':
+      self.view_template = ko.observable('disabledNodeTemplate');
     break;
     break;
 
 
     case 'kill':
     case 'kill':
-    case 'end':
       self.view_template = ko.observable('emptyTemplate');
       self.view_template = ko.observable('emptyTemplate');
     break;
     break;