open-nomad/ui/app/controllers/allocations/allocation.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
export default class AllocationsAllocationController extends Controller {
@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';
}
// Allocation breadcrumbs extend from job / task group breadcrumbs
// even though the route structure does not.
get breadcrumbs() {
const { allocation, job, jobNamespace } = this;
const jobQueryParams = qpBuilder({
jobNamespace,
});
return [
{ label: 'Jobs', args: ['jobs.index', jobQueryParams] },
{ type: 'job', job: job },
{
title: 'Task Group',
label: allocation.taskGroupName,
2022-01-20 15:39:02 +00:00
args: [
'jobs.job.task-group',
job.plainId,
allocation.taskGroupName,
jobQueryParams,
],
},
{
title: 'Allocation',
label: allocation.shortId,
args: ['allocations.allocation', allocation],
},
];
}
}