Midway point on only showing alloc-specific checks

This commit is contained in:
Phil Renaud
2022-09-07 15:35:58 -04:00
parent 0029de8a5f
commit dd44596c36
5 changed files with 29 additions and 4 deletions

View File

@@ -41,6 +41,11 @@ export default class AllocationAdapter extends Watchable {
`/v1/client/allocation/${model.id}/checks`
);
const data = await res.json();
// Append allocation ID to each check
Object.values(data).forEach((check) => {
check.Alloc = model.id;
check.Timestamp = check.Timestamp * 1000; // Convert to milliseconds
});
return data;
}
}

View File

@@ -1,3 +1,5 @@
{{log "TODO: test" @service.healthChecks.length}}
<div
class="sidebar has-subnav service-sidebar {{if this.isSideBarOpen "open"}}"
{{on-click-outside
@@ -86,8 +88,8 @@
</div>
</div>
</div>
{{#if @service.mostRecentChecks.length}}
<ListTable class="health-checks" @source={{@service.mostRecentChecks}} as |t|>
{{#if this.checks.length}}
<ListTable class="health-checks" @source={{this.checks}} as |t|>
<t.head>
<th>
Name
@@ -103,6 +105,11 @@
<tr data-service-health={{row.model.Status}}>
<td class="name">
<span title={{row.model.Check}}>{{row.model.Check}}</span>
TODO: TEMP
{{format-ts
row.model.Timestamp
}}
</td>
<td class="status">
<span>

View File

@@ -38,4 +38,15 @@ export default class AllocationServiceSidebarComponent extends Component {
? 'Unhealthy'
: 'Healthy';
}
get checks() {
if (!this.args.service || !this.args.allocation) return;
console.log('getting checks and', this.args.service);
let allocID = this.args.allocation.id;
return this.args.service.healthChecks
.filterBy('Alloc', allocID)
.sortBy('Timestamp')
.reverse();
// .uniqBy('Check');
}
}

View File

@@ -88,11 +88,12 @@ export default class IndexController extends Controller.extend(Sortable) {
if (
!service.healthChecks.find(
(sc) =>
sc.Check === check.Check && sc.Timestamp === check.Timestamp
sc.Check === check.Check &&
sc.Timestamp === check.Timestamp &&
this.model.id === check.Alloc
)
) {
service.healthChecks.pushObject(check);
service.healthChecks = [...service.healthChecks.slice(-10)];
}
});
}

View File

@@ -9,6 +9,7 @@ export default class TaskGroup extends ApplicationSerializer {
normalize(typeHash, hash) {
if (hash.Services) {
console.log('yeah group has services, but what about allocs', hash);
hash.Services.forEach((service) => {
service.GroupName = hash.Name;
});