CVSROOT:        /cvs/cluster
Module name:    conga
Changes by:     [EMAIL PROTECTED]       2008-02-08 21:48:12

Modified files:
        luci/cluster   : cluster_config-macros cluster_svc-macros 
                         form-chooser form-macros index_html 
                         system_svc-macros 
        luci/homebase  : form-macros index_html 
        luci/site/luci/Extensions: LuciValidation.py LuciZope.py 
                                   LuciZopeAsync.py LuciZopeExternal.py 
                                   conga_constants.py 
        luci/site/luci/var: Data.fs 
        luci/storage   : index_html 
Added files:
        luci/plone-custom: manage_inactive.js 

Log message:
        Fixes for 429151 and 429152

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/cluster_config-macros.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/cluster_svc-macros.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-chooser.diff?cvsroot=cluster&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.221&r2=1.222
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/index_html.diff?cvsroot=cluster&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/system_svc-macros.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/index_html.diff?cvsroot=cluster&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/manage_inactive.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeAsync.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/var/Data.fs.diff?cvsroot=cluster&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/index_html.diff?cvsroot=cluster&r1=1.14&r2=1.15

--- conga/luci/cluster/cluster_config-macros    2008/01/02 20:52:22     1.3
+++ conga/luci/cluster/cluster_config-macros    2008/02/08 21:47:55     1.4
@@ -22,9 +22,6 @@
                var cur_label_elem = null;
        </script>
        <script type="text/javascript"
-               src="conga_ajax.js">
-       </script>
-       <script type="text/javascript"
                src="validate_xvm_key.js">
        </script>
 
--- conga/luci/cluster/cluster_svc-macros       2008/01/15 04:41:41     1.3
+++ conga/luci/cluster/cluster_svc-macros       2008/02/08 21:47:55     1.4
@@ -623,7 +623,6 @@
        <script type="text/javascript"
                src="/luci/homebase/homebase_common.js">
        </script>
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript"
                src="/luci/cluster/resource_form_handlers.js">
        </script>
--- conga/luci/cluster/form-chooser     2008/01/22 15:02:33     1.24
+++ conga/luci/cluster/form-chooser     2008/02/08 21:47:55     1.25
@@ -229,6 +229,14 @@
        <tal:block tal:condition="python: ptype == '1002'">
                <div 
metal:use-macro="here/form-macros/macros/get-system-info-form" />
        </tal:block>
+
+       <tal:block tal:condition="python: ptype == '1010'">
+               <div 
metal:use-macro="here/form-macros/macros/check-inactive-form" />
+       </tal:block>
+
+       <tal:block tal:condition="python: ptype == '1011'">
+               <div 
metal:use-macro="here/form-macros/macros/update-inactive-form" />
+       </tal:block>
 </tal:block>
 </metal:choose-form>
 
--- conga/luci/cluster/form-macros      2008/01/25 00:36:59     1.221
+++ conga/luci/cluster/form-macros      2008/02/08 21:47:55     1.222
@@ -156,7 +156,6 @@
        <script type="text/javascript" 
src="/luci/homebase/homebase_common.js"></script>
        <script type="text/javascript" 
src="/luci/homebase/validate_cluster_add.js"></script>
        <script type="text/javascript" src="validate_create_gulm.js"></script>
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript" src="update_hostinfo.js"></script>
        
        <script type="text/javascript">
@@ -1075,7 +1074,6 @@
        </script>
        <script type="text/javascript" 
src="/luci/homebase/validate_cluster_add.js">
        </script>
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript" src="update_hostinfo.js"></script>
 
        <form name="add_node" action="" method="post"
@@ -1324,5 +1322,14 @@
        <tal:block tal:define="ret python: here.get_sysinfo_async(request)" />
 </div>
 
+<div metal:define-macro="check-inactive-form">
+       <tal:block tal:define="ret python: here.check_inactive_async(request)" 
/>
+</div>
+
+<div metal:define-macro="update-inactive-form">
+       <tal:block tal:define="ret python: here.update_inactive_async(request)" 
/>
+</div>
+
+
 </body>
 </html>
--- conga/luci/cluster/index_html       2008/01/22 15:02:33     1.41
+++ conga/luci/cluster/index_html       2008/02/08 21:47:56     1.42
@@ -58,17 +58,10 @@
     </metal:headslot>
 
     <metal:cssslot fill-slot="css_slot">
