This commit is contained in:
James Barnsley
2017-03-23 19:20:41 +13:00
parent fd916bac24
commit 866b7ff291
3 changed files with 50 additions and 13 deletions

View File

@ -8,16 +8,16 @@ import FontAwesome from 'react-fontawesome'
class URISchemesList extends React.Component{
constructor(props) {
super(props);
super(props)
}
render(){
if( !this.props.mopidy.uri_schemes ) return null;
if( !this.props.uri_schemes ) return null;
return (
<div className="uri-schemes-list">
{
this.props.mopidy.uri_schemes.map( (scheme, index) => {
this.props.uri_schemes.map( (scheme, index) => {
scheme = scheme.replace(':','')
return (
<span key={index+'_'+scheme}>
@ -26,7 +26,7 @@ class URISchemesList extends React.Component{
{ scheme }
</span>
</span>
);
)
})
}
</div>
@ -35,7 +35,9 @@ class URISchemesList extends React.Component{
}
const mapStateToProps = (state, ownProps) => {
return state;
return {
uri_schemes: (state.mopidy.uri_schemes ? state.mopidy.uri_schemes : [])
}
}
export default connect(mapStateToProps)(URISchemesList)

View File

@ -61,7 +61,7 @@ ReactDOM.render(
<Route path="debug" component={Debug} />
<Route path="search/:query" component={Search} />
<Route path="search/:query/:type" component={Search} />
<Route path="search/:query/:source/:type" component={Search} />
<Route path="album/:uri" component={Album} />
<Route path="artist/:uri" component={Artist} />
<Route path="playlist/:uri" component={Playlist} />

View File

@ -42,9 +42,18 @@ class Search extends React.Component{
}
performSearch( props = this.props ){
var source = props.params.source
var type = props.params.type
this.props.uiActions.startSearch(props.params.query)
this.props.spotifyActions.getSearchResults( props.params.query )
if( props.mopidy_connected ) this.props.mopidyActions.getSearchResults( props.params.query, props.uri_schemes )
if (!source || source == 'all' || source == 'spotify'){
this.props.spotifyActions.getSearchResults( props.params.query )
}
if( props.mopidy_connected ){
this.props.mopidyActions.getSearchResults( props.params.query, props.uri_schemes )
}
}
loadMore(type){
@ -164,15 +173,22 @@ class Search extends React.Component{
}
}
handleViewChange(val){
handleTypeChange(val){
this.props.uiActions.hideContextMenu()
hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+val)
var source = (this.props.params.source ? this.props.params.source : 'all')
hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+source+'/'+val)
}
handleSourceChange(val){
this.props.uiActions.hideContextMenu()
var type = (this.props.params.type ? this.props.params.type : 'all')
hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+val+'/'+type)
}
render(){
var view_options = [
var type_options = [
{
value: '',
value: 'all',
label: 'All'
},
{
@ -193,9 +209,28 @@ class Search extends React.Component{
}
]
var source_options = [
{
value: 'all',
label: 'All'
},
{
value: 'spotify',
label: 'Spotify'
}
]
for (var i = 0; i < this.props.uri_schemes.length; i++){
var scheme = this.props.uri_schemes[i].replace(':','')
source_options.push({
value: scheme,
label: scheme
})
}
var options = (
<span>
<DropdownField icon="eye" name="View" value={this.props.params.type} options={view_options} handleChange={val => this.handleViewChange(val)} />
<DropdownField icon="cube" name="Type" value={this.props.params.type} options={type_options} handleChange={val => this.handleTypeChange(val)} />
<DropdownField icon="server" name="Source" value={this.props.params.source} options={source_options} handleChange={val => this.handleSourceChange(val)} />
</span>
)