Skip to content

Commit

Permalink
v0.0.3 - just bug fixes / performance improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrux committed Sep 19, 2018
1 parent b054570 commit 79033a2
Show file tree
Hide file tree
Showing 10 changed files with 20,880 additions and 60 deletions.
55 changes: 11 additions & 44 deletions app/actions/connect_eon.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,15 @@ export function FAIL_sshCommand(err) {

// LOCATE ACTION CREATORS
export function BEGIN_scanNetwork() {
console.log("dispatched BEGIN_scanNetwork");
// console.log("dispatched BEGIN_scanNetwork");

return {
type: types.SCAN_NETWORK
};
}

export function SUCCESS_scanNetwork(results,state) {
let currentEons = state.connectEon.scanResults;
let newList = [];
newList = results.map((result) => {
const foundCurrent = currentEons.filter((item) => {
result.mac === item.mac
});

if (!foundCurrent.length) {
return result;
}
});
console.log(newList);
settings.set("scanResults",results);
return {
type: types.SCAN_NETWORK_SUCCESS,
payload: {
Expand Down Expand Up @@ -188,7 +177,7 @@ export function sendPiped(eon, command, commandArgs = [], stdOut = () => {}, std
export function sendCommand(eon, command, commandArgs = []) {
const privateKey = getPrivateKey();
const sshClient = new SSH();
console.log("Connecting...");
// console.log("Connecting...");
return sshClient.connect({
host: eon.ip,
username: 'root',
Expand All @@ -204,38 +193,16 @@ export function sendCommand(eon, command, commandArgs = []) {
export function scanNetwork() {
return (dispatch, getState) => {
dispatch(BEGIN_scanNetwork());
return new Promise((resolve,reject) => {
let foundItem;
let tryCount = 0;
// while (!foundItem || tryCount >= 100) {
// netList.findFirst('OnePlus', {}, (err, obj) => {
// console.log(obj);
// resolve(obj);
// if (obj.vendor === "OnePlus Technology (Shenzhen) Co., Ltd") {
// console.warn("FOUND");
// foundItem = obj;
//
// skip;
// }
// });
// }

netList.scan({}, (err, arr) => {
if(err!=null) {
dispatch(FAIL_scanNetwork(err));
return reject(err);
}
var aliveResults = arr.filter(item => item.alive);
var eonResults = arr.filter(item => item.vendor === "OnePlus Technology (Shenzhen) Co., Ltd");
// console.warn(aliveResults);
if (eonResults.length) {
dispatch(SUCCESS_scanNetwork(eonResults,getState()));
} else {
dispatch(NO_FOUND_scanNetwork("Could not find EON on your network."))
let found = false;

netList.scanEach({}, (err, obj) => {
// console.log(obj);

if (obj.vendor === "OnePlus Technology (Shenzhen) Co., Ltd") {
dispatch(SUCCESS_scanNetwork([obj],getState()));
found = true;
}
resolve(aliveResults);
});
});
};
}

Expand Down
2 changes: 1 addition & 1 deletion app/components/ConnectEon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ConnectEon extends Component {
}

<form onSubmit={this.handleSubmit}>
<input type="text" name="ip_address" id="ip_address" value={this.state.value} onChange={this.handleChange} className={styles.add_field + " form-control bg-dark"} placeholder="Add IP Address Manually" />
<input type="text" name="ip_address" id="ip_address" value={this.state.value} onChange={this.handleChange} className={styles.add_field + " form-control text-light bg-dark"} placeholder="Add IP Address Manually" />
</form>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/LoadingIndicator/Styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
width: 100%;
height: 100%;
position: relative;
margin:25px auto;
/* margin:25px auto; */
}
.circle {
width: 75px;
Expand Down
14 changes: 8 additions & 6 deletions app/components/LoadingIndicator/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, { Component } from 'react';
import Circle from './Circle';
import styles from './Styles.css';

const LoadingIndicator = () => (
<div className={styles.spinner}>
<Circle />
</div>
);
class LoadingIndicator extends Component {
render() {
return (<div className={this.props.className}>
<Circle />
</div>)
}
}

export default LoadingIndicator;
38 changes: 37 additions & 1 deletion app/components/Openpilot/Styles.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
.eon_bar {
position:relative;
}
.loading_overlay {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
.loading_overlay {
position:absolute;
top:50%;
left:50%;
height:75px;
width:75px;
transform:translate(-50%,-50%);

/* width:100%;
height:100%; */
}
.loading_overlay img {
}
.add_field {
border:0;
}
Expand All @@ -27,17 +47,33 @@
display:table;
width:100%;
}
.state_spinner {
height: 20px;
width: 20px;
}
.state_spinner img {
width:100%;
height:100%;
}
.state_item {
display:table-row;
}

.state_label,.state_status {
display:table-cell;
border-bottom: 1px solid #555;
vertical-align: middle;
width:50%;
}
.state_label {
font-weight:200;
text-align:right;
padding:3px 15px;
color:#888;
}
.state_status {

/* color:#28a745; */
}
.state_status.started {
color:#28a745;
}
8 changes: 4 additions & 4 deletions app/components/Openpilot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Openpilot extends Component {
render() {
const processKeys = Object.keys(processInfo);
if (!this.props.tmuxAttached) {
return <div className={styles.loading_overlay}><LoadingIndicator /></div>;
return <LoadingIndicator className={styles.loading_overlay} />;
}

// PROCESS ITEMS
Expand All @@ -69,12 +69,12 @@ class Openpilot extends Component {
return (
<div key={key} className={styles.state_item}>
<span className={styles.state_label}>{processDetails.label}</span>
<span className={styles.state_status + " " + processStatus}>
<span className={styles.state_status}>
{processStatus && (processStatus === 'started') &&
<i className="fa fa-check"></i>
}
{!processStatus || (processStatus !== 'started') &&
<LoadingIndicator />
{(processStatus !== 'started') &&
<LoadingIndicator className={styles.state_spinner} />
}
</span>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openpilot-workbench",
"name": "Workbench",
"productName": "Workbench",
"version": "0.0.2",
"version": "0.0.3",
"description": "The Openpilot Workbench is to help people fix problems with EON, Openpilot, etc.",
"main": "./main.prod.js",
"author": {
Expand Down
Loading

0 comments on commit 79033a2

Please sign in to comment.