Pārlūkot izejas kodu

AMBARI-3575. Wrong reinstall popup. (onechiporenko)

Oleg Nechiporenko 11 gadi atpakaļ
vecāks
revīzija
3e1a60aa4b

+ 48 - 90
ambari-web/app/controllers/main/host/details.js

@@ -181,33 +181,6 @@ App.MainHostDetailsController = Em.Controller.extend({
       async: false,
       async: false,
       success: function (data) {
       success: function (data) {
         deleted = null;
         deleted = null;
-        // If ZooKeeper Server component was removed, 
-        // restart ZooKeeper service.
-        /*
-         * Commenting it out as user can restart service
-         * whenever they want. We mention in message.
-        if (component.get('componentName') === 'ZOOKEEPER_SERVER') {
-          App.ajax.send({
-            'name': 'service.item.start_stop',
-            'sender': this,
-            'data': {
-              'requestInfo': 'Stop ZooKeeper',
-              'serviceName': 'ZOOKEEPER',
-              'state': 'INSTALLED'
-            },
-            'callback': function() {
-              App.ajax.send({
-                'name': 'service.item.start_stop',
-                'sender': this,
-                'data': {
-                  'requestInfo': 'Start ZooKeeper',
-                  'serviceName': 'ZOOKEEPER',
-                  'state': 'STARTED'
-                }
-              });
-            }
-          });
-        }*/
       },
       },
       error: function (xhr, textStatus, errorThrown) {
       error: function (xhr, textStatus, errorThrown) {
         console.log('Error deleting host component');
         console.log('Error deleting host component');
@@ -360,15 +333,15 @@ App.MainHostDetailsController = Em.Controller.extend({
         });
         });
         dn += " ("+dns.join(", ")+")";
         dn += " ("+dns.join(", ")+")";
       }
       }
-      var dialogContent = 
-        [Em.I18n.t('hosts.host.addComponent.msg').format(dn) + "<br><br>",
-        '{{t hosts.host.addComponent.note}}'];
       App.ModalPopup.show({
       App.ModalPopup.show({
         primary: Em.I18n.t('yes'),
         primary: Em.I18n.t('yes'),
         secondary: Em.I18n.t('no'),
         secondary: Em.I18n.t('no'),
         header: Em.I18n.t('popup.confirmation.commonHeader'),
         header: Em.I18n.t('popup.confirmation.commonHeader'),
+        addComponentMsg: function() {
+          return Em.I18n.t('hosts.host.addComponent.msg').format(dn);
+        }.property(),
         bodyClass: Ember.View.extend({
         bodyClass: Ember.View.extend({
-          template: Ember.Handlebars.compile(dialogContent.join(''))
+          templateName: require('templates/main/host/details/addComponentPopup')
         }),
         }),
         onPrimary: function () {
         onPrimary: function () {
           this.hide();
           this.hide();
@@ -390,6 +363,7 @@ App.MainHostDetailsController = Em.Controller.extend({
       });
       });
     }
     }
   },
   },
+
   primary: function(component) {
   primary: function(component) {
     var self = this;
     var self = this;
     var componentName = component.get('componentName').toUpperCase().toString();
     var componentName = component.get('componentName').toUpperCase().toString();
@@ -461,11 +435,11 @@ App.MainHostDetailsController = Em.Controller.extend({
       primary: Em.I18n.t('yes'),
       primary: Em.I18n.t('yes'),
       secondary: Em.I18n.t('no'),
       secondary: Em.I18n.t('no'),
       header: Em.I18n.t('popup.confirmation.commonHeader'),
       header: Em.I18n.t('popup.confirmation.commonHeader'),
+      installComponentMessage: function(){
+        return Em.I18n.t('hosts.host.installComponent.msg').format(displayName);
+      }.property(),
       bodyClass: Ember.View.extend({
       bodyClass: Ember.View.extend({
-        template: Ember.Handlebars.compile([
-          '{{t hosts.delete.popup.body}}<br /><br />',
-          '{{t hosts.host.addComponent.note}}'
-        ].join(''))
+        templateName: require('templates/main/host/details/installComponentPopup')
       }),
       }),
       onPrimary: function () {
       onPrimary: function () {
         this.hide();
         this.hide();
@@ -602,7 +576,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         console.log(textStatus);
         console.log(textStatus);
         console.log(errorThrown);
         console.log(errorThrown);
       }
       }
-    }
+    };
     jQuery.ajax(configsAjax);
     jQuery.ajax(configsAjax);
   },
   },
 
 
