You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/08/07 13:08:35 UTC

[cloudstack] branch master updated: ui: fix for custom constrained offering params range check (#3545)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new a10e539  ui: fix for custom constrained offering params range check (#3545)
a10e539 is described below

commit a10e539dd6226dc98d36bc2a459b69be48b5a947
Author: Abhishek Kumar <ab...@gmail.com>
AuthorDate: Wed Aug 7 18:38:22 2019 +0530

    ui: fix for custom constrained offering params range check (#3545)
    
    This PR fixes range check in VM deployment wizard while using custom constrained offering.
    Existing code was failing while checking user input value in the form for CPU cores and RAM size when minimum and maximum value vary in digit count.
    Also, while re-selecting offerings slider position was not restored to minimum value. THis has been fixed with changes.
    
    Signed-off-by: Abhishek Kumar <ab...@gmail.com>
---
 ui/scripts/ui-custom/instanceWizard.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js
index 5ce1870..b240c37 100644
--- a/ui/scripts/ui-custom/instanceWizard.js
+++ b/ui/scripts/ui-custom/instanceWizard.js
@@ -636,8 +636,8 @@
                                                 $step.find('.custom-slider-container').show();
                                                 var setupSlider = function(sliderClassName, minVal, maxVal) {
                                                     $step.find('.custom-slider-container .' + sliderClassName + ' .size.min span').html(minVal);
-                                                    $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').val(minVal);
                                                     $step.find('.custom-slider-container .' + sliderClassName + ' .size.max span').html(maxVal);
+                                                    $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').val(minVal);
                                                     $step.find('.custom-slider-container .' + sliderClassName + ' .slider').each(function() {
                                                         var $slider = $(this);
                                                         $slider.slider({
@@ -651,20 +651,22 @@
                                                     });
 
                                                     $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').bind('change', function() {
-                                                        var val = $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').val();
+                                                        var val = parseInt($(this).val(), 10);
                                                         if (val < minVal || val > maxVal) {
                                                             cloudStack.dialog.notice({ message: $.validator.format(_l('message.validate.range'), [minVal, maxVal]) });
                                                         }
                                                         if (val < minVal) {
                                                             val = minVal;
-                                                            $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').val(val);
+                                                            $(this).val(val);
                                                         }
                                                         if(val > maxVal) {
                                                             val = maxVal;
-                                                            $step.find('.custom-slider-container .' + sliderClassName + ' input[type=text]').val(val);
+                                                            $(this).val(val);
                                                         }
                                                         $step.find('span.custom-slider-container .' + sliderClassName).html(_s(val));
+                                                        $step.find('.custom-slider-container .' + sliderClassName + ' span.ui-slider-handle').css('left', (((val-minVal)/(maxVal-minVal))*100)+'%');
                                                     });
+                                                    $step.find('.custom-slider-container .' + sliderClassName + ' span.ui-slider-handle').css('left', '0%');
                                                 }
                                                 setupSlider('slider-cpu-cores', minCpuNumber, maxCpuNumber);
                                                 setupSlider('slider-memory-mb', minMemory, maxMemory);