2017-03-08 09:13:24 +13:00
|
|
|
|
2018-07-09 19:09:12 +12:00
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
2018-10-24 21:34:41 +13:00
|
|
|
import Link from '../../components/Link'
|
2018-07-09 19:09:12 +12:00
|
|
|
import ReactGA from 'react-ga'
|
2017-03-08 09:13:24 +13:00
|
|
|
|
2018-07-09 19:09:12 +12:00
|
|
|
import Modal from './Modal';
|
|
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import * as coreActions from '../../services/core/actions'
|
|
|
|
|
import * as uiActions from '../../services/ui/actions'
|
|
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
|
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
2018-02-01 08:06:40 +13:00
|
|
|
import * as helpers from '../../helpers';
|
2017-03-08 09:13:24 +13:00
|
|
|
|
2018-07-09 19:09:12 +12:00
|
|
|
class AddToQueue extends React.Component{
|
2017-03-08 09:13:24 +13:00
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
this.state = {
|
|
|
|
|
uris: '',
|
2017-05-05 10:47:18 +12:00
|
|
|
next: false
|
2017-03-08 09:13:24 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 16:48:41 +12:00
|
|
|
componentDidMount(){
|
|
|
|
|
this.props.uiActions.setWindowTitle("Add to queue");
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-08 09:13:24 +13:00
|
|
|
handleSubmit(e){
|
2018-07-09 19:09:12 +12:00
|
|
|
e.preventDefault();
|
2017-11-17 20:25:43 +13:00
|
|
|
var uris = this.state.uris.split(',');
|
|
|
|
|
this.props.mopidyActions.enqueueURIs(uris, null, this.state.next);
|
2018-07-09 19:09:12 +12:00
|
|
|
window.history.back();
|
2017-03-08 09:13:24 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
2018-07-13 16:48:41 +12:00
|
|
|
<Modal className="modal--add-to-queue">
|
2017-07-14 08:57:53 +12:00
|
|
|
<h1>Add to queue</h1>
|
2018-10-13 15:57:01 +13:00
|
|
|
<h2 className="mid_grey-text">Add a comma-separated list of URIs to the play queue. You must have the appropriate Mopidy backend enabled for each URI schema (eg spotify:, yt:).</h2>
|
2017-03-08 09:13:24 +13:00
|
|
|
|
|
|
|
|
<form onSubmit={e => this.handleSubmit(e)}>
|
|
|
|
|
<div className="field text">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">URI(s)</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
onChange={e => this.setState({uris: e.target.value})}
|
|
|
|
|
value={this.state.uris} />
|
|
|
|
|
</div>
|
2017-03-08 09:13:24 +13:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="field radio white">
|
2018-06-06 16:54:09 +12:00
|
|
|
<div className="name">
|
2018-05-29 21:05:03 +12:00
|
|
|
Position
|
|
|
|
|
</div>
|
|
|
|
|
<div className="input">
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="next"
|
|
|
|
|
checked={!this.state.next}
|
|
|
|
|
onChange={e => this.setState({next: false})} />
|
|
|
|
|
<span className="label">End</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label>
|
|
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="next"
|
|
|
|
|
checked={this.state.next}
|
|
|
|
|
onChange={e => this.setState({next: true})} />
|
|
|
|
|
<span className="label">After current track</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
2017-03-08 09:13:24 +13:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="actions centered-text">
|
2018-12-05 21:39:06 +13:00
|
|
|
<button type="submit" className="button button--primary button--large">Add</button>
|
2017-03-08 09:13:24 +13:00
|
|
|
</div>
|
|
|
|
|
</form>
|
2018-07-09 19:09:12 +12:00
|
|
|
</Modal>
|
2017-03-08 09:13:24 +13:00
|
|
|
)
|
|
|
|
|
}
|
2018-07-09 19:09:12 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {
|
|
|
|
|
mopidy_connected: state.mopidy.connected,
|
|
|
|
|
playlist: (state.core.playlists[ownProps.params.uri] !== undefined ? state.core.playlists[ownProps.params.uri] : null),
|
|
|
|
|
playlists: state.core.playlists
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
coreActions: bindActionCreators(coreActions, dispatch),
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AddToQueue)
|