ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-19251. Ambari capacity queue manager only accepts values in integers i.e not decimal values like 0.5 (Akhil PB via pallavkul)
Date Tue, 10 Jan 2017 15:06:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d97b9d5f1 -> 6b87b44de


AMBARI-19251. Ambari capacity queue manager only accepts values in integers i.e not decimal
values like 0.5 (Akhil PB via pallavkul)


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

Branch: refs/heads/trunk
Commit: 6b87b44de1e2b7aefec5c6d399b0a8615608a70b
Parents: d97b9d5
Author: pallavkul <pallav.kul@gmail.com>
Authored: Tue Jan 10 20:35:03 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Tue Jan 10 20:35:03 2017 +0530

----------------------------------------------------------------------
 .../ui/app/components/capacityInput.js          | 25 +++++++++++++++-----
 .../src/main/resources/ui/app/serializers.js    |  6 +++--
 .../resources/ui/app/styles/application.less    | 10 ++++----
 .../ui/app/templates/capacityEditForm.hbs       |  8 +++----
 .../templates/components/editLabelCapacity.hbs  |  4 ++--
 .../templates/components/editQueueCapacity.hbs  |  4 ++--
 6 files changed, 36 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/capacityInput.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/capacityInput.js
b/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/capacityInput.js
index 8f0246a..8eb06c2 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/capacityInput.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/components/capacityInput.js
@@ -117,13 +117,24 @@ App.MaxCapacityInputComponent = App.CapacityInputComponent.extend({
   }.observes('queue.maximum_capacity','queue.capacity')
 });
 
