From 3275a9251e0d52a21acbfcfcd5cc3a88a1e10a48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Tue, 7 Sep 2010 08:18:26 +0000
Subject: [PATCH] add page template & action to tail the event log

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38163 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_actions/tail_event_log.xml         |  71 +++++++++
 .../IntrospectionTool_tailEventLog.xml        | 140 ++++++++++++++++++
 bt5/erp5_administration/bt/revision           |   2 +-
 .../bt/template_action_path_list              |   1 +
 4 files changed, 213 insertions(+), 1 deletion(-)
 create mode 100644 bt5/erp5_administration/ActionTemplateItem/portal_types/portal_actions/tail_event_log.xml
 create mode 100644 bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/IntrospectionTool_tailEventLog.xml

diff --git a/bt5/erp5_administration/ActionTemplateItem/portal_types/portal_actions/tail_event_log.xml b/bt5/erp5_administration/ActionTemplateItem/portal_types/portal_actions/tail_event_log.xml
new file mode 100644
index 0000000000..7d7b014e75
--- /dev/null
+++ b/bt5/erp5_administration/ActionTemplateItem/portal_types/portal_actions/tail_event_log.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>action</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>category</string> </key>
+            <value> <string>global</string> </value>
+        </item>
+        <item>
+            <key> <string>condition</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>icon</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>tail_event_log</string> </value>
+        </item>
+        <item>
+            <key> <string>permissions</string> </key>
+            <value>
+              <tuple>
+                <string>Manage portal</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>priority</string> </key>
+            <value> <float>200.0</float> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Tail Event Log</string> </value>
+        </item>
+        <item>
+            <key> <string>visible</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="Expression" module="Products.CMFCore.Expression"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>text</string> </key>
+            <value> <string>string:${portal_url}/portal_introspections/IntrospectionTool_tailEventLog</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/IntrospectionTool_tailEventLog.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/IntrospectionTool_tailEventLog.xml
new file mode 100644
index 0000000000..389d7ddcad
--- /dev/null
+++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/IntrospectionTool_tailEventLog.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+<html>\n
+  <head>\n
+    <script type="text/javascript">\n
+      var request;\n
+      var url;\n
+      function init(my_url){\n
+      url = my_url;\n
+      try {\n
+        request = new XMLHttpRequest();\n
+      } catch (trymicrosoft) {\n
+        try {\n
+          request = new ActiveXObject("Msxml2.XMLHTTP");\n
+        } catch (othermicrosoft) {\n
+          try {\n
+            request = new ActiveXObject("Microsoft.XMLHTTP");\n
+          } catch (failed) {\n
+            request = null;\n
+            } \n
+          }\n
+        }\n
+      if (request == null)\n
+        alert("Error creating request object!");\n
+   \n
+      request = createRequest();\n
+      }\n
+\n
+      function getLog(timer) {\n
+      request.open("GET", url, true);\n
+      request.onreadystatechange = updatePage;\n
+      request.send(null);\n
+      startTail(timer);\n
+      }\n
+\n
+      function startTail(timer, url) {\n
+        if (timer == "stop") {\n
+          stopTail();\n
+        } else {\n
+          t= setTimeout("getLog()",4000);\n
+        }\n
+      }\n
+\n
+      function stopTail() {\n
+        clearTimeout(t);\n
+        var pause = "The log viewer has been paused. To begin viewing logs again, click the Start Viewer button.";\n
+        logDiv = document.getElementById("log");\n
+        var newNode=document.createTextNode(pause);\n
+        logDiv.replaceChild(newNode,logDiv.childNodes[0]);\n
+      }\n
+\n
+      function updatePage() {\n
+        if (request.readyState == 4) {\n
+          if (request.status == 200) {\n
+            var currentLogValue = request.responseText.split("\\n");\n
+            eval(currentLogValue);\n
+            logDiv = document.getElementById("log");\n
+            var logLine = \' \';\n
+            for (i=0; i < currentLogValue.length - 1; i++) {\n
+              logLine += currentLogValue[i] + \'<br/>\\n\';\n
+            }\n
+            logDiv.innerHTML=logLine;\n
+          } else\n
+            alert("Error! Request status is " + request.status);\n
+        }\n
+      }\n
+    </script>\n
+   </head>\n
+  <span tal:define="global tailer python:context.getPortalObject().portal_introspections.absolute_url()+\'/tailEventLog\'">\n
+  <body tal:attributes="onload string:init(\'$tailer\')">\n
+      <button tal:attributes="onclick string:getLog(\'start\')">Start Log</button>\n
+      <button onclick="stopTail();">Stop Log</button>\n
+    <div id="log" style="border:solid 1px #dddddd; margin-left:25px; font-size:9px;\n
+                         padding-left:5px; padding-right:10px; padding-top:10px; padding-bottom:20px;\n
+                         margin-top:10px; margin-bottom:10px; width:90%; text-align:left;">\n
+      This is the Event Log Viewer. To begin viewing the log live in this window, click Start Viewer. To stop the window refreshes, click Pause Viewer.\n
+    </div>\n
+  </body>\n
+  </span>\n
+</html>\n
+
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>content_type</string> </key>
+            <value> <string>text/html</string> </value>
+        </item>
+        <item>
+            <key> <string>expand</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>IntrospectionTool_tailEventLog</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_administration/bt/revision b/bt5/erp5_administration/bt/revision
index c9c41087e2..078fa0fe57 100644
--- a/bt5/erp5_administration/bt/revision
+++ b/bt5/erp5_administration/bt/revision
@@ -1 +1 @@
-114
\ No newline at end of file
+119
diff --git a/bt5/erp5_administration/bt/template_action_path_list b/bt5/erp5_administration/bt/template_action_path_list
index e39651a2bd..db33df1d26 100644
--- a/bt5/erp5_administration/bt/template_action_path_list
+++ b/bt5/erp5_administration/bt/template_action_path_list
@@ -1,4 +1,5 @@
 Applied Rule | view
 Simulation Movement | view
 Simulation Tool | view
+portal_actions | tail_event_log
 portal_properties | consistency
\ No newline at end of file
-- 
2.30.9