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