Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5498e4f

Browse files
author
Stefania
committedApr 17, 2019
restored v2
1 parent c61925e commit 5498e4f

File tree

6 files changed

+180
-59
lines changed

6 files changed

+180
-59
lines changed
 

‎.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
36
"rules": {
47
"max-len": 0,
58
"comma-dangle": 0,
@@ -13,7 +16,8 @@
1316
"arrow-parens": 0,
1417
"consistent-return": 0,
1518
"no-useless-escape": 0,
16-
"no-underscore-dangle": 0
19+
"no-underscore-dangle": 0,
20+
"react/jsx-uses-vars": 2
1721
},
1822
"extends": "airbnb-base",
1923
"env": {

‎demo/app.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import React from 'react';
2222
import Daemon from '../src';
2323

2424
import { HEX } from './serial_mirror';
25-
// import V2 from './v2/v2.jsx';
25+
import V2 from './v2/v2.jsx';
2626

2727
const chromeExtensionID = 'hfejhkbipnickajaidoppbadcomekkde';
2828

@@ -274,9 +274,9 @@ class App extends React.Component {
274274
<textarea aria-label="Serial Monitor output" id="serial-textarea" value={ this.state.serialMonitorContent } readOnly/>
275275
</div>
276276

277-
{/* <div className="v2">
277+
<div className="v2">
278278
<V2 daemon={daemon}></V2>
279-
</div> */}
279+
</div>
280280

281281
<div className="section">
282282
<h2>Upload a sample sketch on a MKR1000 at /dev/ttyACM0</h2>

‎package-lock.json

Lines changed: 151 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"lib": "lib"
1616
},
1717
"dependencies": {
18-
"detect-browser": "^4.1.0",
18+
"detect-browser": "^4.4.0",
1919
"rxjs": "^6.4.0",
2020
"semver-compare": "^1.0.0",
2121
"socket.io-client": "2.2.0"
@@ -29,11 +29,12 @@
2929
"babel-preset-env": "^1.7.0",
3030
"babel-preset-es2015": "^6.24.1",
3131
"babel-preset-react": "^6.24.1",
32-
"clean-webpack-plugin": "^1.0.1",
32+
"clean-webpack-plugin": "^2.0.1",
3333
"cross-env": "^5.2.0",
3434
"eslint": "^5.16.0",
3535
"eslint-config-airbnb-base": "^13.1.0",
36-
"eslint-plugin-import": "^2.17.1",
36+
"eslint-plugin-import": "^2.17.2",
37+
"eslint-plugin-react": "^7.12.4",
3738
"html-webpack-plugin": "^3.2.0",
3839
"react": "^16.8.6",
3940
"react-dom": "^16.8.6",
@@ -51,6 +52,7 @@
5152
},
5253
"scripts": {
5354
"test": "",
55+
"https": "webpack-dev-server --https",
5456
"dev": "webpack-dev-server",
5557
"lint": "./node_modules/.bin/eslint src",
5658
"lint-fix": "./node_modules/.bin/eslint --fix src --ext .js",

‎src/socket-daemon.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { timer, BehaviorSubject } from 'rxjs';
2626
import { filter, takeUntil, first } from 'rxjs/operators';
2727

2828
import Daemon from './daemon';
29-
// import V2 from './socket-daemon.v2';
29+
import V2 from './socket-daemon.v2';
3030

3131
// Required agent version
3232
const browser = detect();
@@ -63,17 +63,17 @@ export default class SocketDaemon extends Daemon {
6363

6464
this.openChannel(() => this.socket.emit('command', 'list'));
6565

66-
// this.agentV2Found = new BehaviorSubject(null);
66+
this.agentV2Found = new BehaviorSubject(null);
6767

6868
this.agentFound
6969
.subscribe(agentFound => {
7070
if (agentFound) {
7171
this._wsConnect();
72-
/* const v2 = new V2(this.pluginURL);
72+
const v2 = new V2(this.pluginURL);
7373
v2.init().then(() => {
7474
this.v2 = v2;
7575
this.agentV2Found.next(this.v2);
76-
}); */
76+
});
7777
}
7878
else {
7979
this.findAgent();
@@ -279,10 +279,7 @@ export default class SocketDaemon extends Daemon {
279279
*/
280280
update() {
281281
return fetch(`${this.agentInfo[this.selectedProtocol]}/update`, {
282-
method: 'POST',
283-
headers: {
284-
'Content-Type': 'text/plain; charset=utf-8'
285-
}
282+
method: 'POST'
286283
})
287284
.then(result => result.json())
288285
.then(response => {
@@ -307,10 +304,7 @@ export default class SocketDaemon extends Daemon {
307304
stopPlugin() {
308305
if (this.agentFound.getValue()) {
309306
return fetch(`${this.agentInfo[this.selectedProtocol]}/pause`, {
310-
method: 'POST',
311-
headers: {
312-
'Content-Type': 'text/plain; charset=utf-8'
313-
}
307+
method: 'POST'
314308
});
315309
}
316310
}
@@ -434,9 +428,6 @@ export default class SocketDaemon extends Daemon {
434428
daemonUpload(data) {
435429
fetch(`${this.pluginURL}/upload`, {
436430
method: 'POST',
437-
headers: {
438-
'Content-Type': 'text/plain; charset=utf-8'
439-
},
440431
body: JSON.stringify(data)
441432
})
442433
.then(result => {
@@ -471,15 +462,15 @@ export default class SocketDaemon extends Daemon {
471462
_upload(uploadPayload, uploadCommandInfo) {
472463
if (Array.isArray(uploadCommandInfo.tools)) {
473464
uploadCommandInfo.tools.forEach(tool => {
474-
// if (this.v2) {
475-
// this.downloading.next({ status: this.DOWNLOAD_IN_PROGRESS });
476-
// this.v2.installTool(tool).then(() => {
477-
// this.downloading.next({ status: this.DOWNLOAD_DONE });
478-
// });
479-
// }
480-
// else {
481-
this.downloadTool(tool.name, tool.version, tool.packager);
482-
// }
465+
if (this.v2) {
466+
this.downloading.next({ status: this.DOWNLOAD_IN_PROGRESS });
467+
this.v2.installTool(tool).then(() => {
468+
this.downloading.next({ status: this.DOWNLOAD_DONE });
469+
});
470+
}
471+
else {
472+
this.downloadTool(tool.name, tool.version, tool.packager);
473+
}
483474
});
484475
}
485476

‎src/socket-daemon.v2.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export default class SocketDaemonV2 {
3434
// }
3535
installTool(payload) {
3636
return fetch(`${this.daemonURL}/pkgs/tools/installed`, {
37-
method: 'PUT',
38-
headers: {
39-
'Content-Type': 'text/plain; charset=utf-8'
40-
},
37+
method: 'POST',
4138
body: JSON.stringify(payload)
4239
}).then(res => res.json()
4340
.then((json) => {

0 commit comments

Comments
 (0)
Please sign in to comment.