2017-12-15 21:39:18 +00:00
|
|
|
import Route from '@ember/routing/route';
|
2018-02-28 19:31:48 +00:00
|
|
|
import { collect } from '@ember/object/computed';
|
|
|
|
import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2018-06-27 19:17:23 +00:00
|
|
|
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2018-03-01 00:27:15 +00:00
|
|
|
export default Route.extend(WithWatchers, {
|
2018-06-27 19:17:23 +00:00
|
|
|
breadcrumbs(model) {
|
|
|
|
if (!model) return [];
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: model.get('name'),
|
|
|
|
args: [
|
|
|
|
'jobs.job.task-group',
|
|
|
|
model.get('name'),
|
|
|
|
qpBuilder({ jobNamespace: model.get('job.namespace.name') || 'default' }),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
model({ name }) {
|
|
|
|
// If the job is a partial (from the list request) it won't have task
|
|
|
|
// groups. Reload the job to ensure task groups are present.
|
|
|
|
return this.modelFor('jobs.job')
|
|
|
|
.reload()
|
|
|
|
.then(job => {
|
|
|
|
return job
|
|
|
|
.hasMany('allocations')
|
|
|
|
.reload()
|
|
|
|
.then(() => {
|
|
|
|
return job.get('taskGroups').findBy('name', name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2018-02-28 19:31:48 +00:00
|
|
|
|
2018-03-06 22:27:01 +00:00
|
|
|
startWatchers(controller, model) {
|
2018-02-28 19:31:48 +00:00
|
|
|
const job = model.get('job');
|
|
|
|
controller.set('watchers', {
|
|
|
|
job: this.get('watchJob').perform(job),
|
2018-03-28 22:12:27 +00:00
|
|
|
summary: this.get('watchSummary').perform(job.get('summary')),
|
2018-02-28 19:31:48 +00:00
|
|
|
allocations: this.get('watchAllocations').perform(job),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
watchJob: watchRecord('job'),
|
2018-03-28 22:12:27 +00:00
|
|
|
watchSummary: watchRecord('job-summary'),
|
2018-02-28 19:31:48 +00:00
|
|
|
watchAllocations: watchRelationship('allocations'),
|
|
|
|
|
2018-03-01 00:27:15 +00:00
|
|
|
watchers: collect('watchJob', 'watchSummary', 'watchAllocations'),
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|