open-nomad/ui/app/components/allocation-service-sidebar.js
Phil Renaud eca0e7bf56
[ui] task logs in sidebar (#14612)
* button styles

* Further styles including global toggle adjustment

* sidebar funcs and header

* Functioning task logs in high-level sidebars

* same-lineify the show tasks toggle

* Changelog

* Full-height sidebar calc in css, plz drop soon container queries

* Active status and query params for allocations page

* Reactive shouldShowLogs getter and added to client and task group pages

* Higher order func passing, thanks @DingoEatingFuzz

* Non-service job types get allocation params passed

* Keyframe animation for task log sidebar

* Acceptance test

* A few more sub-row tests

* Lintfix
2022-09-22 10:58:52 -04:00

59 lines
1.5 KiB
JavaScript

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
export default class AllocationServiceSidebarComponent extends Component {
@service store;
@service system;
get isSideBarOpen() {
return !!this.args.service;
}
keyCommands = [
{
label: 'Close Service 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() {
return this.checks.any((check) => check.Status === 'failure')
? 'Unhealthy'
: 'Healthy';
}
get consulRedirectLink() {
return this.system.agent.get('config')?.UI?.Consul?.BaseUIURL;
}
get checks() {
if (!this.args.service || !this.args.allocation) return [];
let allocID = this.args.allocation.id;
// 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.
return (this.args.service.healthChecks || [])
.filterBy('Alloc', allocID)
.sortBy('Timestamp')
.reverse()
.uniqBy('Check')
.sortBy('Check');
}
}