mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
Simplify the data control flow around job.plan()
This commit is contained in:
@@ -77,15 +77,19 @@ export default Watchable.extend({
|
||||
},
|
||||
|
||||
plan(job) {
|
||||
const url = addToPath(this.urlForFindRecord(job.get('id'), 'job'), '/plan');
|
||||
const jobId = job.get('id');
|
||||
const store = this.get('store');
|
||||
const url = addToPath(this.urlForFindRecord(jobId, 'job'), '/plan');
|
||||
|
||||
return this.ajax(url, 'POST', {
|
||||
data: {
|
||||
Job: job.get('_newDefinitionJSON'),
|
||||
Diff: true,
|
||||
},
|
||||
}).then(json => {
|
||||
json.ID = job.get('id');
|
||||
this.get('store').pushPayload('job-plan', { jobPlans: [json] });
|
||||
json.ID = jobId;
|
||||
store.pushPayload('job-plan', { jobPlans: [json] });
|
||||
return store.peekRecord('job-plan', jobId);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -55,8 +55,7 @@ export default Component.extend({
|
||||
}
|
||||
|
||||
try {
|
||||
yield this.get('job').plan();
|
||||
const plan = this.get('store').peekRecord('job-plan', this.get('job.id'));
|
||||
const plan = yield this.get('job').plan();
|
||||
this.set('planOutput', plan);
|
||||
} catch (err) {
|
||||
const error = messageFromAdapterError(err) || 'Could not plan job';
|
||||
|
||||
Reference in New Issue
Block a user