diff --git a/src/sunstone/public/app/tabs/vms-tab/dialogs/disk-resize.js b/src/sunstone/public/app/tabs/vms-tab/dialogs/disk-resize.js
index b26d3bd5e3..7c12fddda6 100644
--- a/src/sunstone/public/app/tabs/vms-tab/dialogs/disk-resize.js
+++ b/src/sunstone/public/app/tabs/vms-tab/dialogs/disk-resize.js
@@ -23,7 +23,8 @@ define(function(require) {
var TemplateHTML = require('hbs!./disk-resize/html');
var Sunstone = require('sunstone');
var Tips = require('utils/tips');
- var RangeSlider = require('utils/range-slider');
+ var UserInputs = require("utils/user-inputs");
+ //var RangeSlider = require('utils/range-slider');
var Humanize = require('utils/humanize');
/*
@@ -82,13 +83,16 @@ define(function(require) {
Tips.setup(context);
var oneTera = Humanize.sizeToMB("1024GB")*1024;
var max = that.diskSize > oneTera? that.diskSize*1024 : oneTera;
- $( ".diskSlider", context).html(RangeSlider.html({
- min: that.diskSize,
- max: max,
- initial: that.diskSize,
- name: "resize",
- max_value: ""
- }));
+ var attrs = {
+ min: that.diskSize,
+ max: max,
+ initial: that.diskSize,
+ name: "resize",
+ max_value: "",
+ type: "range"
+ }
+ //$( ".diskSlider", context).html(RangeSlider.html(attrs));
+ UserInputs.insertAttributeInputMB(attrs, $(".diskSlider", context))
$( ".uinput-slider-val",context).prop('type', 'text');
$( ".uinput-slider-val",context).val(Humanize.size($( ".uinput-slider",context).val()));
diff --git a/src/sunstone/public/app/utils/range-slider.js b/src/sunstone/public/app/utils/range-slider.js
index 502836b119..43b1523280 100644
--- a/src/sunstone/public/app/utils/range-slider.js
+++ b/src/sunstone/public/app/utils/range-slider.js
@@ -45,7 +45,6 @@ define(function(require) {
function _html(opts) {
opts['sliderId'] = sliderId;
-
opts['ticks'] = [];
if (opts.tick_size !== undefined){
var tick_val = opts.tick_size * Math.ceil(opts.min / opts.tick_size);
@@ -53,6 +52,15 @@ define(function(require) {
opts['ticks'].push(tick_val);
tick_val += opts.tick_size;
}
+ if(
+ opts &&
+ opts.min &&
+ opts.tick_size &&
+ parseInt(opts.min,10) &&
+ parseInt(opts.min, 10) < parseInt(opts.tick_size)
+ ){
+ opts['ticks'].unshift(opts.min)
+ }
}
sliderId += 1;
return TemplateHTML(opts);
@@ -66,9 +74,10 @@ define(function(require) {
if(parseInt(this.value) > parseInt(max))
$("input[type=number]", $(this).closest('.uinput-slider-container')).val(max);
});
-
$(document).off("input", "input.uinput-slider");
$(document).on("input", "input.uinput-slider", function(){
+ //change selector to MB
+ $(".mb_input_unit", $(this).closest('.mb_input_wrapper')).val("MB");
$("input[type=number]", $(this).closest('.uinput-slider-container')).val( this.value );
});
}
diff --git a/src/sunstone/public/app/utils/range-slider/html.hbs b/src/sunstone/public/app/utils/range-slider/html.hbs
index 7655fc9286..8973fe2481 100644
--- a/src/sunstone/public/app/utils/range-slider/html.hbs
+++ b/src/sunstone/public/app/utils/range-slider/html.hbs
@@ -34,10 +34,13 @@
-
+ {{#if disabled}}disabled="true"{{/if}}/>
+
diff --git a/src/sunstone/public/app/utils/user-inputs.js b/src/sunstone/public/app/utils/user-inputs.js
index ad8f15150a..ec2b94a71d 100644
--- a/src/sunstone/public/app/utils/user-inputs.js
+++ b/src/sunstone/public/app/utils/user-inputs.js
@@ -718,52 +718,11 @@ define(function(require) {
if (attr.type == "range"){
attr.tick_size = 1024;
}
- delete attr_gb.initial;
- attr_gb.wizard_field_disabled = true;
- if (attr_gb.type == "range"){
- attr_gb.type = "range-float";
- attr_gb.min = Math.ceil((attr_gb.min / 1024));
- attr_gb.max = Math.floor((attr_gb.max / 1024));
- attr_gb.step = "1";
- attr_gb.tick_size = 1;
- } else if (attr_gb.type == "list"){
- attr_gb.options = attr_gb.options.map(function(e){
- return e / 1024;
- });
- } else if (attr_gb.type == "number"){
- attr_gb.type = "number-float";
- attr_gb.step = "0.1";
- }
- // Modified input for TB
- var attr_tb = $.extend({}, attr);
- delete attr_tb.initial;
- attr_tb.wizard_field_disabled = true;
- if (attr_tb.type == "range"){
- attr_tb.type = "range-float";
- attr_tb.min = (attr_tb.min / (1024*1024));
- attr_tb.max = (attr_tb.max / (1024*1024));
- attr_tb.step = "0.0001";
- attr_tb.tick_size = 0.0001;
- } else if (attr_tb.type == "list"){
- attr_tb.options = attr_tb.options.map(function(e){
- return e / (1024*1024);
- });
- } else if (attr_tb.type == "number"){
- attr_tb.type = "number-float";
- attr_tb.step = "0.1";
- }
div.html(
"");
_setupAttributeInputMB(div);
- // Update attr_gb with the value set in attr
$("input, select", $("div.mb_input", div)).trigger("input");
var input_val = $("input, select", $("div.mb_input", div)).val();
if (input_val == ""){
$(".mb_input_unit", div).val("GB").change();
}else{
- if ((input_val >= 1024) && (input_val < 1048576) && (input_val % 1024 == 0)){
+ if (
+ (input_val >= 1024) &&
+ (input_val < 1048576) &&
+ (input_val % 1024 == 0)
+ ){
$(".mb_input_unit", div).val("GB").change();
} else if ((input_val >= 1048576) && (input_val % 1048576 == 0)){
$(".mb_input_unit", div).val("TB").change();
@@ -790,72 +752,53 @@ define(function(require) {
}
function _setupAttributeInputMB(context) {
- // MB to GB and TB
- $("div.mb_input", context).on("change", "input, select", function(){
- var valGB = "";
- var valTB = "";
+ $("div.mb_input", context).on("change", "input.visor, select", function(e){
+ var base = 1024;
+ var baseCal = 1;
+ var unit = "MB";
+ var valueInMB = 0;
+ var element = $(this);
+ var min = parseInt(element.attr("data-min"),10);
+ var max = parseInt(element.attr("data-max"),10);
+ var value = element.val();
+ var valueInUnit = value;
- if (this.value && this.value >= 0) {
- valGB = this.value / 1024;
- valTB = this.value / 1048576;
+ var contextElement = $("div.mb_input", context);
+ var mb_input_unit_val = $(".mb_input_unit :selected", context).val();
+
+ switch (mb_input_unit_val) {
+ case 'TB':
+ baseCal = base**2;
+ unit = "TB";
+ break;
+ case 'GB':
+ baseCal = base;
+ unit = "GB";
+ break;
+ default:
+ break;
}
- $("input, select", $("div.gb_input", context)).val(valGB);
- $("input, select", $("div.tb_input", context)).val(valTB);
- });
-
- // GB to MB and TB
- $("div.gb_input", context).on("change", "input, select", function(){
- var valMB = "";
- var valTB = "";
-
- if (this.value && this.value >= 0) {
- valMB = Math.floor(this.value * 1024);
- valTB = this.value / 1024;
+ if (value && value.length > 0) {
+ //aca se puede colocar el div de validation de min and max
+ valueInMB = value * baseCal;
+ if(!isNaN(min) && parseInt(min, 10) > valueInMB ){
+ valueInMB = min;
+ }
+ $("input, select", contextElement).val(valueInMB);
+ valueInUnit = valueInMB / baseCal;
}
- $("input, select", $("div.mb_input", context)).val(valMB);
- $("input, select", $("div.tb_input", context)).val(valTB);
- });
-
- // TB to MB and GB
- $("div.tb_input", context).on("change", "input, select", function(){
- var valMB = "";
- var valGB = "";
-
- if (this.value && this.value >= 0) {
- valGB = Math.floor(this.value * (1024));
- valMB = Math.floor(this.value * (1048576));
- }
-
- $("input, select", $("div.mb_input", context)).val(valMB);
- $("input, select", $("div.gb_input", context)).val(valGB);
+ $("input.visor", contextElement).val(valueInUnit);
+ var contextUnit = contextElement.siblings(".input-group-button");
+ $(".mb_input_unit", contextUnit).val(unit);
});
// Unit select
$(".mb_input_unit", context).on("change", function() {
var mb_input_unit_val = $(".mb_input_unit :selected", context).val();
-
- if (mb_input_unit_val == "TB") {
- $("div.mb_input", context).hide();
- $("div.gb_input", context).hide();
- $("div.tb_input", context).show();
-
- $("input, select", $("div.mb_input",context)).trigger("change");
- } else if (mb_input_unit_val == "GB") {
- $("div.mb_input", context).hide();
- $("div.gb_input", context).show();
- $("div.tb_input", context).hide();
-
- $("input, select", $("div.mb_input",context)).trigger("change");
- } else {
- $("div.mb_input", context).show();
- $("div.gb_input", context).hide();
- $("div.tb_input", context).hide();
- }
+ $("input, select", $("div.mb_input",context)).trigger("change");
});
-
- $(".mb_input_unit", context).change();
}
/**