Skip to content

Commit 4d416ae

Browse files
committed
Overhauled the way EONs are searched out. Also beginnings of two separate lists
1 parent 7daeb22 commit 4d416ae

21 files changed

+302
-96
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ script:
7777
- yarn package
7878
- yarn lint
7979
- |
80-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
80+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
8181
docker run --rm \
8282
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|_TOKEN|_KEY|AWS_|STRIP|BUILD_') \
8383
-v ${PWD}:/project \

app/actions/eon_detail_actions.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import settings from 'electron-settings';
22
const app = require('electron').remote.app;
3-
const path = require("path");
3+
const RSAKey = require('rsa-key');
4+
const mkdirp = require("mkdirp");
5+
import path from 'path';
6+
import fs from 'fs';
47
import * as types from '../constants/eon_detail_action_types';
5-
import * as eonListActions from './eon_list_actions';
68
import * as commands from '../constants/commands.json';
7-
import * as regex from '../constants/tmux_regex';
9+
810
const SSH = require('node-ssh');
911
import * as vehicle_connection_statuses from '../constants/vehicle_connection_statuses.json';
1012
// ACTION CREATORS
@@ -113,7 +115,7 @@ export function RESPONSE_GET_FINGERPRINT(fingerprint, state) {
113115
return {
114116
type: types.GET_FINGERPRINT_RESPONSE,
115117
payload: {
116-
fingerprint: fingerprint,
118+
// fingerprint: fingerprint,
117119
fingerprintString: "[{\n" + Object.keys(fingerprint).sort((a, b) => { return parseInt(a)-parseInt(b);}).map((key) => { let fgpiece = fingerprint[key]; return `${key}: ${fgpiece}`;}).join(", ") + "\n}]"
118120
}
119121
};
@@ -214,6 +216,12 @@ export function RESPONSE_sshCommand(stdout,stderr) {
214216
};
215217
}
216218