@@ -704,47 +678,42 @@ App.MainHostDetailsController = Em.Controller.extend({
        });
        });
      }
      }
      if (masterComponents.length > 0) {
      if (masterComponents.length > 0) {
-       var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
-       bodyHtml += Em.I18n.t('hosts.cant.do.popup.masterList.body').format(masterComponents.length);
-       bodyHtml += "</p><i>";
-       bodyHtml += masterComponents.join(", ");
-       bodyHtml += "</i>";
-       this.raiseDeleteComponentsError(bodyHtml);
+       this.raiseDeleteComponentsError(masterComponents, 'masterList');
        return;
        return;
      } else if (nonDeletableComponents.length > 0) {
      } else if (nonDeletableComponents.length > 0) {
-       var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
-       bodyHtml += Em.I18n.t('hosts.cant.do.popup.nonDeletableList.body').format(nonDeletableComponents.length);
-       bodyHtml += "</p><i>";
-       bodyHtml += nonDeletableComponents.join(", ");
-       bodyHtml += "</i>";
-       this.raiseDeleteComponentsError(bodyHtml);
+       this.raiseDeleteComponentsError(nonDeletableComponents, 'nonDeletableList');
        return;
        return;
      } else if(runningComponents.length > 0) {
      } else if(runningComponents.length > 0) {
-       var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
-       bodyHtml += Em.I18n.t('hosts.cant.do.popup.runningList.body').format(runningComponents.length);
-       bodyHtml += "</p><i>";
-       bodyHtml += runningComponents.join(", ");
-       bodyHtml += "</i><br><br><p>";
-       bodyHtml += Em.I18n.t('hosts.cant.do.popup.runningList.body.end');
-       bodyHtml += "</p>";
-       this.raiseDeleteComponentsError(bodyHtml);
+       this.raiseDeleteComponentsError(runningComponents, 'runningList');
        return;
        return;
      }
      }
      this._doDeleteHost(unknownComponents);
      this._doDeleteHost(unknownComponents);
   },
   },
   
   
-  raiseDeleteComponentsError: function (bodyHtml) {
-    var self = this;
+  raiseDeleteComponentsError: function (components, type) {
     App.ModalPopup.show({
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.cant.do.popup.title'),
       header: Em.I18n.t('hosts.cant.do.popup.title'),
-      html: true,
-      encodeBody: false,
-      body: bodyHtml,
-      primary: Em.I18n.t('ok'),
-      secondary: null,
-      onPrimary: function() {
-        this.hide();
-      }
+      type: type,
+      showBodyEnd: function() {
+        return this.get('type') === 'runningList';
+      }.property(),
+      components: components,
+      componentsStr: function() {
+        return this.get('components').join(", ");
+      }.property(),
+      componentsBody: function() {
+        return Em.I18n.t('hosts.cant.do.popup.'+type+'.body').format(this.get('components').length);
+      }.property(),
+      componentsBodyEnd: function() {
+        if (this.get('showBodyEnd')) {
+          return Em.I18n.t('hosts.cant.do.popup.'+type+'.body.end');
+        }
+        return '';
+      }.property(),
+      bodyClass: Em.View.extend({
+        templateName: require('templates/main/host/details/raiseDeleteComponentErrorPopup')
+      }),
+      secondary: null
     })
     })
   },
   },
 
 
