Fully-functional proof-of-concept
This commit is contained in:
@ -82,7 +82,7 @@ export default class Notifications extends React.Component{
|
||||
<div className={"notification notification--"+notification.type+(notification.closing ? ' closing' : '')} key={notification.key} data-key={notification.key} data-duration={notification.duration}>
|
||||
<Icon name="close" className="close-button" onClick={ e => this.props.uiActions.removeNotification(notification.key, true) } />
|
||||
{notification.title ? <h4>{notification.title}</h4> : null}
|
||||
{notification.content ? <p className="content" dangerouslySetInnerHTML={{__html: notification.content}}></p> :null}
|
||||
{notification.content ? <p className="content" dangerouslySetInnerHTML={{__html: notification.content}}></p> : null}
|
||||
{notification.description ? <p className="description" dangerouslySetInnerHTML={{__html: notification.description}}></p> : null }
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -30,18 +30,6 @@ export function connecting(){
|
||||
}
|
||||
}
|
||||
|
||||
export function upgrading(){
|
||||
return {
|
||||
type: 'MOPIDY_UPGRADING'
|
||||
}
|
||||
}
|
||||
|
||||
export function restarting(){
|
||||
return {
|
||||
type: 'MOPIDY_RESTARTING'
|
||||
}
|
||||
}
|
||||
|
||||
export function disconnect(){
|
||||
return {
|
||||
type: 'MOPIDY_DISCONNECT'
|
||||
@ -56,6 +44,42 @@ export function debug(call, value){
|
||||
}
|
||||
}
|
||||
|
||||
export function restartStarted(){
|
||||
return {
|
||||
type: 'MOPIDY_RESTART_STARTED'
|
||||
}
|
||||
}
|
||||
|
||||
export function restartFinished(){
|
||||
return {
|
||||
type: 'MOPIDY_RESTART_FINISHED'
|
||||
}
|
||||
}
|
||||
|
||||
export function upgradeStarted(){
|
||||
return {
|
||||
type: 'MOPIDY_UPGRADE_STARTED'
|
||||
}
|
||||
}
|
||||
|
||||
export function upgradeFinished(){
|
||||
return {
|
||||
type: 'MOPIDY_UPGRADE_FINISHED'
|
||||
}
|
||||
}
|
||||
|
||||
export function localScanStarted(){
|
||||
return {
|
||||
type: 'MOPIDY_LOCAL_SCAN_STARTED'
|
||||
}
|
||||
}
|
||||
|
||||
export function localScanFinished(){
|
||||
return {
|
||||
type: 'MOPIDY_LOCAL_SCAN_FINISHED'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Core play actions
|
||||
**/
|
||||
|
||||
@ -4,21 +4,29 @@ import * as helpers from '../../helpers';
|
||||
export default function reducer(mopidy = {}, action){
|
||||
switch (action.type){
|
||||
|
||||
case 'MOPIDY_SET':
|
||||
return Object.assign({}, mopidy, action.data);
|
||||
|
||||
case 'MOPIDY_CONNECT':
|
||||
case 'MOPIDY_CONNECTING':
|
||||
return Object.assign({}, mopidy, { connected: false, connecting: true });
|
||||
|
||||
case 'MOPIDY_RESTARTING':
|
||||
return Object.assign({}, mopidy, { restarting: true });
|
||||
|
||||
case 'MOPIDY_UPGRADING':
|
||||
return Object.assign({}, mopidy, { upgrading: true });
|
||||
return Object.assign({}, mopidy, {
|
||||
connected: false,
|
||||
connecting: true
|
||||
});
|
||||
|
||||
case 'MOPIDY_CONNECTED':
|
||||
return Object.assign({}, mopidy, { connected: true, connecting: false, restarting: false, upgrading: false });
|
||||
return Object.assign({}, mopidy, {
|
||||
connected: true,
|
||||
connecting: false,
|
||||
restart_running: false,
|
||||
upgrade_running: false
|
||||
});
|
||||
|
||||
case 'MOPIDY_DISCONNECTED':
|
||||
return Object.assign({}, mopidy, { connected: false, connecting: false });
|
||||
return Object.assign({}, mopidy, {
|
||||
connected: false,
|
||||
connecting: false
|
||||
});
|
||||
|
||||
case 'MOPIDY_CHANGE_TRACK':
|
||||
return Object.assign({}, mopidy, {
|
||||
@ -30,8 +38,23 @@ export default function reducer(mopidy = {}, action){
|
||||
uri_schemes: action.uri_schemes
|
||||
});
|
||||
|
||||
case 'MOPIDY_SET':
|
||||
return Object.assign({}, mopidy, action.data);
|
||||
case 'MOPIDY_RESTART_STARTED':
|
||||
return Object.assign({}, mopidy, { restart_running: true });
|
||||
|
||||
case 'MOPIDY_RESTART_FINISHED':
|
||||
return Object.assign({}, mopidy, { restart_running: false });
|
||||
|
||||
case 'MOPIDY_UPGRADE_STARTED':
|
||||
return Object.assign({}, mopidy, { upgrade_running: true });
|
||||
|
||||
case 'MOPIDY_UPGRADE_FINISHED':
|
||||
return Object.assign({}, mopidy, { upgrade_running: false });
|
||||
|
||||
case 'MOPIDY_LOCAL_SCAN_STARTED':
|
||||
return Object.assign({}, mopidy, { local_scan_running: true });
|
||||
|
||||
case 'MOPIDY_LOCAL_SCAN_FINISHED':
|
||||
return Object.assign({}, mopidy, { local_scan_running: false });
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -48,9 +48,15 @@ export function restart(){
|
||||
}
|
||||
}
|
||||
|
||||
export function runLocalScan(){
|
||||
export function localScan(){
|
||||
return {
|
||||
type: 'PUSHER_RUN_LOCAL_SCAN'
|
||||
type: 'PUSHER_LOCAL_SCAN'
|
||||
}
|
||||
}
|
||||
|
||||
export function test(){
|
||||
return {
|
||||
type: 'PUSHER_TEST'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -114,14 +114,13 @@ const PusherMiddleware = (function(){
|
||||
case 'reload':
|
||||
window.location.reload(true);
|
||||
break;
|
||||
case 'upgrading':
|
||||
case 'upgrade_started':
|
||||
store.dispatch(mopidyActions.upgrading());
|
||||
store.dispatch(uiActions.createNotification({content: 'Upgrading...', type: 'info'}));
|
||||
break;
|
||||
case 'restarting':
|
||||
store.dispatch(mopidyActions.restarting());
|
||||
store.dispatch(uiActions.createNotification({content: 'Restarting...', type: 'info'}));
|
||||
case 'update_process':
|
||||
if (message.params.finished){
|
||||
store.dispatch(uiActions.processFinished(message.params.key));
|
||||
store.dispatch(uiActions.createNotification(message.params));
|
||||
} else {
|
||||
store.dispatch(uiActions.updateProcess(message.params.key, message.params.message));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -649,15 +648,7 @@ const PusherMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'PUSHER_RESTART':
|
||||
request(store, 'restart')
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch(mopidyActions.restarting());
|
||||
},
|
||||
error => {
|
||||
store.dispatch(uiActions.createNotification({content: error.message, description: (error.description ? error.description : null), type: 'bad'}));
|
||||
}
|
||||
);
|
||||
request(store, 'restart');
|
||||
next(action);
|
||||
break
|
||||
|
||||
@ -665,30 +656,18 @@ const PusherMiddleware = (function(){
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Upgrade', label: '' });
|
||||
}
|
||||
request(store, 'upgrade')
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch(mopidyActions.upgrading());
|
||||
},
|
||||
error => {
|
||||
store.dispatch(uiActions.createNotification({content: error.message, description: (error.description ? error.description : null), type: 'bad'}));
|
||||
}
|
||||
);
|
||||
request(store, 'upgrade');
|
||||
break;
|
||||
|
||||
case 'PUSHER_RUN_LOCAL_SCAN':
|
||||
case 'PUSHER_LOCAL_SCAN':
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Pusher', action: 'Run local scan', label: '' });
|
||||
ReactGA.event({ category: 'Pusher', action: 'Local scan', label: '' });
|
||||
}
|
||||
request(store, 'run_local_scan')
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch(mopidyActions.localScanRunning());
|
||||
},
|
||||
error => {
|
||||
store.dispatch(uiActions.createNotification({content: error.message, description: (error.description ? error.description : null), type: 'bad'}));
|
||||
}
|
||||
);
|
||||
request(store, 'local_scan');
|
||||
break;
|
||||
|
||||
case 'PUSHER_TEST':
|
||||
request(store, 'test');
|
||||
break;
|
||||
|
||||
case 'PUSHER_VERSION':
|
||||
|
||||
@ -136,6 +136,12 @@ export function createBrowserNotification(data){
|
||||
}
|
||||
|
||||
export function createNotification(data){
|
||||
|
||||
// Allow 'message' as an alias of our content
|
||||
if (data.message){
|
||||
data.content = data.message;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'CREATE_NOTIFICATION',
|
||||
notification: Object.assign(
|
||||
|
||||
@ -122,8 +122,7 @@ class Debug extends React.Component{
|
||||
<div className="name"></div>
|
||||
<div className="input">
|
||||
<a className="button secondary" onClick={e => this.props.uiActions.createNotification({content: 'Test notification'})}>Create notification</a>
|
||||
<a className="button secondary" onClick={e => this.props.uiActions.startProcess('test_process', 'Test process', {total: 100, remaining: 17})}>Start process</a>
|
||||
<a className="button secondary" onClick={e => this.props.uiActions.processFinishing('test_process')}>Stop process</a>
|
||||
<a className="button secondary" onClick={e => this.props.pusherActions.test()}>Run test process</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -202,28 +202,6 @@ class Settings extends React.Component {
|
||||
</a>
|
||||
</span>
|
||||
)
|
||||
|
||||
if (this.props.mopidy.upgrading){
|
||||
var upgrade_button = (
|
||||
<button className="alternative working">
|
||||
Upgrading...
|
||||
</button>
|
||||
);
|
||||
} else if (this.props.pusher.version.upgrade_available){
|
||||
var upgrade_button = <button className="alternative" onClick={e => this.props.pusherActions.upgrade()}>Upgrade to { this.props.pusher.version.latest }</button>;
|
||||
} else {
|
||||
var upgrade_button = null;
|
||||
}
|
||||
|
||||
if (this.props.mopidy.local_scan_running){
|
||||
var local_scan_button = (
|
||||
<button className="working">
|
||||
Running scan...
|
||||
</button>
|
||||
);
|
||||
} else {
|
||||
var local_scan_button = <button onClick={e => this.props.pusherActions.runLocalScan()}>Run local scan</button>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="view settings-view">
|
||||
@ -438,13 +416,13 @@ class Settings extends React.Component {
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
{local_scan_button}
|
||||
<button onClick={e => this.props.pusherActions.localScan()}>Run local scan</button>
|
||||
<Link className="button" to={global.baseURL+"share-configuration"}>Share configuration</Link>
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
{upgrade_button}
|
||||
<button className={"destructive"+(this.props.mopidy.restarting ? ' working' : '')} onClick={e => this.props.pusherActions.restart()}>{this.props.mopidy.restarting ? 'Restarting...' : 'Restart server'}</button>
|
||||
{this.props.pusher.version.upgrade_available ? <button className="alternative" onClick={e => this.props.pusherActions.upgrade()}>Upgrade to { this.props.pusher.version.latest }</button> : null }
|
||||
<button className={"destructive"+(this.props.mopidy.restarting ? ' working' : '')} onClick={e => this.props.pusherActions.restart()}>Restart server</button>
|
||||
<ConfirmationButton className="destructive" content="Reset all settings" confirmingContent="Are you sure?" onConfirm={() => this.resetAllSettings()} />
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user