open-nomad/ui/app/routes/jobs/job.js
Michael Lange 8b0ad9f2fb Move job watchers to job.index
They are only for the overview page, not the whole hierarchy
2018-03-05 09:32:04 -08:00

26 lines
791 B
JavaScript

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
import notifyError from 'nomad-ui/utils/notify-error';
export default Route.extend({
store: service(),
token: service(),
serialize(model) {
return { job_name: model.get('plainId') };
},
model(params, transition) {
const namespace = transition.queryParams.namespace || this.get('system.activeNamespace.id');
const name = params.job_name;
const fullId = JSON.stringify([name, namespace || 'default']);
return this.get('store')
.findRecord('job', fullId, { reload: true })
.then(job => {
return RSVP.all([job.get('allocations'), job.get('evaluations')]).then(() => job);
})
.catch(notifyError(this));
},
});