@@ -753,31 +722,20 @@ App.MainHostDetailsController = Em.Controller.extend({
    */
    */
   _doDeleteHost: function(unknownComponents) {
   _doDeleteHost: function(unknownComponents) {
     var self = this;
     var self = this;
-    var bodyHtml = "<p><i class=\"icon-warning-sign\"></i> ";
-    bodyHtml += Em.I18n.t('hosts.delete.popup.body').format("<i>"+this.get('content.publicHostName')+"</i>");
-    bodyHtml += "</p>";
-    if (unknownComponents!=null && unknownComponents.length > 0) {
-      bodyHtml += "<div class=\"alert\">";
-      bodyHtml += Em.I18n.t('hosts.delete.popup.unknownComponents') + "<br>";
-      bodyHtml += "<i>"
-      bodyHtml += unknownComponents.join(", ");
-      bodyHtml += "</i></div>";
-    }
-    bodyHtml += "<p>";
-    bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg1');
-    bodyHtml += "</p><p>";
-    bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg2');
-    bodyHtml += "</p><p>";
-    bodyHtml += "<span class=\"label label-important\">"+Em.I18n.t('common.important')+"</span>  ";
-    bodyHtml += Em.I18n.t('hosts.delete.popup.body.msg3');
-    bodyHtml += "</p>";
     App.ModalPopup.show({
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.delete.popup.title'),
       header: Em.I18n.t('hosts.delete.popup.title'),
-      html: true,
-      encodeBody: false,
-      body: bodyHtml,
-      primary: Em.I18n.t('ok'),
-      secondary: Em.I18n.t('common.cancel'),
+      deletePopupBody: function() {
+        return Em.I18n.t('hosts.delete.popup.body').format(self.get('content.publicHostName'));
+      }.property(),
+      unknownComponents: function() {
+        if (unknownComponents && unknownComponents.length) {
+          return unknownComponents.join(", ");
+        }
+        return '';
+      }.property(),
+      bodyClass: Em.View.extend({
+        templateName: require('templates/main/host/details/doDeleteHostPopup')
+      }),
       onPrimary: function() {
       onPrimary: function() {
         var dialogSelf = this;
         var dialogSelf = this;
         var allComponents = self.get('content.hostComponents');
         var allComponents = self.get('content.hostComponents');
@@ -820,4 +778,4 @@ App.MainHostDetailsController = Em.Controller.extend({
       }
       }
     })
     })
   }
   }
-})
+});

+ 2 - 1
ambari-web/app/messages.js

@@ -1267,6 +1267,7 @@ Em.I18n.translations = {
   'host.host.componentFilter.master':'Master Components',
   'host.host.componentFilter.master':'Master Components',
   'host.host.componentFilter.slave':'Slave Components',
   'host.host.componentFilter.slave':'Slave Components',
   'host.host.componentFilter.client':'Client Components',
   'host.host.componentFilter.client':'Client Components',
+  '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.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.',
   '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.',
   'hosts.host.addComponent.securityNote':'You are running your cluster in secure mode. You must set up the keytab for {0} on {1} before you proceed. Otherwise, the component will not be able to start properly.',
   'hosts.host.addComponent.securityNote':'You are running your cluster in secure mode. You must set up the keytab for {0} on {1} before you proceed. Otherwise, the component will not be able to start properly.',
@@ -1290,7 +1291,7 @@ Em.I18n.translations = {
   'hosts.host.alerts.st':'&nbsp;!&nbsp;',
   'hosts.host.alerts.st':'&nbsp;!&nbsp;',
   'hosts.decommission.popup.body':'Are you sure?',
   'hosts.decommission.popup.body':'Are you sure?',
   'hosts.decommission.popup.header':'Confirmation',
   'hosts.decommission.popup.header':'Confirmation',
-  'hosts.delete.popup.body':'Are you sure you want to delete host {0}?',
+  'hosts.delete.popup.body':'Are you sure you want to delete host <i>{0}</i>?',
   '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.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.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.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.',

+ 20 - 0
ambari-web/app/templates/main/host/details/addComponentPopup.hbs

@@ -0,0 +1,20 @@
+{{!
+* 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.
+}}
+
+{{addComponentMsg}}<br /><br />
+{{t hosts.host.addComponent.note}}

+ 28 - 0
ambari-web/app/templates/main/host/details/doDeleteHostPopup.hbs

@@ -0,0 +1,28 @@
+{{!
+* 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.
+}}
+
+<p><i class="icon-warning-sign"></i> {{{deletePopupBody}}}</p>
+{{#if unknownComponents}}
+  <div class="alert">
+  {{t hosts.delete.popup.unknownComponents}}<br />
+    <i>{{unknownComponents}}</i>
+  </div>
+{{/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>

+ 20 - 0
ambari-web/app/templates/main/host/details/installComponentPopup.hbs

@@ -0,0 +1,20 @@
+{{!
+* 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.
+}}
+
+{{installComponentMessage}}<br /><br />
+{{t hosts.host.addComponent.note}}

+ 24 - 0
ambari-web/app/templates/main/host/details/raiseDeleteComponentErrorPopup.hbs

@@ -0,0 +1,24 @@
+{{!
+* 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.
+}}
+
+<p><i class="icon-warning-sign"></i> {{componentsBody}}</p>
+<i>{{componentsStr}}</i>
+{{#if showBodyEnd}}
+    <br /><br />
+    <p>{{componentsBodyEnd}}</p>
+{{/if}}