2016-10-03 14:44:27 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
2017-02-10 09:06:41 +13:00
|
|
|
import { hashHistory } from 'react-router'
|
2016-10-03 14:44:27 +13:00
|
|
|
import { bindActionCreators } from 'redux'
|
2016-10-14 22:42:45 +13:00
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-12-21 10:22:43 +13:00
|
|
|
|
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'
|
2017-01-22 12:54:20 +13:00
|
|
|
import Dater from '../components/Dater'
|
2016-11-25 22:49:34 +13:00
|
|
|
import SidebarToggleButton from '../components/SidebarToggleButton'
|
2016-11-04 13:51:17 +13:00
|
|
|
import FullPlayer from '../components/FullPlayer'
|
2016-10-25 21:36:33 +13:00
|
|
|
import ArtistSentence from '../components/ArtistSentence'
|
2016-10-23 23:48:06 +13:00
|
|
|
import Header from '../components/Header'
|
|
|
|
|
|
2016-11-03 18:22:26 +13:00
|
|
|
import * as uiActions from '../services/ui/actions'
|
2016-12-20 19:54:19 +13:00
|
|
|
import * as pusherActions from '../services/pusher/actions'
|
2016-11-03 18:22:26 +13:00
|
|
|
import * as spotifyActions from '../services/spotify/actions'
|
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-11-12 17:09:29 +13:00
|
|
|
removeTracks( tracks_indexes ){
|
2016-10-19 14:09:34 +13:00
|
|
|
var tlids = [];
|
2016-11-12 17:09:29 +13:00
|
|
|
for( var i = 0; i < tracks_indexes.length; i++ ){
|
|
|
|
|
tlids.push( this.props.current_tracklist[tracks_indexes[i]].tlid )
|
2016-10-19 14:09:34 +13:00
|
|
|
}
|
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-11-16 13:13:35 +13:00
|
|
|
reorderTracks( indexes, index ){
|
|
|
|
|
this.props.mopidyActions.reorderTracklist( indexes, index )
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-22 12:54:20 +13:00
|
|
|
renderQueueStats(){
|
|
|
|
|
var total_time = 0
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="queue-stats grey-text">
|
|
|
|
|
<span>{this.props.current_tracklist.length} tracks</span>
|
|
|
|
|
|
|
|
|
|
|
{this.props.current_tracklist.length > 0 ? <Dater type="total-time" data={this.props.current_tracklist} /> : <span>0 mins</span>}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 14:44:27 +13:00
|
|
|
render(){
|
2017-01-22 12:54:20 +13:00
|
|
|
var actions = (
|
2017-01-31 08:44:12 +13:00
|
|
|
<span>
|
2017-02-10 09:06:41 +13:00
|
|
|
<button onClick={e => this.props.uiActions.openModal('edit_radio')}>
|
2017-01-31 08:44:12 +13:00
|
|
|
<FontAwesome name="spotify" />
|
|
|
|
|
Radio
|
|
|
|
|
</button>
|
2017-02-10 09:06:41 +13:00
|
|
|
<button onClick={e => this.props.mopidyActions.clearTracklist()}>
|
2017-01-31 08:44:12 +13:00
|
|
|
<FontAwesome name="trash" />
|
|
|
|
|
Clear
|
|
|
|
|
</button>
|
2017-02-10 09:06:41 +13:00
|
|
|
<button onClick={e => hashHistory.push(global.baseURL+'queue-history')}>
|
|
|
|
|
<FontAwesome name="history" />
|
|
|
|
|
History
|
|
|
|
|
</button>
|
2017-01-31 08:44:12 +13:00
|
|
|
</span>
|
2017-01-22 12:54:20 +13:00
|
|
|
)
|
|
|
|
|
|
2016-10-03 14:44:27 +13:00
|
|
|
return (
|
2017-01-30 16:59:37 +13:00
|
|
|
<div className="view queue-view">
|
2017-01-22 12:54:20 +13:00
|
|
|
<Header icon="play" title="Now playing" actions={actions} />
|
2016-11-04 13:51:17 +13:00
|
|
|
<FullPlayer />
|
2016-11-04 15:55:17 +13:00
|
|
|
|
|
|
|
|
<section className="list-wrapper">
|
2016-11-09 13:18:03 +13:00
|
|
|
<TrackList
|
|
|
|
|
show_source_icon={true}
|
2017-02-14 20:24:35 +13:00
|
|
|
context="queue"
|
|
|
|
|
tracks={this.props.current_tracklist}
|
2016-11-09 13:18:03 +13:00
|
|
|
removeTracks={ tracks => this.removeTracks( tracks ) }
|
|
|
|
|
playTracks={ tracks => this.playTracks( tracks ) }
|
2016-11-16 13:13:35 +13:00
|
|
|
playTrack={ track => this.playTrack( track ) }
|
|
|
|
|
reorderTracks={ (indexes, index) => this.reorderTracks(indexes, index) } />
|
2016-11-04 15:55:17 +13:00
|
|
|
</section>
|
|
|
|
|
|
2016-10-03 14:44:27 +13:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2016-11-09 13:18:03 +13:00
|
|
|
return {
|
2016-12-20 16:58:20 +13:00
|
|
|
radio: state.ui.radio,
|
2016-11-09 13:18:03 +13:00
|
|
|
current_tracklist: state.ui.current_tracklist
|
|
|
|
|
}
|
2016-10-03 14:44:27 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
2016-11-03 18:22:26 +13:00
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
2016-12-20 19:54:19 +13:00
|
|
|
pusherActions: bindActionCreators(pusherActions, dispatch),
|
2016-11-03 18:22:26 +13:00
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
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)
|