// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Parity. If not, see . import React, { Component, PropTypes } from 'react'; import AvPause from 'material-ui/svg-icons/av/pause'; import AvPlay from 'material-ui/svg-icons/av/play-arrow'; import AvReplay from 'material-ui/svg-icons/av/replay'; import ReorderIcon from 'material-ui/svg-icons/action/reorder'; import { Container } from '~/ui'; import styles from './debug.css'; export default class Debug extends Component { static propTypes = { actions: PropTypes.shape({ clearStatusLogs: PropTypes.func.isRequired, toggleStatusLogs: PropTypes.func.isRequired }).isRequired, nodeStatus: PropTypes.object.isRequired } state = { reversed: true } render () { const { nodeStatus } = this.props; const { devLogsLevels } = nodeStatus; return ( { this.renderActions() }

{ devLogsLevels || '-' }

{ this.renderToggle() } { this.renderLogs() }
); } renderToggle () { const { devLogsEnabled } = this.props.nodeStatus; if (devLogsEnabled) { return null; } return (
Refresh and display of logs from Parity is currently stopped via the UI, start it to see the latest updates.
); } renderLogs () { const { nodeStatus } = this.props; const { reversed } = this.state; const { devLogs } = nodeStatus; const dateRegex = /^(\d{4}.\d{2}.\d{2}.\d{2}.\d{2}.\d{2})(.*)$/i; if (!devLogs) { return null; } const logs = reversed ? [].concat(devLogs).reverse() : [].concat(devLogs); const text = logs .map((log, index) => { const logDate = dateRegex.exec(log); if (!logDate) { return (

{ log }

); } return (

{ logDate[1] } { logDate[2] }

); }); return (
{ text }
); } renderActions () { const { devLogsEnabled } = this.props.nodeStatus; const toggleButton = devLogsEnabled ? : ; return (
{ toggleButton }
); } clear = () => { const { clearStatusLogs } = this.props.actions; clearStatusLogs(); } toggle = () => { const { devLogsEnabled } = this.props.nodeStatus; const { toggleStatusLogs } = this.props.actions; toggleStatusLogs(!devLogsEnabled); } reverse = () => { const { reversed } = this.state; this.setState({ reversed: !reversed }); } }