Merge branch 'feature/background-zcashd' of
https://github.com/andrerfneves/zec-react-wallet into feature/background-zcashd
This commit is contained in:
commit
b20c21e64b
|
@ -43,6 +43,7 @@
|
||||||
"ignoreTrailingComments": true
|
"ignoreTrailingComments": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"consistent-return": 0
|
"consistent-return": 0,
|
||||||
|
"react/destructuring-assignment": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,4 @@ export const DASHBOARD_ROUTE = '/';
|
||||||
export const SEND_ROUTE = '/send';
|
export const SEND_ROUTE = '/send';
|
||||||
export const RECEIVE_ROUTE = '/receive';
|
export const RECEIVE_ROUTE = '/receive';
|
||||||
export const SETTINGS_ROUTE = '/settings';
|
export const SETTINGS_ROUTE = '/settings';
|
||||||
|
export const CONSOLE_ROUTE = '/console';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE,
|
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE, CONSOLE_ROUTE,
|
||||||
} from './routes';
|
} from './routes';
|
||||||
|
|
||||||
export const MENU_OPTIONS = [
|
export const MENU_OPTIONS = [
|
||||||
|
@ -17,6 +17,10 @@ export const MENU_OPTIONS = [
|
||||||
label: 'Receive',
|
label: 'Receive',
|
||||||
route: RECEIVE_ROUTE,
|
route: RECEIVE_ROUTE,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Console',
|
||||||
|
route: CONSOLE_ROUTE,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
route: SETTINGS_ROUTE,
|
route: SETTINGS_ROUTE,
|
||||||
|
|
|
@ -10,9 +10,11 @@ import { SendView } from '../views/send';
|
||||||
import { ReceiveView } from '../views/receive';
|
import { ReceiveView } from '../views/receive';
|
||||||
import { SettingsView } from '../views/settings';
|
import { SettingsView } from '../views/settings';
|
||||||
import { NotFoundView } from '../views/not-found';
|
import { NotFoundView } from '../views/not-found';
|
||||||
|
import { ConsoleView } from '../views/console';
|
||||||
import { LayoutComponent } from '../components/layout';
|
import { LayoutComponent } from '../components/layout';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE,
|
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE, CONSOLE_ROUTE,
|
||||||
} from '../constants/routes';
|
} from '../constants/routes';
|
||||||
|
|
||||||
export const RouterComponent = () => (
|
export const RouterComponent = () => (
|
||||||
|
@ -26,6 +28,7 @@ export const RouterComponent = () => (
|
||||||
<Route path={SEND_ROUTE} component={SendView} />
|
<Route path={SEND_ROUTE} component={SendView} />
|
||||||
<Route path={RECEIVE_ROUTE} component={ReceiveView} />
|
<Route path={RECEIVE_ROUTE} component={ReceiveView} />
|
||||||
<Route path={SETTINGS_ROUTE} component={SettingsView} />
|
<Route path={SETTINGS_ROUTE} component={SettingsView} />
|
||||||
|
<Route path={CONSOLE_ROUTE} component={ConsoleView} />
|
||||||
<Route component={NotFoundView} />
|
<Route component={NotFoundView} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</LayoutComponent>
|
</LayoutComponent>
|
||||||
|
|
|
@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,10 +3,12 @@ import cp from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import processExists from 'process-exists';
|
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 isDev from 'electron-is-dev';
|
||||||
import type { ChildProcess } from 'child_process';
|
import type { ChildProcess } from 'child_process';
|
||||||
import eres from 'eres';
|
import eres from 'eres';
|
||||||
|
/* eslint-disable-next-line import/named */
|
||||||
|
import { mainWindow } from '../electron';
|
||||||
|
|
||||||
import getBinariesPath from './get-binaries-path';
|
import getBinariesPath from './get-binaries-path';
|
||||||
import getOsFolder from './get-os-folder';
|
import getOsFolder from './get-os-folder';
|
||||||
|
@ -78,8 +80,8 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
|
|
||||||
childProcess.stdout.on('data', () => {
|
childProcess.stdout.on('data', (data) => {
|
||||||
// TODO: Send logs to app
|
if (mainWindow) mainWindow.webContents.send('zcashd-log', data.toString());
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
resolve(childProcess);
|
resolve(childProcess);
|
||||||
resolved = true;
|
resolved = true;
|
||||||
|
|
|
@ -64,6 +64,7 @@ const createWindow = () => {
|
||||||
mainWindow.loadURL(isDev ? 'http://0.0.0.0:8080/' : `file://${path.join(__dirname, '../build/index.html')}`);
|
mainWindow.loadURL(isDev ? 'http://0.0.0.0:8080/' : `file://${path.join(__dirname, '../build/index.html')}`);
|
||||||
|
|
||||||
exports.app = app;
|
exports.app = app;
|
||||||
|
exports.mainWindow = mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-disable-next-line consistent-return */
|
/* eslint-disable-next-line consistent-return */
|
||||||
|
|
|
@ -10,6 +10,7 @@ module.exports = {
|
||||||
minimizer: [new UglifyJSPlugin({ sourceMap: true })],
|
minimizer: [new UglifyJSPlugin({ sourceMap: true })],
|
||||||
},
|
},
|
||||||
devtool: 'cheap-module-source-map',
|
devtool: 'cheap-module-source-map',
|
||||||
|
target: 'electron-renderer',
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue