Add ability to force a periodic job launch

This commit is contained in:
Michael Lange 2018-01-26 14:32:11 -08:00
parent 732c61baf9
commit abcfda9911
4 changed files with 31 additions and 1 deletions

View file

@ -65,4 +65,17 @@ export default ApplicationAdapter.extend({
const url = this.buildURL('job', name, job, 'findRecord');
return this.ajax(url, 'GET', { data: assign(this.buildQuery() || {}, namespaceQuery) });
},
forcePeriodic(job) {
if (job.get('periodic')) {
const [name, namespace] = JSON.parse(job.get('id'));
let url = `${this.buildURL('job', name, job, 'findRecord')}/periodic/force`;
if (namespace) {
url += `?namespace=${namespace}`;
}
return this.ajax(url, 'POST');
}
},
});

View file

@ -1,3 +1,15 @@
import AbstractJobPage from './abstract';
import { inject as service } from '@ember/service';
export default AbstractJobPage.extend();
export default AbstractJobPage.extend({
store: service(),
actions: {
forceLaunch() {
this.get('job')
.forcePeriodic()
.then(() => {
this.get('store').findAll('job');
});
},
},
});

View file

@ -139,6 +139,10 @@ export default Model.extend({
return this.store.adapterFor('job').fetchRawDefinition(this);
},
forcePeriodic() {
return this.store.adapterFor('job').forcePeriodic(this);
},
statusClass: computed('status', function() {
const classMap = {
pending: 'is-pending',

View file

@ -10,6 +10,7 @@
{{job.name}}
<span class="bumper-left tag {{job.statusClass}}" data-test-job-status>{{job.status}}</span>
<span class="tag is-hollow">periodic</span>
<button class="button is-primary" onclick={{action "forceLaunch"}}>Force Launch</button>
</h1>
<div class="boxed-section job-stats">