[Kimchi-devel] [PATCH V4] Bugfix#424: Edit Template, "Disk (GB)" is changing with storage pool

Wen Wang wenwang at linux.vnet.ibm.com
Wed Sep 24 07:54:49 UTC 2014


From: Wen Wang <wenwang at linux.vnet.ibm.com>

V3 -> V4:
Change the variable name that store "Disk(GB)" into the format without
"kimchi" and fixed oneline of error coding.

V2 -> V3:
Make the value of "Disk(GB)" inputbox consistent with user input. If
choosing iSCSI or SCSI, inputbox is disabled and value of "Disk(GB)" is
refreshed with the system. If changing back, the value stays the same
with user last input.

V1 -> V2:
Considering iSCSI and SCSI situation that we need to have the input box
disabled when choosing iSCSI and SCSI for storage pool and enable when
choosing others.

This patch fix the bug that value of "Disk(GB)" input box is changing
with the item of "Storage Pool" in "Templates" --> "Actions" --> "Edit"
-->"Edit Templates" dialogue. This might be comfusing to user when
changing the "Storage Pool", "Disk(GB)" is changed with it without even
notice. This might confuse the users and is not necessary. Solved by
removing the change.

Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.template_edit_main.js |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index cb43091..2f4cc9a 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -19,6 +19,7 @@ kimchi.template_edit_main = function() {
     var templateEditForm = $('#form-template-edit');
     var origDisks;
     var origPool;
+    var templateDiskSize;
     $('#template-name', templateEditForm).val(kimchi.selectedTemplate);
     kimchi.retrieveTemplate(kimchi.selectedTemplate, function(template) {
         origDisks =  template.disks;
@@ -40,6 +41,7 @@ kimchi.template_edit_main = function() {
         }
         var disks = template.disks;
         $('input[name="disks"]').val(disks[0].size);
+        templateDiskSize = $('input[name="disks"]').val();
         if (disks[0].volume) {
             var spool_value = $('#form-template-edit [name="storagepool"]').val();
             $('input[name="storagepool"]', templateEditForm).val(spool_value + '/' + disks[0].volume);
@@ -131,16 +133,13 @@ kimchi.template_edit_main = function() {
                 kimchi.message.error(err.responseJSON.reason);
             });
         } else {
-            if (origPool == storagepool) {
-                // Previous disk size value
-                $('input[name="disks"]', templateEditForm).val(origDisks[0].size);
-            } else {
-                // Default disk size value
-                $('input[name="disks"]', templateEditForm).val(10);
-            }
             $('input[name="disks"]', templateEditForm).removeAttr('disabled');
+            $('input[name="disks"]', templateEditForm).val(templateDiskSize);
         }
     });
+    $('input[name="disks"]', templateEditForm).keyup(function() {
+        templateDiskSize = $('input[name="disks"]', templateEditForm).val();
+    });
 
     $('#tmpl-edit-button-save').on('click', function() {
         var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
-- 
1.7.1




More information about the Kimchi-devel mailing list