Updated Branches:
  refs/heads/trunk 0b5dfa542 -> ac94d2779

AMBARI-3593 Ambari ui works incorrect when we delete host which has last slave 
component on the cluster


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/ac94d277
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/ac94d277
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/ac94d277

Branch: refs/heads/trunk
Commit: ac94d2779e9e11a21577ed66fb1252a0fa62d5f2
Parents: 0b5dfa5
Author: aBabiichuk <[email protected]>
Authored: Fri Oct 25 21:38:49 2013 +0300
Committer: aBabiichuk <[email protected]>
Committed: Mon Oct 28 14:22:47 2013 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 30 ++++++++++++++++++--
 ambari-web/app/mappers/status_mapper.js         |  2 ++
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/styles/application.less          |  8 ++++++
 .../main/host/details/doDeleteHostPopup.hbs     |  8 +++++-
 ambari-web/app/views/common/modal_popup.js      |  4 +--
 6 files changed, 47 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ac94d277/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 72092bd..40447f3 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -659,9 +659,19 @@ App.MainHostDetailsController = Em.Controller.extend({
      var runningComponents = [];
      var unknownComponents = [];
      var nonDeletableComponents = [];
+     var lastComponents = [];
      var components = this.get('content.hostComponents');
      if (components!=null && components.get('length')>0){
-       components.forEach(function (cInstance) { 
+       components.forEach(function (cInstance) {
+         var numberOfComponents = 0;
+         var allComponents = cInstance.get('service.hostComponents');
+         allComponents.forEach(function(component) {
+           if (component.get('componentName') == 
cInstance.get('componentName')) numberOfComponents++;
+           if (numberOfComponents > 1) return;
+         });
+         if (numberOfComponents == 1) {
+           lastComponents.push(cInstance.get('displayName'));
+         }
          var workStatus = cInstance.get('workStatus');
          if (cInstance.get('isMaster') && !cInstance.get('isDeletable')) {
            masterComponents.push(cInstance.get('displayName'));
@@ -687,7 +697,7 @@ App.MainHostDetailsController = Em.Controller.extend({
        this.raiseDeleteComponentsError(runningComponents, 'runningList');
        return;
      }
-     this._doDeleteHost(unknownComponents);
+     this._doDeleteHost(unknownComponents,lastComponents);
   },
   
   raiseDeleteComponentsError: function (components, type) {
@@ -720,13 +730,26 @@ App.MainHostDetailsController = Em.Controller.extend({
   /**
    * show confirmation popup to delete host
    */
-  _doDeleteHost: function(unknownComponents) {
+  _doDeleteHost: function(unknownComponents,lastComponents) {
     var self = this;
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.delete.popup.title'),
       deletePopupBody: function() {
         return 
Em.I18n.t('hosts.delete.popup.body').format(self.get('content.publicHostName'));
       }.property(),
+      lastComponent: function() {
+         if (lastComponents && lastComponents.length) {
+           this.set('enablePrimary',false);
+           return true;
+         } else {
+           this.set('enablePrimary',true);
+           return false;
+         }
+      }.property(),
+      enablePrimary: false,
+      lastComponentError:  Em.View.extend({
+        template: 
Ember.Handlebars.compile(Em.I18n.t('hosts.delete.popup.body.msg4').format(lastComponents))
+      }),
       unknownComponents: function() {
         if (unknownComponents && unknownComponents.length) {
           return unknownComponents.join(", ");
@@ -737,6 +760,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         templateName: require('templates/main/host/details/doDeleteHostPopup')
       }),
       onPrimary: function() {
+        if (!this.get('enablePrimary')) return;
         var dialogSelf = this;
         var allComponents = self.get('content.hostComponents');
         var deleteError = null;

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ac94d277/ambari-web/app/mappers/status_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/status_mapper.js 
b/ambari-web/app/mappers/status_mapper.js
index c902389..5630f97 100644
--- a/ambari-web/app/mappers/status_mapper.js
+++ b/ambari-web/app/mappers/status_mapper.js
@@ -194,6 +194,7 @@ App.statusMapper = App.QuickDataMapper.create({
   updateServicesStatus: function(services, servicesMap){
     services.forEach(function(_service){
       var service = servicesMap[_service.get('id')];
+      if (service) {
       var serviceName = _service.get('serviceName');
       var serviceSpecificObj = null;
       switch (serviceName) {
@@ -258,6 +259,7 @@ App.statusMapper = App.QuickDataMapper.create({
         serviceSpecificObj.set('isStopped', service.isRunning);
         serviceSpecificObj.set('toolTipContent', service.toolTipContent);
       }
+      }
     }, this);
   },
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ac94d277/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index b68626b..9a3f4e6 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1295,6 +1295,7 @@ Em.I18n.translations = {
   'hosts.delete.popup.body.msg1':'This will remove the host from Ambari\'s 
management. Ambari will ignore any communications from this host.',
   'hosts.delete.popup.body.msg2':'Installed bits of service components will 
not be removed from the system. Individual service components should not be 
restarted later to join the cluster. This will introduce inconsistencies in 
monitoring data.',
   'hosts.delete.popup.body.msg3':'Nagios service should be restarted for 
alerts and notifications to work properly. ZooKeeper service should be 
restarted if any ZooKeeper components are removed. Go to the <i>Services</i> 
page to restart services.',
+  'hosts.delete.popup.body.msg4':'<b>WARNING!</b> Delete the last <i>{0}</i> 
component[s] in the cluster?</br>Deleting the last components in the cluster 
could result in permanent loss of service data.',
   'hosts.delete.popup.header':'Confirmation',
   'hosts.delete.popup.title':'Delete Host',
   'hosts.delete.popup.unknownComponents':'Components with unknown status:',

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ac94d277/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less 
b/ambari-web/app/styles/application.less
index baaf372..4977601 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -4355,6 +4355,10 @@ i.icon-asterisks {
     *width: 5.929714493544281%;
   }
 
+  .row-fluid .tinyspan {
+    width: 2%;
+  }
+
   .row-fluid .offset12 {
     margin-left: 105.12820512820512%;
     *margin-left: 105.02182214948171%;
@@ -4475,6 +4479,10 @@ i.icon-asterisks {
     *margin-left: 8.440625568285142%;
   }
 
+  .row-fluid .tinyoffset {
+    margin-left: 3%!important;
+  }
+
   input,
   textarea,
   .uneditable-input {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ac94d277/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs 
b/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs
index 7690bc8..9a83447 100644
--- a/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs
+++ b/ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs
@@ -25,4 +25,10 @@
 {{/if}}
 <p>{{t hosts.delete.popup.body.msg1}}</p>
 <p>{{t hosts.delete.popup.body.msg2}}</p>
-<p><span class="label label-important">{{t common.important}}</span> {{t 
hosts.delete.popup.body.msg3}}</p>
\ No newline at end of file
+<p><span class="label label-important">{{t common.important}}</span> {{t 
hosts.delete.popup.body.msg3}}</p>
+{{#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/ac94d277/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js 
b/ambari-web/app/views/common/modal_popup.js
index 94c2ba1..ecb8b5e 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -40,7 +40,7 @@ App.ModalPopup = Ember.View.extend({
     '{{else}}',
     '<div class="modal-footer">',
     '{{#if view.secondary}}<a class="btn" {{action onSecondary 
target="view"}}>{{view.secondary}}</a>{{/if}}',
-    '{{#if view.primary}}<a class="btn btn-success" {{action onPrimary 
target="view"}}>{{view.primary}}</a>{{/if}}',
+    '{{#if view.primary}}<a {{bindAttr class="view.enablePrimary::disabled 
:btn :btn-success"}} {{action onPrimary 
target="view"}}>{{view.primary}}</a>{{/if}}',
     '</div>',
     '{{/if}}',
     '{{/if}}',
@@ -55,7 +55,7 @@ App.ModalPopup = Ember.View.extend({
   primary: Em.I18n.t('ok'),
   secondary: Em.I18n.t('common.cancel'),
   autoHeight: true,
-
+  enablePrimary: true,
   onPrimary: function () {
     this.hide();
   },

Reply via email to