Skip to content

Commit 22a84fd

Browse files
authored
Merge pull request #68 from Omega-Numworks/recovery
Added recovery button in installer
2 parents 20de973 + b825873 commit 22a84fd

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
"@testing-library/jest-dom": "^4.2.4",
88
"@testing-library/react": "^9.5.0",
99
"@testing-library/user-event": "^7.2.1",
10-
"firebase": "^7.17.2",
11-
"jszip": "^3.5.0",
10+
"firebase": "^7.24.0",
11+
"jszip": "^3.6.0",
1212
"monaco-editor": "^0.20.0",
13-
"monaco-editor-webpack-plugin": "^1.9.0",
13+
"monaco-editor-webpack-plugin": "^1.9.1",
1414
"node-sass": "^4.14.1",
15-
"numworks.js": "^1.1.0",
16-
"react": "^16.13.1",
17-
"react-dom": "^16.13.1",
18-
"react-intl": "^5.8.2",
15+
"numworks.js": "^1.2.1",
16+
"react": "^16.14.0",
17+
"react-dom": "^16.14.0",
18+
"react-intl": "^5.17.6",
1919
"react-intl-cra": "^0.3.4",
2020
"react-intl-translations-manager": "^5.0.3",
2121
"react-monaco-editor": "^0.34.0",
2222
"react-resize-detector": "^4.2.3",
2323
"react-reveal": "^1.2.2",
2424
"react-router-dom": "^5.2.0",
25-
"react-scripts": "^3.4.1"
25+
"react-scripts": "^3.4.4"
2626
},
2727
"scripts": {
2828
"start": "react-app-rewired start",
@@ -48,6 +48,6 @@
4848
]
4949
},
5050
"devDependencies": {
51-
"react-app-rewired": "^2.1.6"
51+
"react-app-rewired": "^2.1.8"
5252
}
5353
}

src/dfu/installer.js

+30
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default class Installer {
2929

3030
this.calculator = new Numworks();
3131
this.storage_content = new Numworks.Storage();
32+
this.calculator_recovery = new Numworks.Recovery();
3233
this.downloader = new Downloader();
3334
}
3435

@@ -248,6 +249,23 @@ export default class Installer {
248249
});
249250
}
250251

252+
async __installRecovery(callback) {
253+
var _this = this;
254+
var file_name = "flasher.verbose.bin";
255+
256+
_this.downloader.downloadFirmwareCheck(_this.installInstance.state.model, "flasher", file_name, async (flasher_check, flasher_blob) => {
257+
if (!flasher_check) {
258+
_this.installInstance.calculatorError(true, "Download of flasher seems corrupted, please retry.");
259+
}
260+
261+
let flasher = await flasher_blob.arrayBuffer();
262+
263+
await _this.calculator_recovery.flashRecovery(flasher);
264+
265+
await callback();
266+
});
267+
}
268+
251269
async __detectCallback() {
252270
await this.__setCalculatorInfos();
253271
}
@@ -261,6 +279,18 @@ export default class Installer {
261279
this.calculator.detect(this.__detectCallback.bind(this), this.__detectErrorCallback.bind(this));
262280
}
263281

282+
async __recoveryDetectCallback() {
283+
this.installInstance.setModel("N" + this.calculator_recovery.getModel());
284+
await this.__installRecovery(async function() {
285+
286+
});
287+
}
288+
289+
recovery() {
290+
this.installInstance.calculatorError(false, null);
291+
this.calculator_recovery.detect(this.__recoveryDetectCallback.bind(this), this.__detectErrorCallback.bind(this));
292+
}
293+
264294
__onUnexpectedDisconnectCallback(event) {
265295
if (this.ignore_disconnect === false)
266296
this.installInstance.calculatorError(true, event);

src/pages/Install.js

+10
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ export default class Install extends Component {
9595
this.enableName = this.enableName.bind(this);
9696
this.disableName = this.disableName.bind(this);
9797
this.nameChanged = this.nameChanged.bind(this);
98+
99+
// Recovery
100+
this.recoveryCalculator = this.recoveryCalculator.bind(this);
101+
}
102+
103+
recoveryCalculator(e) {
104+
this.state.installerInstance.recovery();
98105
}
99106

100107
nameChanged(e) {
@@ -287,6 +294,9 @@ export default class Install extends Component {
287294
<Button onClick={this.detectCalculator} className={"installer__content__buttons__button " + (!this.state.calculatorDetected ? "installer__content__buttons__button-active" : "")} blue>
288295
<FormattedMessage id="installer.detect" defaultMessage="DETECT CALCULATOR" />
289296
</Button>
297+
<Button onClick={this.recoveryCalculator} className={"installer__content__buttons__button " + (!this.state.calculatorDetected ? "installer__content__buttons__button-active" : "")} blue>
298+
<FormattedMessage id="installer.recovery" defaultMessage="RECOVERY" />
299+
</Button>
290300
<Button onClick={this.install} className={"installer__content__buttons__button" + ((this.state.calculatorDetected && !this.state.install && !this.state.installationFinished) ? " installer__content__buttons__button-active" : "")} disabled={this.state.showPopup} blue>
291301
<FormattedMessage id="installer.install" defaultMessage="INSTALL OMEGA" />
292302
</Button>

src/pages/sass/installer.sass

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
&__button
174174
float: right
175175
display: none
176+
margin-left: 8px
176177

177178
&-active
178179
display: inherit

0 commit comments

Comments
 (0)