1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var results_table = null;
function coop_init_datatable(params, data, cols, action_btn) {
var buttons = [];
var columns = [];
$.each(cols, function(i, e) {
columns.push(e);
});
var settings = {
dom: '<lf<t>ip><"clear"><B>',
lengthMenu : [
[
50,
100,
150,
200,
-1
],
[
50,
100,
150,
200,
'Tout'
]
],
pageLength : 50,
buttons: buttons,
columns: columns,
//select: select ,
rowId : "_id",
data : data,
language: {url : '/static/js/datatables/french.json'}
};
return $('#results').DataTable(settings);
}
var viewJSErrors = function() {
$.get('/monitor/js_errors', {dataType: 'json'})
.done(function(rData) {
if (typeof rData.res.content != "undefined") {
if (results_table) results_table.destroy();
var data = [];
var cols = [
{data: 'date', title: "Date"},
{data: 'module', title: "Module"},
{data: 'agent', title: "Signature nav."},
{data: 'context', title: "Contexte"},
{data: 'message', title: "Message"}
];
rData.res.content.forEach(function(e) {
var line = e;
if (typeof e.data == 'object') {
line.context = e.data.ctx;
line.message = e.data.msg;
delete e.data;
} else {
line.context = '?';
line.message = e.data;
}
data.push(line);
});
console.log(data);
results_table = coop_init_datatable(null, data, cols);
}
});
};
$(document).ready(function() {
if (coop_is_connected()) {
$('header').show();
$('.nav-list .js_errors').click(viewJSErrors);
}
});