From 1666c842175bb71598b4559f5874092a07793cae Mon Sep 17 00:00:00 2001 From: Stefania Date: Tue, 19 Jan 2021 14:54:48 +0100 Subject: [PATCH 1/7] fix diable list option, improve output formatting, fix issue about toolbar hidden on output growing [EDITOR-559] --- home.html | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/home.html b/home.html index 8021c83f4..382eb756c 100644 --- a/home.html +++ b/home.html @@ -1,5 +1,5 @@ - + Arduino Create Agent Debug Console @@ -17,19 +17,37 @@ var MESSAGES_MAX_COUNT = 2000; function appendLog(msg) { - var startsWithBracked = msg.indexOf('{') == 0; + let jsonMsg = {}; + let portListing = false; + try { + jsonMsg = JSON.parse(msg); + portsListing = jsonMsg.Ports; + } catch { + } + var startsWithList = msg.indexOf('list') == 0; - if (listenabled.checked || (typeof msg === 'string' && !startsWithBracked && !startsWithList)) { - messages.push(msg); - if (messages.length > MESSAGES_MAX_COUNT) { - messages.shift(); - } - log.innerHTML = messages.join('
'); - if (autoscroll.checked) { - log.scrollTop = log.scrollHeight - log.clientHeight; - } - } + if (listenabled.checked || (!portsListing && !startsWithList)) { + let printMsg = msg; + if (jsonMsg.Ports) { + if (jsonMsg.Network) { + printMsg = `Network Ports:
${JSON.stringify(jsonMsg.Ports, ['Name', 'SerialNumber', 'IsOpen', 'VendorID', 'ProductID'], 2)}` + } else { + printMsg = `Serial Ports:
${JSON.stringify(jsonMsg.Ports, ['Name', 'SerialNumber', 'IsOpen', 'VendorID', 'ProductID'], 2)}` + } + } else if (Object.keys(jsonMsg).length !== 0) { + printMsg = `${JSON.stringify(jsonMsg, undefined, 2)}`; + } + messages.push(printMsg); + if (messages.length > MESSAGES_MAX_COUNT) { + messages.shift(); + } + log.innerHTML = messages.join('

'); + if (autoscroll.checked) { + log.scrollTop = log.scrollHeight - log.clientHeight; + } + } + } $('#form').submit(function(e) { @@ -92,7 +110,7 @@ #container { display: flex; flex-direction: column; - height: 100%; + height: 100vh; width: 100%; } @@ -100,6 +118,7 @@ flex-grow: 1; font-family: "Roboto Mono", "Courier", "Lucida Grande", Verdana, sans-serif; background-color: #DAE3E3; + height: calc(100vh - 61px); margin: 15px 15px 10px; padding: 8px 10px; overflow-y: auto; @@ -182,16 +201,15 @@ font-size: 1em; outline: none; } -
-
This is some random text This is some random textThis is some random textThis is some random textThis is some random textThis is some random textThis is some random text
This is some random text
This is some random text
+