Improved saving events in CSV format.

This commit is contained in:
Ylian Saint-Hilaire 2020-02-05 16:12:08 -08:00
parent cddb95a00d
commit c40145588e
3 changed files with 14 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.4.8-p", "version": "0.4.8-q",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -20250,10 +20250,7 @@
"ja": "時間、タイプ、アクション、ユーザー、メッセージ", "ja": "時間、タイプ、アクション、ユーザー、メッセージ",
"nl": "tijd, type, actie, gebruiker, bericht", "nl": "tijd, type, actie, gebruiker, bericht",
"pt": "hora, tipo, ação, usuário, mensagem", "pt": "hora, tipo, ação, usuário, mensagem",
"ru": "time, type, action, user, message", "ru": "time, type, action, user, message"
"xloc": [
"default.handlebars->25->1200"
]
}, },
{ {
"cs": "celkem", "cs": "celkem",
@ -20317,6 +20314,12 @@
"default.handlebars->25->1241" "default.handlebars->25->1241"
] ]
}, },
{
"en": "utc, time, type, action, user, device, message",
"xloc": [
"default.handlebars->25->1200"
]
},
{ {
"en": "{0} - Agent Installation", "en": "{0} - Agent Installation",
"xloc": [ "xloc": [

View File

@ -8786,7 +8786,6 @@
function p3showDownloadEventsDialog(mode) { function p3showDownloadEventsDialog(mode) {
if (xxdialogMode) return; if (xxdialogMode) return;
console.log('p3showDownloadEventsDialog');
var x = "Download the list of events with one of the file formats below." + '<br /><br />'; var x = "Download the list of events with one of the file formats below." + '<br /><br />';
x += addHtmlValue("CSV Format", '<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogCSV(' + mode + ')">' + "eventslist.csv" + '</a>'); x += addHtmlValue("CSV Format", '<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogCSV(' + mode + ')">' + "eventslist.csv" + '</a>');
x += addHtmlValue("JSON Format", '<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogJSON(' + mode + ')">' + "eventslist.json" + '</a>'); x += addHtmlValue("JSON Format", '<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogJSON(' + mode + ')">' + "eventslist.json" + '</a>');
@ -8798,8 +8797,12 @@
if (mode == 1) { eventList = currentDeviceEvents; } if (mode == 1) { eventList = currentDeviceEvents; }
if (mode == 2) { eventList = events; } if (mode == 2) { eventList = events; }
if (mode == 3) { eventList = currentUserEvents; } if (mode == 3) { eventList = currentUserEvents; }
csv = "time, type, action, user, message" + '\r\n'; csv = "utc, time, type, action, user, device, message" + '\r\n';
for (var i in eventList) { csv += '\"' + eventList[i].time + '\",\"' + eventList[i].etype + '\",\"' + ((eventList[i].action != null) ? eventList[i].action : '') + '\",\"' + ((eventList[i].username != null) ? eventList[i].username : '') + '\",\"' + ((eventList[i].msg != null) ? eventList[i].msg : '') + '\"\r\n'; } for (var i in eventList) {
var nodename = '';
if (eventList[i].nodeid) { var node = getNodeFromId(eventList[i].nodeid); if (node && node.name) { nodename = node.name; } }
csv += '\"' + eventList[i].time + '\",\"' + printDateTime(new Date(eventList[i].time)) + '\",\"' + eventList[i].etype + '\",\"' + ((eventList[i].action != null) ? eventList[i].action : '') + '\",\"' + ((eventList[i].username != null) ? eventList[i].username : '') + '\",\"' + EscapeHtml(nodename) + '\",\"' + ((eventList[i].msg != null) ? eventList[i].msg : '').split(',').join(' -') + '\"\r\n';
}
saveAs(new Blob([csv], { type: 'application/octet-stream' }), "eventslist.csv"); saveAs(new Blob([csv], { type: 'application/octet-stream' }), "eventslist.csv");
return false; return false;
} }