github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/job-client-status-row.js (about)

     1  import EmberObject from '@ember/object';
     2  import Component from '@glimmer/component';
     3  
     4  export default class ClientRow extends Component {
     5    // Attribute set in the template as @onClick.
     6    onClick() {}
     7  
     8    get row() {
     9      return this.args.row.model;
    10    }
    11  
    12    get shouldDisplayAllocationSummary() {
    13      return this.args.row.model.jobStatus !== 'notScheduled';
    14    }
    15  
    16    get allocationSummaryPlaceholder() {
    17      switch (this.args.row.model.jobStatus) {
    18        case 'notScheduled':
    19          return 'Not Scheduled';
    20        default:
    21          return '';
    22      }
    23    }
    24  
    25    get humanizedJobStatus() {
    26      switch (this.args.row.model.jobStatus) {
    27        case 'notScheduled':
    28          return 'not scheduled';
    29        default:
    30          return this.args.row.model.jobStatus;
    31      }
    32    }
    33  
    34    get jobStatusClass() {
    35      switch (this.args.row.model.jobStatus) {
    36        case 'notScheduled':
    37          return 'not-scheduled';
    38        default:
    39          return this.args.row.model.jobStatus;
    40      }
    41    }
    42  
    43    get allocationContainer() {
    44      const statusSummary = {
    45        queuedAllocs: 0,
    46        completeAllocs: 0,
    47        failedAllocs: 0,
    48        runningAllocs: 0,
    49        startingAllocs: 0,
    50        lostAllocs: 0,
    51        unknownAllocs: 0,
    52      };
    53  
    54      switch (this.args.row.model.jobStatus) {
    55        case 'notSchedule':
    56          break;
    57        case 'queued':
    58          statusSummary.queuedAllocs = this.args.row.model.allocations.length;
    59          break;
    60        case 'starting':
    61          statusSummary.startingAllocs = this.args.row.model.allocations.length;
    62          break;
    63        default:
    64          for (const alloc of this.args.row.model.allocations) {
    65            switch (alloc.clientStatus) {
    66              case 'running':
    67                statusSummary.runningAllocs++;
    68                break;
    69              case 'lost':
    70                statusSummary.lostAllocs++;
    71                break;
    72              case 'failed':
    73                statusSummary.failedAllocs++;
    74                break;
    75              case 'complete':
    76                statusSummary.completeAllocs++;
    77                break;
    78              case 'starting':
    79                statusSummary.startingAllocs++;
    80                break;
    81              case 'unknown':
    82                statusSummary.unknownAllocs++;
    83                break;
    84            }
    85          }
    86      }
    87  
    88      const Allocations = EmberObject.extend({
    89        ...statusSummary,
    90      });
    91      return Allocations.create();
    92    }
    93  }