AMBARI-7277 Slider View: Creating app without metrics should not show Metrics section. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e10ec8b0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e10ec8b0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e10ec8b0 Branch: refs/heads/branch-alerts-dev Commit: e10ec8b0943eda245c6ae6959b31430c45515f4a Parents: 18f427d Author: atkach <atk...@hortonworks.com> Authored: Fri Sep 12 14:48:05 2014 +0300 Committer: atkach <atk...@hortonworks.com> Committed: Fri Sep 12 14:48:05 2014 +0300 ---------------------------------------------------------------------- .../createAppWizard/step1_controller.js | 26 +++++++++++--------- .../createAppWizard/step3_controller.js | 4 +++ .../main/resources/ui/app/models/slider_app.js | 7 +++++- .../app/templates/components/configSection.hbs | 3 ++- 4 files changed, 27 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e10ec8b0/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js index 9faaa32..9ffc432 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js @@ -139,18 +139,22 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend({ */ loadGangliaClustersSuccessCallback: function (data) { var gangliaCustomClusters = []; + if (data.items[0]) { - //parse CSV string with cluster names and ports - Em.get(data.items[0].configurations[0].properties, 'ganglia_custom_clusters').replace(/\'/g, "").split(',').forEach(function(item, index){ - if (index % 2 === 0) { - gangliaCustomClusters.push({ - name: item - }) - } else { - gangliaCustomClusters[gangliaCustomClusters.length - 1].port = parseInt(item); - } - }); - App.set('gangliaClusters', gangliaCustomClusters); + var prop = Em.get(data.items[0].configurations[0].properties, 'ganglia_custom_clusters'); + if (prop) { + //parse CSV string with cluster names and ports + prop.replace(/\'/g, "").split(',').forEach(function(item, index){ + if (index % 2 === 0) { + gangliaCustomClusters.push({ + name: item + }) + } else { + gangliaCustomClusters[gangliaCustomClusters.length - 1].port = parseInt(item); + } + }); + App.set('gangliaClusters', gangliaCustomClusters); + } } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/e10ec8b0/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 a2eaa2e..2dd5b72 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 @@ -76,6 +76,7 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({ */ configsSet: [ { + name: 'ganglia_metrics', trigger: {value: false, label: Em.I18n.t('configs.enable.metrics'), viewType: 'checkbox'}, isSet: true, section: 'global', @@ -152,6 +153,9 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({ configsSet.forEach(function (configSet) { if (configSet.configs.length === configSet.configNames.length) { delete configSet.configNames; + if (configSet.name === 'ganglia_metrics') { + configSet.trigger.readOnly = (!App.get('gangliaClusters') || App.get('gangliaClusters').length === 0); + } configSet.trigger = App.ConfigProperty.create(configSet.trigger); this.initConfigSetDependecies(configSet); configs.unshift(configSet); http://git-wip-us.apache.org/repos/asf/ambari/blob/e10ec8b0/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js index bf02f30..3710877 100644 --- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js +++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js @@ -112,8 +112,13 @@ App.SliderApp = DS.Model.extend({ * @type {boolean} */ showMetrics: function() { + var global = this.get('configs')['global']; + //check whether slider has GANGLIA configured if not metrics should be hidden + if (!(global['ganglia_server_host'] && global['ganglia_server_id'] && global['ganglia_server_port'])) { + return false; + } return App.SliderApp.Status.running === this.get('status'); - }.property('status'), + }.property('status', 'configs'), /** * Map object to array http://git-wip-us.apache.org/repos/asf/ambari/blob/e10ec8b0/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 dca8f9d..326218a 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 @@ -26,7 +26,8 @@ <div class="col-sm-6"> {{view view.configSet.trigger.view - checked=view.configSet.trigger.value + checked=view.configSet.trigger.value + disabled=view.configSet.trigger.readOnly }} </div> </div>