浏览代码

HUE-4750 [oozie] Drag & dropped a saved Shell query

Romain Rigaux 9 年之前
父节点
当前提交
0bec844678

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

@@ -812,6 +812,7 @@ class Node():
       self.data['properties']['shell_command'] = action['properties']['command_path']
       self.data['properties']['env_var'] = [{'value': prop} for prop in action['properties']['env_var']]
       self.data['properties']['capture_output'] = action['properties']['capture_output']
+      self.data['properties']['arguments'] = []
 
       self.data['properties']['files'] = [{'value': action['properties']['command_path']}] + [{'value': prop} for prop in action['properties']['files']]
       self.data['properties']['archives'] = [{'value': prop} for prop in action['properties']['archives']]

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

@@ -513,6 +513,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
     self.getDocuments('query-pig', self.pigScripts);
     self.getDocuments('query-sqoop1', self.sqoopScripts);
     self.getDocuments('query-distcp', self.distCpScripts);
+    self.getDocuments('query-shell', self.shellScripts);
   };
 
   self.getDocuments = function(type, destination) {
@@ -561,6 +562,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.pigScripts = ko.observableArray();
   self.sqoopScripts = ko.observableArray();
   self.distCpScripts = ko.observableArray();
+  self.shellScripts = ko.observableArray();
   self.history = ko.mapping.fromJS(history_json);
 
   self.getDocumentById = function (type, uuid) {
@@ -575,6 +577,8 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
       data = self.sqoopScripts();
     } else if (type.indexOf('distcp') != -1) {
       data = self.distCpScripts();
+    } else if (type.indexOf('shell') != -1) {
+      data = self.shellScripts();
     } else {
       data = self.hiveQueries();
     }
@@ -1304,6 +1308,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
   self.draggablePigDocumentAction = ko.observable(bareWidgetBuilder("Pig", "pig-document-widget"));
   self.draggableSqoopDocumentAction = ko.observable(bareWidgetBuilder("Sqoop", "sqoop-document-widget"));
   self.draggableDistCpDocumentAction = ko.observable(bareWidgetBuilder("DistCp", "distcp-document-widget"));
+  self.draggableShellDocumentAction = ko.observable(bareWidgetBuilder("Shell", "shell-document-widget"));
   self.draggableKillNode = ko.observable(bareWidgetBuilder("Kill", "kill-widget"));
 };
 

+ 67 - 3
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -181,7 +181,7 @@
       <a class="widget-icon"><i class="fa fa-code-fork"></i></a>
       <!-- /ko -->
 
-      <!-- ko if: widgetType() == 'shell-widget' -->
+      <!-- ko if: widgetType() == 'shell-widget' || widgetType() == 'shell-document-widget' -->
       <a class="widget-icon"><i class="fa fa-terminal"></i></a>
       <!-- /ko -->
 
@@ -1705,6 +1705,70 @@
 </script>
 
 
+<script type="text/html" id="shell-document-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>
+      <!-- ko if: $root.getDocumentById(type(), properties.uuid()) -->
+      <!-- ko with: $root.getDocumentById(type(), properties.uuid()) -->
+        <a data-bind="attr: { href: absoluteUrl() }" target="_blank"><span data-bind='text: name'></span></a>
+        <br/>
+        <span data-bind='text: description' class="muted"></span>
+      <!-- /ko -->
+      <!-- /ko -->
+    </div>
+
+    <div data-bind="visible: $root.isEditing">
+      <div data-bind="visible: ! $parent.ooziePropertiesExpanded()" class="nowrap">
+        <!-- ko if: $root.getDocumentById(type(), properties.uuid()) -->
+        <!-- ko with: $root.getDocumentById(type(), properties.uuid()) -->
+          <select data-bind="options: $root.shellScripts, optionsText: 'name', optionsValue: 'uuid', value: $parent.properties.uuid, select2Version4:{ placeholder: '${ _ko('Shell program name...')}'}"></select>
+          <a href="#" data-bind="attr: { href: absoluteUrl() }" target="_blank" title="${ _('Open') }">
+            <i class="fa fa-external-link-square"></i>
+          </a>
+          <div data-bind='text: description' style="padding: 3px; margin-top: 2px" class="muted"></div>
+        <!-- /ko -->
+        <!-- /ko -->
+
+        <div class="row-fluid">
+          <div class="span6" data-bind="template: { name: 'common-properties-files' }"></div>
+        </div>
+
+      </div>
+    </div>
+
+    <div data-bind="visible: $parent.ooziePropertiesExpanded">
+      <ul class="nav nav-tabs">
+        <li class="active"><a data-bind="attr: { href: '#properties-' + id()}" data-toggle="tab">${ _('Properties') }</a></li>
+        <li><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: 'properties-' + id() }">
+          <span data-bind="template: { name: 'common-action-properties' }"></span>
+        </div>
+
+        <div class="tab-pane" 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="ssh-widget">
   <!-- ko if: $root.workflow.getNodeById(id()) -->
   <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="padding: 10px">
