8000 Merge branch 'feature/auto-connect' into feature/new-toolbar · arduino/lab-micropython-editor@22c541f · GitHub
[go: up one dir, main page]

Skip to content

Commit 22c541f

Browse files
committed
Merge branch 'feature/auto-connect' into feature/new-toolbar
2 parents 2791e00 + 07fa1ce commit 22c541f

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

ui/arduino/main.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ button.small .icon {
339339
}
340340

341341
#panel #drag-handle {
342-
width: 100%;
342+
flex-grow: 2;
343343
height: 100%;
344344
cursor: grab;
345345
}
@@ -359,6 +359,19 @@ button.small .icon {
359359
background: #008184;
360360
}
361361

362+
.panel-bar #connection-status {
363+
display: flex;
364+
align-items: center;
365+
gap: 10px;
366+
color: white;
367+
}
368+
369+
.panel-bar #connection-status img {
370+
width: 1.25em;
371+
height: 1.25em;
372+
filter: invert(1);
373+
}
374+
362375
.panel-bar .term-operations {
363376
transition: opacity 0.15s;
364377
display: flex;

ui/arduino/store.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,20 @@ async function store(state, emitter) {
213213
emitter.emit('render')
214214
})
215215

216+
emitter.on('connect', async () => {
217+
try {
218+
state.availablePorts = await getAvailablePorts()
219+
} catch(e) {
220+
console.error('Could not get available ports. ', e)
221+
}
222+
223+
if(state.availablePorts.length == 1) {
224+
emitter.emit('select-port', state.availablePorts[0])
225+
} else {
226+
emitter.emit('open-connection-dialog')
227+
}
228+
})
229+
216230
// CODE EXECUTION
217231
emitter.on('run', async (onlySelected = false) => {
218232
log('run')

ui/arduino/views/components/repl-panel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ function ReplPanel(state, emit) {
1818
return html`
1919
<div id="panel" style="height: ${state.panelHeight}px">
2020
<div class="panel-bar">
21+
<div id="connection-status" style="visibility:${state.isConnected ? 'visible' : 'hidden'};">
22+
<img src="media/connect.svg" />
23+
<div>${state.isConnected ? 'Connected to ' + state.connectedPort : ''}</div>
24+
</div>
2125
<div id="drag-handle"
2226
onmousedown=${() => emit('start-resizing-panel')}
2327
onmouseup=${() => emit('stop-resizing-panel')}

ui/arduino/views/components/toolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Toolbar(state, emit) {
1818
icon: state.isConnected ? 'connect.svg' : 'disconnect.svg',
1919
label: state.isConnected ? 'Disconnect' : 'Connect',
2020
tooltip: state.isConnected ? `Disconnect (${metaKeyString}+Shift+D)` : `Connect (${metaKeyString}+Shift+C)`,
21-
onClick: () => state.isConnected ? emit('disconnect') : emit('open-connection-dialog'),
21+
onClick: () => state.isConnected ? emit('disconnect') : emit('connect'),
2222
active: state.isConnected,
2323
first: true
2424
})}

0 commit comments

Comments
 (0)
0