import React from 'react'; import Link from './Link'; import Icon from './Icon'; export default class Notifications extends React.Component{ constructor(props){ super(props) } importConfiguration(notification_key, configuration){ console.log("Importing configuration", configuration); var configurations = ""; if (configuration.interface){ this.props.uiActions.set(configuration.interface); } if (configuration.spotify){ this.props.spotifyActions.importAuthorization(configuration.spotify.authorization, configuration.spotify.me); } if (configuration.lastfm){ this.props.lastfmActions.importAuthorization(configuration.lastfm.authorization, configuration.lastfm.me); } if (configuration.genius){ this.props.geniusActions.importAuthorization(configuration.genius.authorization, configuration.genius.me); } this.props.uiActions.removeNotification(notification_key, true); this.props.uiActions.createNotification({type: 'info', content: 'Import successful'}); } renderNotifications(){ if (!this.props.notifications || this.props.notifications.length <= 0) return null var notifications = [] for (var key in this.props.notifications){ if (this.props.notifications.hasOwnProperty(key)){ notifications.push(this.props.notifications[key]) } } return ( { notifications.map(notification => { switch (notification.type){ case 'shortcut': return (
) case 'share-configuration-received': return (
this.props.uiActions.removeNotification(notification.key, true) } />

Configuration shared

Another user has shared their configuration with you. This includes:

    {notification.configuration.ui ?
  • User interface
  • : null} {notification.configuration.spotify ?
  • Spotify
  • : null} {notification.configuration.lastfm ?
  • LastFM
  • : null} {notification.configuration.genius ?
  • Genius
  • : null}

Do you want to import this?

this.importConfiguration(notification.key, notification.configuration)}>Import
) default: return (
this.props.uiActions.removeNotification(notification.key, true) } /> {notification.title ?

{notification.title}

: null} {notification.content ?
{notification.content}
: null} {notification.description ?
{notification.description}
: null } {notification.links ?
{notification.links.map((link, i) => { return {link.text} })}
: null }
) } }) }
) } renderProcess(process){ var progress = 0; if (process.data.total && process.data.remaining){ progress = ((process.data.total - process.data.remaining) / process.data.total * 100).toFixed() } switch (process.status){ case 'running': return(
{process.message} {this.props.uiActions.cancelProcess(process.key)}} />
) case 'cancelling': return(
Cancelling
) case 'cancelled': case 'finished': return null } } renderProcesses(){ if (!this.props.processes || this.props.processes.length <= 0) return null var processes = [] for (var key in this.props.processes){ if (this.props.processes.hasOwnProperty(key)){ processes.push(this.props.processes[key]) } } return ( {processes.map(process => { return this.renderProcess(process) })} ) } // do we want the loading of everything to be displayed? // not likely... renderLoader(){ if (!this.props.load_queue){ return null } var load_queue = this.props.load_queue var load_count = 0 for (var key in load_queue){ if (load_queue.hasOwnProperty(key)){ load_count++ } } if (load_count > 0){ var className = "loading " if (load_count > 20){ className += 'high' } else if (load_count > 5){ className += 'medium' } else { className += 'low' } return (
) } else { return null } } render(){ return (
{this.renderLoader()} {this.renderNotifications()} {this.renderProcesses()}
) } }