[Kimchi-devel] [PATCH 2/2] Allow admin user change permission settings when VM is running

Wen Wang wenwang at linux.vnet.ibm.com
Fri Aug 22 06:03:47 UTC 2014


On 8/22/2014 2:30 AM, Aline Manera wrote:
>
> Some comments:
>
> 1) When VM is running, the edit dialog blinks when it is open to fill 
> the input boxes. (ie, in a first moment the input boxes are displayed 
> empty and after some seconds it is filled)
>     From my understanding it should not happen as the data will be 
> always displayed, the difference is if it is enabled or disabled for 
> edition.
>     Could you check it and maybe do some improvements?
I have tried to rebase for the investigation. By adding no code just 
enable the "Edit" button when VM is running, the time-delay still 
exists. So this should probably not be the problem that front-end cause. 
Could you please help with the investigation in the back-end? Could it 
be the problem caused by retrieving information delay when VM is running?
>
> 2) There is a different behavior in  Storage tab to Network tab.
>      In the Storage tab the disks (that can not be edited) are listed 
> without any icon BUT in the Network tab, there is an edit icon disabled.
>      I suggest to remove the icon when edition is not allowed.
>
I have fixed this in V2
>
> On 08/21/2014 08:38 AM, Wen Wang wrote:
>> Functions changed:
>> 1) Enable "Edit" whether VM is running or off
>> 2) Disable edit function of "General", "Storage", "Interface" except
>> "replace" of the cdrom under "Storage".
>>
>> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
>> ---
>>   ui/js/src/kimchi.guest_edit_main.js |   54 
>> ++++++++++++++++++++++++-----------
>>   ui/js/src/kimchi.guest_main.js      |    1 -
>>   ui/pages/guest-edit.html.tmpl       |    2 +-
>>   3 files changed, 38 insertions(+), 19 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.guest_edit_main.js 
>> b/ui/js/src/kimchi.guest_edit_main.js
>> index 01d8045..ab63bb2 100644
>> --- a/ui/js/src/kimchi.guest_edit_main.js
>> +++ b/ui/js/src/kimchi.guest_edit_main.js
>> @@ -19,7 +19,12 @@ kimchi.guest_edit_main = function() {
>>       var buttonContainer = $('#action-button-container');
>>       $('#guest-edit-tabs').tabs({
>>           beforeActivate: function(event, ui) {
>> -            var display_list = ['form-guest-edit-general', 
>> 'form-guest-edit-permission']
>> +            var display_list = null;
>> +            if(kimchi.thisVMState === "running") {
>> +                display_list = ['form-guest-edit-permission'];
>> +            } else {
>> +                display_list = ['form-guest-edit-general', 
>> 'form-guest-edit-permission'];
>> +            }
>>               $(buttonContainer).addClass('hidden');
>>               var deactivated = ui['newPanel'];
>>               if(display_list.indexOf($(deactivated).attr('id')) >= 0) {
>> @@ -52,12 +57,17 @@ kimchi.guest_edit_main = function() {
>>                   text: false
>>               });
>>
>> -            $('.detach', container).button({
>> -                icons: {
>> -                    primary: 'ui-icon-trash'
>> -                },
>> -                text: false
>> -            });
>> +            if(kimchi.thisVMState != "running") {
>> +                $('.detach', container).button({
>> +                    icons: {
>> +                        primary: 'ui-icon-trash'
>> +                    },
>> +                    text: false
>> +                });
>> +
>> +            } else {
>> +                $('.detach', container).remove();
>> +            }
>>
>>               $('.save', container).button({
>>                   icons: {
>> @@ -170,6 +180,9 @@ kimchi.guest_edit_main = function() {
>>               var itemNode = 
>> $.parseHTML(kimchi.substitute($('#interface-tmpl').html(),data));
>>               $(".body", "#form-guest-edit-interface").append(itemNode);
>>               $("select", itemNode).append(networkOptions);
>> +            if(kimchi.thisVMState === "running") {
>> +                $("#form-guest-edit-interface .delete").remove();
>> +            }
>>               if(data.network!==""){
>>                   $("select", itemNode).val(data.network);
>>               }
>> @@ -340,18 +353,25 @@ kimchi.guest_edit_main = function() {
>>       var initContent = function(guest) {
>>           guest['icon'] = guest['icon'] || 'images/icon-vm.png';
>>           $('#form-guest-edit-general').fillWithObject(guest);
>> +        kimchi.thisVMState = guest['state'];
>>
>>           refreshCDROMs();
>> -
>> -        $('#guest-edit-attach-cdrom-button').button({
>> -            icons: {
>> -                primary: "ui-icon-plusthick"
>> -            },
>> -            text: false
>> -        }).click(function(event) {
>> -            event.preventDefault();
>> -            kimchi.window.open("guest-storage-add.html");
>> -        });
>> +        if(kimchi.thisVMState === "running") {
>> +            $("#form-guest-edit-general input").prop("disabled", 
>> "disabled");
>> +            $("#guest-edit-attach-cdrom-button").remove();
>> +            $("#form-guest-edit-interface .header button").remove();
>> +        } else {
>> +            $('#guest-edit-attach-cdrom-button').button({
>> +                icons: {
>> +                    primary: "ui-icon-plusthick"
>> +                },
>> +                text: false
>> +            }).click(function(event) {
>> +                event.preventDefault();
>> +                kimchi.window.open("guest-storage-add.html");
>> +            });
>> + $("#action-button-container").removeClass("hidden");
>> +        }
>>
>>           var onAttached = function(params) {
>>               refreshCDROMs();
>> diff --git a/ui/js/src/kimchi.guest_main.js 
>> b/ui/js/src/kimchi.guest_main.js
>> index 320847e..5cbdb40 100644
>> --- a/ui/js/src/kimchi.guest_main.js
>> +++ b/ui/js/src/kimchi.guest_main.js
>> @@ -253,7 +253,6 @@ kimchi.createGuestLi = function(vmObject, 
>> prevScreenImage, openMenu) {
>>       //Setup the VM Actions
>>       var guestActions=result.find("div[name=guest-actions]");
>>       guestActions.find(".shutoff-disabled").prop('disabled', 
>> !vmRunningBool );
>> -    guestActions.find(".running-disabled").prop('disabled', 
>> vmRunningBool );
>>
>>       if (vmRunningBool) {
>>           guestActions.find(".running-hidden").hide();
>> diff --git a/ui/pages/guest-edit.html.tmpl 
>> b/ui/pages/guest-edit.html.tmpl
>> index ed7ddeb..47615be 100644
>> --- a/ui/pages/guest-edit.html.tmpl
>> +++ b/ui/pages/guest-edit.html.tmpl
>> @@ -145,7 +145,7 @@
>>           </div>
>>       </div>
>>       <footer>
>> -        <div id="action-button-container" class="btn-group">
>> +        <div id="action-button-container" class="btn-group hidden">
>>               <button id="guest-edit-button-save" class="btn-normal">
>>                   <span class="text">$_("Save")</span>
>>               </button>
>





More information about the Kimchi-devel mailing list