Bugfixes on sending

- added checks to prevent adding to the queue useless items
- fixed issue with mta settings (duplicated "host" input / renamed duplicate to "domain" for MailGun)
- fixed namespace issue on cron daemon/supervisor
- fixed typo in migration preventing the newsletter_templates table to be created.
- partially fixed cron.jsx
This commit is contained in:
Jonathan Labreuille
2015-12-07 13:29:42 +01:00
parent c0ba218949
commit 268dabdc9f
8 changed files with 132 additions and 108 deletions

View File

@@ -1,98 +1,102 @@
define(
[
'react',
'react-dom',
'mailpoet'
],
function (
React,
ReactDOM,
MailPoet
) {
var CronControl = React.createClass({
getInitialState: function () {
return (cronDaemon) ? cronDaemon : null;
},
getDaemonData: function () {
MailPoet.Ajax.post({
endpoint: 'cron',
action: 'getDaemonStatus'
}).done(function (response) {
jQuery('.button-primary').removeClass('disabled');
if (!response) {
this.replaceState();
} else {
this.setState(response);
}
}.bind(this));
},
componentDidMount: function componentDidMount() {
if (this.isMounted()) {
this.getDaemonData;
setInterval(this.getDaemonData, 5000);
}
},
controlDaemon: function (action) {
jQuery('.button-primary').addClass('disabled');
MailPoet.Ajax.post({
endpoint: 'cron',
action: 'controlDaemon',
data: {'action': action}
}).done(function (response) {
if (!response) {
this.replaceState();
} else {
this.setState(response);
}
}.bind(this));
},
render: function () {
if (!this.state) {
return
<div>
Woops, daemon is not running ;\
</div>
}
switch (this.state.status) {
case 'started':
return (
[
'react',
'react-dom',
'mailpoet'
],
function(
React,
ReactDOM,
MailPoet
) {
var CronControl = React.createClass({
getInitialState: function() {
return {
status: 'loading'
};
},
getDaemonData: function() {
MailPoet.Ajax.post({
endpoint: 'cron',
action: 'getDaemonStatus'
})
.done(function(response) {
jQuery('.button-primary')
.removeClass('disabled');
if(response.status !== undefined) {
this.setState(response);
} else {
this.replaceState();
}
}.bind(this));
},
componentDidMount: function() {
if(this.isMounted()) {
this.getDaemonData();
setInterval(this.getDaemonData, 5000);
}
},
controlDaemon: function(action) {
jQuery('.button-primary')
.addClass('disabled');
MailPoet.Ajax.post({
endpoint: 'cron',
action: 'controlDaemon',
data: {
'action': action
}
})
.done(function(response) {
if(!response.result) {
//this.replaceState();
} else {
//this.setState(response);
}
}.bind(this));
},
render: function() {
if(this.state.status === 'loading') {
return(<div>Loading daemon status...</div>);
}
switch(this.state.status) {
case 'started':
return(
<div>
<div>
Cron daemon is running.
<br/>
<br/>
It was started
<strong> {this.state.timeSinceStart} </strong> and last executed
<strong> {this.state.timeSinceUpdate} </strong> for a total of
<strong> {this.state.counter} </strong> times (once every 30 seconds, unless it was interrupted and restarted).
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlDaemon.bind(null, 'stop')}>Stop</a>&nbsp;&nbsp;
<a href="#" className="button-primary" onClick={this.controlDaemon.bind(null, 'pause')}>Pause</a>
</div>
Cron daemon is running.
<br/>
<br/>
It was started
<strong> {this.state.timeSinceStart} </strong> and last executed
<strong> {this.state.timeSinceUpdate} </strong> for a total of
<strong> {this.state.counter} </strong> times (once every 30 seconds, unless it was interrupted and restarted).
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlDaemon.bind(null, 'stop')}>Stop</a>&nbsp;&nbsp;
<a href="#" className="button-primary" onClick={this.controlDaemon.bind(null, 'pause')}>Pause</a>
</div>
);
break;
case 'paused':
case 'stopped':
return (
);
break;
case 'paused':
case 'stopped':
return(
<div>
Daemon is {this.state.status}
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlDaemon.bind(null, 'start')}>Start</a>
</div>
)
break;
}
}
});
let container = document.getElementById('cron_container');
if (container) {
ReactDOM.render(
);
break;
}
}
});
const container = document.getElementById('cron_container');
if(container) {
ReactDOM.render(
<CronControl />,
document.getElementById('cron_status')
)
}
}
);
container
);
}
});