+App.DecimalInputRangeComponent = Em.TextField.extend({
+  type: 'range',
+  step: '0.01',
+  action: 'mouseUp',
+
+  mouseUp: function () {
+    this.sendAction('action', this.get('value'));
+  }
+});
+
 App.DecimalCapacityInputComponent = Ember.TextField.extend({
   classNames: ['form-control'],
   maxVal: null,
+  totalCapacity: null,
   queue: null,
 
   initVal: function() {
-    this.set('value', parseFloat(this.get('value')));
+    this.set('value', (!Em.isBlank(this.get('value')) && !isNaN(parseFloat(this.get('value'))))
? parseFloat(this.get('value')): null);
   }.on('init'),
 
   keyDown: function(evt) {
@@ -137,7 +148,8 @@ App.DecimalCapacityInputComponent = Ember.TextField.extend({
       return false;
     }
 
-    if (evt.keyCode === 190) {
+    //Allow decimal point and tab keys
+    if (evt.keyCode === 190 || evt.keyCode === 9) {
       return true;
     }
 
@@ -151,7 +163,7 @@ App.DecimalCapacityInputComponent = Ember.TextField.extend({
       val = val.substring(0, evt.target.selectionStart) + newChar + val.substring(evt.target.selectionEnd);
     }
 
-    //Restricting three decimal places, allow decimal precision=2
+    //Restricting decimal places to less than or equal to 2
     if (/^\d+\.\d{3}$/.test(val)) {
       return false;
     }
@@ -160,20 +172,22 @@ App.DecimalCapacityInputComponent = Ember.TextField.extend({
   },
 
   debounceId: null,
+
   cancelDebounceCallback: function() {
     Ember.run.cancel(this.get('debounceId'));
     this.set('debounceId', null);
   },
+
   initDebounceCallback: function(val, maxVal) {
     var debounce = Ember.run.debounce(this, function() {
       this.set('value', (parseFloat(val) > maxVal)? parseFloat(maxVal) : parseFloat(val));
-    }, 3000);
+    }, 8000);
     this.set('debounceId', debounce);
   },
 
   valueDidChange: function() {
     var val = this.get('value'),
-    maxVal = this.get('maxVal');
+        maxVal = this.get('maxVal');
     this.cancelDebounceCallback();
     if (/^\d+(\.(\d{1,2})?)?$/.test(val)) {
       if (/^\d+\.[0]$/.test(val) || /^\d+\.$/.test(val)) {
@@ -183,7 +197,6 @@ App.DecimalCapacityInputComponent = Ember.TextField.extend({
       }
     }
   }.observes('value').on('change')
-
 });
 
 App.DecimalMaxcapacityInputComponent = App.DecimalCapacityInputComponent.extend({

http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/serializers.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/serializers.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/serializers.js
index ee7bdd4..de19cc9 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/serializers.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/serializers.js
@@ -97,8 +97,6 @@ App.SerializerMixin = Em.Mixin.create({
           state:                         props[base_path + ".state"] || null,
           acl_administer_queue:          props[base_path + ".acl_administer_queue"] || null,
           acl_submit_applications:       props[base_path + ".acl_submit_applications"] ||
null,
-          capacity:                      (props[base_path + ".capacity"])?+props[base_path
+ ".capacity"]:null,
-          maximum_capacity:              (props[base_path + ".maximum-capacity"])?+props[base_path
+ ".maximum-capacity"]:null,
           user_limit_factor:             (props[base_path + ".user-limit-factor"])?+props[base_path
+ ".user-limit-factor"]:null,
           minimum_user_limit_percent:    (props[base_path + ".minimum-user-limit-percent"])?+props[base_path
+ ".minimum-user-limit-percent"]:null,
           maximum_applications:          (props[base_path + ".maximum-applications"])?+props[base_path
+ ".maximum-applications"]:null,
@@ -111,6 +109,10 @@ App.SerializerMixin = Em.Mixin.create({
           isPreemptionInherited:         (props[base_path + '.disable_preemption'] !== undefined)?false:true
         };
 
+    //Converting capacity and max-capacity into two decimal point float numbers
+    q.capacity = (props[base_path + ".capacity"])? +parseFloat(props[base_path + ".capacity"]).toFixed(2)
: null;
+    q.maximum_capacity = (props[base_path + ".maximum-capacity"])? +parseFloat(props[base_path
+ ".maximum-capacity"]).toFixed(2) : null;
+
     switch ((props.hasOwnProperty(labelsPath))?props[labelsPath]:'') {
       case '*':
         q.labels = this.get('store.nodeLabels.content').map(function(item) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
b/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
index e24bf4e..823a044 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/styles/application.less
@@ -814,7 +814,7 @@
 }
 
 .input-percent-width {
-  width: 65px;
+  width: 80px;
   .input-group-addon {
     padding: 3px;
   }
@@ -1041,7 +1041,7 @@
     }
   }
   .input-group-addon {
-    padding: 7px 6px;
+    padding: 7px 6px 8px 6px;
     width: 26px;
   }
   .yellow-warning {
@@ -1162,7 +1162,7 @@
       float: left;
       display: inline-block;
       input {
-        width: 55px;
+        width: 60px;
       }
     }
     .capacity-input-slider {
@@ -1214,9 +1214,9 @@
     margin-bottom: 10px;
   }
   .label-capacity-input {
-    width: 80px;
+    width: 84px;
     input {
-      width: 54px !important;
+      width: 56px !important;
     }
     .input-group-addon {
       float: left;

http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capacityEditForm.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capacityEditForm.hbs
b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capacityEditForm.hbs
index 78aca04..6267cb3 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capacityEditForm.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/capacityEditForm.hbs
@@ -26,13 +26,13 @@
       }}
       <div class="form-group">
         <div class="input-group input-percent">
-          {{capacity-input class='input-sm' value=this.capacity totalCapacity=view.totalCapacity
queue=this maxVal=100}}
+          {{decimal-capacity-input class='input-sm' value=this.capacity totalCapacity=view.totalCapacity
queue=this maxVal=100}}
           <span class="input-group-addon">%</span>
         </div>
       </div>
     </div>
     <div class="form-group">
-      {{input-range min="0" max="100" step="1" value=this.capacity class="input-sm"}}
+      {{decimal-input-range min="0" max="100" step="0.01" value=this.capacity class="input-sm"}}
     </div>
     <div class="rollback-wrap">
       {{#if view.dirty_capacity}}
@@ -50,13 +50,13 @@
       }}
       <div class="form-group">
         <div class="input-group input-percent">
-          {{max-capacity-input class='input-sm' value=this.maximum_capacity totalCapacity=view.totalCapacity
queue=this maxVal=100}}
+          {{decimal-maxcapacity-input class='input-sm' value=this.maximum_capacity totalCapacity=view.totalCapacity
queue=this maxVal=100}}
           <span class="input-group-addon">%</span>
         </div>
       </div>
     </div>
     <div {{bind-attr class=":form-group this.isValid::has-error" }}>
-      {{input-range min="0" max="100" step="1" value=this.maximum_capacity class="input-sm
"}}
+      {{decimal-input-range min="0" max="100" step="0.01" value=this.maximum_capacity class="input-sm"}}
       {{#each this.errors.maximum_capacity}}
         <span class="help-block">{{message}}</span>
       {{/each}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editLabelCapacity.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editLabelCapacity.hbs
b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editLabelCapacity.hbs
index 5e1ae16..405ed8f 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editLabelCapacity.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editLabelCapacity.hbs
@@ -35,7 +35,7 @@
         <span class="input-group-addon">%</span>
       </div>
       <div class="form-group label-capacity-slider">
-        {{input-range min="0" max="100" step="1" value=label.capacity class="input-sm" disabled=isAccessDisabled}}
+        {{decimal-input-range min="0" max="100" step="0.01" value=label.capacity class="input-sm"
disabled=isAccessDisabled}}
       </div>
       {{#unless isAccessDisabled}}
         {{#if isLabelCapacityDirty}}
@@ -51,7 +51,7 @@
         <span class="input-group-addon">%</span>
       </div>
       <div class="form-group label-capacity-slider">
-        {{input-range min="0" max="100" step="1" value=label.maximum_capacity class="input-sm"
disabled=isAccessDisabled}}
+        {{decimal-input-range min="0" max="100" step="0.01" value=label.maximum_capacity
class="input-sm" disabled=isAccessDisabled}}
       </div>
       {{#unless isAccessDisabled}}
         {{#if isLabelMaxCapacityDirty}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/6b87b44d/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editQueueCapacity.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editQueueCapacity.hbs
b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editQueueCapacity.hbs
index baa77db..7e2a458 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editQueueCapacity.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/components/editQueueCapacity.hbs
@@ -26,7 +26,7 @@
       <span class="input-group-addon">%</span>
     </div>
     <div class="form-group capacity-input-slider">
-      {{input-range min="0" max="100" step="1" value=queue.capacity class="input-sm"}}
+      {{decimal-input-range min="0" max="100" step="0.01" value=queue.capacity class="input-sm"}}
     </div>
     {{#if isQueueCapacityDirty}}
       <div class="btn-group btn-group-xs">
@@ -40,7 +40,7 @@
       <span class="input-group-addon">%</span>
     </div>
     <div class="form-group capacity-input-slider">
-      {{input-range min="0" max="100" step="1" value=queue.maximum_capacity class="input-sm"}}
+      {{decimal-input-range min="0" max="100" step="0.01" value=queue.maximum_capacity class="input-sm"}}
     </div>
     {{#if isQueueMaximumCapacityDirty}}
       <div class="btn-group btn-group-xs">


Mime
View raw message