浏览代码

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 年之前
父节点
当前提交
e79f57665b
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 14 0
      ambari-web/app/controllers/main/charts/heatmap.js
  2. 2 2
      ambari-web/app/templates/main/charts/heatmap.hbs

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

@@ -80,6 +80,19 @@ App.MainChartsHeatmapController = Em.Controller.extend({
   }.property(),
   }.property(),
 
 
   selectedMetric: null,
   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
    *  route on host detail page
    * @param event
    * @param event
@@ -103,6 +116,7 @@ App.MainChartsHeatmapController = Em.Controller.extend({
     if (selectedMetric) {
     if (selectedMetric) {
       selectedMetric.refreshHostSlots();
       selectedMetric.refreshHostSlots();
     }
     }
+    this.set('inputMaximum', this.get('selectedMetric.maximumValue'));
   }.observes('selectedMetric'),
   }.observes('selectedMetric'),
 
 
   /**
   /**

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

@@ -53,8 +53,8 @@
 					  {{/each}}
 					  {{/each}}
 					</table>
 					</table>
 	        {{t common.maximum}}:
 	        {{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}}
 	          {{controller.selectedMetric.units}}
 	        </div>
 	        </div>
         {{/if}}
         {{/if}}