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