Repository: ambari Updated Branches: refs/heads/trunk 4db1ddac6 -> 05d8743bc
AMBARI-15843 Adding Test Connection widget to a theme for custom service requires JS change. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/05d8743b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/05d8743b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/05d8743b Branch: refs/heads/trunk Commit: 05d8743bcb587ab1a6646583ee8f83d3a2e5c2ff Parents: 4db1dda Author: ababiichuk <[email protected]> Authored: Tue Apr 12 19:47:45 2016 +0300 Committer: ababiichuk <[email protected]> Committed: Wed Apr 13 13:42:07 2016 +0300 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 18 +++++++++-- .../app/controllers/wizard/step7_controller.js | 33 ++++++++++++++------ ambari-web/app/models/stack_service.js | 5 --- ambari-web/app/utils/config.js | 12 +++++++ .../widgets/test_db_connection_widget_view.js | 15 ++++++++- ambari-web/test/utils/config_test.js | 13 ++++++++ 6 files changed, 77 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 6437bf8..b589040 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -556,9 +556,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A addHostNamesToConfigs: function(serviceConfig) { serviceConfig.get('configCategories').forEach(function(c) { if (c.showHost) { - var stackComponent = App.StackServiceComponent.find(c.name); - var component = stackComponent.get('isMaster') ? App.MasterComponent.find(c.name) : App.SlaveComponent.find(c.name); - var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), c.name, component.get('hostNames') || [], stackComponent); + var stackComponent = App.StackServiceComponent.find(c.name), + value = this.getComponentHostValue(c.name); + var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), c.name, value, stackComponent); serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty)); } }, this); @@ -580,6 +580,18 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A }, /** + * Method to get host for master or slave component + * + * @param componentName + * @returns {Array} + */ + getComponentHostValue: function(componentName) { + var stackComponent = App.StackServiceComponent.find(componentName); + var component = stackComponent.get('isMaster') ? App.MasterComponent.find(componentName) : App.SlaveComponent.find(componentName); + return component.get('hostNames') || [] + }, + + /** * Trigger loadSelectedVersion * @method doCancel */ http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/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 029ca20..eb44842 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -774,17 +774,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) { serviceConfig.get('configCategories').forEach(function(c) { if (c.showHost) { - var value = []; var componentName = c.name; - var masters = masterComponents && masterComponents.filterProperty('component', componentName); - if (masters.length) { - value = masters.mapProperty('hostName'); - } else { - var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName); - if (slaves) { - value = slaves.hosts.mapProperty('hostName'); - } - } + var value = this.getComponentHostValue(componentName, masterComponents, slaveComponents); var stackComponent = App.StackServiceComponent.find(componentName); var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent); var newConfigName = Em.get(hProperty, 'name'); @@ -796,6 +787,28 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E }, /** + * Method to get host for master or slave component + * + * @param componentName + * @param masterComponents + * @param slaveComponents + * @returns {Array} + */ + getComponentHostValue: function(componentName, masterComponents, slaveComponents) { + var value = []; + var masters = masterComponents && masterComponents.filterProperty('component', componentName); + if (masters.length) { + value = masters.mapProperty('hostName'); + } else { + var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName); + if (slaves) { + value = slaves.hosts.mapProperty('hostName'); + } + } + return value || []; + }, + + /** * create new child configs from overrides, attach them to parent config * override - value of config, related to particular host(s) * @param configProperty http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/ambari-web/app/models/stack_service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/stack_service.js b/ambari-web/app/models/stack_service.js index 649bf89..c1a5bf5 100644 --- a/ambari-web/app/models/stack_service.js +++ b/ambari-web/app/models/stack_service.js @@ -346,11 +346,6 @@ App.StackService.configCategories = function () { App.ServiceConfigCategory.create({ name: 'KnoxSSOSettings', displayName: 'Knox SSO Settings'}) ]); break; - case 'RANGER_KMS': - serviceConfigCategories.pushObjects([ - App.ServiceConfigCategory.create({ name: 'RANGER_KMS_SERVER', displayName: 'Ranger KMS Server', showHost: true}) - ]); - break; case 'ACCUMULO': serviceConfigCategories.pushObjects([ App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}) http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index 50c6c4a..f78cf8f 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -347,6 +347,18 @@ App.config = Em.Object.create({ }, /** + * Get component name from config name string + * + * @param configName + * @returns {string} + */ + getComponentName: function(configName) { + var match = configName.match(/^(.*)_host[s]?$/) || [], + component = match[1]; + return component ? component.toUpperCase() : ""; + }, + + /** * This method merge properties form <code>stackConfigProperty<code> which are taken from stack * with <code>UIConfigProperty<code> which are hardcoded on UI * @param coreObject http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js b/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js index 87d0359..39f7e6e 100644 --- a/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js @@ -78,7 +78,20 @@ App.TestDbConnectionWidgetView = App.ConfigWidgetView.extend({ var split = requiredProperties[key].split('/'); var fileName = split[0] + '.xml'; var configName = split[1]; - return serviceConfigs.filterProperty('filename',fileName).findProperty('name', configName); + var requiredConfig = serviceConfigs.filterProperty('filename',fileName).findProperty('name', configName); + if (!requiredConfig) { + var componentName = App.config.getComponentName(configName); + var stackComponent = App.StackServiceComponent.find(componentName); + if (stackComponent && stackComponent.get('componentName')) { + var value = this.get('controller').getComponentHostValue(componentName, + this.get('controller.wizardController.content.masterComponentHosts'), + this.get('controller.wizardController.content.slaveComponentHosts')); + var hProperty = App.config.createHostNameProperty(serviceName, componentName, value, stackComponent); + return App.ServiceConfigProperty.create(hProperty); + } + } else { + return requiredConfig; + } }, this); this.set('requiredProperties', requiredServiceConfigs); http://git-wip-us.apache.org/repos/asf/ambari/blob/05d8743b/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index 8ac5bff..1a2d899 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -874,4 +874,17 @@ describe('App.config', function () { }); }); + describe('#getComponentName', function () { + [ + { configName: 'somename_host', componentName: 'SOMENAME' }, + { configName: 'somename_hosts', componentName: 'SOMENAME' }, + { configName: 'somenamehost', componentName: '' }, + { configName: 'somenamehosts', componentName: '' } + ].forEach(function (t) { + it('format config name ' + t.configName + ' to component ', function() { + expect(App.config.getComponentName(t.configName)).to.equal(t.componentName); + }); + }); + }); + });
