2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2022-08-26 16:04:59 +00:00
|
|
|
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-service-status-bar')
|
|
|
|
export default class ServiceStatusBar extends DistributionBar {
|
|
|
|
layoutName = 'components/distribution-bar';
|
|
|
|
|
2022-09-07 14:23:39 +00:00
|
|
|
status = null;
|
2022-08-26 16:04:59 +00:00
|
|
|
|
|
|
|
'data-test-service-status-bar' = true;
|
|
|
|
|
2022-09-07 14:23:39 +00:00
|
|
|
@computed('status.{failure,pending,success}')
|
2022-08-26 16:04:59 +00:00
|
|
|
get data() {
|
2022-09-07 14:23:39 +00:00
|
|
|
if (!this.status) {
|
2022-08-26 16:04:59 +00:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2022-09-07 14:23:39 +00:00
|
|
|
const pending = this.status.pending || 0;
|
|
|
|
const failing = this.status.failure || 0;
|
|
|
|
const success = this.status.success || 0;
|
2022-08-26 16:04:59 +00:00
|
|
|
|
2022-10-04 20:59:50 +00:00
|
|
|
const [grey, red, green] = ['queued', 'failed', 'running'];
|
2022-08-26 16:04:59 +00:00
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: 'Pending',
|
|
|
|
value: pending,
|
|
|
|
className: grey,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Failing',
|
|
|
|
value: failing,
|
|
|
|
className: red,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Success',
|
|
|
|
value: success,
|
|
|
|
className: green,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|