From cdbcbd10a8c9622f8fab2584ae316512a2464193 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Sun, 29 Jan 2017 12:54:06 +1300 Subject: [PATCH] Debug info panel --- src/js/components/DebugInfo.js | 50 +++++++++++++++++++++++++++++++++ src/js/views/App.js | 5 +++- src/js/views/Debug.js | 9 ++++++ src/scss/app.scss | 1 + src/scss/components/_debug.scss | 11 ++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100755 src/js/components/DebugInfo.js create mode 100755 src/scss/components/_debug.scss diff --git a/src/js/components/DebugInfo.js b/src/js/components/DebugInfo.js new file mode 100755 index 00000000..4d808866 --- /dev/null +++ b/src/js/components/DebugInfo.js @@ -0,0 +1,50 @@ + +import React, { PropTypes } from 'react' +import { connect } from 'react-redux' +import { Link } from 'react-router' +import { createStore, bindActionCreators } from 'redux' + +import * as uiActions from '../services/ui/actions' + +class DebugInfo extends React.Component{ + + constructor(props) { + super(props); + } + + render(){ + return ( +
+
+ {this.props.ui.albums ? Object.keys(this.props.ui.albums).length : '0'} albums +
+
+ {this.props.ui.artists ? Object.keys(this.props.ui.artists).length : '0'} artists +
+
+ {this.props.ui.playlists ? Object.keys(this.props.ui.playlists).length : '0'} playlists +
+
+ {this.props.ui.users ? Object.keys(this.props.ui.users).length : '0'} users +
+
+ {'ontouchstart' in document.documentElement ? 'can touch' : 'no touch'} +
+
+ ); + } +} + +const mapStateToProps = (state, ownProps) => { + return { + ui: state.ui + } +} + +const mapDispatchToProps = (dispatch) => { + return { + uiActions: bindActionCreators(uiActions, dispatch) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(DebugInfo) \ No newline at end of file diff --git a/src/js/views/App.js b/src/js/views/App.js index 45e80322..76605906 100755 --- a/src/js/views/App.js +++ b/src/js/views/App.js @@ -12,6 +12,7 @@ import ContextMenu from '../components/ContextMenu' import Dragger from '../components/Dragger' import Modal from '../components/Modal/Modal' import Notifications from '../components/Notifications' +import DebugInfo from '../components/DebugInfo' import * as uiActions from '../services/ui/actions' import * as pusherActions from '../services/pusher/actions' @@ -132,6 +133,7 @@ class App extends React.Component{ + {this.props.debug_info ? : null} ); } @@ -151,7 +153,8 @@ const mapStateToProps = (state, ownProps) => { sidebar_open: state.ui.sidebar_open, dragger: state.ui.dragger, modal: state.ui.modal, - context_menu: state.ui.context_menu + context_menu: state.ui.context_menu, + debug_info: state.ui.debug_info } } diff --git a/src/js/views/Debug.js b/src/js/views/Debug.js index 02fe0c46..df52f463 100755 --- a/src/js/views/Debug.js +++ b/src/js/views/Debug.js @@ -87,6 +87,14 @@ class Debug extends React.Component{ onChange={ e => this.props.uiActions.set({ log_actions: !this.props.log_actions })} /> Log actions in developer console + @@ -161,6 +169,7 @@ const mapStateToProps = (state, ownProps) => { connectionid: state.pusher.connectionid, emulate_touch: state.ui.emulate_touch, log_actions: state.ui.log_actions, + debug_info: state.ui.debug_info, debug_response: state.ui.debug_response } } diff --git a/src/scss/app.scss b/src/scss/app.scss index cda2f2f3..8b169085 100755 --- a/src/scss/app.scss +++ b/src/scss/app.scss @@ -23,6 +23,7 @@ @import 'components/notifications'; @import 'components/dropdown-field'; @import 'components/loader'; +@import 'components/debug'; @import 'views/artist'; @import 'views/user'; diff --git a/src/scss/components/_debug.scss b/src/scss/components/_debug.scss new file mode 100755 index 00000000..8e682756 --- /dev/null +++ b/src/scss/components/_debug.scss @@ -0,0 +1,11 @@ + +.debug-info { + font-size: 10px; + position: fixed; + top: 0; + right: 0; + padding: 10px; + background: rgba(0,0,0,0.5); + color: #FFFFFF; + pointer-events: none; +} \ No newline at end of file