2017-03-24 08:46:20 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import FontAwesome from 'react-fontawesome'
|
|
|
|
|
|
|
|
|
|
import Icon from '../Icon'
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
|
|
|
|
export default class SearchSettingsModal extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
spotify: true,
|
|
|
|
|
uri_schemes: []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
if (this.props.search_settings){
|
2017-06-11 06:44:33 +12:00
|
|
|
this.setState(Object.assign({},this.props.search_settings))
|
2017-03-24 08:46:20 +13:00
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
spotify: true,
|
2017-06-11 06:44:33 +12:00
|
|
|
uri_schemes: Object.assign([],this.props.uri_schemes)
|
2017-03-24 08:46:20 +13:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleSubmit(e){
|
|
|
|
|
this.props.uiActions.set({search_settings: this.state})
|
|
|
|
|
this.props.uiActions.closeModal()
|
2017-08-03 16:42:54 +12:00
|
|
|
this.props.coreActions.startSearch(this.props.data.type, this.props.data.query)
|
2017-03-24 08:46:20 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleToggle(scheme){
|
|
|
|
|
var uri_schemes = this.state.uri_schemes
|
|
|
|
|
var index = uri_schemes.indexOf(scheme)
|
|
|
|
|
|
|
|
|
|
if (index > -1){
|
|
|
|
|
uri_schemes.splice(index,1)
|
|
|
|
|
} else {
|
|
|
|
|
uri_schemes.push(scheme)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState({uri_schemes: uri_schemes})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2017-06-21 09:16:26 +12:00
|
|
|
<h1 className="no-bottom-padding">Search sources</h1>
|
|
|
|
|
<h2 className="grey-text bottom-padding">Customise the providers used when searching. Reduce the number of providers to speed up your searches. Please note that not all backends support searching by artist, album or playlist.</h2>
|
2017-03-24 08:46:20 +13:00
|
|
|
|
|
|
|
|
<form onSubmit={e => this.handleSubmit(e)}>
|
2017-03-25 10:21:10 +13:00
|
|
|
<div className="list small">
|
|
|
|
|
<div className="list-item field checkbox white">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="enabled"
|
|
|
|
|
checked={ this.state.spotify }
|
|
|
|
|
onChange={ e => this.setState({ spotify: !this.state.spotify })} />
|
|
|
|
|
<span className="label">spotify <span className="grey-text">(http)</span></span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
{
|
|
|
|
|
this.props.uri_schemes.map(scheme => {
|
|
|
|
|
return (
|
|
|
|
|
<div className="list-item field checkbox white" key={scheme}>
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name={scheme}
|
|
|
|
|
checked={this.state.uri_schemes.indexOf(scheme) > -1}
|
|
|
|
|
onChange={ e => this.handleToggle(scheme)} />
|
|
|
|
|
<span className="label">{scheme.replace(':','')} <span className="grey-text">(mopidy)</span></span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
2017-03-24 08:46:20 +13:00
|
|
|
|
|
|
|
|
<div className="actions centered-text">
|
|
|
|
|
<button type="submit" className="primary wide">Save</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|