open-nomad/ui/app/components/allocation-status-bar.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

93 lines
2.4 KiB
JavaScript

import { computed } from '@ember/object';
import DistributionBar from './distribution-bar';
import { attributeBindings } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
@classic
@attributeBindings('data-test-allocation-status-bar')
export default class AllocationStatusBar extends DistributionBar {
layoutName = 'components/distribution-bar';
allocationContainer = null;
job = null;
'data-test-allocation-status-bar' = true;
generateLegendLink(job, status) {
if (!job || status === 'queued') return null;
return {
queryParams: {
status: JSON.stringify([status]),
namespace: job.belongsTo('namespace').id(),
},
};
}
@computed(
'allocationContainer.{queuedAllocs,completeAllocs,failedAllocs,runningAllocs,startingAllocs,lostAllocs,unknownAllocs}',
'job.namespace'
)
get data() {
if (!this.allocationContainer) {
return [];
}
const allocs = this.allocationContainer.getProperties(
'queuedAllocs',
'completeAllocs',
'failedAllocs',
'runningAllocs',
'startingAllocs',
'lostAllocs',
'unknownAllocs'
);
return [
{
label: 'Queued',
value: allocs.queuedAllocs,
className: 'queued',
legendLink: this.generateLegendLink(this.job, 'queued'),
},
{
label: 'Starting',
value: allocs.startingAllocs,
className: 'starting',
layers: 2,
legendLink: this.generateLegendLink(this.job, 'starting'),
},
{
label: 'Running',
value: allocs.runningAllocs,
className: 'running',
legendLink: this.generateLegendLink(this.job, 'running'),
},
{
label: 'Complete',
value: allocs.completeAllocs,
className: 'complete',
legendLink: this.generateLegendLink(this.job, 'complete'),
},
{
label: 'Unknown',
value: allocs.unknownAllocs,
className: 'unknown',
legendLink: this.generateLegendLink(this.job, 'unknown'),
help: 'Allocation is unknown since its node is disconnected.',
},
{
label: 'Failed',
value: allocs.failedAllocs,
className: 'failed',
legendLink: this.generateLegendLink(this.job, 'failed'),
},
{
label: 'Lost',
value: allocs.lostAllocs,
className: 'lost',
legendLink: this.generateLegendLink(this.job, 'lost'),
},
];
}
}