zepio/app/views/console.js

95 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-12-05 08:32:13 -08:00
// @flow
import React, { Component, Fragment } from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
2018-12-05 08:32:13 -08:00
import { ipcRenderer } from 'electron';
import styled from 'styled-components';
import uuid from 'uuid/v4';
import { TextComponent } from '../components/text';
2019-01-10 04:37:28 -08:00
import ConsoleSymbol from '../assets/images/console_zcash.png';
const Wrapper = styled.div`
max-height: 100%;
overflow-y: auto;
background-color: ${props => props.theme.colors.cardBackgroundColor};
margin-top: ${props => props.theme.layoutContentPaddingTop};
border-radius: ${props => props.theme.boxBorderRadius};
padding: 38px 33.5px;
`;
const ConsoleText = styled(TextComponent)`
font-family: 'Source Code Pro', monospace;
`;
const ConsoleImg = styled.img`
height: 200px;
width: auto;
`;
2018-12-05 08:32:13 -08:00
const initialLog = `
Thank you for running a Zcash node!
You're helping to strengthen the network and contributing to a social good :)
In order to ensure you are adequately protecting your privacy when using Zcash, please see <https://z.cash/support/security/>.
`;
2019-01-10 04:37:28 -08:00
const defaultState = `
Thank you for running a Zcash node!
You're helping to strengthen the network and contributing to a social good :)
In order to ensure you are adequately protecting your privacy when using Zcash, please see <https://z.cash/support/security/>.
2019-02-04 20:41:45 -08:00
Block height | 0
Connections | 0
Network solution rate | 0 Sol/s
You are currently not mining.
To enable mining, add 'gen=1' to your zcash.conf and restart.
2019-01-10 04:37:28 -08:00
Since starting this node 0 minutes, 0 seconds ago:
- You have validated 0 transactions!
2019-01-10 04:37:28 -08:00
\n
------------------------------------------
`;
const breakpoints = [1, 4, 7, 10, 13];
2018-12-05 08:32:13 -08:00
type Props = {};
type State = {
log: string,
2018-12-05 08:32:13 -08:00
};
export class ConsoleView extends Component<Props, State> {
state = {
2019-01-10 04:37:28 -08:00
log: defaultState,
2018-12-05 08:32:13 -08:00
};
componentDidMount() {
ipcRenderer.on('zcashd-log', (event: empty, message: string) => {
this.setState(() => ({ log: initialLog + message }));
2018-12-05 08:32:13 -08:00
});
}
componentWillUnmount() {
ipcRenderer.removeAllListeners('zcashd-log');
}
2018-12-05 08:32:13 -08:00
render() {
const { log } = this.state;
2018-12-05 08:32:13 -08:00
return (
2019-01-23 09:04:11 -08:00
<Wrapper id='console-wrapper'>
<Fragment>
<ConsoleImg src={ConsoleSymbol} alt='Zcashd' />
{log.split('\n').map((item, idx) => (
<Fragment key={uuid()}>
<ConsoleText value={item} />
{breakpoints.includes(idx) ? <br /> : null}
</Fragment>
))}
</Fragment>
</Wrapper>
2018-12-05 08:32:13 -08:00
);
}
}