Browse Source

HUE-4473 [oozie] Bulk add parameters and arguments

Enrico Berti 8 years ago
parent
commit
21e4268bb8

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

@@ -519,7 +519,7 @@
       <span class="muted move-widget">
       <span class="muted move-widget">
         <i class="fa fa-arrows"></i>
         <i class="fa fa-arrows"></i>
       </span>
       </span>
-      <input type="text" class="span11" data-bind="value: value, attr: { placeholder: $root.workflow_properties.arguments.help_text }" validate="nonempty"/>
+      <input type="text" class="span11" data-bind="value: value, attr: { placeholder: $root.workflow_properties.arguments.help_text }, parseArguments: { list: $parent.properties.arguments, objectKey: 'value', callback: function(){ $(document).trigger('drawArrows'); } }" validate="nonempty"/>
       <a href="#" data-bind="click: function(){ $parent.properties.arguments.remove(this); $(document).trigger('drawArrows') }">
       <a href="#" data-bind="click: function(){ $parent.properties.arguments.remove(this); $(document).trigger('drawArrows') }">
         <i class="fa fa-minus"></i>
         <i class="fa fa-minus"></i>
       </a>
       </a>
@@ -783,7 +783,7 @@
                 <span class="muted move-widget">
                 <span class="muted move-widget">
                   <i class="fa fa-arrows"></i>
                   <i class="fa fa-arrows"></i>
                 </span>
                 </span>
-                <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder:  $root.workflow_properties.arguments.help_text }" validate="nonempty"/>
+                <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder: $root.workflow_properties.arguments.help_text }, parseArguments: { list: $parent.properties.arguments, objectKey: 'value', callback: function(){ $(document).trigger('drawArrows'); } }" validate="nonempty"/>
                 <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
                 <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
                 <a href="#" data-bind="click: function(){ $parent.properties.arguments.remove(this); $(document).trigger('drawArrows') }">
                 <a href="#" data-bind="click: function(){ $parent.properties.arguments.remove(this); $(document).trigger('drawArrows') }">
                   <i class="fa fa-minus"></i>
                   <i class="fa fa-minus"></i>
@@ -945,7 +945,7 @@
                 <span class="muted move-widget">
                 <span class="muted move-widget">
                   <i class="fa fa-arrows"></i>
                   <i class="fa fa-arrows"></i>
                 </span>
                 </span>
-                <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder:  $root.workflow_properties.spark_arguments.help_text }" validate="nonempty"/>
+                <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder:  $root.workflow_properties.spark_arguments.help_text }, parseArguments: { list: $parent.properties.spark_arguments, objectKey: 'value', callback: function(){ $(document).trigger('drawArrows'); } }" validate="nonempty"/>
                 <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
                 <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
                 <a href="#" data-bind="click: function(){ $parent.properties.spark_arguments.remove(this); $(document).trigger('drawArrows') }">
                 <a href="#" data-bind="click: function(){ $parent.properties.spark_arguments.remove(this); $(document).trigger('drawArrows') }">
                   <i class="fa fa-minus"></i>
                   <i class="fa fa-minus"></i>
@@ -2113,7 +2113,7 @@
             <span class="muted move-widget">
             <span class="muted move-widget">
               <i class="fa fa-arrows"></i>
               <i class="fa fa-arrows"></i>
             </span>
             </span>
-            <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, value: value, attr: { placeholder: $root.workflow_properties.distcp_parameters.help_text }" validate="nonempty"/>
+            <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, value: value, attr: { placeholder: $root.workflow_properties.distcp_parameters.help_text }, parseArguments: { list: $parent.properties.distcp_parameters, objectKey: 'value', callback: function(){ $(document).trigger('drawArrows'); } }" validate="nonempty"/>
             <span data-bind='template: { name: "common-fs-link", data: {path: value(), with_label: false} }, visible: value().length > 0'></span>
             <span data-bind='template: { name: "common-fs-link", data: {path: value(), with_label: false} }, visible: value().length > 0'></span>
             <a href="#" data-bind="click: function(){ $parent.properties.distcp_parameters.remove(this);  }">
             <a href="#" data-bind="click: function(){ $parent.properties.distcp_parameters.remove(this);  }">
               <i class="fa fa-minus"></i>
               <i class="fa fa-minus"></i>

+ 45 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -5073,6 +5073,51 @@
     }
     }
   };
   };
 
 
+  ko.bindingHandlers.parseArguments = {
+    init: function (element, valueAccessor, allBindingsAccessor) {
+      $el = $(element);
+
+      function splitStrings(str) {
+        var bits = [];
+        var isInQuotes = false;
+        var tempStr = '';
+        str.split('').forEach(function (char) {
+          if (char == '"' || char == "'") {
+            isInQuotes = !isInQuotes;
+          }
+          else if ((char == ' ' || char == '\n') && !isInQuotes && tempStr != '') {
+            bits.push(tempStr);
+            tempStr = '';
+          }
+          else {
+            tempStr += char;
+          }
+        });
+        if (tempStr != '') {
+          bits.push(tempStr);
+        }
+        return bits;
+      }
+
+      $el.bind('paste', function (e) {
+        var pasted = e.originalEvent.clipboardData.getData('text');
+        var args = splitStrings(pasted);
+        if (args.length > 1) {
+          var newList = [];
+          args.forEach(function (arg) {
+            var obj = {};
+            obj[valueAccessor().objectKey] = arg;
+            newList.push(obj);
+          });
+          valueAccessor().list(ko.mapping.fromJS(newList)());
+          valueAccessor().callback();
+        }
+      });
+
+    }
+  };
+
+
   var aceInstancesById = {},
   var aceInstancesById = {},
     aceInitId = 0;
     aceInitId = 0;