-               <style type="text/css">
-                       <!-- @import url(clusterportlet.css); -->
-               </style>
-               <style type="text/css">
-                       <!-- @import url(luci.css); -->
-               </style>
                <metal:cssslot define-slot="css_slot" />
     </metal:cssslot>
 
     <metal:javascriptslot fill-slot="javascript_head_slot">
-               <script type="text/javascript" src="/luci/conga.js"></script>
       <SCRIPT TYPE="text/javascript">
       <!--
        function dropdown(mySel)
--- conga/luci/cluster/system_svc-macros        2008/01/02 20:52:22     1.2
+++ conga/luci/cluster/system_svc-macros        2008/02/08 21:47:56     1.3
@@ -17,9 +17,6 @@
 
 <div metal:define-macro="system-svc-form">
        <script type="text/javascript"
-               src="conga_ajax.js">
-       </script>
-       <script type="text/javascript"
                src="/luci/cluster/validate_sys_svc.js">
        </script>
        <h2>Configure System Services</h2>
--- conga/luci/homebase/form-macros     2008/02/06 04:57:50     1.66
+++ conga/luci/homebase/form-macros     2008/02/08 21:47:56     1.67
@@ -289,7 +289,6 @@
                                        -> if yes, confirm again, showing list
        </tal:comment>
 
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript" src="update_hostinfo.js"></script>
        <script type="text/javascript" src="validate_auth.js"></script>
        <script type="text/javascript" 
src="/luci/homebase/validate_sys_remove.js">
@@ -612,7 +611,6 @@
 
        <script type="text/javascript" src="/luci/homebase/validate_sys_add.js">
        </script>
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript" src="update_hostinfo.js"></script>
 
        <script type="text/javascript">
@@ -940,7 +938,6 @@
                        - At least one node name/password are given and are 
valid
        </tal:comment>
 
-       <script type="text/javascript" src="conga_ajax.js"></script>
        <script type="text/javascript" src="update_hostinfo.js"></script>
        <script type="text/javascript" 
src="/luci/homebase/validate_cluster_add_initial.js">
        </script>
--- conga/luci/homebase/index_html      2008/01/22 15:02:32     1.26
+++ conga/luci/homebase/index_html      2008/02/08 21:47:56     1.27
@@ -34,20 +34,12 @@
        </metal:headslot>
 
        <metal:cssslot fill-slot="css_slot">
-               <style type="text/css">
-                       <!-- @import url(clusterportlet.css); -->
-               </style>
-
-               <style type="text/css">
-                       <!-- @import url(luci.css); -->
-               </style>
                <tal:block
                        tal:define="global data 
python:here.homebaseControl(request)" />
                <metal:cssslot define-slot="css_slot" />
        </metal:cssslot>
 
        <metal:javascriptslot fill-slot="javascript_head_slot">
-               <script type="text/javascript" src="/luci/conga.js"></script>
                <script type="text/javascript"
                        src="/luci/homebase/homebase_common.js">
                </script>
