From dd44596c36a30af89c1dd5a83e58295fa4fcd4fa Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Wed, 7 Sep 2022 15:35:58 -0400 Subject: [PATCH 1/5] Midway point on only showing alloc-specific checks --- ui/app/adapters/allocation.js | 5 +++++ ui/app/components/allocation-service-sidebar.hbs | 11 +++++++++-- ui/app/components/allocation-service-sidebar.js | 11 +++++++++++ ui/app/controllers/allocations/allocation/index.js | 5 +++-- ui/app/serializers/task-group.js | 1 + 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ui/app/adapters/allocation.js b/ui/app/adapters/allocation.js index 66ba70940..cbba94096 100644 --- a/ui/app/adapters/allocation.js +++ b/ui/app/adapters/allocation.js @@ -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; } } diff --git a/ui/app/components/allocation-service-sidebar.hbs b/ui/app/components/allocation-service-sidebar.hbs index ada404772..3fac66a0d 100644 --- a/ui/app/components/allocation-service-sidebar.hbs +++ b/ui/app/components/allocation-service-sidebar.hbs @@ -1,3 +1,5 @@ +{{log "TODO: test" @service.healthChecks.length}} + - {{#if @service.mostRecentChecks.length}} - + {{#if this.checks.length}} + Name @@ -103,6 +105,11 @@ {{row.model.Check}} + TODO: TEMP + {{format-ts + row.model.Timestamp + }} + diff --git a/ui/app/components/allocation-service-sidebar.js b/ui/app/components/allocation-service-sidebar.js index a66d3ff62..4e9b2ff7c 100644 --- a/ui/app/components/allocation-service-sidebar.js +++ b/ui/app/components/allocation-service-sidebar.js @@ -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'); + } } diff --git a/ui/app/controllers/allocations/allocation/index.js b/ui/app/controllers/allocations/allocation/index.js index d3e4d5a9e..d28b77dde 100644 --- a/ui/app/controllers/allocations/allocation/index.js +++ b/ui/app/controllers/allocations/allocation/index.js @@ -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)]; } }); } diff --git a/ui/app/serializers/task-group.js b/ui/app/serializers/task-group.js index b98b5cfef..b0d363eb3 100644 --- a/ui/app/serializers/task-group.js +++ b/ui/app/serializers/task-group.js @@ -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; }); From f81faa9c4834c38a09cfda400767028c393e43bf Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 8 Sep 2022 11:31:38 -0400 Subject: [PATCH 2/5] Move uniquing to the sidebar itself --- ui/app/components/allocation-service-sidebar.hbs | 2 -- ui/app/components/allocation-service-sidebar.js | 10 +++++++--- ui/app/controllers/allocations/allocation/index.js | 11 +---------- ui/app/serializers/service-fragment.js | 4 ---- ui/app/serializers/task-group.js | 1 - 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/ui/app/components/allocation-service-sidebar.hbs b/ui/app/components/allocation-service-sidebar.hbs index 3fac66a0d..03fe47b58 100644 --- a/ui/app/components/allocation-service-sidebar.hbs +++ b/ui/app/components/allocation-service-sidebar.hbs @@ -1,5 +1,3 @@ -{{log "TODO: test" @service.healthChecks.length}} -