[Kimchi-devel] [PATCH] VM Edit: CPU and memory

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Thu Apr 10 22:09:33 UTC 2014


Adam, during my tests I found 2 problems you need to fix:
- cpus and memory must be number, not string
- if an error occurs, the save button remains disabled forever

These changes can fix the problem:

      var submitForm = function(event) {
          $(saveButton).prop('disabled', true);
          var data=$('#form-guest-edit-general').serializeObject();
+        data['memory'] = Number(data['memory']);
+        data['cpus']   = Number(data['cpus']);
          kimchi.updateVM(kimchi.selectedGuest, data, function() {
              kimchi.listVmsAuto();
              kimchi.window.close();
          }, function(err) {
              kimchi.message.error(err.responseJSON.reason);
+            $(saveButton).prop('disabled', false);
          });


feel free to implement as you think more appropriate.

Thanks,

Rodrigo


On 04/10/2014 11:23 AM, Rodrigo Trujillo wrote:
> Adam,
>
> can you please modify the "Memory" lable in edit window ??
> Change from "Memory" to "Memory (MB)" ... then we avoid user mistakes 
> when he updates the number
>
> Rodrigo
>
> On 04/07/2014 03:30 PM, Adam King wrote:
>> Update the edit VM form to use the new form extensions.
>> Enable the cpu and memory fields to be edited.
>>
>> Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
>> ---
>>   ui/js/src/kimchi.guest_edit_main.js | 10 ++--------
>>   ui/pages/guest-edit.html.tmpl       | 12 +++++-------
>>   2 files changed, 7 insertions(+), 15 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.guest_edit_main.js 
>> b/ui/js/src/kimchi.guest_edit_main.js
>> index 9375c51..4758dc0 100644
>> --- a/ui/js/src/kimchi.guest_edit_main.js
>> +++ b/ui/js/src/kimchi.guest_edit_main.js
>> @@ -80,9 +80,7 @@ kimchi.guest_edit_main = function() {
>>
>>       var initContent = function(guest) {
>>           guest['icon'] = guest['icon'] || 'images/icon-vm.png';
>> -        for ( var prop in guest) {
>> -            $('input[name="' + prop + '"]', 
>> guestEditForm).val(guest[prop]);
>> -        }
>> +        $('#form-guest-edit-general').fillWithObject(guest);
>>
>>           refreshCDROMs();
>>
>> @@ -116,11 +114,7 @@ kimchi.guest_edit_main = function() {
>>
>>       var submitForm = function(event) {
>>           $(saveButton).prop('disabled', true);
>> -        var editableFields = [ 'name' ];
>> -        var data = {};
>> -        $.each(editableFields, function(i, field) {
>> -            data[field] = $('#form-guest-edit [name="' + field + 
>> '"]').val();
>> -        });
>> +        var data=$('#form-guest-edit-general').serializeObject();
>>           kimchi.updateVM(kimchi.selectedGuest, data, function() {
>>               kimchi.listVmsAuto();
>>               kimchi.window.close();
>> diff --git a/ui/pages/guest-edit.html.tmpl 
>> b/ui/pages/guest-edit.html.tmpl
>> index 804fc39..bf7ea56 100644
>> --- a/ui/pages/guest-edit.html.tmpl
>> +++ b/ui/pages/guest-edit.html.tmpl
>> @@ -59,8 +59,7 @@
>>                               <input
>>                                   id="guest-edit-cores-textbox"
>>                                   name="cpus"
>> -                                type="text"
>> -                                disabled="disabled" />
>> +                                type="text" />
>>                           </div>
>>                       </div>
>>                       <div>
>> @@ -72,8 +71,7 @@
>>                           <div class="guest-edit-wrapper-controls">
>>                               <input id="guest-edit-memory-textbox"
>>                                   name="memory"
>> -                                type="text"
>> -                                disabled="disabled" />
>> +                                type="text" />
>>                           </div>
>>                       </div>
>>                       <div>
>> @@ -98,7 +96,7 @@
>>                       <div>
>>                           <button id="guest-edit-attach-cdrom-button"
>>                               class="guest-edit-cdrom-button attach"
>> -                            title="$_("Attach")">
>> +                            title='$_("Attach")'>
>>                           </button>
>>                       </div>
>>                   </fieldset>
>> @@ -124,11 +122,11 @@
>>                   value="{path}" readonly="readonly" />
>>               <button class="guest-edit-cdrom-button replace"
>>                   data-vm="{vm}" data-dev="{dev}"
>> -                title="$_("Replace")">
>> +                title='$_("Replace")'>
>>               </button>
>>               <button class="guest-edit-cdrom-button detach"
>>                   data-vm="{vm}" data-dev="{dev}"
>> -                title="$_("Detach")">
>> +                title='$_("Detach")'>
>>               </button>
>>           </div>
>>       </div>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list