/cvs/cluster/conga/luci/plone-custom/manage_inactive.js,v  -->  standard output
revision 1.1
--- conga/luci/plone-custom/manage_inactive.js
+++ -   2008-02-08 21:48:13.610802000 +0000
@@ -0,0 +1,84 @@
+/*
+** Copyright (C) 2008 Red Hat, Inc.
+**
+** This program is free software; you can redistribute
+** it and/or modify it under the terms of version 2 of the
+** GNU General Public License as published by the
+** Free Software Foundation.
+*/
+
+var update_activity_url = '/luci/cluster?pagetype=1011';
+var check_inactive_url = '/luci/cluster?pagetype=1010';
+var pending_events = 0;
+
+function activity_event_handler() {
+       ++pending_events;
+}
+
+function update_activity_check(ret_status, obj) {
+       /* Doesn't matter what comes back */
+       return;
+}
+
+function check_inactive_check(ret_status, obj) {
+       if (ret_status === null) {
+               return;
+       }
+
+       if (ret_status !== true) {
+               /* A communication error occurred. */
+               return;
+       }
+
+       var err = get_ricci_response_status(obj.responseXML);
+       if (err !== null && err.length > 0) {
+               alert(err.join('\n'));
+               return;
+       }
+
+       try {
+               obj = obj.responseXML.getElementsByTagName('dict')[0];
+       } catch (e) {
+               alert('Received a malformed response from the luci server.');
+               return;
+       }
+
+       var var_elem = obj.getElementsByTagName('var');
+       for (var i = 0 ; i < var_elem.length ; i++) {
+               if (var_elem[i].getAttribute('name') == 'inactive') {
+                       if (var_elem[i].getAttribute('value') != 'False') {
+                               window.location.assign('/luci/logout');
+                               alert('You have been logged out due to 
inactivity.');
+                       }
+               }
+       }
+}
+
+function update_activity_callback() {
+       return check_ajax_xml(xmlHttp_object, update_activity_check);
+}
+
+function check_inactive_callback() {
+       return check_ajax_xml(xmlHttp_object, check_inactive_check);
+}
+
+function update_last_active() {
+       if (pending_events < 1) {
+               return (false);
+       }
+       initiate_async_get(update_activity_url, update_activity_callback);
+       pending_events = 0;
+       return (true);
+}
+
+function check_user_inactive() {
+       if (update_last_active() === true) {
+               return (0);
+       }
+       return (initiate_async_get(check_inactive_url, 
check_inactive_callback));
+}
+
+setInterval("update_last_active()", 1000 * 30);
+setInterval("check_user_inactive()", 1000 * 60);
+window.onmousemove = new Function('activity_event_handler()');
+window.onkeypress = new Function('activity_event_handler()');
--- conga/luci/site/luci/Extensions/LuciValidation.py   2008/02/05 18:26:54     
1.7
+++ conga/luci/site/luci/Extensions/LuciValidation.py   2008/02/08 21:47:56     
1.8
@@ -8,7 +8,6 @@
 from ClusterModel.RefObject import RefObject
 from ClusterModel.Service import Service
 from ClusterModel.Method import Method
-from ClusterModel.Fence import Fence
 from ClusterModel.FailoverDomain import FailoverDomain
 from ClusterModel.FailoverDomainNode import FailoverDomainNode
 from ClusterModel.QuorumD import QuorumD
--- conga/luci/site/luci/Extensions/LuciZope.py 2008/02/06 05:19:57     1.8
+++ conga/luci/site/luci/Extensions/LuciZope.py 2008/02/08 21:47:56     1.9
@@ -82,6 +82,8 @@
        if not userAuthenticated(self):
                return []
 
+       enforce_inactivity_timeout(self, req)
+
        htab = {
                'Title': 'homebase',
                'Description': 'Home base for this luci server',
@@ -163,28 +165,42 @@
 
        return '/luci/cluster/index_html?pagetype=7&clustername=%s' % 
clustername
 
+def user_update_inactive(self, request):
+       from time import time
+       if userAuthenticated(self):
+               request.SESSION.set('last_activity', int(time()))
+
 def user_check_inactive(self, request):
        from time import time
        from conga_constants import INACTIVITY_TIMEOUT_SEC as INACTIVITY_TIMEOUT
 
        if not userAuthenticated(self):
-               return
+               return (False, -1)
 
        cur_time = int(time())
        old_time = request.SESSION.get('last_activity', None)
        if old_time is None:
                request.SESSION.set('last_activity', cur_time)
-               return
+               return (False, -2)
        old_time = int(old_time)
 
        time_diff = cur_time - old_time
        if time_diff >= INACTIVITY_TIMEOUT:
-               try:
-                       
request.SESSION.getBrowserIdManager().flushBrowserIdCookie()
-                       request.SESSION.invalidate()
-               except Exception, e:
-                       if LUCI_DEBUG_MODE is True:
-                               luci_log.debug_verbose('UCI0: %r %s' % (e, 
str(e)))
-               request.RESPONSE.redirect('/luci/logout')
-       else:
-               request.SESSION.set('last_activity', cur_time)
+               return (True, time_diff)
+       return (False, time_diff)
+
+def enforce_inactivity_timeout(self, request):
+       from time import time
+       pagetype = request.get('pagetype')
+       if pagetype != '1010' and pagetype != '1011':
+               (ret, dummy) = user_check_inactive(self, request)
+               if ret is True:
+                       try:
+                               
request.SESSION.getBrowserIdManager().flushBrowserIdCookie()
+                               request.SESSION.invalidate()
+                       except Exception, e:
+                               if LUCI_DEBUG_MODE is True:
+                                       luci_log.debug_verbose('UCI0: %r %s' % 
(e, str(e)))
+                       request.RESPONSE.redirect('/luci/logout')
+               else:
+                       request.SESSION.set('last_activity', int(time()))
--- conga/luci/site/luci/Extensions/LuciZopeAsync.py    2008/02/07 06:13:04     
1.7
+++ conga/luci/site/luci/Extensions/LuciZopeAsync.py    2008/02/08 21:47:56     
1.8
@@ -169,6 +169,18 @@
        xml_obj = result_to_xml((len(errors) < len(node_list), ret))
        write_xml_resp(request, xml_obj)
 
+def check_inactive_async(self, request):
+       from LuciZope import user_check_inactive
+       (inactive, diff) = user_check_inactive(self, request)
+       xml_obj = result_to_xml((True, { 'inactive': inactive, 'diff': diff }))
+       write_xml_resp(request, xml_obj)
+
+def update_inactive_async(self, request):
+       from LuciZope import user_update_inactive
+       user_update_inactive(self, request)
+       xml_obj = result_to_xml((True, { 'result': True }))
+       write_xml_resp(request, xml_obj)
+
 def get_sysinfo_async(self, request):
        from HelperFunctions import get_system_info
 
--- conga/luci/site/luci/Extensions/LuciZopeExternal.py 2008/02/06 05:19:57     
1.8
+++ conga/luci/site/luci/Extensions/LuciZopeExternal.py 2008/02/08 21:47:56     
1.9
@@ -35,7 +35,7 @@
 
 from LuciZope import appendModel, bytes_to_value_prefunits, \
        set_persistent_var, strFilter, getTabs, siteIsSetup, \
-       getClusterURL, user_check_inactive
+       getClusterURL
 
 from LuciZopeClusterPortal import createCluChooser, createCluConfigTree
 
@@ -55,4 +55,4 @@
 from system_adapters import get_sys_svc_list, validate_manage_svc
 
 from LuciZopeAsync import get_cluster_nodes_async, get_sysinfo_async, \
-       validate_clusvc_async
+       validate_clusvc_async, check_inactive_async, update_inactive_async
--- conga/luci/site/luci/Extensions/conga_constants.py  2008/02/06 05:19:57     
1.48
+++ conga/luci/site/luci/Extensions/conga_constants.py  2008/02/08 21:47:56     
1.49
@@ -136,7 +136,6 @@
 ]
 
 REDIRECT_SEC = 5
-INACTIVITY_TIMEOUT_SEC = 600
 
 # cluster/node create error status messages
 PRE_INSTALL = 'The install state is not yet complete.'
@@ -148,6 +147,9 @@
 
 REDIRECT_MSG = ' -- You will be redirected in %d seconds.' % REDIRECT_SEC
 
+# Log users out after 10 minutes of inactivity.
+
+INACTIVITY_TIMEOUT_SEC = 600
 
 # Debugging parameters. Set LUCI_DEBUG_MODE to True and LUCI_DEBUG_VERBOSITY
 # to >= 2 to get full debugging output in syslog (LOG_DAEMON/LOG_DEBUG).
Binary files /cvs/cluster/conga/luci/site/luci/var/Data.fs      2008/02/06 
21:23:52     1.30 and /cvs/cluster/conga/luci/site/luci/var/Data.fs  2008/02/08 
21:47:56     1.31 differ
rcsdiff: /cvs/cluster/conga/luci/site/luci/var/Data.fs: diff failed
--- conga/luci/storage/index_html       2007/09/26 21:36:56     1.14
+++ conga/luci/storage/index_html       2008/02/08 21:48:12     1.15
@@ -36,7 +36,6 @@
        <metal:javascriptslot fill-slot="javascript_head_slot">
                <metal:javascriptslot define-slot="javascript_head_slot">
                        <!-- async helper functions -->
-                       <script type="text/javascript" src="conga.js"></script>
                        <script type="text/javascript" 
src="storage_async.js"></script>
                </metal:javascriptslot>
        </metal:javascriptslot>

Reply via email to