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

wenwang at linux.vnet.ibm.com wenwang at linux.vnet.ibm.com
Fri Jul 18 11:18:06 UTC 2014


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);
             window.location.replace(next_url)
         }, function() {
-            $("#messUserPass").show()
+            $("#messUserPass").show();
             $("#messSession").hide();
-            $("#logging").hide()
-            $("#login").show()
+            $("#logging").hide();
+            $("#login").show();
         });
 
         return false;
-- 
1.7.1




More information about the Kimchi-devel mailing list