2017-12-15 21:39:18 +00:00
|
|
|
import Route from '@ember/routing/route';
|
2018-03-01 00:27:15 +00:00
|
|
|
import { collect } from '@ember/object/computed';
|
2018-02-28 19:48:06 +00:00
|
|
|
import { watchRecord } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2018-03-13 21:58:22 +00:00
|
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
2018-06-27 19:48:26 +00:00
|
|
|
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
|
|
|
|
import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils';
|
2017-09-28 17:59:59 +00:00
|
|
|
|
2018-03-13 21:58:22 +00:00
|
|
|
export default Route.extend(WithWatchers, {
|
2018-03-06 22:27:01 +00:00
|
|
|
startWatchers(controller, model) {
|
2018-02-28 19:48:06 +00:00
|
|
|
controller.set('watcher', this.get('watch').perform(model));
|
|
|
|
},
|
|
|
|
|
2018-06-27 19:48:26 +00:00
|
|
|
// Allocation breadcrumbs extend from job / task group breadcrumbs
|
|
|
|
// even though the route structure does not.
|
|
|
|
breadcrumbs(model) {
|
|
|
|
return [
|
2018-06-27 20:40:44 +00:00
|
|
|
{ label: 'Jobs', args: ['jobs.index'] },
|
2018-06-27 19:48:26 +00:00
|
|
|
...jobCrumbs(model.get('job')),
|
|
|
|
{
|
|
|
|
label: model.get('taskGroupName'),
|
|
|
|
args: [
|
|
|
|
'jobs.job.task-group',
|
|
|
|
model.get('job'),
|
|
|
|
model.get('taskGroupName'),
|
|
|
|
qpBuilder({
|
|
|
|
jobNamespace: model.get('namespace.name') || 'default',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: model.get('shortId'),
|
|
|
|
args: ['allocations.allocation', model],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
|
2018-03-13 21:58:22 +00:00
|
|
|
model() {
|
|
|
|
// Preload the job for the allocation since it's required for the breadcrumb trail
|
|
|
|
return this._super(...arguments)
|
|
|
|
.then(allocation => allocation.get('job').then(() => allocation))
|
|
|
|
.catch(notifyError(this));
|
|
|
|
},
|
|
|
|
|
2018-02-28 19:48:06 +00:00
|
|
|
watch: watchRecord('allocation'),
|
2018-03-01 00:27:15 +00:00
|
|
|
|
|
|
|
watchers: collect('watch'),
|
2018-02-28 19:48:06 +00:00
|
|
|
});
|