diff --git a/frontend-js/src/main/js/gui/admin/LogListDialog.js b/frontend-js/src/main/js/gui/admin/LogListDialog.js index ffc387fd677eda4f0ff82405a99774dbf482669d..80b38494be0111694bf73f79951de68cc6ed3f3a 100644 --- a/frontend-js/src/main/js/gui/admin/LogListDialog.js +++ b/frontend-js/src/main/js/gui/admin/LogListDialog.js @@ -48,7 +48,13 @@ LogListDialog.prototype.createLogListDialogGui = function () { type: "thead", content: "<tr>" + "<th>ID</th>" + + "<th>Type</th>" + + "<th>Severity</th>" + + "<th>Object ID</th>" + + "<th>Object Class</th>" + + "<th>Map name</th>" + "<th>Content</th>" + + "<th>Source</th>" + "</tr>" }); var body = Functions.createElement({ @@ -85,11 +91,8 @@ LogListDialog.prototype.createLogListDialogGui = function () { }); var FileSaver = require("file-saver"); return FileSaver.saveAs(blob, self._projectId + "-logs.txt"); - }).then(function () { + }).catch(GuiConnector.alert).finally(function () { GuiConnector.hideProcessing(); - }, function (error) { - GuiConnector.hideProcessing(); - GuiConnector.alert(error); }); }, xss: false @@ -98,6 +101,34 @@ LogListDialog.prototype.createLogListDialogGui = function () { }; +function removeNull(object) { + if (object === null || object === undefined) { + return ""; + } + return object; +} + +function extractTypeName(type) { + if (type === undefined || type === null) { + return ""; + } + var result = type.toLowerCase().replace("_", " "); + return result[0].toUpperCase() + result.slice(1); +} + +function entryToRow(entry) { + var row = []; + row[0] = removeNull(entry.id); + row[1] = removeNull(extractTypeName(entry.type)); + row[2] = removeNull(entry.level); + row[3] = removeNull(entry.objectIdentifier); + row[4] = removeNull(entry.objectClass); + row[5] = removeNull(entry.mapName); + row[6] = removeNull(entry.content); + row[7] = removeNull(entry.source); + return row; +} + /** * * @param {Object} data @@ -121,12 +152,11 @@ LogListDialog.prototype._dataTableAjaxCall = function (data, callback) { projectId: self._projectId }).then(function (logEntries) { var out = []; + for (var i = 0; i < logEntries.data.length; i++) { var entry = logEntries.data[i]; - var row = []; - row[0] = entry.id; - row[1] = entry.content; + var row = entryToRow(entry); out.push(row); } callback({ @@ -150,7 +180,7 @@ LogListDialog.prototype.downloadAll = function () { }).then(function (logEntries) { var tmp = []; for (var i = 0; i < logEntries.data.length; i++) { - tmp.push(logEntries.data[i].content); + tmp.push(entryToRow(logEntries.data[i]).join("\t")); } return tmp.join("\n"); }); @@ -196,8 +226,20 @@ LogListDialog.prototype.open = function () { LogListDialog.prototype.getColumnsDefinition = function () { return [{ name: "id" + }, { + name: "type" + }, { + name: "level" + }, { + name: "objectIdentifier" + }, { + name: "objectClass" + }, { + name: "mapName" }, { name: "content" + }, { + name: "source" }]; };