Jelajahi Sumber

AMBARI-2563. Heatmaps page: add validation for Maximum input field. (Aleksandr Kovalenko via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1499827 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 tahun lalu
induk
melakukan
e79f57665b

+ 14 - 0
ambari-web/app/controllers/main/charts/heatmap.js

@@ -80,6 +80,19 @@ App.MainChartsHeatmapController = Em.Controller.extend({
   }.property(),
 
   selectedMetric: null,
+
+  inputMaximum: '',
+
+  validation: function () {
+    if (this.get('selectedMetric')) {
+      if (/^\d+$/.test(this.get('inputMaximum'))) {
+        $('#inputMaximum').removeClass('error');
+        this.set('selectedMetric.maximumValue', this.get('inputMaximum'));
+      } else {
+        $('#inputMaximum').addClass('error');
+      }
+    }
+  }.observes('inputMaximum'),
   /**
    *  route on host detail page
    * @param event
@@ -103,6 +116,7 @@ App.MainChartsHeatmapController = Em.Controller.extend({
     if (selectedMetric) {
       selectedMetric.refreshHostSlots();
     }
+    this.set('inputMaximum', this.get('selectedMetric.maximumValue'));
   }.observes('selectedMetric'),
 
   /**

+ 2 - 2
ambari-web/app/templates/main/charts/heatmap.hbs

@@ -53,8 +53,8 @@
 					  {{/each}}
 					</table>
 	        {{t common.maximum}}:
-	        <div>
-	          {{view Ember.TextField type="text" valueBinding="controller.selectedMetric.maximumValue" class="span6"}}
+	        <div id="inputMaximum" class="control-group">
+	          {{view Ember.TextField type="text" maxlength="8" valueBinding="controller.inputMaximum" class="span6"}}
 	          {{controller.selectedMetric.units}}
 	        </div>
         {{/if}}