From: Samuel Guimarães <sguimaraes943(a)gmail.com>
Signed-off-by: Samuel Guimarães <sguimaraes943(a)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