github.com/manicqin/nomad@v0.9.5/ui/app/routes/jobs/job.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Route from '@ember/routing/route';
     3  import RSVP from 'rsvp';
     4  import notifyError from 'nomad-ui/utils/notify-error';
     5  import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils';
     6  
     7  export default Route.extend({
     8    store: service(),
     9    token: service(),
    10  
    11    breadcrumbs: jobCrumbs,
    12  
    13    serialize(model) {
    14      return { job_name: model.get('plainId') };
    15    },
    16  
    17    model(params, transition) {
    18      const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id');
    19      const name = params.job_name;
    20      const fullId = JSON.stringify([name, namespace || 'default']);
    21      return this.store
    22        .findRecord('job', fullId, { reload: true })
    23        .then(job => {
    24          return RSVP.all([job.get('allocations'), job.get('evaluations')]).then(() => job);
    25        })
    26        .catch(notifyError(this));
    27    },
    28  });