From 0db301dea8b264d16a20d752738e38aad80770c1 Mon Sep 17 00:00:00 2001 From: Scott Bell Date: Thu, 12 Dec 2024 14:05:14 +0100 Subject: [PATCH] add facility to send action to mounted component regarding extending lines --- index.html | 2 +- .../events/EventTimelineViewProvider.js | 4 +- .../events/components/EventTimelineView.vue | 23 +++++- src/plugins/events/plugin.js | 4 +- src/plugins/timeline/ExtendedLinesBus.js | 15 +++- src/plugins/timeline/ExtendedLinesOverlay.vue | 2 +- src/plugins/timeline/TimelineObjectView.vue | 78 +++++++++++++------ src/plugins/timeline/TimelineViewLayout.vue | 13 ++-- src/plugins/timeline/TimelineViewProvider.js | 4 +- src/plugins/timeline/plugin.js | 8 +- src/ui/components/swim-lane/SwimLane.vue | 58 +++++++++++++- 11 files changed, 162 insertions(+), 49 deletions(-) diff --git a/index.html b/index.html index b33b822759..42417f0022 100644 --- a/index.html +++ b/index.html @@ -235,7 +235,7 @@ openmct.install(openmct.plugins.Timelist()); openmct.install(openmct.plugins.BarChart()); openmct.install(openmct.plugins.ScatterPlot()); - openmct.install(openmct.plugins.EventTimestripPlugin(timeLinePlugin.eventBus)); + openmct.install(openmct.plugins.EventTimestripPlugin(timeLinePlugin.extendedLinesBus)); document.addEventListener('DOMContentLoaded', function () { openmct.start(); }); diff --git a/src/plugins/events/EventTimelineViewProvider.js b/src/plugins/events/EventTimelineViewProvider.js index 18b446b2ac..ed8049d016 100644 --- a/src/plugins/events/EventTimelineViewProvider.js +++ b/src/plugins/events/EventTimelineViewProvider.js @@ -23,7 +23,7 @@ import mount from 'utils/mount'; import EventTimelineView from './components/EventTimelineView.vue'; -export default function EventTimestripViewProvider(openmct, timelineEventBus) { +export default function EventTimestripViewProvider(openmct, extendedLinesBus) { const type = 'event.time-line.view'; function hasEventTelemetry(domainObject) { @@ -66,7 +66,7 @@ export default function EventTimestripViewProvider(openmct, timelineEventBus) { openmct: openmct, domainObject: domainObject, objectPath: objectPath, - timelineEventBus + extendedLinesBus }, template: '' }, diff --git a/src/plugins/events/components/EventTimelineView.vue b/src/plugins/events/components/EventTimelineView.vue index d4969ad77a..8bfe8f8dcb 100644 --- a/src/plugins/events/components/EventTimelineView.vue +++ b/src/plugins/events/components/EventTimelineView.vue @@ -44,7 +44,7 @@ const ID_PREFIX = 'wrapper-'; export default { mixins: [eventData], - inject: ['openmct', 'domainObject', 'objectPath', 'timelineEventBus'], + inject: ['openmct', 'domainObject', 'objectPath', 'extendedLinesBus'], data() { const timeSystem = this.openmct.time.getTimeSystem(); this.metadata = {}; @@ -78,6 +78,7 @@ export default { this.setTimeContext(); this.limitEvaluator = this.openmct.telemetry.limitEvaluator(this.domainObject); + this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier); const metadata = this.openmct.telemetry.getMetadata(this.domainObject); if (metadata) { this.valueMetadata = @@ -90,6 +91,8 @@ export default { this.eventStripResizeObserver.observe(this.$refs.events); this.unlisten = this.openmct.objects.observe(this.domainObject, '*', this.observeForChanges); + this.extendedLinesBus.on('disable-extended-lines', this.disableExtendEventLines); + this.extendedLinesBus.on('enable-extended-lines', this.enableExtendEventLines); }, beforeUnmount() { if (this.eventStripResizeObserver) { @@ -103,6 +106,9 @@ export default { if (this.destroyEventContainer) { this.destroyEventContainer(); } + + this.extendedLinesBus.off('disable-extended-lines', this.disableExtendEventLines); + this.extendedLinesBus.off('enable-extended-lines', this.enableExtendEventLines); }, methods: { setTimeContext() { @@ -111,6 +117,16 @@ export default { this.timeContext.on('timeSystem', this.setScaleAndPlotEvents); this.timeContext.on('boundsChanged', this.updateViewBounds); }, + enableExtendEventLines(keyStringToEnable) { + if (this.keyString === keyStringToEnable) { + this.extendLines = true; + } + }, + disableExtendEventLines(keyStringToDisable) { + if (this.keyString === keyStringToDisable) { + this.extendLines = false; + } + }, firstNonDomainAttribute(metadata) { return metadata .values() @@ -409,7 +425,10 @@ export default { const lines = this.eventHistory .filter((e) => this.isEventInBounds(e)) .map((e) => ({ x: this.xScale(e.time) })); - this.timelineEventBus.emit('update-extended-lines', lines); + this.timelineEventBus.emit('update-extended-lines', { + lines, + keyString: this.keyString + }); } } }; diff --git a/src/plugins/events/plugin.js b/src/plugins/events/plugin.js index f4dcfcfabc..d81423b041 100644 --- a/src/plugins/events/plugin.js +++ b/src/plugins/events/plugin.js @@ -23,9 +23,9 @@ import EventInspectorViewProvider from './EventInspectorViewProvider.js'; import EventTimelineViewProvider from './EventTimelineViewProvider.js'; -export default function plugin(timelineEventBus) { +export default function plugin(extendedLinesBus) { return function install(openmct) { - openmct.objectViews.addProvider(new EventTimelineViewProvider(openmct, timelineEventBus)); + openmct.objectViews.addProvider(new EventTimelineViewProvider(openmct, extendedLinesBus)); openmct.inspectorViews.addProvider(new EventInspectorViewProvider(openmct)); }; } diff --git a/src/plugins/timeline/ExtendedLinesBus.js b/src/plugins/timeline/ExtendedLinesBus.js index b088de0392..3745cd8431 100644 --- a/src/plugins/timeline/ExtendedLinesBus.js +++ b/src/plugins/timeline/ExtendedLinesBus.js @@ -21,8 +21,17 @@ *****************************************************************************/ import { EventEmitter } from 'eventemitter3'; -export default class EventBusAPI extends EventEmitter { - updateExtendedLine(lineData) { - this.emit('update-extended-lines', lineData); +export default class ExtendedLinesBus extends EventEmitter { + updateExtendedLines(keyString, lineData) { + console.debug('🍯 ExtendedLines#updateExtendedLines'); + this.emit('update-extended-lines', { lineData, keyString }); + } + disableExtendEventLines(keyString) { + console.debug('🍯 ExtendedLines#disableExtendedLines'); + this.emit('disable-extended-lines', keyString); + } + enableExtendEventLines(keyString) { + console.debug('🍯 ExtendedLines#enableExtendedLines'); + this.emit('enable-extended-lines', keyString); } } diff --git a/src/plugins/timeline/ExtendedLinesOverlay.vue b/src/plugins/timeline/ExtendedLinesOverlay.vue index c224163ea3..288aa52fbe 100644 --- a/src/plugins/timeline/ExtendedLinesOverlay.vue +++ b/src/plugins/timeline/ExtendedLinesOverlay.vue @@ -37,7 +37,7 @@ export default { props: { extendedLines: { type: Array, - default: () => [] + default: () => {} }, height: { type: Number, diff --git a/src/plugins/timeline/TimelineObjectView.vue b/src/plugins/timeline/TimelineObjectView.vue index b10f592765..72fdd40f74 100644 --- a/src/plugins/timeline/TimelineObjectView.vue +++ b/src/plugins/timeline/TimelineObjectView.vue @@ -28,6 +28,11 @@ :show-ucontents="isPlanLikeObject(item.domainObject)" :span-rows-count="item.rowCount" :domain-object="item.domainObject" + button-title="Toggle event lines" + button-icon="icon-timeline" + :hide-button="!hasEventTelemetry()" + :button-click-on="enableExtendEventLines" + :button-click-off="disableExtendEventLines" >