Commit 1a9f1eb0 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core] activity watcher: use renderJS onLoop functionnality

parent 53982a05
...@@ -17,60 +17,41 @@ ...@@ -17,60 +17,41 @@
} }
rJS(window) rJS(window)
.ready(function (g) { .onLoop(function () {
g.props = {};
})
.ready(function (g) {
return g.getElement().push(function (element) {
g.props.element = element;
});
})
.declareService(function () {
var form_gadget = this, var form_gadget = this,
html_content, basedir = location.pathname.split('/').slice(0, -1).join('/') + '/';
basedir = location.pathname.split('/').slice(0, -1).join('/') + '/', return new RSVP.Queue()
queue = new RSVP.Queue(); .push(function () {
function getDataExamine() { return jIO.util.ajax(
queue {
.push(function () { "type": "POST",
return jIO.util.ajax( "url": basedir + 'ActivityTool_getSqlStatisticList',
{ "xhrFields": {
"type": "POST", withCredentials: true
"url": basedir + 'ActivityTool_getSqlStatisticList',
"xhrFields": {
withCredentials: true
}
} }
); }
}) );
.push(function (evt) { })
var data = JSON.parse(evt.target.response); .push(function (evt) {
html_content = get_data_template( var data = JSON.parse(evt.target.response);
{ form_gadget.element.querySelector(".activity_watcher_gadget")
time: new Date().toTimeString(), .innerHTML = get_data_template(
messageList1: putMessageType(data, 'dict', 'SQLDict'), {
messageList2: putMessageType(data, 'queue', 'SQLQueue'), time: new Date().toTimeString(),
messagePri1 : putMessageType(data, 'dict', 'SQLDict2'), messageList1: putMessageType(data, 'dict', 'SQLDict'),
messagePri2 : putMessageType(data, 'queue', 'SQLQueue2') messageList2: putMessageType(data, 'queue', 'SQLQueue'),
} messagePri1 : putMessageType(data, 'dict', 'SQLDict2'),
); messagePri2 : putMessageType(data, 'queue', 'SQLQueue2')
}
);
form_gadget.props.element.querySelector(".activity_watcher_gadget") }, function (error) {
.innerHTML = html_content; //Exception is raised if network is lost for some reasons,
}, function (error) { //in this case, try patiently until network is back.
//Exception is raised if network is lost for some reasons, console.warn("Unable to fetch activities from ERP5", error);
//in this case, try patiently until network is back. form_gadget.element.querySelector(".activity_watcher_gadget")
console.log("Unable to fetch activities from ERP5", error); .textContent = "Unable to fetch activities from ERP5";
}) });
.push(function () {
return RSVP.delay(1000); }, 1000);
})
.push(function () {
return getDataExamine();
});
}
return queue.push(function () {
return getDataExamine();
});
});
}(rJS, jIO, Handlebars, RSVP, window)); }(rJS, jIO, Handlebars, RSVP, window));
\ No newline at end of file
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