2021-11-30 20:10:01 +00:00
|
|
|
import Controller from '@ember/controller';
|
2021-12-13 15:29:25 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2021-11-30 20:10:01 +00:00
|
|
|
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
|
|
|
|
|
|
|
|
export default class AllocationsAllocationController extends Controller {
|
2021-12-13 15:29:25 +00:00
|
|
|
@service store;
|
|
|
|
|
|
|
|
get allocation() {
|
|
|
|
return this.model;
|
|
|
|
}
|
|
|
|
|
|
|
|
get job() {
|
|
|
|
const allocation = this.model;
|
|
|
|
const jobId = allocation.belongsTo('job').id();
|
|
|
|
const job = this.store.peekRecord('job', jobId);
|
|
|
|
return job;
|
|
|
|
}
|
|
|
|
|
|
|
|
get jobNamespace() {
|
|
|
|
const jobNamespaceId = this.job.belongsTo('namespace').id();
|
|
|
|
|
|
|
|
return jobNamespaceId || 'default';
|
|
|
|
}
|
2021-11-30 20:10:01 +00:00
|
|
|
// Allocation breadcrumbs extend from job / task group breadcrumbs
|
|
|
|
// even though the route structure does not.
|
|
|
|
get breadcrumbs() {
|
2021-12-13 15:29:25 +00:00
|
|
|
const { allocation, job, jobNamespace } = this;
|
2021-11-30 20:10:01 +00:00
|
|
|
const jobQueryParams = qpBuilder({
|
2021-12-13 15:29:25 +00:00
|
|
|
jobNamespace,
|
2021-11-30 20:10:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return [
|
|
|
|
{ label: 'Jobs', args: ['jobs.index', jobQueryParams] },
|
2021-12-13 15:29:25 +00:00
|
|
|
{ type: 'job', job: job },
|
2021-11-30 20:10:01 +00:00
|
|
|
{
|
2021-12-16 14:40:43 +00:00
|
|
|
title: 'Task Group',
|
2021-12-13 15:29:25 +00:00
|
|
|
label: allocation.taskGroupName,
|
2022-01-20 15:39:02 +00:00
|
|
|
args: [
|
|
|
|
'jobs.job.task-group',
|
|
|
|
job.plainId,
|
|
|
|
allocation.taskGroupName,
|
|
|
|
jobQueryParams,
|
|
|
|
],
|
2021-11-30 20:10:01 +00:00
|
|
|
},
|
|
|
|
{
|
2021-12-16 14:40:43 +00:00
|
|
|
title: 'Allocation',
|
2021-12-13 15:29:25 +00:00
|
|
|
label: allocation.shortId,
|
|
|
|
args: ['allocations.allocation', allocation],
|
2021-11-30 20:10:01 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|