Commit 4fa3a1b9 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core] Allow to view the activity watcher in ERP5JS

parent d72c36be
......@@ -16,13 +16,13 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_report</string>
<string>action_type/object_jio_report</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_report</string> </value>
<value> <string>object_jio_report</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
......
......@@ -120,7 +120,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -12,6 +12,7 @@
<list>
<string>editable</string>
<string>gadget_url</string>
<string>renderjs_extra</string>
<string>title</string>
</list>
</value>
......@@ -50,6 +51,10 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -64,6 +69,16 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -87,6 +102,12 @@
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Watcher</string> </value>
......@@ -110,4 +131,17 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: {\'read_activity_list_url\': here.absolute_url() + \'/ActivityTool_getSqlStatisticList\'}</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -8,6 +8,7 @@
<script id="getData" type="text/x-handlebars-template">
Date : {{time}}
<table>
<thead>
<tr>
<th>Type</th>
<th>Count</th>
......@@ -16,6 +17,7 @@
<th>Min pri</th>
<th>Max pri</th>
</tr>
</thead><tbody>
{{#each messageList1}}
<tr>
<td>{{this.messagetype}} </td>
......@@ -36,8 +38,10 @@
<td>{{this.max_pri}}</td>
</tr>
{{/each}}
</tbody>
</table>
<table>
<thead>
<tr>
<th>Type</th>
<th>Priority</th>
......@@ -45,6 +49,7 @@
<th>Avg</th>
<th>Max</th>
</tr>
</thead><tbody>
{{#each messagePri1}}
<tr>
<td>{{this.messagetype}} </td>
......@@ -63,6 +68,7 @@
<td>{{this.max}}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>
......
/*global window, rJS, RSVP, Handlebars, jIO, location, console */
/*global window, rJS, RSVP, Handlebars, jIO, console */
/*jslint nomen: true, maxlen:80, indent:2*/
(function (rJS, jIO, Handlebars, RSVP, window) {
"use strict";
......@@ -17,15 +17,24 @@
}
rJS(window)
.declareMethod('render', function (options) {
console.log(options);
return this.changeState(options);
})
.onLoop(function () {
var form_gadget = this,
basedir = location.pathname.split('/').slice(0, -1).join('/') + '/';
var form_gadget = this;
if (!form_gadget.state.read_activity_list_url) {
// renderjs has not yet been called
// gadget doesn't know which URL to call
return;
}
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax(
{
"type": "POST",
"url": basedir + 'ActivityTool_getSqlStatisticList',
"type": "GET",
"url": form_gadget.state.read_activity_list_url,
"xhrFields": {
withCredentials: true
}
......@@ -35,15 +44,13 @@
.push(function (evt) {
var data = JSON.parse(evt.target.response);
form_gadget.element.querySelector(".activity_watcher_gadget")
.innerHTML = get_data_template(
{
.innerHTML = get_data_template({
time: new Date().toTimeString(),
messageList1: putMessageType(data, 'dict', 'SQLDict'),
messageList2: putMessageType(data, 'queue', 'SQLQueue'),
messagePri1 : putMessageType(data, 'dict', 'SQLDict2'),
messagePri2 : putMessageType(data, 'queue', 'SQLQueue2')
}
);
messagePri1: putMessageType(data, 'dict', 'SQLDict2'),
messagePri2: putMessageType(data, 'queue', 'SQLQueue2')
});
}, function (error) {
//Exception is raised if network is lost for some reasons,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment