Add new model action for stopping a job

This commit is contained in:
Michael Lange 2018-04-18 12:17:55 -07:00
parent 361ff9e140
commit c7639237ba
2 changed files with 21 additions and 7 deletions

View File

@ -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;
}

View File

@ -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',