2022-09-07 14:23:39 +00:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
|
|
|
|
export default class AllocationServiceSidebarComponent extends Component {
|
|
|
|
@service store;
|
2022-09-12 14:00:30 +00:00
|
|
|
@service system;
|
2022-09-07 14:23:39 +00:00
|
|
|
|
|
|
|
get isSideBarOpen() {
|
|
|
|
return !!this.args.service;
|
|
|
|
}
|
|
|
|
keyCommands = [
|
|
|
|
{
|
|
|
|
label: 'Close Evaluations Sidebar',
|
|
|
|
pattern: ['Escape'],
|
|
|
|
action: () => this.args.fns.closeSidebar(),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
get service() {
|
|
|
|
return this.store.query('service-fragment', { refID: this.args.serviceID });
|
|
|
|
}
|
|
|
|
|
|
|
|
get address() {
|
|
|
|
const port = this.args.allocation?.allocatedResources?.ports?.findBy(
|
|
|
|
'label',
|
|
|
|
this.args.service.portLabel
|
|
|
|
);
|
|
|
|
if (port) {
|
|
|
|
return `${port.hostIp}:${port.value}`;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get aggregateStatus() {
|
2022-09-08 16:03:08 +00:00
|
|
|
return this.checks.any((check) => check.Status === 'failure')
|
2022-09-07 14:23:39 +00:00
|
|
|
? 'Unhealthy'
|
|
|
|
: 'Healthy';
|
|
|
|
}
|
2022-09-07 19:35:58 +00:00
|
|
|
|
2022-09-12 14:00:30 +00:00
|
|
|
get consulRedirectLink() {
|
|
|
|
return this.system.agent.get('config')?.UI?.Consul?.BaseUIURL;
|
|
|
|
}
|
|
|
|
|
2022-09-07 19:35:58 +00:00
|
|
|
get checks() {
|
2022-09-08 20:03:56 +00:00
|
|
|
if (!this.args.service || !this.args.allocation) return [];
|
2022-09-07 19:35:58 +00:00
|
|
|
let allocID = this.args.allocation.id;
|
2022-09-08 15:31:38 +00:00
|
|
|
// Our UI checks run every 2 seconds; but a check itself may only update every, say, minute.
|
|
|
|
// Therefore, we'll have duplicate checks in a service's healthChecks array.
|
|
|
|
// Only get the most recent check for each check.
|
2022-09-08 16:03:08 +00:00
|
|
|
return (this.args.service.healthChecks || [])
|
2022-09-07 19:35:58 +00:00
|
|
|
.filterBy('Alloc', allocID)
|
|
|
|
.sortBy('Timestamp')
|
2022-09-08 15:31:38 +00:00
|
|
|
.reverse()
|
|
|
|
.uniqBy('Check')
|
|
|
|
.sortBy('Check');
|
2022-09-07 19:35:58 +00:00
|
|
|
}
|
2022-09-07 14:23:39 +00:00
|
|
|
}
|