Skip to content

Commit 89d9f79

Browse files
author
Stefania
committed
fix diable list option, improve output formatting, fix issue about toolbar hidden on output growing [EDITOR-559]
1 parent b1a3b5c commit 89d9f79

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

home.html

+34-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
44
<title>Arduino Create Agent Debug Console</title>
55
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700&display=swap" rel="stylesheet">
@@ -17,19 +17,37 @@
1717
var MESSAGES_MAX_COUNT = 2000;
1818

1919
function appendLog(msg) {
20-
var startsWithBracked = msg.indexOf('{') == 0;
20+
let jsonMsg = {};
21+
let portListing = false;
22+
try {
23+
jsonMsg = JSON.parse(msg);
24+
portsListing = jsonMsg.Ports;
25+
} catch {
26+
}
27+
2128
var startsWithList = msg.indexOf('list') == 0;
2229

23-
if (listenabled.checked || (typeof msg === 'string' && !startsWithBracked && !startsWithList)) {
24-
messages.push(msg);
25-
if (messages.length > MESSAGES_MAX_COUNT) {
26-
messages.shift();
27-
}
28-
log.innerHTML = messages.join('<br>');
29-
if (autoscroll.checked) {
30-
log.scrollTop = log.scrollHeight - log.clientHeight;
31-
}
32-
}
30+
if (listenabled.checked || (!portsListing && !startsWithList)) {
31+
let printMsg = msg;
32+
if (jsonMsg.Ports) {
33+
if (jsonMsg.Network) {
34+
printMsg = `<b>Network Ports</b>:<br>${JSON.stringify(jsonMsg.Ports, ['Name', 'SerialNumber', 'IsOpen', 'VendorID', 'ProductID'], 2)}`
35+
} else {
36+
printMsg = `<b>Serial Ports</b>:<br>${JSON.stringify(jsonMsg.Ports, ['Name', 'SerialNumber', 'IsOpen', 'VendorID', 'ProductID'], 2)}`
37+
}
38+
} else if (Object.keys(jsonMsg).length !== 0) {
39+
printMsg = `${JSON.stringify(jsonMsg, undefined, 2)}`;
40+
}
41+
messages.push(printMsg);
42+
if (messages.length > MESSAGES_MAX_COUNT) {
43+
messages.shift();
44+
}
45+
log.innerHTML = messages.join('<br><br>');
46+
if (autoscroll.checked) {
47+
log.scrollTop = log.scrollHeight - log.clientHeight;
48+
}
49+
}
50+
3351
}
3452

3553
$('#form').submit(function(e) {
@@ -92,14 +110,15 @@
92110
#container {
93111
display: flex;
94112
flex-direction: column;
95-
height: 100%;
113+
height: 100vh;
96114
width: 100%;
97115
}
98116

99117
#log {
100118
flex-grow: 1;
101119
font-family: "Roboto Mono", "Courier", "Lucida Grande", Verdana, sans-serif;
102120
background-color: #DAE3E3;
121+
height: calc(100vh - 61px);
103122
margin: 15px 15px 10px;
104123
padding: 8px 10px;
105124
overflow-y: auto;
@@ -182,16 +201,15 @@
182201
font-size: 1em;
183202
outline: none;
184203
}
185-
186204
</style>
187205
</head>
188206
<body>
189207
<div id="container">
190-
<div id="log">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<br />This is some random text<br />This is some random text<br /></div>
208+
<pre id="log"></pre>
191209
<div id="footer">
192210
<form id="form">
193211
<input type="submit" class="button" value="Send" />
194-
<input type="text" id="input" class="textfield" />
212+
<input type="text" id="input" class="textfield" aria-label="send command" />
195213
</form>
196214
<div id="secondary-controls">
197215
<div>

0 commit comments

Comments
 (0)