User-defined SSL settings; Git.io hosted app
This commit is contained in:
1
src/js/bootstrap.js
vendored
1
src/js/bootstrap.js
vendored
@ -53,6 +53,7 @@ var initialState = {
|
||||
connected: false,
|
||||
host: window.location.hostname,
|
||||
port: (window.location.port ? window.location.port : (window.location.protocol === 'https:' ? '443' : '80')),
|
||||
ssl: (window.location.protocol === 'https:' ? true : false),
|
||||
mute: false,
|
||||
volume: 0,
|
||||
progress: 0,
|
||||
|
||||
@ -63,7 +63,8 @@ const localstorageMiddleware = (function(){
|
||||
'mopidy',
|
||||
{
|
||||
host: action.config.host,
|
||||
port: action.config.port
|
||||
port: action.config.port,
|
||||
ssl: action.config.ssl
|
||||
}
|
||||
);
|
||||
break;
|
||||
|
||||
@ -205,7 +205,7 @@ const MopidyMiddleware = (function(){
|
||||
var state = store.getState()
|
||||
|
||||
socket = new Mopidy({
|
||||
webSocketUrl: 'ws'+(window.location.protocol === 'https:' ? 's' : '')+'://'+state.mopidy.host+':'+state.mopidy.port+'/mopidy/ws/',
|
||||
webSocketUrl: 'ws'+(state.mopidy.ssl ? 's' : '')+'://'+state.mopidy.host+':'+state.mopidy.port+'/mopidy/ws/',
|
||||
callingConvention: 'by-position-or-by-name'
|
||||
})
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@ export default function reducer(mopidy = {}, action){
|
||||
|
||||
case 'MOPIDY_SET_CONFIG':
|
||||
return Object.assign({}, mopidy, {
|
||||
host: action.host,
|
||||
port: action.port,
|
||||
ssl: action.ssl
|
||||
host: action.config.host,
|
||||
port: action.config.port,
|
||||
ssl: action.config.ssl
|
||||
});
|
||||
|
||||
case 'MOPIDY_CHANGE_TRACK':
|
||||
|
||||
@ -33,6 +33,7 @@ class Settings extends React.Component {
|
||||
locale: this.props.core.locale,
|
||||
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
|
||||
}
|
||||
@ -75,10 +76,16 @@ class Settings extends React.Component {
|
||||
return false;
|
||||
}
|
||||
|
||||
setMopidyConfig(e){
|
||||
this.setState({input_in_focus: null})
|
||||
setConfig(e){
|
||||
this.setState({input_in_focus: null});
|
||||
e.preventDefault();
|
||||
this.props.mopidyActions.setConfig({ host: this.state.mopidy_host, port: this.state.mopidy_port });
|
||||
|
||||
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;
|
||||
}
|
||||
@ -100,7 +107,11 @@ class Settings extends React.Component {
|
||||
}
|
||||
|
||||
renderApplyButton(){
|
||||
if (this.props.mopidy.host == this.state.mopidy_host && this.props.mopidy.port == this.state.mopidy_port) return null
|
||||
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 (
|
||||
<div className="field">
|
||||
@ -280,7 +291,7 @@ class Settings extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form onSubmit={(e) => this.setMopidyConfig(e)}>
|
||||
<form onSubmit={(e) => this.setConfig(e)}>
|
||||
<div className="field">
|
||||
<div className="name">Host</div>
|
||||
<div className="input">
|
||||
@ -303,6 +314,22 @@ class Settings extends React.Component {
|
||||
value={ this.state.mopidy_port } />
|
||||
</div>
|
||||
</div>
|
||||
<div className="field checkbox">
|
||||
<div className="name">Encryption</div>
|
||||
<div className="input">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="ssl"
|
||||
checked={this.state.mopidy_ssl}
|
||||
onChange={e => this.setState({mopidy_ssl: !this.state.mopidy_ssl})} />
|
||||
<span className="label has-tooltip">
|
||||
Enable SSL
|
||||
<span className="tooltip">Requires SSL proxy</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{this.renderApplyButton()}
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user