Repository: ambari Updated Branches: refs/heads/branch-1.7.0 aeaa66a72 -> de214f22e
AMBARI-7839. Slider View: java_home config value should be populated from API property (Max Shepel via srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/de214f22 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/de214f22 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/de214f22 Branch: refs/heads/branch-1.7.0 Commit: de214f22e9feff927d204b04c52f20d1f9c26276 Parents: aeaa66a Author: Srimanth Gunturi <[email protected]> Authored: Fri Oct 17 10:54:13 2014 -0700 Committer: Srimanth Gunturi <[email protected]> Committed: Fri Oct 17 11:01:57 2014 -0700 ---------------------------------------------------------------------- .../createAppWizard/step3_controller.js | 4 ++ .../ui/app/controllers/slider_controller.js | 1 + .../src/main/resources/ui/app/initialize.js | 8 ++- .../app/templates/components/configSection.hbs | 2 +- .../createAppWizard/step3_controller_test.js | 59 ++++++++++++++++++++ .../unit/controllers/slider_controller_test.js | 6 +- 6 files changed, 77 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js index 308378d..81552b5 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js @@ -136,6 +136,10 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({ $.extend({name: key, value: newAppConfigs[key], label: label}, configSettings[key]) : {name: key, value: newAppConfigs[key], label: label}; + if (key === 'java_home' && !!setDefaults && App.get('javaHome')) { + configSetting.value = App.get('javaHome'); + } + if (key === "site.global.ganglia_server_host" && !!setDefaults && App.get('gangliaHost')) { configSetting.value = App.get('gangliaHost'); } http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js index 303e361..e4476fd 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js @@ -52,6 +52,7 @@ App.SliderController = Ember.Controller.extend(App.RunPeriodically, { getViewDisplayParametersSuccessCallback: function(data) { App.set('description', Em.get(data, 'ViewInstanceInfo.description')); App.set('label', Em.get(data, 'ViewInstanceInfo.label')); + App.set('javaHome', Em.get(data, 'ViewInstanceInfo.instance_data') && Em.get(data, 'ViewInstanceInfo.instance_data')['java.home']); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/app/initialize.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/initialize.js b/contrib/views/slider/src/main/resources/ui/app/initialize.js index 090c894..42bfb3f 100755 --- a/contrib/views/slider/src/main/resources/ui/app/initialize.js +++ b/contrib/views/slider/src/main/resources/ui/app/initialize.js @@ -112,7 +112,13 @@ App.initializer({ * Last time when mapper ran * @type {null|number} */ - mapperTime: null + mapperTime: null, + + /** + * Default java_home value for Slider View instance + * @type {string|null} + */ + javaHome: null }); if(!window.QUnit) { http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs index 2446e0c..f92b1b1 100644 --- a/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs +++ b/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs @@ -16,7 +16,7 @@ * limitations under the License. }} -{{#bs-panel heading=sectionLabel collapsible=true dismiss=false open=isGeneral }} +{{#bs-panel heading=sectionLabel collapsible=true dismiss=false open=false }} <form class="form-horizontal" role="form"> {{#each config in sectionConfigs}} {{#if config.isSet}} http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step3_controller_test.js b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step3_controller_test.js new file mode 100644 index 0000000..56346b2 --- /dev/null +++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step3_controller_test.js @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +moduleFor('controller:createAppWizardStep3', 'App.CreateAppWizardStep3Controller', { + + needs: [ + 'controller:createAppWizard', + 'controller:slider' + ] + +}); + +test('initConfigs', function () { + + var controller = this.subject(), + wizardController = controller.get('controllers.createAppWizard'); + + Em.run(function () { + wizardController.setProperties({ + content: {}, + newApp: { + appType: { + configs: [] + }, + configs: { + java_home: '/usr/jdk64/jdk1.7.0_40' + } + } + }); + App.__container__.lookup('controller:slider').getViewDisplayParametersSuccessCallback({ + "ViewInstanceInfo" : { + "instance_data": { + "java.home": "/usr/jdk64/jdk1.7.0_45" + } + } + }); + Em.run(function () { + controller.initConfigs(true); + }); + }); + + equal(controller.get('configs').findBy('label', 'java_home').get('value'), '/usr/jdk64/jdk1.7.0_45', 'should set default java_home property value'); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/de214f22/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_controller_test.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_controller_test.js b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_controller_test.js index d953cc3..474d209 100644 --- a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_controller_test.js +++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_controller_test.js @@ -25,11 +25,15 @@ test('getViewDisplayParametersSuccessCallback', function () { sliderController.getViewDisplayParametersSuccessCallback({ "ViewInstanceInfo" : { "description" : "description s1", - "label" : "display s1" + "label" : "display s1", + "instance_data": { + "java.home": "/usr/jdk64/jdk1.7.0_45" + } } }) }); equal(App.get('label'), 'display s1', 'valid label is set'); equal(App.get('description'), 'description s1', 'valid description is set'); + equal(App.get('javaHome'), '/usr/jdk64/jdk1.7.0_45', 'valid default java_home property is set'); });
