[PATCH] [Kimchi] Fixed "Add a Storage Device to VM" modal behavior when guest is running

From: Samuel Guimarães <sguimaraes943@gmail.com> This patch fixes an issue when trying to attach a storage device when a guest is running. The combo box was showing the correct option but the disk panel was hidden. Samuel Guimarães (1): Fixed "Add a Storage Device to VM" modal behavior when guest is running ui/js/src/kimchi.guest_storage_add.main.js | 38 ++++++++++++++++-------------- ui/pages/guest-storage-add.html.tmpl | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) -- 1.9.3

From: Samuel Guimarães <sguimaraes943@gmail.com> Signed-off-by: Samuel Guimarães <sguimaraes943@gmail.com> --- ui/js/src/kimchi.guest_storage_add.main.js | 38 ++++++++++++++++-------------- ui/pages/guest-storage-add.html.tmpl | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/ui/js/src/kimchi.guest_storage_add.main.js b/ui/js/src/kimchi.guest_storage_add.main.js index 3f416e7..3c72a79 100644 --- a/ui/js/src/kimchi.guest_storage_add.main.js +++ b/ui/js/src/kimchi.guest_storage_add.main.js @@ -83,12 +83,12 @@ kimchi.guest_storage_add_main = function() { } formatTextbox.empty(); formatTextbox.append(selectFormatHTML); - $(formatTextbox).change(); + $(formatTextbox).trigger('change'); formatTextbox.selectpicker(); $('.selectpicker').selectpicker('refresh'); }; - typeTextbox.change(function() { + typeTextbox.on('change',function() { var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'}; selectType = $(this).val(); $.each(pathObject, function(type, value) { @@ -105,13 +105,13 @@ kimchi.guest_storage_add_main = function() { if ($('#new-disk').checked) { $('#existing-disk-box').addClass('hidden'); $(newPoolTextbox).val('default'); - $(newPoolTextbox).change(); + $(newPoolTextbox).trigger('change'); $(formatTextbox).val('qcow2'); - $(formatTextbox).change(); + $(formatTextbox).trigger('change'); } else if ($('#existing-disk').checked) { $('#new-disk-box').addClass('hidden'); $(poolTextbox).val('default'); - $(poolTextbox).change(); + $(poolTextbox).trigger('change'); } else { //Goes here the first time since radiobuttons are undefined if (rbExisting === 'true') { @@ -119,7 +119,7 @@ kimchi.guest_storage_add_main = function() { } else { $('#existing-disk-box').addClass('hidden'); $(formatTextbox).val('qcow2'); - $(formatTextbox).change(); + $(formatTextbox).trigger('change'); } } } else { @@ -159,7 +159,7 @@ kimchi.guest_storage_add_main = function() { if (radioButton === 'existing') { poolTextbox.empty(); poolTextbox.append(selectStoragePoolHTML); - $(poolTextbox).change(); + $(poolTextbox).trigger('change'); poolTextbox.selectpicker(); $('.selectpicker').selectpicker('refresh'); } else if (radioButton === 'new') { //new disk @@ -176,7 +176,7 @@ kimchi.guest_storage_add_main = function() { //First time retrieving list of Storage Pools - defaulting to new disk getStoragePools('new'); - poolTextbox.change(function() { + poolTextbox.on('change',function() { var options = []; selectStorageVolHTML = ''; volTextbox.empty(); @@ -198,7 +198,7 @@ kimchi.guest_storage_add_main = function() { } volTextbox.append(selectStorageVolHTML); $(volTextbox).val(options[0].value); - $(volTextbox).change(); + $(volTextbox).trigger('change'); $(volTextbox).prop('disabled',false); }else { $(volTextbox).prop('disabled',true); @@ -213,7 +213,7 @@ kimchi.guest_storage_add_main = function() { }, null, false); }); - typeTextbox.change(function() { + typeTextbox.on('change',function() { var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'}; var selectType = $(this).val(); $.each(pathObject, function(type, value) { @@ -226,7 +226,7 @@ kimchi.guest_storage_add_main = function() { }); var currentPage = 'new-disk-box'; - $('#existing-disk').change(function() { + $('#existing-disk').on('change',function() { if (this.checked) { rbExisting = 'true'; if (currentPage === 'new-disk-box') { @@ -246,10 +246,10 @@ kimchi.guest_storage_add_main = function() { } }); - $('#new-disk').change(function() { + $('#new-disk').on('change',function() { if (this.checked) { $(formatTextbox).val("qcow2"); - $(formatTextbox).change(); + $(formatTextbox).trigger('change'); rbExisting = 'false'; if (currentPage === 'existing-disk-box') { kimchi.switchPage(currentPage, 'new-disk-box', 'right'); @@ -268,19 +268,21 @@ kimchi.guest_storage_add_main = function() { } }); + var selectType = $(typeTextbox).val(); if (kimchi.thisVMState === 'running') { - types =typesRunning; - $(typeTextbox).val('disk'); - typeTextbox.change(); - poolTextbox.change(); + types = typesRunning; } - var selectType = $(typeTextbox).val(); for (var i = 0; i < types.length; i++) { selectStorageTypeHTML += '<option value="'+ types[i].value + '">' + types[i].label + '</option>'; } typeTextbox.append(selectStorageTypeHTML); typeTextbox.find('option:first').attr('selected','selected'); typeTextbox.selectpicker(); + if (kimchi.thisVMState === 'running') { + $(typeTextbox).val('disk'); + typeTextbox.trigger('change'); + poolTextbox.trigger('change'); + } var validateCDROM = function(settings) { if (/^((https|http|ftp|ftps|tftp|\/).*)+$/.test(settings['path'])){ diff --git a/ui/pages/guest-storage-add.html.tmpl b/ui/pages/guest-storage-add.html.tmpl index 18da825..afc72c8 100644 --- a/ui/pages/guest-storage-add.html.tmpl +++ b/ui/pages/guest-storage-add.html.tmpl @@ -39,7 +39,7 @@ <label>$_("Device Type")</label> <select id="guest-storage-type" class="selectpicker col-md-12 col-lg-12"> </select> - <p class="help-block"><i class="fa fa-info-circle"></i> $_("The device type. Currently, \"cdrom\" and \"disk\" are supported.")</p> + <p class="help-block"><i class="fa fa-info-circle"></i> $_("The device type. Currently, \"cdrom\" and \"disk\" are supported. If the guest is running, only \"disk\" is supported.")</p> </div> <div class="volume-section hidden form-group"> <div class="template-modal-container"> -- 1.9.3

I tested it and it worked but I have one comment: the default disk format should be set to qcow2. When the guest is powered off, the format is properly set to qcow2 but on running guest, the default format goes to 'bochs'. Samuel, could you fix it and resend? On 03/10/2016 04:23 PM, sguimaraes943@gmail.com wrote:
From: Samuel Guimarães <sguimaraes943@gmail.com>
This patch fixes an issue when trying to attach a storage device when a guest is running. The combo box was showing the correct option but the disk panel was hidden.
Samuel Guimarães (1): Fixed "Add a Storage Device to VM" modal behavior when guest is running
ui/js/src/kimchi.guest_storage_add.main.js | 38 ++++++++++++++++-------------- ui/pages/guest-storage-add.html.tmpl | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-)

I'll go ahead and make the change. Will send v2 shortly. Thanks -Socorro On 03/11/2016 12:45 PM, Aline Manera wrote:
I tested it and it worked but I have one comment: the default disk format should be set to qcow2.
When the guest is powered off, the format is properly set to qcow2 but on running guest, the default format goes to 'bochs'.
Samuel, could you fix it and resend?
On 03/10/2016 04:23 PM, sguimaraes943@gmail.com wrote:
From: Samuel Guimarães <sguimaraes943@gmail.com>
This patch fixes an issue when trying to attach a storage device when a guest is running. The combo box was showing the correct option but the disk panel was hidden.
Samuel Guimarães (1): Fixed "Add a Storage Device to VM" modal behavior when guest is running
ui/js/src/kimchi.guest_storage_add.main.js | 38 ++++++++++++++++-------------- ui/pages/guest-storage-add.html.tmpl | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
participants (3)
-
Aline Manera
-
sguimaraes943@gmail.com
-
Socorro Stoppler