2016-10-03 14:44:27 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
|
|
2016-10-14 22:42:45 +13:00
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-10-03 15:22:15 +13:00
|
|
|
import TrackList from '../components/TrackList'
|
2016-10-03 21:21:14 +13:00
|
|
|
import Track from '../components/Track'
|
2016-10-14 22:42:45 +13:00
|
|
|
import Player from '../components/Player'
|
2016-10-25 21:36:33 +13:00
|
|
|
import ArtistSentence from '../components/ArtistSentence'
|
2016-10-16 12:37:37 +13:00
|
|
|
import AlbumLink from '../components/AlbumLink'
|
2016-10-23 23:48:06 +13:00
|
|
|
import Header from '../components/Header'
|
|
|
|
|
|
2016-10-27 13:34:22 +13:00
|
|
|
import * as mopidyActions from '../services/mopidy/actions'
|
2016-10-03 14:44:27 +13:00
|
|
|
|
2016-10-03 20:05:44 +13:00
|
|
|
class Queue extends React.Component{
|
2016-10-03 14:44:27 +13:00
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 21:21:14 +13:00
|
|
|
renderTrackInFocus(){
|
|
|
|
|
if( this.props.mopidy && this.props.mopidy.trackInFocus ){
|
|
|
|
|
return (
|
2016-10-16 12:37:37 +13:00
|
|
|
<div>
|
|
|
|
|
<div>{ this.props.mopidy.trackInFocus.track.name }</div>
|
2016-10-25 21:36:33 +13:00
|
|
|
<div><ArtistSentence artists={ this.props.mopidy.trackInFocus.track.artists } /></div>
|
2016-10-16 12:37:37 +13:00
|
|
|
<div><AlbumLink album={ this.props.mopidy.trackInFocus.track.album } /></div>
|
|
|
|
|
</div>
|
2016-10-03 21:21:14 +13:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderTrackList(){
|
2016-10-03 20:05:44 +13:00
|
|
|
if( this.props.mopidy && this.props.mopidy.tracks ){
|
2016-10-03 14:44:27 +13:00
|
|
|
return (
|
2016-10-19 14:09:34 +13:00
|
|
|
<TrackList
|
2016-10-27 10:02:12 +13:00
|
|
|
context="queue"
|
2016-10-19 14:09:34 +13:00
|
|
|
tracks={this.props.mopidy.tracks}
|
|
|
|
|
removeTracks={ tracks => this.removeTracks( tracks ) }
|
2016-10-27 13:34:22 +13:00
|
|
|
playTracks={ tracks => this.playTracks( tracks ) }
|
2016-10-19 14:09:34 +13:00
|
|
|
playTrack={ track => this.playTrack( track ) }
|
|
|
|
|
/>
|
2016-10-03 14:44:27 +13:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 14:09:34 +13:00
|
|
|
removeTracks( tracks ){
|
|
|
|
|
var tlids = [];
|
|
|
|
|
for( var i = 0; i < tracks.length; i++ ){
|
|
|
|
|
tlids.push( tracks[i].tlid )
|
|
|
|
|
}
|
2016-10-27 13:34:22 +13:00
|
|
|
this.props.mopidyActions.removeTracks( tlids )
|
2016-10-19 14:09:34 +13:00
|
|
|
}
|
|
|
|
|
|
2016-10-21 16:34:16 +13:00
|
|
|
playTrack( track ){
|
2016-10-27 13:34:22 +13:00
|
|
|
this.props.mopidyActions.changeTrack( track.tlid )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playTracks( tracks ){
|
|
|
|
|
this.props.mopidyActions.changeTrack( tracks[0].tlid )
|
2016-10-19 14:09:34 +13:00
|
|
|
}
|
|
|
|
|
|
2016-10-03 14:44:27 +13:00
|
|
|
render(){
|
|
|
|
|
return (
|
2016-10-26 16:55:47 +13:00
|
|
|
<div className="view queue-view">
|
2016-10-23 23:48:06 +13:00
|
|
|
<Header
|
|
|
|
|
icon="play"
|
|
|
|
|
title="Now playing"
|
|
|
|
|
/>
|
2016-10-03 21:21:14 +13:00
|
|
|
{ this.renderTrackInFocus() }
|
|
|
|
|
{ this.renderTrackList() }
|
2016-10-03 14:44:27 +13:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
2016-10-27 13:34:22 +13:00
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch)
|
2016-10-03 14:44:27 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 20:05:44 +13:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Queue)
|