open-nomad/ui/app/routes/jobs.js

44 lines
1015 B
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
import { action } from '@ember/object';
import classic from 'ember-classic-decorator';
2017-09-19 14:47:10 +00:00
@classic
export default class JobsRoute extends Route.extend(WithForbiddenState) {
@service store;
@service system;
2017-09-19 14:47:10 +00:00
breadcrumbs = [
2018-06-27 18:29:04 +00:00
{
label: 'Jobs',
args: ['jobs.index'],
},
];
2018-06-27 18:29:04 +00:00
queryParams = {
jobNamespace: {
refreshModel: true,
},
};
beforeModel(transition) {
return this.get('system.namespaces').then(namespaces => {
2019-10-08 18:44:19 +00:00
const queryParam = transition.to.queryParams.namespace;
this.set('system.activeNamespace', queryParam || 'default');
return namespaces;
});
}
model() {
2019-10-08 18:44:19 +00:00
return this.store.findAll('job', { reload: true }).catch(notifyForbidden(this));
}
@action
refreshRoute() {
this.refresh();
}
}