aboutsummaryrefslogtreecommitdiff
path: root/src/public/js/logviewer.js
diff options
context:
space:
mode:
authorjakobst1n <jakob.stendahl@outlook.com>2018-09-07 00:32:51 +0200
committerjakobst1n <jakob.stendahl@outlook.com>2018-09-07 00:32:51 +0200
commit78d7c8d75a5f55ab56dd018edc85ebce9aa033bb (patch)
tree2ad9da977667b79236cfdd827d0446a5bf9fea18 /src/public/js/logviewer.js
downloadLuxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.tar.gz
Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.zip
:construction: Add pre-v1 project
Because of some stupid mistakes with the repo, I decided to delete the git history. Create a new, fresh repo, and move all the code there. Since all this is pre-v1, everything is in a testing-phase anyways. So i do not think we are going to feel the need for any history. The old repo is renamed to Luxcena-Neo-Old, and will be there until i convince myself i won't need the history.
Diffstat (limited to 'src/public/js/logviewer.js')
-rw-r--r--src/public/js/logviewer.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/public/js/logviewer.js b/src/public/js/logviewer.js
new file mode 100644
index 0000000..d376196
--- /dev/null
+++ b/src/public/js/logviewer.js
@@ -0,0 +1,64 @@
+let socket = io();
+
+module.exports = () => {
+ M.AutoInit();
+
+ socket.emit("GetLog", {filter: "success error event debug python info warning", entryN: 1000});
+ socket.on("lastLogEntries", (entries) => {
+ M.toast({html: "Loading log-files..."});
+ console.log("Log-entries received: " + entries.length);
+ let HTMLBasicTable = "";
+ let HTMLAdvancedTable = "";
+ let HTMLScriptTable = "";
+ let HTMLRAWTable = "";
+
+ entries.forEach((entry) => {
+ let strHTML = "<tr><td>" + prettifyType(entry.type) + "</td><td>" + entry.time + "</td><td>" + entry.details + "</td></tr>";
+
+ if (entry.type === "SUCCESS") { HTMLBasicTable += strHTML; }
+ if (entry.type === "ERROR") { HTMLBasicTable += strHTML; }
+ if (entry.type === "EVENT") { HTMLBasicTable += strHTML; }
+ if (entry.type === "PYTHON") { HTMLScriptTable += strHTML; }
+ if (entry.type !== "PYTHON") { HTMLAdvancedTable += strHTML; }
+
+ //HTMLRAWTable += entry.join(" ");
+ });
+
+ document.getElementById("log-table-basic").innerHTML = HTMLBasicTable;
+ document.getElementById("log-table-script").innerHTML = HTMLScriptTable;
+ document.getElementById("log-table-advanced").innerHTML = HTMLAdvancedTable;
+ //document.getElementById("log-table-raw").innerHTML = HTMLRAWTable;
+
+ });
+
+ socket.on("newLogEntry", (entry) => {
+ if (entry.type === "SUCCESS") { appendEntryToTable("log-table-basic", entry); }
+ if (entry.type === "ERROR") { appendEntryToTable("log-table-basic", entry); }
+ if (entry.type === "EVENT") { appendEntryToTable("log-table-basic", entry); }
+ if (entry.type === "PYTHON") { appendEntryToTable("log-table-script", entry); }
+ if (entry.type !== "PYTHON") { appendEntryToTable("log-table-advanced", entry); }
+ });
+
+};
+
+function appendEntryToTable(tableName, entry) {
+ let newEntry = document.getElementById(tableName).insertRow(0);
+ newEntry.insertCell(0).innerHTML = prettifyType(entry.type);
+ newEntry.insertCell(1).innerHTML = entry.time;
+ newEntry.insertCell(2).innerHTML = entry.details;
+ M.AutoInit();
+ newEntry.className = "newLogEntry";
+}
+
+function prettifyType(type) {
+ let prettyTable = {
+ "DEBUG": `<span class="tooltipped" data-position="top" data-tooltip="Debug-log">😸</span>`,
+ "INFO": `<span class="tooltipped" data-position="top" data-tooltip="Just some information">â„šī¸</span>`,
+ "WARNING": `<span class="tooltipped" data-position="top" data-tooltip="A warning">âš ī¸</span>`,
+ "EVENT": `<span class="tooltipped" data-position="top" data-tooltip="Event">âšĄī¸</span>`,
+ "SUCCESS": `<span class="tooltipped" data-position="top" data-tooltip="Something exited successfully">✅</span>`,
+ "ERROR": `<span class="tooltipped" data-position="top" data-tooltip="Error">🔴</span>`,
+ "PYTHON": `<span class="tooltipped" data-position="top" data-tooltip="Output from user-script">🐍</span>`
+ };
+ return prettyTable[type];
+} \ No newline at end of file