@@ -2219,8 +2283,8 @@
 
     <div data-bind="visible: ! $root.isEditing()">
       <span data-bind="template: { name: 'logs-icon' }"></span>
-      <!-- ko if: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
-      <!-- ko with: $root.getDocumentById('query-sqoop1', properties.uuid()) -->
+      <!-- ko if: $root.getDocumentById(type(), properties.uuid()) -->
+      <!-- ko with: $root.getDocumentById(type(), properties.uuid()) -->
         <a data-bind="attr: { href: absoluteUrl() }" target="_blank"><span data-bind='text: name'></span></a>
         <br/>
         <span data-bind='text: description' class="muted"></span>

+ 9 - 2
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -154,6 +154,13 @@ ${ layout.menubar(section='workflows', is_editor=True, pullright=buttons) }
          title="${_('Saved DistCp command')}" rel="tooltip" data-placement="top">
          <a class="draggable-icon"><i class="fa fa-files-o"></i></a>
     </div>
+
+    <div data-bind="css: { 'draggable-widget': true },
+                    draggable: {data: draggableShellDocumentAction(), isEnabled: true,
+                    options: {'refreshPositions': true, 'stop': function(){ $root.isDragging(false); }, 'start': function(event, ui){ $root.isDragging(true); $root.currentlyDraggedWidget(draggableShellDocumentAction());}}}"
+         title="${_('Saved Shell command')}" rel="tooltip" data-placement="top">
+         <a class="draggable-icon"><i class="fa fa-terminal"></i></a>
+    </div>
     % endif
 
     <div class="toolbar-label">${ _('ACTIONS') }</div>
@@ -310,8 +317,8 @@ ${ workflow.render() }
           <!-- ko if: type() == 'workflow' -->
           <select data-bind="options: $root.subworkflows, optionsText: 'name', optionsValue: 'value', value: value"></select>
           <!-- /ko -->
-          <!-- ko if: ['hive', 'java', 'spark', 'pig', 'sqoop', 'distcp-doc'].indexOf(type()) != -1 -->
-          <select data-bind="options: type() == 'java' ? $root.javaQueries() : (type() == 'spark' ? $root.sparkApps() : (type() == 'pig' ? $root.pigScripts() : (type() == 'sqoop' ? $root.sqoopScripts() : (type() == 'distcp-doc' ? $root.distCpScripts() : $root.hiveQueries())))), optionsText: 'name', optionsValue: 'uuid', value: value, select2Version4:{ placeholder: '${ _ko('Document name...')}'}"></select>
+          <!-- ko if: ['hive', 'java', 'spark', 'pig', 'sqoop', 'distcp-doc', 'shell-doc'].indexOf(type()) != -1 -->
+          <select data-bind="options: type() == 'java' ? $root.javaQueries() : (type() == 'spark' ? $root.sparkApps() : (type() == 'pig' ? $root.pigScripts() : (type() == 'sqoop' ? $root.sqoopScripts() : (type() == 'distcp-doc' ? $root.distCpScripts() : (type() == 'shell-doc' ? $root.shellScripts() : $root.hiveQueries()))))), optionsText: 'name', optionsValue: 'uuid', value: value, select2Version4:{ placeholder: '${ _ko('Document name...')}'}"></select>
           <!-- ko if: $root.getDocumentById(type(), value()) -->
             <!-- ko with: $root.getDocumentById(type(), value()) -->
               <a href="#" data-bind="attr: { href: $data.absoluteUrl() }" target="_blank" title="${ _('Open') }">