Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide own renderWhenVisible function since manually creating an object view #7281

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
inspector view needs renderWhenVisible function
  • Loading branch information
davetsay committed Dec 7, 2023
commit 6d1c3118f73f24ec4f24bae64176d32d170b8968
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<script>
import mount from 'utils/mount';

import VisibilityObserver from '../../utils/visibility/VisibilityObserver';
import Plot from '../plot/PlotView.vue';
import TelemetryFrame from './TelemetryFrame.vue';

Expand Down Expand Up @@ -89,8 +90,9 @@ export default {
this.clearPlots();

this.unregisterTimeContextList = [];
this.elementsList = [];
this.componentsList = [];
this.elementsList = [];
this.visibilityObservers = [];

this.telemetryKeys.forEach(async (telemetryKey) => {
const plotObject = await this.openmct.objects.get(telemetryKey);
Expand All @@ -109,15 +111,19 @@ export default {
return this.openmct.time.addIndependentContext(keyString, this.bounds);
},
renderPlot(plotObject) {
const { vNode, destroy } = mount(
const wrapper = document.createElement('div');
const visibilityObserver = new VisibilityObserver(wrapper);

const { destroy } = mount(
{
components: {
TelemetryFrame,
Plot
},
provide: {
openmct: this.openmct,
path: [plotObject]
path: [plotObject],
renderWhenVisible: visibilityObserver.renderWhenVisible
},
data() {
return {
Expand All @@ -133,13 +139,15 @@ export default {
</TelemetryFrame>`
},
{
app: this.openmct.app
app: this.openmct.app,
element: wrapper
}
);

this.componentsList.push(destroy);
this.elementsList.push(vNode.el);
this.$refs.numericDataView.append(vNode.el);
this.elementsList.push(wrapper);
this.visibilityObservers.push(visibilityObserver);
this.$refs.numericDataView.append(wrapper);
},
clearPlots() {
if (this.componentsList?.length) {
Expand All @@ -152,6 +160,11 @@ export default {
delete this.elementsList;
}

if (this.visibilityObservers?.length) {
this.visibilityObservers.forEach((visibilityObserver) => visibilityObserver.destroy());
delete this.visibilityObservers;
}

if (this.plotObjects?.length) {
this.plotObjects = [];
}
Expand Down