diff --git a/.eslintrc b/.eslintrc index afeb5e9..390923c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -43,6 +43,7 @@ "ignoreTrailingComments": true } ], - "consistent-return": 0 + "consistent-return": 0, + "react/destructuring-assignment": 0 } } diff --git a/app/constants/routes.js b/app/constants/routes.js index 18a4e37..5120961 100644 --- a/app/constants/routes.js +++ b/app/constants/routes.js @@ -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'; diff --git a/app/constants/sidebar.js b/app/constants/sidebar.js index 0434fca..d8d2988 100644 --- a/app/constants/sidebar.js +++ b/app/constants/sidebar.js @@ -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, diff --git a/app/router/router.js b/app/router/router.js index bcfa091..99756e5 100644 --- a/app/router/router.js +++ b/app/router/router.js @@ -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 = () => ( + diff --git a/app/views/console.js b/app/views/console.js new file mode 100644 index 0000000..7b53a4d --- /dev/null +++ b/app/views/console.js @@ -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 { + state = { + log: null, + }; + + componentDidMount() { + ipcRenderer.on('zcashd-log', (event, message) => { + this.setState(() => ({ + log: message, + })); + }); + } + + render() { + return ( +
+ {this.state.log + && this.state.log.split('\n').map(item => ( + + {item} +
+
+ ))} +
+ ); + } +} diff --git a/config/daemon/zcashd-child-process.js b/config/daemon/zcashd-child-process.js index 6283c47..c889a3d 100644 --- a/config/daemon/zcashd-child-process.js +++ b/config/daemon/zcashd-child-process.js @@ -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 = () => 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; diff --git a/config/electron.js b/config/electron.js index 9ba8618..3c741d4 100644 --- a/config/electron.js +++ b/config/electron.js @@ -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 */ diff --git a/config/webpack-main.config.js b/config/webpack-main.config.js index 0e674c4..10b4814 100644 --- a/config/webpack-main.config.js +++ b/config/webpack-main.config.js @@ -10,6 +10,7 @@ module.exports = { minimizer: [new UglifyJSPlugin({ sourceMap: true })], }, devtool: 'cheap-module-source-map', + target: 'electron-renderer', module: { rules: [ {