Repository: ambari Updated Branches: refs/heads/trunk f1273f29d -> b6851a877
AMBARI-6784. Provide 'Add Flume Component' action in Flume service actions menu Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b6851a87 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b6851a87 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b6851a87 Branch: refs/heads/trunk Commit: b6851a877b6252593678e35e553e5280f86137f8 Parents: f1273f2 Author: Srimanth Gunturi <[email protected]> Authored: Thu Aug 7 16:51:28 2014 -0700 Committer: Srimanth Gunturi <[email protected]> Committed: Thu Aug 7 20:27:47 2014 -0700 ---------------------------------------------------------------------- ambari-web/app/controllers/main/service/item.js | 84 +++++--------------- ambari-web/app/messages.js | 1 + ambari-web/app/templates/main/service/item.hbs | 8 +- ambari-web/app/views/main/service/item.js | 41 ++++++---- 4 files changed, 53 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b6851a87/ambari-web/app/controllers/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js index 255bde0..0aaf78c 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -52,30 +52,37 @@ App.MainServiceItemController = Em.Controller.extend({ var hostNames = App.Host.find().mapProperty('hostName'); this.set('allHosts', hostNames); - ['HBASE_MASTER', 'ZOOKEEPER_SERVER'].forEach(function(componentName) { + ['HBASE_MASTER', 'ZOOKEEPER_SERVER', 'FLUME_HANDLER'].forEach(function(componentName) { self.loadHostsWithoutComponent(componentName); }); } }.observes('App.components.masters', 'content.hostComponents.length'), loadHostsWithoutComponent: function (componentName) { + var self = this; var hostsWithComponent = App.HostComponent.find().filterProperty('componentName', componentName).mapProperty('hostName'); var hostsWithoutComponent = this.get('allHosts').filter(function(hostName) { return !hostsWithComponent.contains(hostName); }); + self.set('add' + componentName, function() { + self.addComponent(componentName); + }); - if (componentName === 'HBASE_MASTER') { - this.set('hostsWithoutHBaseMaster', hostsWithoutComponent); - var disabledMsg = Em.I18n.t('services.summary.allHostsAlreadyRunComponent').format(Em.I18n.t('dashboard.services.hbase.masterServer')); - this.set('addHBaseMasterDisabledMsg', disabledMsg); - } - if (componentName === 'ZOOKEEPER_SERVER') { - this.set('hostsWithoutZookeeperServer', hostsWithoutComponent); - var disabledMsg = Em.I18n.t('services.summary.allHostsAlreadyRunComponent').format(Em.I18n.t('dashboard.services.zookeeper.server')); - this.set('addZookeeperServerDisabledMsg', disabledMsg); - } + Em.defineProperty(self, 'addDisabledTooltip-' + componentName, Em.computed('isAddDisabled-' + componentName, 'addDisabledMsg-' + componentName, function() { + if (self.get('isAddDisabled-' + componentName)) { + return self.get('addDisabledMsg-' + componentName); + } + })); + + Em.defineProperty(self, 'isAddDisabled-' + componentName, Em.computed('hostsWithoutComponent-' + componentName, function() { + return self.get('hostsWithoutComponent-' + componentName).length === 0 ? 'disabled' : ''; + })); + + var disabledMsg = Em.I18n.t('services.summary.allHostsAlreadyRunComponent').format(componentName); + self.set('hostsWithoutComponent-' + componentName, hostsWithoutComponent); + self.set('addDisabledMsg-' + componentName, disabledMsg); }, /** @@ -92,34 +99,6 @@ App.MainServiceItemController = Em.Controller.extend({ return !App.get('services.noConfigTypes').concat('HCATALOG').contains(this.get('content.serviceName')); }.property('App.services.noConfigTypes','content.serviceName'), - isAddHBaseMasterDisabled: function() { - return this.get('hostsWithoutHBaseMaster').length === 0; - }.property('hostsWithoutHBaseMaster'), - - addHBaseMasterDisabledMsg: null, - - addHBaseMasterDisabledTooltip: function() { - if (this.get('isAddHBaseMasterDisabled')) { - return this.get('addHBaseMasterDisabledMsg'); - } - }.property('isAddHBaseMasterDisabled', 'addHBaseMasterDisabledMsg'), - - hostsWithoutHBaseMaster: [], - - isAddZooKeeperServerDisabled: function() { - return this.get('hostsWithoutZookeeperServer').length === 0; - }.property('hostsWithoutZookeeperServer'), - - addZookeeperServerDisabledMsg: null, - - addZooKeeperServerDisabledTooltip: function() { - if (this.get('isAddZooKeeperServerDisabled')) { - return this.get('addZookeeperServerDisabledMsg'); - } - }.property('isAddZooKeeperServerDisabled', 'addZookeeperServerDisabledMsg'), - - hostsWithoutZookeeperServer: [], - allHosts: [], /** @@ -445,19 +424,11 @@ App.MainServiceItemController = Em.Controller.extend({ } }, - addHbaseMaster: function () { - this.addClientComponent('HBASE_MASTER'); - }, - - addZooKeeperServer: function () { - this.addClientComponent('ZOOKEEPER_SERVER'); - }, - /** * Send command to server to install client on selected host * @param componentName */ - addClientComponent: function (componentName) { + addComponent: function (componentName) { var self = this; var component = App.HostComponent.find().findProperty('componentName', componentName); var componentDisplayName = component.get('displayName'); @@ -488,13 +459,8 @@ App.MainServiceItemController = Em.Controller.extend({ }.property('componentDisplayName'), hostsWithoutComponent: function() { - if (this.get('componentName') === 'HBASE_MASTER') { - return self.hostsWithoutHBaseMaster; - } - if (this.get('componentName') === 'ZOOKEEPER_SERVER') { - return self.hostsWithoutZookeeperServer; - } - }.property('componentName', 'self.hostsWithoutHBaseMaster', 'self.hostsWithoutZookeeperServer'), + return self.get("hostsWithoutComponent-" + this.get('componentName')); + }.property('componentName', 'self.hostsWithoutComponent-' + this.get('componentName')), anyHostsWithoutComponent: function() { return this.get('hostsWithoutComponent').length > 0 @@ -531,13 +497,7 @@ App.MainServiceItemController = Em.Controller.extend({ hostsWithoutComponent.splice(index, 1); } - if (this.get('componentName') === 'HBASE_MASTER') { - self.set('hostsWithoutHBaseMaster', hostsWithoutComponent) - } - if (this.get('componentName') === 'ZOOKEEPER_SERVER') { - self.set('hostsWithoutZookeeperServer', hostsWithoutComponent) - } - + self.set('hostsWithoutComponent-' + this.get('componentName'), hostsWithoutComponent); this.hide(); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b6851a87/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 417ddc7..1d5395e 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1916,6 +1916,7 @@ Em.I18n.translations = { 'dashboard.services.flume.summary.title':'Flume installed on {0} host{1} ({2} agent{3})', 'dashboard.services.flume.summary.configure':'Configure Agents', 'dashboard.services.flume.agentsLabel': 'Flume', + 'dashboard.services.flume.agentLabel': 'Flume Component', 'dashboard.services.flume.channels': 'Channels', 'dashboard.services.flume.sources': 'Sources', 'dashboard.services.flume.sinks': 'Sinks', http://git-wip-us.apache.org/repos/asf/ambari/blob/b6851a87/ambari-web/app/templates/main/service/item.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/service/item.hbs b/ambari-web/app/templates/main/service/item.hbs index 5e2446c..71bf554 100644 --- a/ambari-web/app/templates/main/service/item.hbs +++ b/ambari-web/app/templates/main/service/item.hbs @@ -83,9 +83,11 @@ <!-- Other service actions --> {{#each option in view.maintenance}} - <li {{bindAttr class="option.disabled:disabled option.isHidden:hidden"}}> - <a {{action "doAction" option target="controller" href=true}} {{bindAttr data-title="option.tooltip"}} rel="HealthTooltip"><i {{bindAttr class="option.cssClass"}}></i> -{{option.label}}</a> + <li {{bindAttr class="option.disabled option.isHidden:hidden"}}> + <a {{action "doAction" option target="controller" href=true}} {{bindAttr data-title="option.tooltip"}} rel="HealthTooltip"> + <i {{bindAttr class="option.cssClass"}}></i> + {{option.label}} + </a> </li> {{/each}} </ul> http://git-wip-us.apache.org/repos/asf/ambari/blob/b6851a87/ambari-web/app/views/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js index 258456f..badd94f 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/ambari-web/app/views/main/service/item.js @@ -92,22 +92,31 @@ App.MainServiceItemView = Em.View.extend({ label: Em.I18n.t('services.service.actions.reassign.master'), cssClass: 'icon-share-alt', disabled: false - }, - ADD_HBASE_MASTER_COMPONENT: { - action: 'addHbaseMaster', + } + } + }, + + addActionMap: function() { + return [ + { cssClass: 'icon-plus', 'label': '{0} {1}'.format(Em.I18n.t('add'), Em.I18n.t('dashboard.services.hbase.masterServer')), - disabled: this.get('controller.isAddHBaseMasterDisabled'), - tooltip: this.get('controller.addHBaseMasterDisabledTooltip') + service: 'HBASE', + component: 'HBASE_MASTER' }, - ADD_ZOO_KEEPER_SERVER_COMPONENT: { - action: 'addZooKeeperServer', + { cssClass: 'icon-plus', 'label': '{0} {1}'.format(Em.I18n.t('add'), Em.I18n.t('dashboard.services.zookeeper.server')), - disabled: this.get('controller.isAddZooKeeperServerDisabled'), - tooltip: this.get('controller.addZooKeeperServerDisabledTooltip') + service: 'ZOOKEEPER', + component: 'ZOOKEEPER_SERVER' + }, + { + cssClass: 'icon-plus', + 'label': '{0} {1}'.format(Em.I18n.t('add'), Em.I18n.t('dashboard.services.flume.agentLabel')), + service: 'FLUME', + component: 'FLUME_HANDLER' } - } + ] }, /** * Create option for MOVE_COMPONENT or ROLLING_RESTART task. @@ -174,12 +183,12 @@ App.MainServiceItemView = Em.View.extend({ options.push(actionMap.TOGGLE_PASSIVE); var serviceName = service.get('serviceName'); - if (serviceName === 'HBASE') { - options.push(actionMap.ADD_HBASE_MASTER_COMPONENT); - } - if (serviceName === 'ZOOKEEPER') { - options.push(actionMap.ADD_ZOO_KEEPER_SERVER_COMPONENT); - } + self.addActionMap().filterProperty('service', serviceName).forEach(function(item) { + item.action = 'add' + item.component; + item.disabled = self.get('controller.isAddDisabled-' + item.component); + item.tooltip = self.get('controller.addDisabledTooltip' + item.component); + options.push(item); + }); } return options; }.property('controller.content', 'controller.isStopDisabled','controller.isClientsOnlyService', 'controller.content.isRestartRequired', 'isPassive'),
