Explorar el Código

AMBARI-12005. Admin View: Setting cluster name to more than 100 chars hangs ambari-server (alexantonenko)

Alex Antonenko hace 10 años
padre
commit
e7a4800b2c

+ 13 - 4
ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html

@@ -22,12 +22,20 @@
       <div class="cluster-section" ng-show="cluster">
         <div id="cluster-name"  ng-switch on="editCluster.editingName">
           <h5 ng-switch-when="false">{{cluster.Clusters.cluster_name}}
-            <i ng-show="cluster.Clusters.provisioning_state == 'INSTALLED'" ng-click="toggleEditName()" class="glyphicon glyphicon-edit pull-right edit-cluster-name" tooltip="Rename Cluster"></i>
+            <i ng-show="cluster.Clusters.provisioning_state == 'INSTALLED'" 
+               ng-click="toggleEditName()" 
+               class="glyphicon glyphicon-edit pull-right edit-cluster-name" tooltip="Rename Cluster">
+            </i>
           </h5>
 
-          <form ng-keyup="toggleEditName($event)" tabindex="1" name="editClusterNameForm" class="editClusterNameForm" ng-switch-when="true"
+          <form ng-keyup="toggleEditName($event)" 
+                tabindex="1" 
+                name="editClusterNameForm" 
+                class="editClusterNameForm" 
+                ng-switch-when="true"
                 ng-submit="editCluster.name !== cluster.Clusters.cluster_name && editClusterNameForm.newClusterName.$valid && confirmClusterNameChange()">
-            <div class="form-group" ng-class="{'has-error': editClusterNameForm.newClusterName.$invalid && !editClusterNameForm.newClusterName.$pristine }">
+            <div class="form-group" 
+                 ng-class="{'has-error': editClusterNameForm.newClusterName.$invalid && !editClusterNameForm.newClusterName.$pristine }">
               <input
                   autofocus
                   type="text"
@@ -37,7 +45,8 @@
                   ng-trim="false"
                   ng-model="editCluster.name"
                   class="form-control input-sm"
-                  tooltip="Only alpha-numeric characters."
+                  ng-maxlength="80"
+                  tooltip="Only alpha-numeric characters, up to 80 characters"
                   tooltip-trigger="focus">
               <button ng-click="toggleEditName()"
                       class="btn btn-xs">

+ 4 - 0
ambari-web/app/controllers/wizard/step0_controller.js

@@ -33,10 +33,14 @@ App.WizardStep0Controller = Em.Controller.extend({
    * set <code>clusterNameError</code> if validation fails
    */
   invalidClusterName: function () {
+    var MAX_CLUSTER_NAME_LENGTH = 80;
     var clusterName = this.get('content.cluster.name');
     if (clusterName == '' && this.get('hasSubmitted')) {
       this.set('clusterNameError', Em.I18n.t('installer.step0.clusterName.error.required'));
       return true;
+    } else if (clusterName.length > MAX_CLUSTER_NAME_LENGTH) {
+      this.set('clusterNameError', Em.I18n.t('installer.step0.clusterName.error.tooLong'));
+      return true;
     } else if (/\s/.test(clusterName)) {
       this.set('clusterNameError', Em.I18n.t('installer.step0.clusterName.error.whitespace'));
       return true;

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

@@ -487,6 +487,7 @@ Em.I18n.translations = {
   'installer.step0.clusterName.tooltip.title':'Cluster Name',
   'installer.step0.clusterName.tooltip.content':'Enter a unique cluster name.',
   'installer.step0.clusterName.error.required':'Cluster Name is required',
+  'installer.step0.clusterName.error.tooLong':'Cluster Name is too long',
   'installer.step0.clusterName.error.whitespace':'Cluster Name cannot contain whitespace',
   'installer.step0.clusterName.error.specialChar':'Cluster Name cannot contain special characters',