open-nomad/ui/app/routes/jobs/job.js
Michael Lange e8593ec1bb
ui: Update namespaces design (#10444)
This rethinks namespaces as a filter on list pages rather than a global setting.

The biggest net-new feature here is being able to select All (*) to list all jobs
or CSI volumes across namespaces.
2021-04-29 15:00:59 -05:00

44 lines
1.2 KiB
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';
import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils';
import classic from 'ember-classic-decorator';
@classic
export default class JobRoute extends Route {
@service can;
@service store;
@service token;
breadcrumbs = jobCrumbs;
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]);
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));
}
}