AMBARI-7611 Host configs page broken when there is no host-components. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/efbaf5cb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/efbaf5cb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/efbaf5cb Branch: refs/heads/branch-alerts-dev Commit: efbaf5cbd33bbd4ab3a837513992741c59f41063 Parents: cc4dfe3 Author: atkach <[email protected]> Authored: Thu Oct 2 15:47:51 2014 +0300 Committer: atkach <[email protected]> Committed: Thu Oct 2 15:47:51 2014 +0300 ---------------------------------------------------------------------- ambari-web/app/styles/application.less | 2 +- ambari-web/app/templates/main/host/configs.hbs | 22 +++++++----- ambari-web/app/views/main/host/configs.js | 6 +++- .../app/views/main/host/configs_service_menu.js | 37 +++++++++----------- 4 files changed, 36 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/efbaf5cb/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 96bb32e..ced5c4e 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -1061,7 +1061,7 @@ h1 { margin: 0 auto; } -#services-menu { +.services-host-menu { margin-top: 20px; padding: 8px 0; } http://git-wip-us.apache.org/repos/asf/ambari/blob/efbaf5cb/ambari-web/app/templates/main/host/configs.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/configs.hbs b/ambari-web/app/templates/main/host/configs.hbs index 1f0d3e2..f9d85ce 100644 --- a/ambari-web/app/templates/main/host/configs.hbs +++ b/ambari-web/app/templates/main/host/configs.hbs @@ -16,11 +16,17 @@ * limitations under the License. }} -<div class="row-fluid" style="margin-top: 7px;"> - <div id="services-menu" class="well span2"> - {{view App.MainHostServiceMenuView}} - </div> - <div class="span10"> - {{outlet service_config_outlet}} - </div> -</div> +{{#if view.isConfigAvailable}} + <div class="row-fluid"> + <div class="well span2 services-host-menu"> + {{view App.MainHostServiceMenuView}} + </div> + <div class="span10"> + {{outlet service_config_outlet}} + </div> + </div> +{{else}} + <div class="services-host-menu"> + <i class="message alert alert-info">{{t hosts.host.serviceNotAvailable}}</i> + </div> +{{/if}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/efbaf5cb/ambari-web/app/views/main/host/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/configs.js b/ambari-web/app/views/main/host/configs.js index a3e42f8..1b8054b 100644 --- a/ambari-web/app/views/main/host/configs.js +++ b/ambari-web/app/views/main/host/configs.js @@ -24,6 +24,10 @@ App.MainHostConfigsView = Em.View.extend({ content: function(){ return App.router.get('mainHostDetailsController.content'); - }.property('App.router.mainHostDetailsController.content') + }.property('App.router.mainHostDetailsController.content'), + + isConfigAvailable: function () { + return !!this.get('content.hostComponents.length'); + }.property('content.hostComponents.length') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/efbaf5cb/ambari-web/app/views/main/host/configs_service_menu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/configs_service_menu.js b/ambari-web/app/views/main/host/configs_service_menu.js index 4724573..30e7c2b 100644 --- a/ambari-web/app/views/main/host/configs_service_menu.js +++ b/ambari-web/app/views/main/host/configs_service_menu.js @@ -20,7 +20,7 @@ var App = require('app'); var misc = require('utils/misc'); App.MainHostServiceMenuView = Em.CollectionView.extend({ - content:function () { + content: function () { var host = this.get('host'); var hostComponents = host.get('hostComponents'); var services = Em.A([]); @@ -29,7 +29,7 @@ App.MainHostServiceMenuView = Em.CollectionView.extend({ var service = hc.get('service'); if (service) { var serviceName = service.get('serviceName'); - if(!App.get('services.noConfigTypes').contains(serviceName)){ + if (!App.get('services.noConfigTypes').contains(serviceName)) { if (!services.findProperty('serviceName', serviceName)) { services.push(service); } @@ -42,43 +42,38 @@ App.MainHostServiceMenuView = Em.CollectionView.extend({ var stackServices = App.StackService.find().mapProperty('serviceName'); return misc.sortByOrder(stackServices, services); }.property('host'), - - host: function(){ + + host: function () { return App.router.get('mainHostDetailsController.content'); }.property('App.router.mainHostDetailsController.content'), - + selectedService: null, - - showHostService: function(event){ + + showHostService: function (event) { var service = event.contexts[0]; - if(service != null) { + if (!Em.isNone(service)) { this.set('selectedService', service); var context = service; context.host = this.get('host'); this.get('controller').connectOutlet('service_config_outlet', 'mainHostServiceConfigs', context); } - else { - this.get('controller').connectOutlet('service_config_outlet', Em.View.extend({ - template: Ember.Handlebars.compile('<i class="message">{{t hosts.host.serviceNotAvailable}}</i>') - })) - } }, - didInsertElement:function () { + didInsertElement: function () { var event = { - contexts: [this.get('content').objectAt(0)] + contexts: [this.get('content').objectAt(0)] }; this.showHostService(event); }, - activeServiceId:null, + activeServiceId: null, - tagName:'ul', - classNames:["nav", "nav-list", "nav-services"], + tagName: 'ul', + classNames: ["nav", "nav-list", "nav-services"], - itemViewClass:Em.View.extend({ - classNameBindings:["active", "clients"], - active:function () { + itemViewClass: Em.View.extend({ + classNameBindings: ["active", "clients"], + active: function () { return this.get('content.serviceName') == this.get('parentView.selectedService.serviceName') ? 'active' : ''; }.property('parentView.selectedService.serviceName'), template: Ember.Handlebars.compile('<a href="#" {{action showHostService view.content target="view.parentView"}} >{{view.content.displayName}}</a>')
