Updated Branches: refs/heads/trunk 020138345 -> a1394c581
AMBARI-3632. Need ability to remove hbase master.(xiwang) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/a1394c58 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/a1394c58 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/a1394c58 Branch: refs/heads/trunk Commit: a1394c581ec7fedc7f862536b0099a69274cab66 Parents: 0201383 Author: Xi Wang <[email protected]> Authored: Thu Oct 31 10:36:47 2013 -0700 Committer: Xi Wang <[email protected]> Committed: Thu Oct 31 10:36:47 2013 -0700 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 54 +++++++++++++++++++- ambari-web/app/messages.js | 4 +- ambari-web/app/styles/application.less | 10 ++++ .../main/host/details/deleteComponentPopup.hbs | 25 +++++++++ ambari-web/app/templates/main/host/summary.hbs | 17 ++++-- ambari-web/app/views/main/host/summary.js | 13 ++++- 6 files changed, 114 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index db69fb8..81b95fa 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -156,11 +156,61 @@ App.MainHostDetailsController = Em.Controller.extend({ } else { App.router.get('clusterController').loadUpdatedStatusDelayed(500); } - App.router.get('backgroundOperationsController').showPopup(); + if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) { + App.router.get('backgroundOperationsController').showPopup(); + } }); }, /** + * send command to server to delete selected host component + * + */ + deleteComponent: function (event) { + var self = this; + var component = event.context; + var componentName = component.get('componentName').toUpperCase().toString(); + var displayName = component.get('displayName'); + var numberOfComponents = 0; + var isLastComponent = false; + var allComponents = component.get('service.hostComponents'); + allComponents.forEach(function(component) { + if (component.get('componentName') == componentName) numberOfComponents++; + if (numberOfComponents > 1) return; + }); + if (numberOfComponents == 1) { + isLastComponent = true; + } + App.ModalPopup.show({ + header: Em.I18n.t('popup.confirmation.commonHeader'), + bodyClass: Ember.View.extend({ + templateName: require('templates/main/host/details/deleteComponentPopup') + }), + enablePrimary: false, + lastComponent: function() { + if (isLastComponent) { + this.set('enablePrimary',false); + return true; + } else { + this.set('enablePrimary',true); + return false; + } + }.property(), + lastComponentError: Em.View.extend({ + template: Ember.Handlebars.compile(Em.I18n.t('hosts.host.deleteComponent.popup.warning').format(displayName)) + }), + deleteComponentMsg: function() { + return Em.I18n.t('hosts.host.deleteComponent.popup.msg').format(displayName); + }.property(), + onPrimary: function () { + if (!this.get('enablePrimary')) return; + self._doDeleteHostComponent(component); + this.hide(); + }, + }); + + }, + /** * Deletes the given host component, or all host components. * * @param component When <code>null</code> all host components are deleted. @@ -352,7 +402,7 @@ App.MainHostDetailsController = Em.Controller.extend({ onPrimary: function () { this.hide(); if (component.get('componentName') === 'CLIENTS') { - // Clients component has many sub-components which + // Clients component has many sub-components which // need to be installed. var scs = component.get('subComponentNames'); scs.forEach(function (sc) { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index cabc24e..eb0e755 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1275,7 +1275,7 @@ Em.I18n.translations = { 'hosts.host.summary.hostname':'Hostname', 'hosts.host.summary.agentHeartbeat':'Agent <br/> Heartbeat', 'hosts.host.summary.hostMetrics':'Host Metrics', - 'hosts.host.summary.action':'Action...', + 'hosts.host.summary.action':'Actions...', 'hosts.host.summary.addComponent':'Add Component...', 'hosts.host.details.hostActions':'Host Actions...', @@ -1288,6 +1288,8 @@ Em.I18n.translations = { 'host.host.componentFilter.master':'Master Components', 'host.host.componentFilter.slave':'Slave Components', 'host.host.componentFilter.client':'Client Components', + 'hosts.host.deleteComponent.popup.msg':'Are you sure you want to delete {0}?', + 'hosts.host.deleteComponent.popup.warning':'<b>WARNING!</b> Delete the last <i>{0}</i> component in the cluster?</br>Deleting the last component in the cluster could result in permanent loss of service data.', 'hosts.host.installComponent.msg':'Are you sure you want to install {0}?', 'hosts.host.addComponent.msg':'Are you sure you want to add {0}?', 'hosts.host.addComponent.note':'Note: After this component is installed, go to Services -> Nagios to restart the Nagios service. This is required for the alerts and notifications to work properly.', http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 84345ef..49c985e 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -3026,6 +3026,16 @@ table.graphs { font-style: italic; } } + + .host-components { + .dropdown-menu { + .disabled { + pointer-events: none; + color: #808080; + cursor: default; + } + } + } } .background-operations { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs new file mode 100644 index 0000000..b50ec51 --- /dev/null +++ b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs @@ -0,0 +1,25 @@ +{{! +* 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. +}} + +{{deleteComponentMsg}}<br /><br /> +{{#if lastComponent}} + <div class="alert-error row-fluid"> + <div class='tinyspan tinyoffset'>{{view Ember.Checkbox checkedBinding="enablePrimary"}}</div> + <div class='span10'>{{view lastComponentError}}</div> + </div> +{{/if}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/templates/main/host/summary.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs index 8da39de..688f22c 100644 --- a/ambari-web/app/templates/main/host/summary.hbs +++ b/ambari-web/app/templates/main/host/summary.hbs @@ -69,11 +69,11 @@ <span class="caret pull-right"></span> </a> <ul class="dropdown-menu"> - <li> - <div class="component-text-status"> - {{view.componentTextStatus}} - </div> - </li> + <li> + <div class="component-text-status"> + {{view.componentTextStatus}} + </div> + </li> {{#if view.isDataNode}} {{#if view.isDataNodeDecommissionAvailable}} <li {{bindAttr class="view.noActionAvailable"}}> @@ -90,6 +90,13 @@ </li> {{/if}} {{/if}} + {{#if view.isHBaseMaster}} + <li {{bindAttr class="view.isDeleteHBaseMasterDisabled:disabled"}}> + <a href="javascript:void(null)" data-toggle="modal" {{action "deleteComponent" view.content target="controller"}}> + {{t common.delete}} + </a> + </li> + {{/if}} {{#unless view.isInstalling}} {{#if view.isStart}} <li {{bindAttr class=" view.isDecommissioning:hidden view.noActionAvailable"}}> http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a1394c58/ambari-web/app/views/main/host/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js index b19e41a..51ef1a0 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -425,7 +425,18 @@ App.MainHostSummaryView = Em.View.extend({ var decommissionHostNames = this.get('decommissionDataNodeHostNames'); var hostName = App.router.get('mainHostDetailsController.content.hostName'); return decommissionHostNames != null && decommissionHostNames.contains(hostName); - }.property('App.router.mainHostDetailsController.content', 'decommissionDataNodeHostNames') + }.property('App.router.mainHostDetailsController.content', 'decommissionDataNodeHostNames'), + + /** + * Shows whether we need to show Delete button + */ + isHBaseMaster: function () { + return this.get('content.componentName') === 'HBASE_MASTER'; + }.property('content'), + isDeleteHBaseMasterDisabled: function () { + return !(this.get('workStatus') == App.HostComponentStatus.stopped || this.get('workStatus') == App.HostComponentStatus.unknown || + this.get('workStatus') == App.HostComponentStatus.install_failed || this.get('workStatus') == App.HostComponentStatus.upgrade_failed); + }.property('workStatus'), }), timeSinceHeartBeat: function () {
