github.com/hernad/nomad@v1.6.112/ui/app/components/allocation-status-bar.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { computed } from '@ember/object';
     7  import DistributionBar from './distribution-bar';
     8  import { attributeBindings } from '@ember-decorators/component';
     9  import classic from 'ember-classic-decorator';
    10  
    11  @classic
    12  @attributeBindings('data-test-allocation-status-bar')
    13  export default class AllocationStatusBar extends DistributionBar {
    14    layoutName = 'components/distribution-bar';
    15  
    16    allocationContainer = null;
    17    job = null;
    18  
    19    'data-test-allocation-status-bar' = true;
    20  
    21    generateLegendLink(job, status) {
    22      if (!job || status === 'queued') return null;
    23  
    24      return {
    25        queryParams: {
    26          status: JSON.stringify([status]),
    27          namespace: job.belongsTo('namespace').id(),
    28        },
    29      };
    30    }
    31  
    32    @computed(
    33      'allocationContainer.{queuedAllocs,completeAllocs,failedAllocs,runningAllocs,startingAllocs,lostAllocs,unknownAllocs}',
    34      'job.namespace'
    35    )
    36    get data() {
    37      if (!this.allocationContainer) {
    38        return [];
    39      }
    40  
    41      const allocs = this.allocationContainer.getProperties(
    42        'queuedAllocs',
    43        'completeAllocs',
    44        'failedAllocs',
    45        'runningAllocs',
    46        'startingAllocs',
    47        'lostAllocs',
    48        'unknownAllocs'
    49      );
    50      return [
    51        {
    52          label: 'Queued',
    53          value: allocs.queuedAllocs,
    54          className: 'queued',
    55          legendLink: this.generateLegendLink(this.job, 'queued'),
    56        },
    57        {
    58          label: 'Starting',
    59          value: allocs.startingAllocs,
    60          className: 'starting',
    61          layers: 2,
    62          legendLink: this.generateLegendLink(this.job, 'starting'),
    63        },
    64        {
    65          label: 'Running',
    66          value: allocs.runningAllocs,
    67          className: 'running',
    68          legendLink: this.generateLegendLink(this.job, 'running'),
    69        },
    70        {
    71          label: 'Complete',
    72          value: allocs.completeAllocs,
    73          className: 'complete',
    74          legendLink: this.generateLegendLink(this.job, 'complete'),
    75        },
    76        {
    77          label: 'Unknown',
    78          value: allocs.unknownAllocs,
    79          className: 'unknown',
    80          legendLink: this.generateLegendLink(this.job, 'unknown'),
    81          help: 'Allocation is unknown since its node is disconnected.',
    82        },
    83        {
    84          label: 'Failed',
    85          value: allocs.failedAllocs,
    86          className: 'failed',
    87          legendLink: this.generateLegendLink(this.job, 'failed'),
    88        },
    89        {
    90          label: 'Lost',
    91          value: allocs.lostAllocs,
    92          className: 'lost',
    93          legendLink: this.generateLegendLink(this.job, 'lost'),
    94        },
    95      ];
    96    }
    97  }