瀏覽代碼

HUE-1803 [oozie] Global configuration mapping

Romain Rigaux 12 年之前
父節點
當前提交
eb47ec3

+ 10 - 10
apps/oozie/src/oozie/models.py

@@ -71,8 +71,8 @@ DEFAULT_SLA = [
     {'key': 'notification-msg', 'value': ''},
     {'key': 'upstream-apps', 'value': ''},
 ]
-DEFAULT_GLOBAL_PROPERTIES = [{}]
-DEFAULT_GLOBAL_CONFIG = [{}]
+DEFAULT_GLOBAL_PROPERTIES = []
+DEFAULT_GLOBAL_CONFIG = []
 
 class JobManager(models.Manager):
 
@@ -227,10 +227,10 @@ class Job(models.Model):
     # Backward compatibility
     if 'sla' not in data_python:
       data_python['sla'] = copy.deepcopy(DEFAULT_SLA)
-    if 'global_properties' not in data_python:
-      data_python['global_properties'] = DEFAULT_GLOBAL_PROPERTIES
-    if 'global_config' not in data_python:
-      data_python['global_config'] = DEFAULT_GLOBAL_CONFIG     
+    if 'globalProperties' not in data_python:
+      data_python['globalProperties'] = DEFAULT_GLOBAL_PROPERTIES
+    if 'globalConfig' not in data_python:
+      data_python['globalConfig'] = DEFAULT_GLOBAL_CONFIG     
     return data_python 
 
   @property
@@ -253,22 +253,22 @@ class Job(models.Model):
 
   @property
   def global_properties(self):
-    return self.data_dict['global_properties']
+    return self.data_dict['globalProperties']
 
   @global_properties.setter
   def global_properties(self, global_properties): 
     data_ = self.data_dict
-    data_['global_properties'] = global_properties
+    data_['globalProperties'] = global_properties
     self.data = json.dumps(data_)
 
   @property
   def global_config(self):
-    return self.data_dict['global_config']
+    return self.data_dict['globalConfig']
 
   @global_config.setter
   def global_config(self, global_config): 
     data_ = self.data_dict
-    data_['global_config'] = global_config
+    data_['globalConfig'] = global_config
     self.data = json.dumps(data_)
 
 

+ 16 - 0
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -117,6 +117,22 @@ ${ layout.menubar(section='workflows') }
         </div>
 
       <div id="advanced-container" class="hide">
+
+        <div id="globalPropertiesEditord" class="control-group">
+          <label class="control-label">
+              ${ _('Global properties') }
+          </label>
+          
+	      <%
+	      workflows.key_value_field(type('globalProperties', (object,), {'label': 'l', 'help_text': 'h'}), {
+	        'name': 'globalProperties',
+	        'remove': '$root.removeGlobalProperties',
+	        'add': '$root.addGlobalProperties',
+	      })
+	      %>
+
+          ${ utils.globalConfigForm() }
+        </div>   
       
         <div id="slaEditord" class="control-group">
           <label class="control-label">

+ 26 - 9
apps/oozie/static/js/workflow.js

@@ -426,21 +426,21 @@ var WorkflowModule = function($, NodeModelChooser, Node, ForkNode, DecisionNode,
     self.el = (options.el) ? $(options.el) : $('#workflow');
     self.nodes = ko.observableArray([]);
     self.kill = null;
-    self.is_dirty = ko.observable( false );
-    self.loading = ko.observable( false );
-    self.read_only = ko.observable( options.read_only || false );
+    self.is_dirty = ko.observable(false);
+    self.loading = ko.observable(false);
+    self.read_only = ko.observable(options.read_only || false);
     self.new_node = ko.observable();
 
     // Create fields from the generic data field
     self.sla = ko.computed(function() {
       return self.data.sla();
     });
-//    self.globalProperties = ko.computed(function() {
-//        return self.data.globalProperties();
-//      });     
-//    self.globalConfig = ko.computed(function() {
-//      return self.data.globalConfig();
-//    });
+    self.globalProperties = ko.computed(function() {
+        return self.data.globalProperties();
+      });     
+    self.globalConfig = ko.computed(function() {
+      return self.data.globalConfig();
+    });
 
     self.url = ko.computed(function() {
       return '/oozie/workflows/' + self.id();
@@ -688,6 +688,23 @@ var WorkflowModule = function($, NodeModelChooser, Node, ForkNode, DecisionNode,
       self.job_properties.remove(data);
     },
 
+    addGlobalProperties: function(data, event) {
+      var self = this;
+      var prop = { name: ko.observable(""), value: ko.observable("") };
+      // force bubble up to containing observable array.
+//      prop.name.subscribe(function(){
+//        self.globalProperties.valueHasMutated();
+//      });
+//      prop.value.subscribe(function(){
+//        self.globalProperties.valueHasMutated();
+//      });
+      self.globalProperties.push(prop);
+    },
+	removeGlobalProperties: function(data, event) {
+	  var self = this;
+      self.globalProperties.remove(data);
+    },    
+    
     // Workflow UI
     // Function to build nodes... recursively.
     build: function() {