import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { hashHistory, Link } from 'react-router' import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' import ConfirmationButton from '../components/Fields/ConfirmationButton' import PusherConnectionList from '../components/PusherConnectionList' import Header from '../components/Header' import Parallax from '../components/Parallax' import Icon from '../components/Icon' import Thumbnail from '../components/Thumbnail' import URILink from '../components/URILink' import Services from '../components/Services' import * as coreActions from '../services/core/actions' import * as uiActions from '../services/ui/actions' import * as pusherActions from '../services/pusher/actions' import * as mopidyActions from '../services/mopidy/actions' import * as lastfmActions from '../services/lastfm/actions' import * as spotifyActions from '../services/spotify/actions' class Settings extends React.Component { constructor(props){ super(props); this.state = { mopidy_host: this.props.mopidy.host, mopidy_port: this.props.mopidy.port, mopidy_ssl: this.props.mopidy.ssl, pusher_username: this.props.pusher.username, input_in_focus: null } } componentWillReceiveProps(newProps){ var changed = false var state = this.state if (newProps.pusher.username != this.state.pusher_username && this.state.input_in_focus != 'pusher_username'){ state.pusher_username = newProps.pusher.username changed = true } if (changed){ this.setState(state) } } resetAllSettings(){ localStorage.clear(); window.location = '#' window.location.reload(true) return false; } setConfig(e){ this.setState({input_in_focus: null}); e.preventDefault(); this.props.mopidyActions.setConfig({ host: this.state.mopidy_host, port: this.state.mopidy_port, ssl: this.state.mopidy_ssl }); window.location.reload(true); return false; } handleBlur(name, value){ this.setState({input_in_focus: null}) var data = {} data[name] = value this.props.coreActions.set(data) } handleUsernameChange(username){ this.setState({pusher_username: username.replace(/\W/g, '')}) } handleUsernameBlur(e){ this.setState({input_in_focus: null}) this.props.pusherActions.setUsername(this.state.pusher_username) } renderApplyButton(){ if (this.props.mopidy.host == this.state.mopidy_host && this.props.mopidy.port == this.state.mopidy_port && this.props.mopidy.ssl == this.state.mopidy_ssl){ return null; } return (
) } renderServerStatus(){ var colour = 'grey'; var icon = 'question-circle'; var status = 'Unknown'; if (this.props.mopidy.connecting || this.props.pusher.connecting){ icon = 'plug'; status = 'Connecting...' } else if (!this.props.mopidy.connected || !this.props.pusher.connected){ colour = 'red'; icon = 'close'; status = 'Disconnected'; } else if (this.props.mopidy.connected && this.props.pusher.connected){ colour = 'green'; icon = 'check'; status = 'Connected'; } return (   {status} ); } render(){ var options = (   Help ) if (this.props.mopidy.upgrading){ var upgrade_button = ( ); } else if (this.props.pusher.version.upgrade_available){ var upgrade_button = ; } else { var upgrade_button = null; } return (

Server

Status
{this.renderServerStatus()}
Username
this.handleUsernameChange(e.target.value)} onFocus={e => this.setState({input_in_focus: 'pusher_username'})} onBlur={e => this.handleUsernameBlur(e)} value={this.state.pusher_username } />
A non-unique string used to identify this client (no special characters)
this.setConfig(e)}>
Host
this.setState({mopidy_host: e.target.value})} onFocus={e => this.setState({input_in_focus: 'mopidy_host'})} onBlur={e => this.setState({input_in_focus: null})} value={ this.state.mopidy_host } />
Port
this.setState({mopidy_port: e.target.value})} onFocus={e => this.setState({input_in_focus: 'mopidy_port'})} onBlur={e => this.setState({input_in_focus: null})} value={ this.state.mopidy_port } />
Encryption
{this.renderApplyButton()}

Services

Advanced

UI behavior
Connections
Version
{this.props.pusher.version.current} installed {this.props.pusher.version.upgrade_available ? Upgrade available :   Up-to-date}
{upgrade_button} this.resetAllSettings()} />

About

Iris is an open-source project by James Barnsley. It is provided free and with absolutely no warranty. If you paid someone for this software, please let me know.

Google Analytics is used to collect usage data and errors to help trace issues and provide valuable insight into how we can continue to make improvements. Personal information is anonymized prior to collection. For more information, see terms and conditions.


); } } const mapStateToProps = (state, ownProps) => { return state; } const mapDispatchToProps = (dispatch) => { return { coreActions: bindActionCreators(coreActions, dispatch), uiActions: bindActionCreators(uiActions, dispatch), pusherActions: bindActionCreators(pusherActions, dispatch), mopidyActions: bindActionCreators(mopidyActions, dispatch), lastfmActions: bindActionCreators(lastfmActions, dispatch), spotifyActions: bindActionCreators(spotifyActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(Settings)