2018-02-01 08:06:40 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
|
|
|
|
|
import Icon from '../Icon'
|
2018-06-05 13:43:02 +12:00
|
|
|
import SpotifyAuthenticationFrame from '../Fields/SpotifyAuthenticationFrame'
|
|
|
|
|
import LastfmAuthenticationFrame from '../Fields/LastfmAuthenticationFrame'
|
|
|
|
|
|
2018-02-01 08:06:40 +13:00
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
|
|
|
|
export default class InitialSetupModal extends React.Component{
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
2018-06-05 13:43:02 +12:00
|
|
|
username: 'Anonymous',
|
|
|
|
|
allow_reporting: this.props.allow_reporting,
|
|
|
|
|
host: this.props.host,
|
|
|
|
|
port: this.props.port,
|
|
|
|
|
ssl: this.props.ssl
|
2018-02-01 08:06:40 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleSubmit(e){
|
2018-06-05 13:43:02 +12:00
|
|
|
e.preventDefault();
|
2018-06-06 21:11:27 +12:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
// Force local username change, even if remote connection absent/failed
|
|
|
|
|
this.props.pusherActions.setUsername(this.state.username, true);
|
2018-06-05 13:43:02 +12:00
|
|
|
|
|
|
|
|
this.props.uiActions.set({
|
|
|
|
|
initial_setup_complete: true,
|
|
|
|
|
allow_reporting: this.state.allow_reporting
|
|
|
|
|
});
|
|
|
|
|
this.props.mopidyActions.setConfig({
|
|
|
|
|
host: this.state.host,
|
|
|
|
|
port: this.state.port,
|
|
|
|
|
ssl: this.state.ssl
|
|
|
|
|
});
|
2018-02-01 08:06:40 +13:00
|
|
|
|
2018-06-05 13:43:02 +12:00
|
|
|
this.setState({saving: true});
|
|
|
|
|
|
2018-06-06 21:11:27 +12:00
|
|
|
// Wait a second to allow changes to apply to store
|
2018-06-05 13:43:02 +12:00
|
|
|
setTimeout(function(){
|
2018-06-06 21:11:27 +12:00
|
|
|
|
|
|
|
|
// We've changed a connection setting, so need to reload
|
|
|
|
|
if (self.state.host !== self.props.host || self.state.port !== self.props.port || self.state.ssl !== self.props.ssl){
|
|
|
|
|
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
|
|
|
|
|
// Safe to just close modal
|
|
|
|
|
} else {
|
|
|
|
|
self.props.uiActions.closeModal();
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
2018-06-05 13:43:02 +12:00
|
|
|
|
|
|
|
|
return false;
|
2018-02-01 08:06:40 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2018-06-05 13:43:02 +12:00
|
|
|
<h1>Get started</h1>
|
2018-02-01 08:06:40 +13:00
|
|
|
<form onSubmit={(e) => this.handleSubmit(e)}>
|
|
|
|
|
|
2018-06-05 13:43:02 +12:00
|
|
|
<div className="field text">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">
|
|
|
|
|
Username
|
|
|
|
|
</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={e => this.setState({username: e.target.value.replace(/\W/g, '')})}
|
|
|
|
|
value={this.state.username } />
|
|
|
|
|
<div className="description">
|
|
|
|
|
A non-unique string used to identify this client (no special characters)
|
|
|
|
|
</div>
|
2018-06-05 13:43:02 +12:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2018-02-01 08:06:40 +13:00
|
|
|
<div className="field">
|
2018-06-05 13:43:02 +12:00
|
|
|
<div className="name">Host</div>
|
2018-02-01 08:06:40 +13:00
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
2018-06-05 13:43:02 +12:00
|
|
|
onChange={ e => this.setState({host: e.target.value})}
|
|
|
|
|
value={ this.state.host } />
|
2018-02-01 08:06:40 +13:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2018-06-05 13:43:02 +12:00
|
|
|
<div className="field">
|
|
|
|
|
<div className="name">Port</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={ e => this.setState({port: e.target.value})}
|
|
|
|
|
value={ this.state.port } />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="field checkbox">
|
|
|
|
|
<div className="input">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="ssl"
|
|
|
|
|
checked={this.state.ssl}
|
|
|
|
|
onChange={e => this.setState({ssl: !this.state.ssl})} />
|
|
|
|
|
<span className="label has-tooltip">
|
|
|
|
|
Enable SSL
|
|
|
|
|
<span className="tooltip">Requires SSL proxy</span>
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2018-06-06 21:11:27 +12:00
|
|
|
<div className="field checkbox">
|
2018-06-05 13:43:02 +12:00
|
|
|
<div className="input">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="allow_reporting"
|
2018-06-06 16:54:09 +12:00
|
|
|
checked={ this.state.allow_reporting }
|
|
|
|
|
onChange={ e => this.setState({ allow_reporting: !this.state.allow_reporting })} />
|
2018-06-05 13:43:02 +12:00
|
|
|
<span className="label">
|
|
|
|
|
Allow reporting of anonymous usage statistics
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2018-06-06 21:11:27 +12:00
|
|
|
{!this.state.allow_reporting ? <p className="description">This anonymous usage data is important in identifying errors and potential features that make Iris better for everyone. Want to know more? Read the <a href="https://github.com/jaedb/Iris/wiki/Terms-of-use#privacy-policy" target="_blank">privacy policy</a>.</p> : null}
|
|
|
|
|
|
2018-02-01 08:06:40 +13:00
|
|
|
<div className="actions centered-text">
|
2018-06-05 13:43:02 +12:00
|
|
|
<button className={"primary large"+(this.state.saving ? " working" : "")} onClick={e => this.handleSubmit(e)}>
|
|
|
|
|
{this.state.saving ? "Saving" : "Save"}
|
|
|
|
|
</button>
|
2018-02-01 08:06:40 +13:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|