Added event log save feature.

Ylian Saint-Hilaire committed May 15, 2019 at 14:26 UTC c526c8b66b185876bb28d71f4a74381491aedf67
2 files changed +23 -2
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.4-j",
3 + "version": "0.3.4-k",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
views/default.handlebars
+22 -1
@@ -286,7 +286,8 @@
286 <option value=250>Last 250</option>
287 <option value=500>Last 500</option>
288 <option value=1000>Last 1000</option>
289 - </select>
289 + </select>&nbsp;
290 + <img src=images/link4.png height=10 width=10 title="Download Events" style=cursor:pointer onclick=p3showDownloadEventsDialog()>&nbsp;
291 </td>
292 <td class="h2"></td>
293 </tr>
@@ -6696,6 +6697,26 @@
6697 meshserver.send({ action: 'events', limit: parseInt(p3limitdropdown.value) });
6698 }
6699
6700 + function p3showDownloadEventsDialog() {
6701 + if (xxdialogMode) return;
6702 + var x = 'Download the list of events with one of the file formats below.<br /><br />';
6703 + x += addHtmlValue('CSV Format', '<a style=cursor:pointer onclick=p3downloadEventsDialogCSV()>eventslist.csv</a>');
6704 + x += addHtmlValue('JSON Format', '<a style=cursor:pointer onclick=p3downloadEventsDialogJSON()>eventslist.json</a>');
6705 + setDialogMode(2, "Event List Export", 1, null, x);
6706 + }
6707 +
6708 + function p3downloadEventsDialogCSV() {
6709 + var csv = "time, type, action, user, message\r\n";
6710 + for (var i in events) { csv += '\"' + events[i].time + '\",\"' + events[i].etype + '\",\"' + ((events[i].action != null)?events[i].action:'') + '\",\"' + ((events[i].username != null)?events[i].username:'') + '\",\"' + ((events[i].msg != null)?events[i].msg:'') + '\"\r\n'; }
6711 + saveAs(new Blob([csv], { type: "application/octet-stream" }), "eventslist.csv");
6712 + }
6713 +
6714 + function p3downloadEventsDialogJSON() {
6715 + var r = []
6716 + for (var i in events) { r.push(events[i]); }
6717 + saveAs(new Blob([JSON.stringify(r)], { type: "application/octet-stream" }), "eventslist.json");
6718 + }
6719 +
6720 //
6721 // MY USERS
6722 //