github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/routes/allocations/allocation/task.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Route from '@ember/routing/route';
     3  import EmberError from '@ember/error';
     4  
     5  export default Route.extend({
     6    store: service(),
     7  
     8    breadcrumbs(model) {
     9      if (!model) return [];
    10      return [
    11        {
    12          label: model.get('name'),
    13          args: ['allocations.allocation.task', model.get('allocation'), model],
    14        },
    15      ];
    16    },
    17  
    18    model({ name }) {
    19      const allocation = this.modelFor('allocations.allocation');
    20      if (allocation) {
    21        const task = allocation.get('states').findBy('name', name);
    22  
    23        if (task) {
    24          return task;
    25        }
    26  
    27        const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`);
    28        err.code = '404';
    29        this.controllerFor('application').set('error', err);
    30      }
    31    },
    32  });