[Kimchi-devel] [PATCH 1/4] Add modes into cookie

Wen Wang wenwang at linux.vnet.ibm.com
Mon Jul 21 05:50:02 UTC 2014


On 07/19/2014 01:33 AM, Aline Manera wrote:
>
> On 07/18/2014 08:18 AM, wenwang at linux.vnet.ibm.com wrote:
>> From: Wen Wang <wenwang at linux.vnet.ibm.com>
>>
>> This patch add each tab's mode into cookie
>>
>> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
>> ---
>>   ui/js/src/kimchi.login.js |   20 +++++++++++++-------
>>   1 files changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.login.js b/ui/js/src/kimchi.login.js
>> index 72d2ee3..9f357dc 100644
>> --- a/ui/js/src/kimchi.login.js
>> +++ b/ui/js/src/kimchi.login.js
>> @@ -36,8 +36,8 @@ kimchi.login_main = function() {
>>       var loginButton = $('#btn-login');
>>
>>       var login = function(event) {
>> -        $("#login").hide()
>> -        $("#logging").show()
>> +        $("#login").hide();
>> +        $("#logging").show();
>>
>>           var userName = userNameBox.val();
>>           userName && kimchi.user.setUserName(userName);
>> @@ -50,18 +50,24 @@ kimchi.login_main = function() {
>>               var query = window.location.search;
>>               var next  = /.*next=(.*?)(&|$)/g.exec(query);
>>               if (next) {
>> -                var next_url = decodeURIComponent(next[1])
>> +                var next_url = decodeURIComponent(next[1]);
>>               }
>>               else {
>>                   var lastPage = kimchi.cookie.get('lastPage');
>> -                var next_url = lastPage ? lastPage.replace(/\"/g,'') 
>> : "/"
>> +                var next_url = lastPage ? lastPage.replace(/\"/g,'') 
>> : "/";
>>               }
>> +            var next_url = lastPage ? lastPage.replace(/\"/g,'') : "/";
>
>> +            kimchi.cookie.set('HostMode', data.roles['host'] === 
>> 'admin' ? 'admin' : 'none', 365);
>> +            kimchi.cookie.set('GuestsMode', data.roles['guests'] === 
>> 'admin' ? 'admin' : 'byInstance', 365);
>> + kimchi.cookie.set('TemplatesMode',data.roles['templates'] === 
>> 'admin' ? 'admin' : 'none', 365);
>> +            kimchi.cookie.set('StorageMode', data.roles['storage'] 
>> === 'admin' ? 'admin' : 'read-only', 365);
>> +            kimchi.cookie.set('NetworkMode', data.roles['network'] 
>> === 'admin' ? 'admin' : 'read-only', 365);
>
> You should only store the data.roles value in a cookie and use this 
> info while loading the tabs
> The mode is described in tabs.xml, and you should get it from there 
> instead of assuming values in UI
> Also remember, Kimchi supports plugins, ie, each plugin has its own 
> mode configuration described on tab-ext.xml
ACK, thanks
>
>> window.location.replace(next_url)
>>           }, function() {
>> -            $("#messUserPass").show()
>> +            $("#messUserPass").show();
>>               $("#messSession").hide();
>> -            $("#logging").hide()
>> -            $("#login").show()
>> +            $("#logging").hide();
>> +            $("#login").show();
>>           });
>>
>>           return false;
>




More information about the Kimchi-devel mailing list