[Kimchi-devel] [PATCH 3/3] Issue 294 The auto logout leaves action menu on page - update JS

Adam King rak at linux.vnet.ibm.com
Mon Mar 10 16:21:24 UTC 2014


This patch updates those parts of the DOM marked with the classes
remove-when-logged-off and empty-when-logged-off
removing or emptying sections as noted by class.

Additionally, the change reloads the browser whenever the AJAX request
which caused us to detect that the session has ended is not marked for
resend. This handles the case where we are in some subwindow of the UI
when we detect that our session has ended, and loads the correct tab.

Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.login_window.js | 3 +++
 ui/js/src/kimchi.main.js         | 2 ++
 ui/js/src/kimchi.network.js      | 2 +-
 ui/pages/tabs/network.html.tmpl  | 2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ui/js/src/kimchi.login_window.js b/ui/js/src/kimchi.login_window.js
index 22d74e0..e9af18f 100644
--- a/ui/js/src/kimchi.login_window.js
+++ b/ui/js/src/kimchi.login_window.js
@@ -87,6 +87,9 @@ kimchi.login_main = function() {
                 $.ajax(pAjax);
                 kimchi.previousAjax = null;
             }
+            else if(pAjax) {
+                window.location.reload();
+            }
 
             kimchi.user.showUser(true);
             kimchi.window.close();
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index c9d56e4..8d12525 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -156,6 +156,8 @@ kimchi.main = function() {
             if (jqXHR['status'] === 401) {
                 kimchi.user.showUser(false);
                 kimchi.previousAjax = ajaxSettings;
+                $(".empty-when-logged-off").empty();
+                $(".remove-when-logged-off").remove();
                 kimchi.window.open({
                     url: 'login-window.html',
                     id: 'login-window-wrapper'
diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index d68697a..a768833 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -187,7 +187,7 @@ kimchi.initNetworkDialog = function() {
         draggable : false,
         resizable : false,
         closeText: "X",
-        dialogClass : "network-ui-dialog",
+        dialogClass : "network-ui-dialog remove-when-logged-off",
         open : function(){
             $(".ui-dialog-titlebar-close", $("#networkConfig").parent()).removeAttr("title");
         },
diff --git a/ui/pages/tabs/network.html.tmpl b/ui/pages/tabs/network.html.tmpl
index 2397fd4..bbb43e3 100644
--- a/ui/pages/tabs/network.html.tmpl
+++ b/ui/pages/tabs/network.html.tmpl
@@ -85,7 +85,7 @@
     </div>
 </div>
 <script id="networkItem" type="text/html">
-    <div id='{name}' class='item'>
+    <div id='{name}' class='item remove-when-logged-off'>
     <span class='column column-name cell' title="{name}">{name}</span><!--
  --><span class='column column-state cell'><span class='network-state {state}'></span></span><!--
  --><span class='column column-type cell'>{type}</span><!--
-- 
1.8.1.4




More information about the Kimchi-devel mailing list