@@ -51,6 +51,8 @@ class App extends React.Component {
5151 serialPortOpen : '' ,
5252 uploadStatus : '' ,
5353 uploadError : '' ,
54+ downloadStatus : '' ,
55+ downloadError : '' ,
5456 supportedBoards : [ ]
5557 } ;
5658 this . handleOpen = this . handleOpen . bind ( this ) ;
@@ -96,6 +98,13 @@ class App extends React.Component {
9698 this . setState ( { uploadStatus : upload . status } ) ;
9799 console . log ( upload ) ;
98100 } ) ;
101+
102+ if ( daemon . downloading ) {
103+ daemon . downloading . subscribe ( download => {
104+ this . setState ( { downloadStatus : download . status } ) ;
105+ console . log ( download ) ;
106+ } ) ;
107+ }
99108 }
100109
101110 showError ( err ) {
@@ -128,6 +137,19 @@ class App extends React.Component {
128137 serialInput . value = '' ;
129138 }
130139
140+ handleDownloadTool ( e ) {
141+ e . preventDefault ( ) ;
142+ const toolname = document . getElementById ( 'toolname' ) ;
143+ const toolversion = document . getElementById ( 'toolversion' ) ;
144+ const packageName = document . getElementById ( 'package' ) ;
145+ const replacement = document . getElementById ( 'replacement' ) ;
146+ daemon . downloadTool ( toolname . value , toolversion . value , packageName . value , replacement . value ) ;
147+ toolname . value = '' ;
148+ toolversion . value = '' ;
149+ packageName . value = '' ;
150+ replacement . value = '' ;
151+ }
152+
131153 render ( ) {
132154 const listSerialDevices = this . state . serialDevices . map ( ( device , i ) =>
133155 < li key = { i } >
@@ -161,42 +183,61 @@ class App extends React.Component {
161183 uploadClass = 'in-progress' ;
162184 }
163185
186+ let downloadClass ;
187+ if ( this . state . downloadStatus === daemon . DOWNLOAD_DONE ) {
188+ downloadClass = 'success' ;
189+ }
190+ else if ( this . state . downloadStatus === daemon . DOWNLOAD_ERROR ) {
191+ downloadClass = 'error' ;
192+ }
193+ else if ( this . state . downloadStatus === daemon . DOWNLOAD_IN_PROGRESS ) {
194+ downloadClass = 'in-progress' ;
195+ }
196+
164197 return (
165198 < div >
166199 < h1 > Test Arduino Create Plugin</ h1 >
167200
168- < p >
169- Agent status: < span className = { this . state . agentStatus ? 'found' : 'not-found' } >
170- { this . state . agentStatus ? 'Found' : 'Not found' }
171- </ span >
172- </ p >
173- < p >
174- Channel status: < span className = { this . state . channelStatus ? 'found' : 'not-found' } >
175- { this . state . channelStatus ? 'Connected' : 'Not connected' }
176- </ span >
177- </ p >
178-
179- < pre >
180- { this . state . agentInfo }
181- </ pre >
201+ < div className = "section" >
202+ < h2 > Plugin info</ h2 >
203+
204+ < p >
205+ Agent status: < span className = { this . state . agentStatus ? 'found' : 'not-found' } >
206+ { this . state . agentStatus ? 'Found' : 'Not found' }
207+ </ span >
208+ </ p >
209+ < p >
210+ Channel status: < span className = { this . state . channelStatus ? 'found' : 'not-found' } >
211+ { this . state . channelStatus ? 'Connected' : 'Not connected' }
212+ </ span >
213+ </ p >
214+
215+ < pre >
216+ { this . state . agentInfo }
217+ </ pre >
218+ </ div >
182219
183220 < div className = "section" >
184- < h2 > Devices</ h2 >
221+ < h2 > Connected Devices</ h2 >
222+
185223 < strong > serial:</ strong >
186224 < ul >
187225 { listSerialDevices }
188226 </ ul >
227+
189228 < strong > network:</ strong >
190229 < ul >
191230 { listNetworkDevices }
192231 </ ul >
232+
193233 < p id = "error" > </ p >
194234 </ div >
195235
196236 {
197237 this . state . supportedBoards . length ?
198238 < div className = "section" >
199239 < h2 > Supported boards</ h2 >
240+
200241 < ul >
201242 { supportedBoards }
202243 </ ul >
@@ -206,10 +247,12 @@ class App extends React.Component {
206247
207248 < div className = "serial-monitor section" >
208249 < h2 > Serial Monitor</ h2 >
250+
209251 < form onSubmit = { this . handleSend } >
210252 < input id = "serial-input" />
211253 < input type = "submit" value = "Send" />
212254 </ form >
255+
213256 < textarea id = "serial-textarea" value = { this . state . serialMonitorContent } />
214257 </ div >
215258
@@ -219,6 +262,37 @@ class App extends React.Component {
219262 < div > Upload status: < span className = { uploadClass } > { this . state . uploadStatus } </ span > </ div >
220263 < div > { this . state . uploadError } </ div >
221264 </ div >
265+
266+ { daemon . downloading ? < div className = "section" >
267+ < h2 > Download tool (not supported on Chrome OS)</ h2 >
268+
269+ < div >
270+ < p > Example:</ p >
271+ < dl >
272+ < dt > Tool Name:</ dt >
273+ < dd > windows-drivers</ dd >
274+
275+ < dt > Tool Version:</ dt >
276+ < dd > latest</ dd >
277+
278+ < dt > Package:</ dt >
279+ < dd > arduino</ dd >
280+
281+ < dt > Replacement Strategy:</ dt >
282+ < dd > keep</ dd >
283+ </ dl >
284+ </ div >
285+
286+ < form onSubmit = { this . handleDownloadTool } >
287+ < div > < input id = "toolname" placeholder = "Tool Name" /> </ div >
288+ < div > < input id = "toolversion" placeholder = "Tool Version" /> </ div >
289+ < div > < input id = "package" placeholder = "Package" /> </ div >
290+ < div > < input id = "replacement" placeholder = "Replacement strategy" /> </ div >
291+
292+ < input type = "submit" value = "Download" />
293+ < div > Download status: < span className = { downloadClass } > { this . state . downloadStatus } </ span > </ div >
294+ </ form >
295+ </ div > : null }
222296 </ div >
223297 ) ;
224298 }
0 commit comments