open-nomad/ui/app/components/job-client-status-row.js
Phil Renaud 15872cc2d4
[ui] Disconnected Clients: "Unknown" allocations in the UI (#12544)
* Unknown status for allocations accounted for

* Canary string removed

* Test cleanup

* Generate unknown in mirage

* aacidentally oovervoowled

* Update ui/app/components/allocation-status-bar.js

Co-authored-by: Derek Strickland <1111455+DerekStrickland@users.noreply.github.com>

* Disconnected state on job status in client

* Renaming Disconnected to Unknown in the job-status-in-client

* Unknown accounted for on job rows filtering and testsfix

* Adding lostAllocs as a computed dependency

* Unknown client status within acceptance test

* Swatches updated and PR comments addressed

* Unknown and disconnected added to test fixtures

Co-authored-by: Derek Strickland <1111455+DerekStrickland@users.noreply.github.com>
2022-04-22 11:25:02 -04:00

94 lines
2.3 KiB
JavaScript

import EmberObject from '@ember/object';
import Component from '@glimmer/component';
export default class ClientRow extends Component {
// Attribute set in the template as @onClick.
onClick() {}
get row() {
return this.args.row.model;
}
get shouldDisplayAllocationSummary() {
return this.args.row.model.jobStatus !== 'notScheduled';
}
get allocationSummaryPlaceholder() {
switch (this.args.row.model.jobStatus) {
case 'notScheduled':
return 'Not Scheduled';
default:
return '';
}
}
get humanizedJobStatus() {
switch (this.args.row.model.jobStatus) {
case 'notScheduled':
return 'not scheduled';
default:
return this.args.row.model.jobStatus;
}
}
get jobStatusClass() {
switch (this.args.row.model.jobStatus) {
case 'notScheduled':
return 'not-scheduled';
default:
return this.args.row.model.jobStatus;
}
}
get allocationContainer() {
const statusSummary = {
queuedAllocs: 0,
completeAllocs: 0,
failedAllocs: 0,
runningAllocs: 0,
startingAllocs: 0,
lostAllocs: 0,
unknownAllocs: 0,
};
switch (this.args.row.model.jobStatus) {
case 'notSchedule':
break;
case 'queued':
statusSummary.queuedAllocs = this.args.row.model.allocations.length;
break;
case 'starting':
statusSummary.startingAllocs = this.args.row.model.allocations.length;
break;
default:
for (const alloc of this.args.row.model.allocations) {
switch (alloc.clientStatus) {
case 'running':
statusSummary.runningAllocs++;
break;
case 'lost':
statusSummary.lostAllocs++;
break;
case 'failed':
statusSummary.failedAllocs++;
break;
case 'complete':
statusSummary.completeAllocs++;
break;
case 'starting':
statusSummary.startingAllocs++;
break;
case 'unknown':
statusSummary.unknownAllocs++;
break;
}
}
}
const Allocations = EmberObject.extend({
...statusSummary,
});
return Allocations.create();
}
}