diff --git a/ui/app/components/chart-primitives/h-annotations.hbs b/ui/app/components/chart-primitives/h-annotations.hbs index feefe542b..78999e2b4 100644 --- a/ui/app/components/chart-primitives/h-annotations.hbs +++ b/ui/app/components/chart-primitives/h-annotations.hbs @@ -4,10 +4,7 @@ diff --git a/ui/app/components/chart-primitives/h-annotations.js b/ui/app/components/chart-primitives/h-annotations.js index 293cb667e..e189fc23c 100644 --- a/ui/app/components/chart-primitives/h-annotations.js +++ b/ui/app/components/chart-primitives/h-annotations.js @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { htmlSafe } from '@ember/template'; -import { action } from '@ember/object'; +import { action, get } from '@ember/object'; import styleString from 'nomad-ui/utils/properties/glimmer-style-string'; export default class ChartPrimitiveVAnnotations extends Component { @@ -29,10 +29,19 @@ export default class ChartPrimitiveVAnnotations extends Component { style: htmlSafe(`transform:translate(${x}px,${y}px)`), label: annotation[labelProp], a11yLabel: `${annotation[labelProp]} at ${formattedY}`, + isActive: this.annotationIsActive(annotation), }; }); } + annotationIsActive(annotation) { + const { key, activeAnnotation } = this.args; + if (!activeAnnotation) return false; + + if (key) return get(annotation, key) === get(activeAnnotation, key); + return annotation === activeAnnotation; + } + @action selectAnnotation(annotation) { if (this.args.annotationClick) this.args.annotationClick(annotation); diff --git a/ui/app/components/chart-primitives/v-annotations.hbs b/ui/app/components/chart-primitives/v-annotations.hbs index 1a2a80399..7b50ec745 100644 --- a/ui/app/components/chart-primitives/v-annotations.hbs +++ b/ui/app/components/chart-primitives/v-annotations.hbs @@ -4,10 +4,7 @@ diff --git a/ui/app/components/chart-primitives/v-annotations.js b/ui/app/components/chart-primitives/v-annotations.js index f05481778..a49c0f268 100644 --- a/ui/app/components/chart-primitives/v-annotations.js +++ b/ui/app/components/chart-primitives/v-annotations.js @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { htmlSafe } from '@ember/template'; -import { action } from '@ember/object'; +import { action, get } from '@ember/object'; import styleString from 'nomad-ui/utils/properties/glimmer-style-string'; const iconFor = { @@ -51,10 +51,20 @@ export default class ChartPrimitiveVAnnotations extends Component { iconClass: iconClassFor[annotation.type], staggerClass: prevHigh ? 'is-staggered' : '', label: `${annotation.type} event at ${formattedX}`, + isActive: this.annotationIsActive(annotation), }; }); } + annotationIsActive(annotation) { + const { key, activeAnnotation } = this.args; + console.log(key, activeAnnotation, annotation); + if (!activeAnnotation) return false; + + if (key) return get(annotation, key) === get(activeAnnotation, key); + return annotation === activeAnnotation; + } + @action selectAnnotation(annotation) { if (this.args.annotationClick) this.args.annotationClick(annotation);