github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/jobs/run.js (about)

     1  import Route from '@ember/routing/route';
     2  import { inject as service } from '@ember/service';
     3  import classic from 'ember-classic-decorator';
     4  
     5  @classic
     6  export default class RunRoute extends Route {
     7    @service can;
     8    @service store;
     9    @service system;
    10  
    11    beforeModel(transition) {
    12      if (
    13        this.can.cannot('run job', null, {
    14          namespace: transition.to.queryParams.namespace,
    15        })
    16      ) {
    17        this.transitionTo('jobs');
    18      }
    19    }
    20  
    21    model() {
    22      // When jobs are created with a namespace attribute, it is verified against
    23      // available namespaces to prevent redirecting to a non-existent namespace.
    24      return this.store.findAll('namespace').then(() => {
    25        return this.store.createRecord('job');
    26      });
    27    }
    28  
    29    resetController(controller, isExiting) {
    30      if (isExiting) {
    31        controller.model.deleteRecord();
    32      }
    33    }
    34  }