diff --git a/src/js/components/ContextMenu.js b/src/js/components/ContextMenu.js index 1137f870..38c648e4 100755 --- a/src/js/components/ContextMenu.js +++ b/src/js/components/ContextMenu.js @@ -137,7 +137,6 @@ class ContextMenu extends React.Component{ { handleClick: 'playURIs', label: 'Play' }, { handleClick: 'playURIsNext', label: 'Play next' }, { handleClick: 'addToQueue', label: 'Add to queue' }, - { handleClick: 'startRadio', label: 'Start radio' }, { handleClick: 'copyURIs', label: 'Copy URI' } ] break diff --git a/src/js/components/Modal/AddToPlaylistModal.js b/src/js/components/Modal/AddToPlaylistModal.js index b22907ae..8ae15da4 100755 --- a/src/js/components/Modal/AddToPlaylistModal.js +++ b/src/js/components/Modal/AddToPlaylistModal.js @@ -31,7 +31,7 @@ export default class AddToPlaylistModal extends React.Component{ { playlists.map( playlist => { return ( -
this.playlistSelected(playlist.uri) }> +
this.playlistSelected(playlist.uri) }>   { playlist.name } diff --git a/src/js/components/Modal/EditRadioModal.js b/src/js/components/Modal/EditRadioModal.js new file mode 100755 index 00000000..8f764d00 --- /dev/null +++ b/src/js/components/Modal/EditRadioModal.js @@ -0,0 +1,111 @@ + +import React, { PropTypes } from 'react' +import FontAwesome from 'react-fontawesome' + +import Icon from '../Icon' +import * as helpers from '../../helpers' + +export default class EditRadioModal extends React.Component{ + + constructor(props){ + super(props) + this.state = { + seed_tracks: [], + seed_genres: [], + seed_artists: [], + uri: '' + } + } + + componentDidMount(){ + this.setState(this.props.radio) + } + + save(){ + this.props.uiActions.closeModal() + } + + addSeed(seed){ + this.setState({uri: ''}) + } + + removeSeed(type,seed){ + console.log('remove', type, seed) + } + + renderSeeds(){ + if (!this.props.radio || !this.props.radio.enabled) return null +/* + var seeds = this.props.radio.resolved_seeds + var uri + + var seeds = [] + for (var i = 0; i < this.props.radio.seed_tracks.length; i++){ + var uri = this.props.radio.seed_tracks[i] + if (this.props.radio.resolved_seeds.hasOwnProperty(uri)){ + seeds.push(this.props.radio.resolved_seeds[uri]) + } + } + for (var i = 0; i < this.props.radio.seed_artists.length; i++){ + var uri = this.props.radio.seed_artists[i] + if (this.props.radio.resolved_seeds.hasOwnProperty(uri)){ + seeds.push(this.props.radio.resolved_seeds[uri]) + } + }*/ + + return ( +
+ { + this.state.seed_tracks.map(seed => { + return ( +
+ {seed} + this.removeSeed('track',seed)} /> +
+ ) + }) + } + { + this.state.seed_genres.map(seed => { + return ( +
+ {seed} + this.removeSeed('genre',seed)} /> +
+ ) + }) + } + { + this.state.seed_artists.map(seed => { + return ( +
+ {seed} + this.removeSeed('artist',seed)} /> +
+ ) + }) + } +
+ ) + } + + render(){ + return ( +
+

Edit radio

+
+ {this.renderSeeds()} +
+ this.setState({uri: e.target.value})} + value={this.state.uri} /> +
+ + +
+
+ ) + } +} \ No newline at end of file diff --git a/src/js/components/Modal/Modal.js b/src/js/components/Modal/Modal.js index 026e2ef5..0d81ed11 100755 --- a/src/js/components/Modal/Modal.js +++ b/src/js/components/Modal/Modal.js @@ -9,6 +9,7 @@ import AddToPlaylistModal from './AddToPlaylistModal' import CreatePlaylistModal from './CreatePlaylistModal' import EditPlaylistModal from './EditPlaylistModal' import SendAuthorizationModal from './SendAuthorizationModal' +import EditRadioModal from './EditRadioModal' import ImageZoomModal from './ImageZoomModal' import * as uiActions from '../../services/ui/actions' @@ -36,6 +37,7 @@ class Modal extends React.Component{ { this.props.modal.name == 'create_playlist' ? : null } { this.props.modal.name == 'edit_playlist' ? : null } { this.props.modal.name == 'send_authorization' ? : null } + { this.props.modal.name == 'edit_radio' ? : null } { this.props.modal.name == 'image_zoom' ? : null }
@@ -47,6 +49,7 @@ class Modal extends React.Component{ const mapStateToProps = (state, ownProps) => { return { modal: state.ui.modal, + radio: state.ui.radio, playlists: state.ui.playlists, context_menu: state.ui.context_menu, mopidy_connected: state.mopidy.connected, diff --git a/src/js/components/Modal/SendAuthorizationModal.js b/src/js/components/Modal/SendAuthorizationModal.js index c609bc0d..1c02e304 100755 --- a/src/js/components/Modal/SendAuthorizationModal.js +++ b/src/js/components/Modal/SendAuthorizationModal.js @@ -35,7 +35,7 @@ class SendAuthorizationModal extends React.Component{ if (connection.connectionid == this.props.connectionid) return null return ( -
this.handleClick(e, connection.connectionid) }> +
this.handleClick(e, connection.connectionid) }> { connection.username }   ({ connection.ip }) diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js index c71d15c8..e8367d71 100755 --- a/src/js/services/spotify/actions.js +++ b/src/js/services/spotify/actions.js @@ -498,12 +498,7 @@ export function resolveRadioSeeds( radio ){ // flush out the previous store value dispatch({ type: 'RADIO_SEEDS_RESOLVING' }); - var resolved_seeds = { - seed_artists: [], - seed_tracks: [], - seed_genres: [] - } - + var resolved_seeds = {} var requests = [] if (radio.seed_artists.length > 0){ @@ -518,7 +513,9 @@ export function resolveRadioSeeds( radio ){ sendRequest( dispatch, getState, 'artists/'+ artist_ids ) .then( response => { if (!(response instanceof Array)) response = [response] - Object.assign(resolved_seeds.seed_artists, response); + for (var i = 0; i < response.length; i++){ + resolved_seeds[response[i].uri] = response[i] + } }) ) } @@ -534,7 +531,9 @@ export function resolveRadioSeeds( radio ){ requests.push( sendRequest( dispatch, getState, 'tracks?ids='+ track_ids ) .then( response => { - Object.assign(resolved_seeds.seed_tracks, response.tracks); + for (var i = 0; i < response.tracks.length; i++){ + resolved_seeds[response.tracks[i].uri] = response.tracks[i] + } }) ) } @@ -544,7 +543,7 @@ export function resolveRadioSeeds( radio ){ ).then( () => { dispatch({ type: 'RADIO_SEEDS_RESOLVED', - data: resolved_seeds + resolved_seeds: resolved_seeds }); }); } diff --git a/src/js/services/ui/reducer.js b/src/js/services/ui/reducer.js index 52640abd..ef516a5e 100755 --- a/src/js/services/ui/reducer.js +++ b/src/js/services/ui/reducer.js @@ -121,7 +121,7 @@ export default function reducer(ui = {}, action){ return Object.assign({}, ui, { seeds_resolved: false }, { radio: action.data.radio }) case 'RADIO_SEEDS_RESOLVED': - var radio = Object.assign({}, ui.radio, action.data, { seeds_resolved: true }) + var radio = Object.assign({}, ui.radio, { resolved_seeds: action.resolved_seeds }) return Object.assign({}, ui, { radio: radio }) diff --git a/src/js/views/Queue.js b/src/js/views/Queue.js index e454c259..30398717 100755 --- a/src/js/views/Queue.js +++ b/src/js/views/Queue.js @@ -55,28 +55,6 @@ class Queue extends React.Component{ ) } - renderRadio(){ - if (!this.props.radio || !this.props.radio.enabled) return null - - var seed_sentence = 'nothing' - if (this.props.radio.seed_artists.length > 0){ - if (this.props.radio.seeds_resolved){ - seed_sentence = - }else{ - seed_sentence = this.props.radio.seed_artists.length +' artists' - } - } - if (this.props.radio.seed_genres.length > 0) seed_sentence =this.props.radio.seed_artists.length+' genres' - if (this.props.radio.seed_tracks.length > 0) seed_sentence =this.props.radio.seed_tracks.length+' tracks' - - return ( -
- Playing radio based on {seed_sentence} - this.props.pusherActions.stopRadio() }>  Stop radio -
- ) - } - render(){ var actions = ( ) - return ( -
- -
+ if (this.props.radio && this.props.radio.enabled){ + var actions = ( + + + + + ) + } + return ( +
+
- { this.renderRadio() } -
-