Add new model action for stopping a job
This commit is contained in:
parent
361ff9e140
commit
c7639237ba
|
@ -74,14 +74,24 @@ export default Watchable.extend({
|
|||
|
||||
forcePeriodic(job) {
|
||||
if (job.get('periodic')) {
|
||||
const [path, params] = this.buildURL('job', job.get('id'), job, 'findRecord').split('?');
|
||||
let url = `${path}/periodic/force`;
|
||||
|
||||
if (params) {
|
||||
url += `?${params}`;
|
||||
}
|
||||
|
||||
const url = addToPath(this.urlForFindRecord(job.get('id'), 'job'), '/periodic/force');
|
||||
return this.ajax(url, 'POST');
|
||||
}
|
||||
},
|
||||
|
||||
stop(job) {
|
||||
const url = this.urlForFindRecord(job.get('id'), 'job');
|
||||
return this.ajax(url, 'DELETE');
|
||||
},
|
||||
});
|
||||
|
||||
function addToPath(url, extension = '') {
|
||||
const [path, params] = url.split('?');
|
||||
let newUrl = `${path}${extension}`;
|
||||
|
||||
if (params) {
|
||||
newUrl += `?${params}`;
|
||||
}
|
||||
|
||||
return newUrl;
|
||||
}
|
||||
|
|
|
@ -162,6 +162,10 @@ export default Model.extend({
|
|||
return this.store.adapterFor('job').forcePeriodic(this);
|
||||
},
|
||||
|
||||
stop() {
|
||||
return this.store.adapterFor('job').stop(this);
|
||||
},
|
||||
|
||||
statusClass: computed('status', function() {
|
||||
const classMap = {
|
||||
pending: 'is-pending',
|
||||
|
|
Loading…
Reference in New Issue