- Fixes blocking HTTP request issue

- Simplifies cron supervisor
This commit is contained in:
Vlad
2016-07-25 11:54:11 -04:00
parent 3cc5812c1d
commit 3f5c36d2d4
6 changed files with 29 additions and 156 deletions

View File

@@ -21,8 +21,6 @@ define(
action: 'getStatus'
})
.done(function(response) {
jQuery('.button-primary')
.removeClass('disabled');
if(response.status !== undefined) {
this.setState(response);
} else {
@@ -36,22 +34,6 @@ define(
setInterval(this.getCronData, 5000);
}
},
controlCron: function(action) {
if(jQuery('.button-primary').hasClass('disabled')) {
return;
}
jQuery('.button-primary')
.addClass('disabled');
MailPoet.Ajax.post({
endpoint: 'cron',
action: action,
})
.done(function(response) {
if(!response.result) {
MailPoet.Notice.error(MailPoet.I18n.t('daemonControlError'));
}
}.bind(this));
},
render: function() {
switch(this.state.status) {
case 'loading':
@@ -60,48 +42,18 @@ define(
{MailPoet.I18n.t('loadingDaemonStatus')}
</div>
);
case 'started':
return(
<div>
{MailPoet.I18n.t('cronDaemonIsRunning')}
<br/>
<br/>
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'stop')}>{MailPoet.I18n.t('stop')}</a>
</div>
);
break;
case 'starting':
case 'stopping':
return(
<div>
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
</div>
);
break;
case 'stopped':
return(
<div>
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'start')}>{MailPoet.I18n.t('start')}</a>
</div>
);
break;
case 'wordpress_task_scheduler_enabled':
return(
<div>
{MailPoet.I18n.t('wordpressTaskSchedulerEnabled')}
</div>
);
break;
case false:
return(
<div>
{MailPoet.I18n.t('daemonNotRunning')}
</div>
);
break;
default:
return(
<div>
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
</div>
);
}
}
});
@@ -114,4 +66,4 @@ define(
container
);
}
});
});