diff --git a/src/react/LogMonitor.js b/src/react/LogMonitor.js index d710dcc4..6c51f819 100644 --- a/src/react/LogMonitor.js +++ b/src/react/LogMonitor.js @@ -1,6 +1,12 @@ import React, { PropTypes, findDOMNode } from 'react'; import LogMonitorEntry from './LogMonitorEntry'; +const ulStyle = { + listStyle: "none", + padding: "20px 0 20px", + position: "relative" +}; + export default class LogMonitor { constructor() { if (typeof window !== 'undefined') { @@ -137,7 +143,9 @@ export default class LogMonitor { - {elements} +
{computedStates.length > 1 && sum + char.charCodeAt(0), - 0 - ) * Math.abs(Math.sin(token.length)); + const number = finalToken.reduce( + (sum, char) => sum + char.charCodeAt(0), + 0 + ) * Math.abs(Math.sin(token.length)); - const h = Math.round((number * (180 / Math.PI) * token.length) % 360); - const s = number % 100 / 100; - const v = 1; + const h = Math.round((number * (180 / Math.PI) * token.length) % 360); + const s = number % 100 / 100; + const v = 1; - return hsvToRgb(h, s, v); + return hsvToRgb(h, s, v); } -export default class LogMonitorEntry { - static propTypes = { - index: PropTypes.number.isRequired, - state: PropTypes.object.isRequired, - action: PropTypes.object.isRequired, - select: PropTypes.func.isRequired, - error: PropTypes.string, - onActionClick: PropTypes.func.isRequired, - collapsed: PropTypes.bool - }; - - printState(state, error) { - let errorText = error; - if (!errorText) { - try { - return JSON.stringify(this.props.select(state)); - } catch (err) { - errorText = 'Error selecting state.'; +export default class LogMonitorEntry extends Component { + constructor(props) { + super(props); + this.state = { + maximizedAction: false, + maximizedState: false } - } + } - return ( - ({errorText}) - ); - } + ); + } - handleActionClick() { - const { index, onActionClick } = this.props; - if (index > 0) { - onActionClick(index); - } - } + handleCollapseClick() { + const { index, onActionClick } = this.props; + if (index > 0) { + onActionClick(index); + } + } - render() { - const { index, error, action, state, collapsed } = this.props; - const { r, g, b } = colorFromString(action.type); + render() { + const { index, error, action, state, collapsed } = this.props; + const { maximizedAction, maximizedState } = this.state; + if (!action.type) { + return null; + } + const { r, g, b } = colorFromString(action.type); + const colorStyle = {color: `rgb(${r}, ${g}, ${b})`}; - return ( -
- 0) ? 'pointer' : 'default', - WebkitUserSelect: 'none' - }}> - {JSON.stringify(action)} - - {!collapsed && -

- ⇧ -

- } + // Heading + const actionComponent = !maximizedAction ? ( +

+ {"+ " + action.type} +

+ ) : ( +
+           
+              {"- " + JSON.stringify(action, null, 2)}
+           
+        
+ ); - {!collapsed && -
- {this.printState(state, error)} -
- } + // Action + const stateComponent = !maximizedState ? ( +

+ {"+ State: object {...}"} +

+ ) : ( +
+            {"- " + this.printState(state, error)}
+         
+ ); -
-
- ); - } + const collapsedComponent = !collapsed ? ✔ Enabled : ✘ Disabled; + + return ( +
  • +
    +
    +
    + + {collapsedComponent} + + this.setState({maximizedAction: !maximizedAction})} href="javascript:;"> + {actionComponent} + + this.setState({maximizedState: !maximizedState})} href="javascript:;"> + {stateComponent} + +
    +
    +
    +
  • + ); + } +} +function getTimestring(d) { + var x = document.getElementById("demo"); + var h = addZero(d.getHours(), 2); + var m = addZero(d.getMinutes(), 2); + var s = addZero(d.getSeconds(), 2); + var ms = addZero(d.getMilliseconds(), 3); + return h + ":" + m + ":" + s + ":" + ms; +} +function addZero(x, n) { + if (x.toString().length < n) { + x = "0" + x; + } + return x; }