Updated Branches: refs/heads/trunk 90f00a2a4 -> c7d94be5a
AMBARI-4397 Add Services: existing Nagios's password and email is cleared out and shows validation error. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c7d94be5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c7d94be5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c7d94be5 Branch: refs/heads/trunk Commit: c7d94be5a0294e3be31eabb09bc4a9e0cf2bc373 Parents: 90f00a2 Author: atkach <[email protected]> Authored: Thu Jan 23 18:34:52 2014 +0200 Committer: atkach <[email protected]> Committed: Thu Jan 23 18:34:52 2014 +0200 ---------------------------------------------------------------------- .../app/controllers/wizard/step7_controller.js | 78 ++++++++++++++++++-- ambari-web/app/utils/config.js | 10 +-- 2 files changed, 77 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c7d94be5/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 34b8592..009c89f 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -55,6 +55,10 @@ App.WizardStep7Controller = Em.Controller.extend({ groupsToDelete: [], selectedConfigGroup: null, + /** + * config tags of actually installed services + */ + serviceConfigTags: [], serviceConfigsData: require('data/service_configs'), @@ -66,8 +70,12 @@ App.WizardStep7Controller = Em.Controller.extend({ return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName'); }.property('content.services').cacheable(), - allInstalledServiceNames: function () { - return this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName'); + allSelectedServiceNames: function () { + return this.get('content.services').filterProperty('isSelected').mapProperty('serviceName'); + }.property('content.services').cacheable(), + + installedServiceNames: function () { + return this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName'); }.property('content.services').cacheable(), masterComponentHosts: function () { @@ -81,6 +89,7 @@ App.WizardStep7Controller = Em.Controller.extend({ customData: [], clearStep: function () { + this.get('serviceConfigTags').clear(); this.get('stepConfigs').clear(); this.set('filter', ''); this.get('filterColumns').setEach('selected', false); @@ -111,7 +120,6 @@ App.WizardStep7Controller = Em.Controller.extend({ var serviceConfigsDef = params.serviceConfigsDef; var serviceName = params.serviceName; var service = this.get('stepConfigs').findProperty('serviceName', serviceName); - console.debug("loadServiceConfigs(): data=", data); // Create default configuration group var defaultConfigGroupHosts = App.Host.find().mapProperty('hostName'); var selectedConfigGroup; @@ -319,7 +327,7 @@ App.WizardStep7Controller = Em.Controller.extend({ //STEP 5: Add custom configs App.config.addCustomConfigs(configs); //put properties from capacity-scheduler.xml into one config with textarea view - if(this.get('allInstalledServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi){ + if (this.get('allSelectedServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi) { configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml'); } this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []); @@ -328,8 +336,12 @@ App.WizardStep7Controller = Em.Controller.extend({ masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'), slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts') }; + if (this.get('wizardController.name') === 'addServiceController') { + this.getConfigTags(); + this.setInstalledServiceConfigs(this.get('serviceConfigTags'), configs); + } //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs) - var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allInstalledServiceNames'), this.get('selectedServiceNames'), localDB); + var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB); if (this.get('wizardController.name') === 'addServiceController') { serviceConfigs.setEach('showConfig', true); serviceConfigs.setEach('selected', false); @@ -363,6 +375,53 @@ App.WizardStep7Controller = Em.Controller.extend({ App.router.send('next'); } }, + getConfigTags: function() { + App.ajax.send({ + name: 'config.tags.sync', + sender: this, + success: 'getConfigTagsSuccess' + }); + }, + + getConfigTagsSuccess: function (data, opt, params) { + var installedServiceSites = []; + this.get('serviceConfigsData').filter(function (service) { + if (this.get('installedServiceNames').contains(service.serviceName)){ + installedServiceSites = installedServiceSites.concat(service.sites); + } + }, this); + installedServiceSites = installedServiceSites.uniq(); + var serviceConfigTags = []; + for (var site in data.Clusters.desired_configs) { + if (installedServiceSites.contains(site)) { + serviceConfigTags.push({ + siteName: site, + tagName: data.Clusters.desired_configs[site].tag, + newTagName: null + }); + } + } + this.set('serviceConfigTags', serviceConfigTags); + }, + + /** + * set configs actual values from server + * @param serviceConfigTags + * @param configs + */ + setInstalledServiceConfigs: function (serviceConfigTags, configs) { + var configsMap = {}; + App.router.get('configurationController').getConfigsByTags(serviceConfigTags).forEach(function(configSite){ + $.extend(configsMap, configSite.properties); + }); + configs.forEach(function (_config) { + if (configsMap[_config.name] !== undefined) { + _config.value = configsMap[_config.name]; + _config.defaultValue = configsMap[_config.name]; + App.config.handleSpecialProperties(_config); + } + }) + }, setGroupsToDelete: function(groups) { var groupsToDelete = this.get('groupsToDelete'); @@ -443,6 +502,7 @@ App.WizardStep7Controller = Em.Controller.extend({ var serviceConfigs = this.get('selectedService.configs'); var selectedGroup = this.get('selectedConfigGroup'); var overrideToAdd = this.get('overrideToAdd'); + var isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName')); if(!selectedGroup) return; var displayedConfigGroups = (selectedGroup.get('isDefault')) ? this.get('selectedService.configGroups').filterProperty('isDefault', false) : @@ -454,7 +514,13 @@ App.WizardStep7Controller = Em.Controller.extend({ }); serviceConfigs.forEach(function (config) { var configOverrides = overrides.filterProperty('name', config.get('name')); - config.set('isEditable', selectedGroup.get('isDefault')); + var isEditable = config.get('isEditable'); + if (isServiceInstalled) { + isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault'); + } else { + isEditable = selectedGroup.get('isDefault'); + } + config.set('isEditable', isEditable); if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) { configOverrides.push(this.addOverrideProperty(config)); this.set('overrideToAdd', null); http://git-wip-us.apache.org/repos/asf/ambari/blob/c7d94be5/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index edb4b87..5ee0bf7 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -509,19 +509,19 @@ App.config = Em.Object.create({ * and wrap each in ServiceConfigProperty object * @param configs * @param storedConfigs - * @param allInstalledServiceNames - * @param selectedServiceNames + * @param allSelectedServiceNames + * @param installedServiceNames * @param localDB * @return {Array} */ - renderConfigs: function (configs, storedConfigs, allInstalledServiceNames, selectedServiceNames, localDB) { + renderConfigs: function (configs, storedConfigs, allSelectedServiceNames, installedServiceNames, localDB) { var renderedServiceConfigs = []; var services = []; this.get('preDefinedServiceConfigs').forEach(function (serviceConfig) { - if (allInstalledServiceNames.contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') { + if (allSelectedServiceNames.contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') { console.log('pushing ' + serviceConfig.serviceName, serviceConfig); - if (selectedServiceNames.contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') { + if (!installedServiceNames.contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') { serviceConfig.showConfig = true; } services.push(serviceConfig);
