From 0eb250d3a053bd322a9a417368e2e4daa53c0290 Mon Sep 17 00:00:00 2001 From: wenincode Date: Thu, 13 Oct 2022 15:47:47 -0600 Subject: [PATCH] Filter healthchecks for synthetic-nodes --- .../dc/services/instance/healthchecks.js | 16 ++ .../dc/services/instance/healthchecks.hbs | 158 +++++++++--------- 2 files changed, 98 insertions(+), 76 deletions(-) create mode 100644 ui/packages/consul-ui/app/controllers/dc/services/instance/healthchecks.js diff --git a/ui/packages/consul-ui/app/controllers/dc/services/instance/healthchecks.js b/ui/packages/consul-ui/app/controllers/dc/services/instance/healthchecks.js new file mode 100644 index 0000000000..8d6270e823 --- /dev/null +++ b/ui/packages/consul-ui/app/controllers/dc/services/instance/healthchecks.js @@ -0,0 +1,16 @@ +import Controller from '@ember/controller'; +import { action } from '@ember/object'; + +export default class HealthChecksController extends Controller { + @action + syntheticNodeSearchPropertyFilter(item, searchProperty) { + return !(item.Node.Meta?.['synthetic-node'] && searchProperty === 'Node'); + } + + @action + syntheticNodeHealthCheckFilter(item, healthcheck, index, list) { + console.log('List to be filtered: ', list); + console.log(healthcheck.Kind); + return !(item.Node.Meta?.['synthetic-node'] && healthcheck?.Kind === 'node'); + } +} diff --git a/ui/packages/consul-ui/app/templates/dc/services/instance/healthchecks.hbs b/ui/packages/consul-ui/app/templates/dc/services/instance/healthchecks.hbs index 454e92f1a6..80f621db55 100644 --- a/ui/packages/consul-ui/app/templates/dc/services/instance/healthchecks.hbs +++ b/ui/packages/consul-ui/app/templates/dc/services/instance/healthchecks.hbs @@ -2,92 +2,98 @@ @name={{routeName}} as |route|> {{#let + (filter (action 'syntheticNodeSearchPropertyFilter' route.model.item) searchProperties) as |filteredSearchProperties|}} + {{#let - (hash - value=(or sortBy "Status:asc") - change=(action (mut sortBy) value="target.selected") - ) + (hash + value=(or sortBy "Status:asc") + change=(action (mut sortBy) value="target.selected") + ) - (hash - status=(hash - value=(if status (split status ',') undefined) - change=(action (mut status) value="target.selectedItems") - ) - check=(hash - value=(if check (split check ',') undefined) - change=(action (mut check) value="target.selectedItems") - ) - searchproperty=(hash - value=(if (not-eq searchproperty undefined) - (split searchproperty ',') - searchProperties + (hash + status=(hash + value=(if status (split status ',') undefined) + change=(action (mut status) value="target.selectedItems") + ) + check=(hash + value=(if check (split check ',') undefined) + change=(action (mut check) value="target.selectedItems") + ) + searchproperty=(hash + value=(if (not-eq searchproperty undefined) + (split searchproperty ',') + filteredSearchProperties + ) + change=(action (mut searchproperty) value="target.selectedItems") + default=filteredSearchProperties ) - change=(action (mut searchproperty) value="target.selectedItems") - default=searchProperties ) - ) - (merge-checks (array route.model.item.Checks route.model.proxy.Checks) route.model.proxy.ServiceProxy.Expose.Checks) + (filter + (action 'syntheticNodeHealthCheckFilter' route.model.item) + (merge-checks (array route.model.item.Checks route.model.proxy.Checks) route.model.proxy.ServiceProxy.Expose.Checks) + ) - as |sort filters items|}} -
+ as |sort filters items|}} +
- {{#if (gt items.length 0) }} - - + - {{/if}} - - {{#let (find-by "Type" "serf" items) as |serf|}} - {{#if (and serf (eq serf.Status "critical"))}} - - -

- {{t "routes.dc.services.instance.healthchecks.critical-serf-notice.header"}} -

-
- - {{t - "routes.dc.services.instance.healthchecks.critical-serf-notice.body" - htmlSafe=true - }} - -
- {{/if}} - {{/let}} - - - - - - - - {{t "routes.dc.services.instance.healthchecks.empty" - items=items.length - htmlSafe=true - }} - - - - + {{/if}} -
+ {{#let (find-by "Type" "serf" items) as |serf|}} + {{#if (and serf (eq serf.Status "critical"))}} + + +

+ {{t "routes.dc.services.instance.healthchecks.critical-serf-notice.header"}} +

+
+ + {{t + "routes.dc.services.instance.healthchecks.critical-serf-notice.body" + htmlSafe=true + }} + +
+ {{/if}} + {{/let}} + + + + + + + + {{t "routes.dc.services.instance.healthchecks.empty" + items=items.length + htmlSafe=true + }} + + + + + +
+ {{/let}} {{/let}}