Skip to content

Commit 6dec6b8

Browse files
committed
Merge pull request #173 from parallaxinc/automaticDownload
Automatic download
2 parents adf04da + f5de701 commit 6dec6b8

File tree

7 files changed

+175
-62
lines changed

7 files changed

+175
-62
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
},
99
"dependencies": {
1010
"alt": "^0.16.7",
11-
"bs2-serial": "^0.8.0",
11+
"bs2-serial": "^0.9.0",
1212
"codemirror": "^4.13.0",
1313
"frylord": "^0.6.0",
1414
"holovisor": "^0.2.0",
1515
"iggins": "^0.2.1",
16-
"irken": "^0.6.1",
16+
"irken": "^0.7.0",
1717
"lodash": "^3.9.1",
1818
"react": "^0.13.1",
1919
"react-loader": "^1.2.0",

plugins/editor/key-extension.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ const { dedent, indent } = require('../../src/actions/text-move');
88
const { print } = require('../../src/actions/system');
99
const { newFile, saveFile } = require('../../src/actions/file');
1010
const { hideOverlays, showSave, showDownload, showProjects } = require('../../src/actions/overlay');
11+
const { disableAuto, enableAuto } = require('../../src/actions/device');
1112

1213
const keyExtension = {
1314
setup: function(app) {
1415

1516
const cmCommands = {
17+
download: {
18+
code: ['F9', 'CTRL_R'],
19+
exec: (evt) => {
20+
evt.preventDefault();
21+
enableAuto();
22+
showDownload();
23+
}
24+
},
1625
findNext: {
1726
code: 'F3',
1827
exec: (evt) => {
@@ -31,6 +40,7 @@ const keyExtension = {
3140
code: ['F6', 'CTRL_I'],
3241
exec: (evt) => {
3342
evt.preventDefault();
43+
disableAuto();
3444
showDownload();
3545
}
3646
},

plugins/overlays/download.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@ const { createContainer } = require('sovereign');
99

1010
const Progress = require('./progress');
1111
const deviceStore = require('../../src/stores/device');
12-
const { download, reloadDevices, updateSelected } = require('../../src/actions/device');
12+
const { disableAuto, reloadDevices, updateSelected } = require('../../src/actions/device');
1313

1414
const styles = require('./styles');
1515

1616
class DownloadOverlay extends React.Component {
1717

1818
constructor(){
1919

20-
this._onAccept = this._onAccept.bind(this);
2120
this._onCancel = this._onCancel.bind(this);
2221
this._onReloadDevices = this._onReloadDevices.bind(this);
23-
this._onUpdateSelected = this._onUpdateSelected.bind(this);
2422

2523
}
2624

2725
componentizeDevice(device, selectedPath){
2826
const highlight = device.path === selectedPath ? 'active' : 'inactive';
2927
return (
30-
<tr style={styles[highlight]} onClick={this._onUpdateSelected.bind(this, device)}>
28+
<tr style={styles[highlight]} onClick={updateSelected.bind(this, device)}>
3129
<td style={styles.deviceTd}>{device.name}</td>
3230
<td style={styles.deviceTd}>{device.version}</td>
3331
<td style={styles.deviceTd}>{device.path}</td>
@@ -36,14 +34,25 @@ class DownloadOverlay extends React.Component {
3634
}
3735

3836
render(){
39-
const { devices, devicePath, progress, searching } = this.props;
37+
const { devices, devicePath, message, progress, searching } = this.props;
4038

4139
const deviceRows = _.map(devices, (device) => this.componentizeDevice(device, devicePath));
4240

41+
let bottomBar;
42+
if(message){
43+
bottomBar = (
44+
<div style={styles.overlayUserMessage}>{message}</div>
45+
);
46+
} else {
47+
bottomBar = (
48+
<Progress percent={progress} />
49+
);
50+
}
51+
4352
return (
44-
<Card styles={[styles.overlay, styles.overlayLarge]}>
45-
<h3 style={styles.overlayTitle}>Please choose your connected device.</h3>
46-
<div>
53+
<Card styles={[styles.overlay, styles.overlayLarge, styles.overlayUnpad]}>
54+
<h3 styles={[styles.overlayTitle, styles.overlayPad]}>Please choose your connected device.</h3>
55+
<div style={styles.overlayPad}>
4756
<Loader loaded={!searching}>
4857
<div style={styles.deviceTableWrapper}>
4958
<div style={styles.deviceTableScroll}>
@@ -63,28 +72,21 @@ class DownloadOverlay extends React.Component {
6372
</div>
6473
</Loader>
6574
</div>
66-
<div>
67-
</div>
68-
<div style={styles.overlayDevicesBottom}>
75+
<div styles={[styles.overlayDevicesBottom, styles.overlayPad]}>
6976
<div style={styles.overlayLoadingContainer}>
7077
<Button onClick={this._onReloadDevices}>Refresh</Button>
7178
</div>
7279
<div style={styles.overlayButtonContainer}>
73-
<Button onClick={this._onAccept}>Download</Button>
7480
<Button onClick={this._onCancel}>Cancel</Button>
7581
</div>
7682
</div>
77-
<Progress percent={progress} />
83+
<div style={styles.bottomBar}>
84+
{bottomBar}
85+
</div>
7886
</Card>
7987
);
8088
}
8189

82-
_onAccept(){
83-
const { handleSuccess, handleError, handleComplete } = this.props;
84-
85-
download(handleSuccess, handleError, handleComplete);
86-
}
87-
8890
_onCancel(evt){
8991
const { onCancel } = this.props;
9092

@@ -97,9 +99,6 @@ class DownloadOverlay extends React.Component {
9799
reloadDevices(this.props);
98100
}
99101

100-
_onUpdateSelected(device){
101-
updateSelected(device);
102-
}
103102
}
104103

105104
module.exports = createContainer(DownloadOverlay, {

plugins/overlays/styles.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const styles = {
1818
overlayLarge: StyleSheet.create({
1919
height: 400
2020
}),
21+
overlayUnpad: {
22+
padding: '16px 0 0'
23+
},
24+
overlayPad: {
25+
padding: '0 16px'
26+
},
2127
overlayTitle: {
2228
margin: 0
2329
},
@@ -36,13 +42,22 @@ const styles = {
3642
display: 'flex',
3743
marginTop: 20
3844
},
45+
overlayUserMessage: {
46+
color: '#911',
47+
backgroundColor: '#fcdede',
48+
padding: '10px 16px',
49+
textAlign: 'center',
50+
width: '100%'
51+
},
52+
bottomBar: {
53+
height: '39px',
54+
display: 'flex'
55+
},
3956
progressContainerStyle: {
4057
width: '100%',
4158
height: '8px',
4259
backgroundColor: '#b0d0ef',
43-
position: 'absolute',
44-
bottom: 0,
45-
left: 0
60+
marginTop: 'auto'
4661
},
4762
progressBarStyle: {
4863
height: '100%',

plugins/sidebar/file-operations.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ const { Menu, MainButton, ChildButton } = require('react-mfb-iceddev');
55

66
const { newFile, saveFile } = require('../../src/actions/file');
77
const { showDelete, showDownload } = require('../../src/actions/overlay');
8+
const { enableAuto } = require('../../src/actions/device');
89

910
require('react-mfb-iceddev/mfb.css');
1011

12+
function download(){
13+
enableAuto();
14+
showDownload();
15+
}
16+
1117
const FileOperations = React.createClass({
1218
render: function(){
1319

@@ -17,7 +23,7 @@ const FileOperations = React.createClass({
1723
iconResting="ion-plus-round"
1824
iconActive="ion-close-round" />
1925
<ChildButton
20-
onClick={showDownload}
26+
onClick={download}
2127
icon="ion-code-download"
2228
label="Download" />
2329
<ChildButton

src/actions/device.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
const alt = require('../alt');
44

55
class DeviceActions {
6-
download(handleSuccess, handleError, handleComplete) {
7-
this.dispatch({ handleSuccess, handleError, handleComplete });
8-
}
96

107
reloadDevices() {
118
this.dispatch();
129
}
1310

11+
disableAuto() {
12+
this.dispatch();
13+
}
14+
15+
enableAuto(){
16+
this.dispatch();
17+
}
18+
1419
updateSelected(device) {
1520
this.dispatch(device);
1621
}

0 commit comments

Comments
 (0)