11import settings from 'electron-settings' ;
22const 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' ;
47import * as types from '../constants/eon_detail_action_types' ;
5- import * as eonListActions from './eon_list_actions' ;
68import * as commands from '../constants/commands.json' ;
7- import * as regex from '../constants/tmux_regex' ;
9+
810const SSH = require ( 'node-ssh' ) ;
911import * 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+
217225export 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
343351export 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+ }
368378export 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}
392402export 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
416426export 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 ( ) ) ;
0 commit comments