import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import Header from '../components/Header'; import Icon from '../components/Icon'; import Button from '../components/Button'; import * as uiActions from '../services/ui/actions'; import * as pusherActions from '../services/pusher/actions'; import * as mopidyActions from '../services/mopidy/actions'; import * as spotifyActions from '../services/spotify/actions'; import * as snapcastActions from '../services/snapcast/actions'; import { I18n, i18n } from '../locale'; class Debug extends React.Component { constructor(props) { super(props); this.state = { mopidy_call: 'playlists.asList', mopidy_data: '{}', pusher_data: '{"method":"get_config"}', snapcast_data: '{"method":"Server.GetStatus"}', access_token: this.props.access_token, toggling_test_mode: false, }; } componentDidMount() { const { uiActions: { setWindowTitle } } = this.props; setWindowTitle(i18n('debug.title')); } onBack = () => { const { history } = this.props; history.push('/settings'); } callMopidy = (e) => { const { mopidyActions: { debug } } = this.props; const { mopidy_call, mopidy_data } = this.state; e.preventDefault(); debug(mopidy_call, JSON.parse(mopidy_data)); } callPusher = (e) => { const { pusherActions: { debug } } = this.props; const { pusher_data } = this.state; e.preventDefault(); debug(JSON.parse(pusher_data)); } callSnapcast = (e) => { const { snapcastActions: { debug } } = this.props; const { snapcast_data } = this.state; e.preventDefault(); debug(JSON.parse(snapcast_data)); } toggleTestMode = (e) => { const { uiActions: { set }, test_mode } = this.props; this.setState({ toggling_test_mode: true }); set({ test_mode: !test_mode }); // Wait a second to allow state to update, and then refresh setTimeout(location.reload(), 1000); } render = () => { const { uiActions, spotifyActions, history, test_mode, debug_response, debug_info, log_actions, log_mopidy, log_pusher, log_snapcast, access_token, } = this.props; const { toggling_test_mode, mopidy_call, mopidy_data, pusher_data, snapcast_data, } = this.state; const options = ( ); return (

Test mode

Spotify