219+
export function STOP_POLLING() {
220+
return {
221+
type: types.STOP_POLLING
222+
};
223+
}
224+
217225
export function FAIL_sshCommand(err) {
218226
return {
219227
type: types.SSH_COMMAND_FAIL,
@@ -282,8 +290,8 @@ export function sendCommand(eon, command, commandArgs = [], stdOut = () => {}, s
282290
}
283291
// export function pipeTmux() {
284292
// return (dispatch, getState) => {
285-
// const { selectedEon, scanResults } = getState().eonList;
286-
// const eon = scanResults[selectedEon];
293+
// const { selectedEon, eons } = getState().eonList;
294+
// const eon = eons[selectedEon];
287295
// console.warn("pipeTmux to:",eon);
288296
// if (eon) {
289297
// dispatch(OPEN_REQUEST_EON_STATE());
@@ -298,8 +306,8 @@ export function sendCommand(eon, command, commandArgs = [], stdOut = () => {}, s
298306

299307
// export function pipeState() {
300308
// return (dispatch, getState) => {
301-
// const { selectedEon, scanResults } = getState().eonList;
302-
// const eon = scanResults[selectedEon];
309+
// const { selectedEon, eons } = getState().eonList;
310+
// const eon = eons[selectedEon];
303311
// console.warn("pipeState to:",eon);
304312
// if (eon) {
305313
// dispatch(OPEN_REQUEST_EON_STATE());
@@ -342,8 +350,8 @@ export function sendCommand(eon, command, commandArgs = [], stdOut = () => {}, s
342350

343351
export function fetchFingerprint() {
344352
return (dispatch, getState) => {
345-
const { selectedEon, scanResults } = getState().eonList;
346-
const eon = scanResults[selectedEon];
353+
const { selectedEon, eons } = getState().eonList;
354+
const eon = eons[selectedEon];
347355
const { polling } = getState().eonDetail;
348356
setTimeout(() => {
349357
fetch(`http://${eon.ip}:8080/fingerprint.json`)
@@ -364,11 +372,13 @@ export function fetchFingerprint() {
364372
},2000);
365373
};
366374
}
367-
375+
export function stopPolling() {
376+
dispatch(STOP_POLLING);
377+
}
368378
export function fetchEonState() {
369379
return (dispatch, getState) => {
370-
const { selectedEon, scanResults } = getState().eonList;
371-
const eon = scanResults[selectedEon];
380+
const { selectedEon, eons } = getState().eonList;
381+
const eon = eons[selectedEon];
372382
const { polling } = getState().eonDetail;
373383
setTimeout(() => {
374384
fetch(`http://${eon.ip}:8080/state.json`)
@@ -391,12 +401,12 @@ export function fetchEonState() {
391401
}
392402
export function install() {
393403
return (dispatch, getState) => {
394-
const { selectedEon, scanResults } = getState().eonList;
404+
const { selectedEon, eons } = getState().eonList;
395405

396-
const eon = scanResults[selectedEon];
406+
const eon = eons[selectedEon];
397407
console.warn("Starting Api install...");
398408
dispatch(BEGIN_install());
399-
dispatch(eonListActions.sendCommand(eon, commands.INSTALL_API, [], (resp) => {
409+
dispatch(sendCommand(eon, commands.INSTALL_API, [], (resp) => {
400410
console.info("Installing...", resp);
401411

402412
app.sshClient.dispose();
@@ -415,13 +425,11 @@ export function install() {
415425

416426
export function uninstall() {
417427
return (dispatch, getState) => {
418-
const { selectedEon, scanResults } = getState().eonList;
419-
console.warn("scanResults:",scanResults);
420-
console.warn("selectedEon:",selectedEon);
421-
const eon = scanResults[selectedEon];
428+
const { selectedEon, eons } = getState().eonList;
429+
const eon = eons[selectedEon];
422430
console.warn("Starting Api UNINSTALL...");
423431
dispatch(BEGIN_uninstall());
424-
dispatch(eonListActions.sendCommand(eon, commands.UNINSTALL_API, [], (resp) => {
432+
dispatch(sendCommand(eon, commands.UNINSTALL_API, [], (resp) => {
425433
console.info("UNINSTALLING...", resp);
426434
app.sshClient.dispose();
427435
dispatch(SUCCESS_uninstall());

app/actions/eon_list_actions.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import path from 'path';
2-
import fs from 'fs';
3-
import settings from 'electron-settings';
4-
import routes from '../constants/routes.json';
1+
52
import * as types from '../constants/eon_list_action_types';
6-
import * as networkActions from './network_connection_actions';
73

84
const app = require('electron').remote.app;
95
const SSH = require('node-ssh');
@@ -16,21 +12,23 @@ function revisedRandId() {
1612

1713
export function ADD_EON(eon) {
1814
let randomId = revisedRandId();
19-
let newEon = {
20-
}
15+
let newEon = {};
16+
2117
newEon[randomId] = {
2218
...eon,
2319
id: randomId
24-
}
20+
};
21+
2522
return {
2623
type: types.ADD_EON,
2724
payload: {
2825
eon: newEon
2926
}
30-
}
27+
};
3128
}
3229

3330
export function SELECT_EON(index) {
31+
console.warn("SELECT_EON:",index);
3432
return {
3533
type: types.SELECT_EON,
3634
payload: {
@@ -47,7 +45,8 @@ export function DESELECT_EON(index) {
4745

4846
export function selectEon(eon) {
4947
return (dispatch, getState) => {
50-
dispatch(SELECT_EON(eon.id));
48+
console.log("Selecting eon",eon);
49+
dispatch(SELECT_EON(eon));
5150
};
5251
}
5352
export function checkExistingEONStatuses() {
Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,72 @@
11
import * as types from '../constants/network_scanner_action_types';
22

3-
// STARTS THE SEARCH
3+
function revisedRandId() {
4+
return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
5+
}
46
export function BEGIN_scanNetwork() {
5-
// console.log("dispatched BEGIN_scanNetwork");
6-
77
return {
88
type: types.SCAN_NETWORK
99
};
1010
}
1111

12-
export function RESULT_scanNetwork(result,state) {
13-
// console.log(result);
14-
if (result.status !== 'open') {
15-
result = null;
16-
} else {
17-
result = {
18-
ip: "",
19-
mac: ""
12+
export function RESULT_scanNetwork(result) {
13+
let randomId = revisedRandId();
14+
let newEon = {
15+
}
16+
if (result.status !== "open") {
17+
return {
18+
type: types.SCAN_RESULT_ERROR
2019
}
2120
}
21+
newEon[randomId] = {
22+
...result,
23+
id: randomId
24+
}
2225
return {
2326
type: types.SCAN_NETWORK_RESULT,
2427
payload: {
25-
...result
28+
eon: newEon
2629
}
2730
};
2831
}
2932

30-
export function PROGRESS_scanNetwork() {
33+
export function MAC_ADDRESS_REQUEST() {
3134
return {
32-
type: types.SCAN_NETWORK_PROGRESS,
35+
type: types.MAC_ADDRESS_REQUEST
3336
};
3437
}
3538

36-
// SUCCESSFUL SCAN
37-
export function SUCCESS_scanNetwork(results,state) {
39+
export function MAC_ADDRESS_SUCCESS(data) {
3840
return {
39-
type: types.SCAN_NETWORK_SUCCESS,
41+
type: types.MAC_ADDRESS_SUCCESS,
4042
payload: {
41-
results
43+
eon: data
4244
}
4345
};
4446
}
4547

46-
export function FOUND_scanNetwork(foundResults,state) {
48+
export function MAC_ADDRESS_ERROR(error) {
4749
return {
48-
type: types.SCAN_NETWORK_FOUND,
50+
type: types.MAC_ADDRESS_ERROR,
4951
payload: {
50-
found: foundResults
52+
error
5153
}
5254
};
5355
}
5456

55-
export function NOT_FOUND_scanNetwork() {
56-
// settings.set("scanResults",results);
57-
console.warn("DISPATCHING");
57+
export function PROGRESS_scanNetwork() {
58+
return {
59+
type: types.SCAN_NETWORK_PROGRESS,
60+
};
61+
}
62+
63+
// SUCCESSFUL SCAN
64+
export function SUCCESS_scanNetwork(results,state) {
5865
return {
59-
type: types.SCAN_NETWORK_NOT_FOUND,
66+
type: types.SCAN_NETWORK_SUCCESS,
67+
payload: {
68+
results
69+
}
6070
};
6171
}
6272

@@ -81,3 +91,12 @@ export function resetScanNetwork() {
8191
type: types.SCAN_NETWORK_RESET
8292
};
8393
}
94+
95+
export function REMOVE_SCANNED_RESULT(id) {
96+
return {
97+
type: types.REMOVE_SCANNED_RESULT,
98+
payload: {
99+
id
100+
}
101+
};
102+
}

app/components/EonDetail/Styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
}
5858
.state_card_header {
5959
border-radius:0!important;
60+
text-transform:capitalize;
6061
background-color:darken(#03111C,1)!important;
6162
}
6263
.state_card_list_group {

app/components/EonDetail/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const propTypes = {
3030
thermal: PropTypes.object,
3131
gpsLocation: PropTypes.object,
3232
network: PropTypes.string,
33+
tmuxError: PropTypes.any,
34+
sshStatus: PropTypes.any,
3335
fingerprint: PropTypes.any,
3436
currentStateKeys: PropTypes.array,
3537
fingerprintString: PropTypes.string
@@ -82,6 +84,7 @@ class EonDetail extends Component {
8284
// }, 3000);
8385
}
8486
componentWillUnmount() {
87+
this.props.STOP_POLLING();
8588
// this.props.uninstall();
8689
}
8790

@@ -91,11 +94,11 @@ class EonDetail extends Component {
9194
// }
9295

9396
render() {
94-
const { network, fingerprint, fingerprintString, currentStateKeys, tmuxStartedAt, thermal, serviceState, eon, selectedEon, healthState, sshConnectionError, sshConnectionStatus, gpsState, vehicleConnection, tmuxAttached } = this.props;
97+
const { network, fingerprint, tmuxError, fingerprintString, currentStateKeys, tmuxStartedAt, thermal, serviceState, eon, selectedEon, healthState, sshConnectionError, sshStatus, sshConnectionStatus, gpsState, vehicleConnection, tmuxAttached } = this.props;
9598
const vehicleConnectionInfo = vehicleConnectionStatuses[vehicleConnection];
9699
// const { usbOnline } = thermal;
100+
console.warn("sshConnectionError:",sshConnectionError);
97101
if (network === 'disconnected' || eon == null) {
98-
// console.warn("SSH CONNECTION ERROR!",sshConnectionError);
99102
return (<Redirect to={routes.EON_LIST} />);
100103
}
101104
if (fingerprint) {
@@ -125,7 +128,7 @@ class EonDetail extends Component {
125128
<Card className={styles.state_card}>
126129
<CardBody className={styles.state_card_body}>
127130
<CardHeader className={styles.state_card_header}>Fingerprint</CardHeader>
128-
<Textarea autoFocus className={styles.fingerprint_input + " form-control text-light"} rows="4">{fingerprintString}</Textarea>
131+
<Textarea autoFocus className={styles.fingerprint_input + " form-control text-light"} rows="4" defaultValue={fingerprintString} />
129132
</CardBody>
130133
</Card>
131134
}

app/components/EonList/Styles.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
color:#FFF;
1010

1111
}
12+
13+
.list_group_header {
14+
font-size:11px;
15+
text-transform:uppercase;
16+
margin-top:10px;
17+
line-height:20px;
18+
display:block;
19+
color:rgba(#FFF,0.5);
20+
}
1221
.react_ip_input {
1322
display: inline-block;
1423
border: 1px solid #c2c3c9;
@@ -168,6 +177,7 @@
168177
right:15px;
169178
top:50%;
170179
transform: translateY(-50%);
180+
color:#FFF!important;
171181
}
172182

173183
.ssh_message {
@@ -189,13 +199,20 @@
189199

190200
.results_button {
191201
display:block;
202+
min-height:68px;
192203
border-radius:0!important;
193204
background-color:rgba(#FFF,0.05)!important;
194205
&:hover {
195206
background-color:rgba(#FFF,0.1)!important;
196207
}
208+
209+
.fa {
210+
color:#FFF!important;
211+
}
197212
}
198213

214+
.results_button_selected
215+
199216
/* .results_button:hover .eon_icon {
200217
opacity: 0.5;
201218
} */

0 commit comments

Comments
 (0)