Browse Source

AMBARI-2607: Ambari manage properties should be relative to a configuration site. (jaimin)

Jaimin Jetly 12 years ago
parent
commit
6106dff05b

+ 21 - 1
ambari-web/app/utils/config.js

@@ -108,6 +108,26 @@ App.config = Em.Object.create({
       return [];
     }
   }.property('App.isHadoop2Stack'),
+
+  /**
+   *
+   * @param siteNames
+   * @returns {Array}
+   */
+  getBySitename: function (siteNames) {
+    var computedConfigs = this.get('configMapping').computed();
+    var siteProperties = [];
+    if (typeof siteNames === "string") {
+      siteProperties = computedConfigs.filterProperty('filename', siteNames);
+    } else if (siteNames instanceof Array) {
+      siteNames.forEach(function (_siteName) {
+        siteProperties = siteProperties.concat(computedConfigs.filterProperty('filename', _siteName));
+      }, this);
+    }
+    return siteProperties;
+  },
+
+
   /**
    * Cache of loaded configurations. This is useful in not loading
    * same configuration multiple times. It is populated in multiple
@@ -253,7 +273,7 @@ App.config = Em.Object.create({
           serviceConfigObj.displayName = configsPropertyDef ? configsPropertyDef.displayName : null;
           serviceConfigObj.options = configsPropertyDef ? configsPropertyDef.options : null;
           globalConfigs.push(serviceConfigObj);
-        } else if (!this.get('configMapping').computed().someProperty('name', index)) {
+        } else if (!this.getBySitename(serviceConfigObj.get('filename')).someProperty('name', index)) {
           isAdvanced = advancedConfigs.someProperty('name', index);
           serviceConfigObj.id = 'site property';
           serviceConfigObj.displayType = stringUtils.isSingleLine(serviceConfigObj.value) ? 'advanced' : 'multiLine';

+ 2 - 1
ambari-web/app/views/common/configs/services_config.js

@@ -368,6 +368,7 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({
   },
   showAddPropertyWindow: function (event) {
     var configsOfFile = this.get('service.configs').filterProperty('filename', this.get('category.siteFileName'));
+    var self =this;
     var serviceConfigObj = Ember.Object.create({
       name: '',
       value: '',
@@ -380,7 +381,7 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({
         var name = this.get('name');
         if (name.trim() != "") {
           if (validator.isValidConfigKey(name)) {
-            var configMappingProperty = App.config.get('configMapping').all().findProperty('name', name);
+            var configMappingProperty = App.config.get('configMapping').all().filterProperty('filename',self.get('category.siteFileName')).findProperty('name', name);
             if ((configMappingProperty == null) && (!configsOfFile.findProperty('name', name))) {
               this.set("isKeyError", false);
               this.set("errorMessage", "");