diff --git a/src/js/components/DebugInfo.js b/src/js/components/DebugInfo.js index f38007b5..4cab8cf0 100755 --- a/src/js/components/DebugInfo.js +++ b/src/js/components/DebugInfo.js @@ -73,6 +73,9 @@ class DebugInfo extends React.Component{
{this.props.ui.users ? Object.keys(this.props.ui.users).length : '0'} users
+
+ {this.props.ui.notifications ? Object.keys(this.props.ui.notifications).length : '0'} notifications +
{touch_state}
diff --git a/src/js/components/Loader.js b/src/js/components/Loader.js deleted file mode 100755 index e5659129..00000000 --- a/src/js/components/Loader.js +++ /dev/null @@ -1,35 +0,0 @@ - -import React, { PropTypes } from 'react' -import FontAwesome from 'react-fontawesome' - -export default class Loader extends React.Component{ - - constructor(props) { - super(props) - } - - render(){ - if (!this.props.load_queue){ - return null - } - - var load_queue = this.props.load_queue - var is_loading = false - for (var key in load_queue){ - if (load_queue.hasOwnProperty(key)){ - is_loading = true - break - } - } - - if (is_loading){ - return ( -
- ) - } else { - return ( -
- ) - } - } -} \ No newline at end of file diff --git a/src/js/components/Notifications.js b/src/js/components/Notifications.js index b4d46782..37ccc332 100755 --- a/src/js/components/Notifications.js +++ b/src/js/components/Notifications.js @@ -1,55 +1,66 @@ import React, { PropTypes } from 'react' -import { connect } from 'react-redux' -import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' -import * as actions from '../services/ui/actions' - -class Notifications extends React.Component{ +export default class Notifications extends React.Component{ constructor(props) { super(props) } - render(){ - if( !this.props.notifications ) return null + renderNotifications(){ + if (!this.props.notifications || this.props.notifications.length <= 0) return null + // we only care about the last notification + var notification = this.props.notifications[this.props.notifications.length-1] + + if (notification.is_shortcut){ + return ( +
+ +
+ ) + } else { + return ( +
+ this.props.uiActions.removeNotification(notification.id) } /> + { notification.content } +
+ ) + } + } + + renderLoader(){ + if (!this.props.load_queue){ + return null + } + + var load_queue = this.props.load_queue + var is_loading = false + for (var key in load_queue){ + if (load_queue.hasOwnProperty(key)){ + is_loading = true + break + } + } + + if (is_loading){ + return ( +
+ Loading +
+ ) + } else { + return null + } + } + + render(){ return (
- { - this.props.notifications.map( notification => { - if (notification.is_shortcut){ - return ( -
- -
- ) - } else { - return ( -
- this.props.actions.removeNotification(notification.id) } /> - { notification.content } -
- ) - } - }) - } + {this.renderNotifications()} + {this.renderLoader()}
) } -} - -const mapStateToProps = (state, ownProps) => { - return { - notifications: state.ui.notifications - } -} - -const mapDispatchToProps = (dispatch) => { - return { - actions: bindActionCreators(actions, dispatch) - } -} - -export default connect(mapStateToProps, mapDispatchToProps)(Notifications) \ No newline at end of file +} \ No newline at end of file diff --git a/src/js/services/mopidy/middleware.js b/src/js/services/mopidy/middleware.js index 2cb2318b..e75a3c06 100755 --- a/src/js/services/mopidy/middleware.js +++ b/src/js/services/mopidy/middleware.js @@ -292,7 +292,7 @@ const MopidyMiddleware = (function(){ // treat empty response as a failed lookup if( !response || response.length <= 0 ){ store.dispatch( uiActions.createNotification('Failed to load URI(s)', 'bad') ) - + console.error(action) }else{ // play it store.dispatch( mopidyActions.changeTrack( response[0].tlid ) ); diff --git a/src/js/services/ui/middleware.js b/src/js/services/ui/middleware.js index 54d9a217..b8b00584 100755 --- a/src/js/services/ui/middleware.js +++ b/src/js/services/ui/middleware.js @@ -252,7 +252,8 @@ const UIMiddleware = (function(){ break case 'PLAYLIST_TRACKS_ADDED': - store.dispatch(uiActions.createNotification('Added '+action.tracks_uris.length+' tracks to playlist')) + store.dispatch(uiActions.createNotification('Added '+action.tracks_uris.length+' tracks to playlist')) + switch(helpers.uriSource(action.key)){ case 'spotify': store.dispatch(spotifyActions.getPlaylist(action.key)) diff --git a/src/js/views/App.js b/src/js/views/App.js index b5c133db..ffaefae5 100755 --- a/src/js/views/App.js +++ b/src/js/views/App.js @@ -156,9 +156,11 @@ class App extends React.Component{ - + {this.props.debug_info ? : null} - ); } @@ -172,6 +174,7 @@ class App extends React.Component{ const mapStateToProps = (state, ownProps) => { return { + notifications: (state.ui.notifications ? state.ui.notifications : []), load_queue: (state.ui.load_queue ? state.ui.load_queue : {}), mopidy_connected: state.mopidy.connected, spotify_authorized: state.spotify.authorized, diff --git a/src/js/views/Debug.js b/src/js/views/Debug.js index a774d042..e4bb52cd 100755 --- a/src/js/views/Debug.js +++ b/src/js/views/Debug.js @@ -59,20 +59,20 @@ class Debug extends React.Component{

User interface

-
Emulation
+
Debug
-
Debug data
+
Logging
- +
+
+
+
+
+
diff --git a/src/scss/app.scss b/src/scss/app.scss index 8b169085..9f34beac 100755 --- a/src/scss/app.scss +++ b/src/scss/app.scss @@ -22,7 +22,6 @@ @import 'components/header'; @import 'components/notifications'; @import 'components/dropdown-field'; -@import 'components/loader'; @import 'components/debug'; @import 'views/artist'; diff --git a/src/scss/components/_loader.scss b/src/scss/components/_loader.scss deleted file mode 100755 index c75bf283..00000000 --- a/src/scss/components/_loader.scss +++ /dev/null @@ -1,28 +0,0 @@ - -.loader { - opacity: 0; - position: fixed; - bottom: 12px; - right: 12px; - margin: 0 auto; - width: 16px; - height: 16px; - border: { - radius: 100%; - style: solid; - color: $blue; - width: 2px; - } - border-top-color: transparent; - pointer-events: none; - - &.active { - opacity: 1; - @include animate(); - @include spin(); - } -} - -.lazy-loader { - padding: 20px 0 40px; -} \ No newline at end of file diff --git a/src/scss/components/_notifications.scss b/src/scss/components/_notifications.scss index 8cb4348b..c7ca93e1 100755 --- a/src/scss/components/_notifications.scss +++ b/src/scss/components/_notifications.scss @@ -2,32 +2,21 @@ .notifications { position: fixed; - top: 15px; - left: 0; - right: 0; - text-align: center; + bottom: 15px; + right: 15px; z-index: 99; pointer-events: none; + max-width: 400px; .notification { - display: inline-block; + display: block; position: relative; background: $dark_grey; padding: 12px 32px 12px 18px; - margin: 0 0.5px; + margin: 10px 0 0 0; color: #FFFFFF; pointer-events: all; - &:first-child { - border-top-left-radius: 50px; - border-bottom-left-radius: 50px; - } - - &:last-child { - border-top-right-radius: 50px; - border-bottom-right-radius: 50px; - } - .close-button { position: absolute; top: 10px; @@ -54,6 +43,25 @@ &.bad { background: $red; } + + &.loading { + position: relative; + padding-right: 18px; + + &:after { + position: absolute; + display: block; + content: ''; + background: $blue; + opacity: 1; + animation: slideloader 1s infinite; + bottom: 0; + left: 0; + right: 0; + height: 3px; + z-index: 1; + } + } } .shortcut-notification { @@ -63,9 +71,10 @@ height: 400px; width: 400px; margin: -200px 0 0 -200px; - background: rgba(10, 10, 10, 0.95); + background: $dark_grey; color: $white; border-radius: 10px; + text-align: center; .fa { font-size: 140px; diff --git a/src/scss/global/_variables.scss b/src/scss/global/_variables.scss index 3c8301af..2db1f978 100755 --- a/src/scss/global/_variables.scss +++ b/src/scss/global/_variables.scss @@ -59,6 +59,12 @@ $bp_shallow: 650px; transition: none !important; } +@keyframes slideloader { + 0% { left: 0%; right: 100%; } + 50% { left: 0%; right: 0%; } + 100% { left: 100%; right: 0%; } +} + @keyframes shrink_from_right { from { width: 100%; } to { width: 0%; }