github.com/hernad/nomad@v1.6.112/ui/app/controllers/allocations/allocation.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import Controller from '@ember/controller';
     7  import { inject as service } from '@ember/service';
     8  import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
     9  
    10  export default class AllocationsAllocationController extends Controller {
    11    @service store;
    12  
    13    get allocation() {
    14      return this.model;
    15    }
    16  
    17    get job() {
    18      const allocation = this.model;
    19      const jobId = allocation.belongsTo('job').id();
    20      const job = this.store.peekRecord('job', jobId);
    21      return job;
    22    }
    23  
    24    get jobNamespace() {
    25      const jobNamespaceId = this.job.belongsTo('namespace').id();
    26  
    27      return jobNamespaceId || 'default';
    28    }
    29    // Allocation breadcrumbs extend from job / task group breadcrumbs
    30    // even though the route structure does not.
    31    get breadcrumbs() {
    32      const { allocation, job, jobNamespace } = this;
    33      const jobQueryParams = qpBuilder({
    34        jobNamespace,
    35      });
    36  
    37      return [
    38        { label: 'Jobs', args: ['jobs.index', jobQueryParams] },
    39        { type: 'job', job: job },
    40        {
    41          title: 'Task Group',
    42          label: allocation.taskGroupName,
    43          args: [
    44            'jobs.job.task-group',
    45            job.idWithNamespace,
    46            allocation.taskGroupName,
    47          ],
    48        },
    49        {
    50          title: 'Allocation',
    51          label: allocation.shortId,
    52          args: ['allocations.allocation', allocation],
    53        },
    54      ];
    55    }
    56  }