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 SpotifyAuthenticationFrame from '../components/SpotifyAuthenticationFrame'
import ConfirmationButton from '../components/ConfirmationButton'
import PusherConnectionList from '../components/PusherConnectionList'
import URISchemesList from '../components/URISchemesList'
import VersionManager from '../components/VersionManager'
import Header from '../components/Header'
import Thumbnail from '../components/Thumbnail'
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'
class Settings extends React.Component{
constructor(props) {
super(props);
this.state = {
mopidy_host: this.props.mopidy.host,
mopidy_port: this.props.mopidy.port,
pusher_username: this.props.pusher.username,
spotify_country: this.props.spotify.country,
spotify_locale: this.props.spotify.locale
};
}
resetAllSettings(){
localStorage.clear();
window.location = '#'
window.location.reload(true)
return false;
}
setMopidyConfig(e){
e.preventDefault();
this.props.mopidyActions.setConfig({ host: this.state.mopidy_host, port: this.state.mopidy_port });
window.location.reload(true);
return false;
}
setSpotifyConfig(e){
e.preventDefault();
this.props.spotifyActions.setConfig({ country: this.state.spotify_country, locale: this.state.spotify_locale });
return false;
}
renderConnectionStatus(service){
if( this.props[service].connected ){
return (
Connected
)
}else if( this.props[service].connecting ){
return (
Connecting
)
}else{
return (
Not connected
)
}
}
renderSpotifyUser(){
var user = null
if (this.props.spotify.me && this.props.spotify.authorized){
user = this.props.spotify.me
} else if (this.props.ui.config && this.props.ui.config.spotify_username){
if (this.props.ui.users && typeof(this.props.ui.users['spotify:user:'+this.props.ui.config.spotify_username]) !== 'undefined'){
user = this.props.ui.users['spotify:user:'+this.props.ui.config.spotify_username]
}
}
if (user){
return (
{user.display_name ? user.display_name : user.username}
{!this.props.spotify.authorized ? (limited access) : null}
)
} else {
return (
Default user
(limited access)
)
}
}
renderSendAuthorizationButton(){
if( !this.props.spotify.authorized ) return null
return (
)
}
render(){
var actions = (
)
return (
Mopidy
Spotify
Status
{ this.renderConnectionStatus('spotify') }
Current user
{ this.renderSpotifyUser() }
Authentication
{ this.renderSendAuthorizationButton() }
Advanced
Connections
Backends
System
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 help trace issues and provide valuable insight into how we can continue to make improvements.