Merge branch 'feature/background-zcashd' of

https://github.com/andrerfneves/zec-react-wallet into feature/background-zcashd
This commit is contained in:
georgelima 2018-12-07 02:06:11 -02:00
commit b20c21e64b
8 changed files with 58 additions and 6 deletions

View File

@ -43,6 +43,7 @@
"ignoreTrailingComments": true
}
],
"consistent-return": 0
"consistent-return": 0,
"react/destructuring-assignment": 0
}
}

View File

@ -4,3 +4,4 @@ export const DASHBOARD_ROUTE = '/';
export const SEND_ROUTE = '/send';
export const RECEIVE_ROUTE = '/receive';
export const SETTINGS_ROUTE = '/settings';
export const CONSOLE_ROUTE = '/console';

View File

@ -1,7 +1,7 @@
// @flow
import {
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE,
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE, CONSOLE_ROUTE,
} from './routes';
export const MENU_OPTIONS = [
@ -17,6 +17,10 @@ export const MENU_OPTIONS = [
label: 'Receive',
route: RECEIVE_ROUTE,
},
{
label: 'Console',
route: CONSOLE_ROUTE,
},
{
label: 'Settings',
route: SETTINGS_ROUTE,

View File

@ -10,9 +10,11 @@ import { SendView } from '../views/send';
import { ReceiveView } from '../views/receive';
import { SettingsView } from '../views/settings';
import { NotFoundView } from '../views/not-found';
import { ConsoleView } from '../views/console';
import { LayoutComponent } from '../components/layout';
import {
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE,
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE, CONSOLE_ROUTE,
} from '../constants/routes';
export const RouterComponent = () => (
@ -26,6 +28,7 @@ export const RouterComponent = () => (
<Route path={SEND_ROUTE} component={SendView} />
<Route path={RECEIVE_ROUTE} component={ReceiveView} />
<Route path={SETTINGS_ROUTE} component={SettingsView} />
<Route path={CONSOLE_ROUTE} component={ConsoleView} />
<Route component={NotFoundView} />
</Switch>
</LayoutComponent>

39
app/views/console.js Normal file
View File

@ -0,0 +1,39 @@
// @flow
import React, { Component, Fragment } from 'react';
/* eslint-disable-next-line import/no-extraneous-dependencies */
import { ipcRenderer } from 'electron';
type Props = {};
type State = {
log: string | null,
};
export class ConsoleView extends Component<Props, State> {
state = {
log: null,
};
componentDidMount() {
ipcRenderer.on('zcashd-log', (event, message) => {
this.setState(() => ({
log: message,
}));
});
}
render() {
return (
<div className='dashboard'>
{this.state.log
&& this.state.log.split('\n').map(item => (
<Fragment key={`${item.slice(0, 10)}`}>
{item}
<br />
</Fragment>
))}
</div>
);
}
}

View File

@ -3,10 +3,12 @@ import cp from 'child_process';
import path from 'path';
import os from 'os';
import processExists from 'process-exists';
/* eslint-disable-next-line import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies */
import isDev from 'electron-is-dev';
import type { ChildProcess } from 'child_process';
import eres from 'eres';
/* eslint-disable-next-line import/named */
import { mainWindow } from '../electron';
import getBinariesPath from './get-binaries-path';
import getOsFolder from './get-os-folder';
@ -78,8 +80,8 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
stdio: ['ignore', 'pipe', 'pipe'],
});
childProcess.stdout.on('data', () => {
// TODO: Send logs to app
childProcess.stdout.on('data', (data) => {
if (mainWindow) mainWindow.webContents.send('zcashd-log', data.toString());
if (!resolved) {
resolve(childProcess);
resolved = true;

View File

@ -64,6 +64,7 @@ const createWindow = () => {
mainWindow.loadURL(isDev ? 'http://0.0.0.0:8080/' : `file://${path.join(__dirname, '../build/index.html')}`);
exports.app = app;
exports.mainWindow = mainWindow;
};
/* eslint-disable-next-line consistent-return */

View File

@ -10,6 +10,7 @@ module.exports = {
minimizer: [new UglifyJSPlugin({ sourceMap: true })],
},
devtool: 'cheap-module-source-map',
target: 'electron-renderer',
module: {
rules: [
{