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'; import classic from 'ember-classic-decorator'; @classic export default class JobRoute extends Route { @service can; @service store; @service token; serialize(model) { return { job_name: model.get('plainId') }; } model(params, transition) { const namespace = transition.to.queryParams.namespace || 'default'; const name = params.job_name; const fullId = JSON.stringify([name, namespace]); console.log( this.store .findRecord('job', fullId, { reload: true }) .then(job => console.log('model\n\n', job)) ); return this.store .findRecord('job', fullId, { reload: true }) .then(job => { const relatedModelsQueries = [ job.get('allocations'), job.get('evaluations'), this.store.query('job', { namespace }), this.store.findAll('namespace'), ]; if (this.can.can('accept recommendation')) { relatedModelsQueries.push(job.get('recommendationSummaries')); } return RSVP.all(relatedModelsQueries).then(() => job); }) .catch(notifyError(this)); } }