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 visibility based rendering as part of the view api #7241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/plugins/LADTable/LADTableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class LADTableView {
this._destroy = null;
}

show(element) {
show(element, isEditing, { renderWhenVisible }) {
ozyx marked this conversation as resolved.
Show resolved Hide resolved
let ladTableConfiguration = new LADTableConfiguration(this.domainObject, this.openmct);

const { vNode, destroy } = mount(
Expand All @@ -46,7 +46,8 @@ export default class LADTableView {
provide: {
openmct: this.openmct,
currentView: this,
ladTableConfiguration
ladTableConfiguration,
renderWhenVisible
},
data: () => {
return {
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/LADTable/components/LadRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ const BLANK_VALUE = '---';
import identifierToString from '/src/tools/url';
import PreviewAction from '@/ui/preview/PreviewAction.js';

import NicelyCalled from '../../../api/nice/NicelyCalled';
import tooltipHelpers from '../../../api/tooltips/tooltipMixins';

export default {
mixins: [tooltipHelpers],
inject: ['openmct', 'currentView'],
inject: ['openmct', 'currentView', 'renderWhenVisible'],
props: {
domainObject: {
type: Object,
Expand Down Expand Up @@ -190,7 +189,6 @@ export default {
}
},
async mounted() {
this.nicelyCalled = new NicelyCalled(this.$refs.tableRow);
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
Expand Down Expand Up @@ -239,12 +237,11 @@ export default {
this.previewAction.off('isVisible', this.togglePreviewState);

this.telemetryCollection.destroy();
this.nicelyCalled.destroy();
},
methods: {
updateView() {
if (!this.updatingView) {
this.updatingView = this.nicelyCalled.execute(() => {
this.updatingView = this.renderWhenVisible(() => {
this.timestamp = this.getParsedTimestamp(this.latestDatum);
this.datum = this.latestDatum;
this.updatingView = false;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/LADTable/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
getLatestTelemetry,
getMockObjects,
getMockTelemetry,
renderWhenVisible,
resetApplicationState,
spyOnBuiltins
} from 'utils/testing';
Expand Down Expand Up @@ -225,7 +226,7 @@ describe('The LAD Table', () => {
(viewProvider) => viewProvider.key === ladTableKey
);
ladTableView = ladTableViewProvider.view(mockObj.ladTable, [mockObj.ladTable]);
ladTableView.show(child, true);
ladTableView.show(child, true, { renderWhenVisible });

await Promise.all([
telemetryRequestPromise,
Expand Down
13 changes: 8 additions & 5 deletions src/plugins/displayLayout/components/TelemetryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ import {
} from '@/plugins/notebook/utils/notebook-storage.js';
import stalenessMixin from '@/ui/mixins/staleness-mixin';

import NicelyCalled from '../../../api/nice/NicelyCalled';
import tooltipHelpers from '../../../api/tooltips/tooltipMixins';
import conditionalStylesMixin from '../mixins/objectStyles-mixin';
import LayoutFrame from './LayoutFrame.vue';

const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5];
const DEFAULT_POSITION = [1, 1];
const CONTEXT_MENU_ACTIONS = ['copyToClipboard', 'copyToNotebook', 'viewHistoricalData'];
const CONTEXT_MENU_ACTIONS = [
'copyToClipboard',
'copyToNotebook',
'viewHistoricalData',
'renderWhenVisible'
];

export default {
makeDefinition(openmct, gridSize, domainObject, position) {
Expand All @@ -106,7 +110,7 @@ export default {
LayoutFrame
},
mixins: [conditionalStylesMixin, stalenessMixin, tooltipHelpers],
inject: ['openmct', 'objectPath', 'currentView'],
inject: ['openmct', 'objectPath', 'currentView', 'renderWhenVisible'],
props: {
item: {
type: Object,
Expand Down Expand Up @@ -274,7 +278,6 @@ export default {
}
this.setObject(foundObject);
await this.$nextTick();
this.nicelyCalled = new NicelyCalled(this.$refs.telemetryViewWrapper);
},
formattedValueForCopy() {
const timeFormatterKey = this.openmct.time.timeSystem().key;
Expand All @@ -291,7 +294,7 @@ export default {
},
updateView() {
if (!this.updatingView) {
this.updatingView = this.nicelyCalled.execute(() => {
this.updatingView = this.renderWhenVisible(() => {
this.datum = this.latestDatum;
this.updatingView = false;
});
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/displayLayout/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DisplayLayoutView {
this.component = null;
}

show(container, isEditing) {
show(container, isEditing, { renderWhenVisible }) {
const { vNode, destroy } = mount(
{
el: container,
Expand All @@ -50,7 +50,8 @@ class DisplayLayoutView {
openmct: this.openmct,
objectPath: this.objectPath,
options: this.options,
currentView: this
currentView: this,
renderWhenVisible
},
data: () => {
return {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/displayLayout/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/

import { createOpenMct, resetApplicationState } from 'utils/testing';
import { createOpenMct, renderWhenVisible, resetApplicationState } from 'utils/testing';
import { nextTick } from 'vue';

import DisplayLayoutPlugin from './plugin';
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('the plugin', function () {
let error;

try {
view.show(child, false);
view.show(child, false, { renderWhenVisible });
} catch (e) {
error = e;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('the plugin', function () {
(viewProvider) => viewProvider.key === 'layout.view'
);
const view = displayLayoutViewProvider.view(displayLayoutItem, displayLayoutItem);
view.show(child, false);
view.show(child, false, { renderWhenVisible });

nextTick(done);
});
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/gauge/GaugePluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { debounce } from 'lodash';
import { createOpenMct, resetApplicationState } from 'utils/testing';
import { createOpenMct, renderWhenVisible, resetApplicationState } from 'utils/testing';
import { nextTick } from 'vue';

let gaugeDomainObject = {
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('Gauge plugin', () => {
return openmct.objects.getMutable(gaugeViewObject.identifier).then((mutableObject) => {
mutablegaugeObject = mutableObject;
gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('Gauge plugin', () => {
return openmct.objects.getMutable(gaugeViewObject.identifier).then((mutableObject) => {
mutablegaugeObject = mutableObject;
gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('Gauge plugin', () => {
return openmct.objects.getMutable(gaugeViewObject.identifier).then((mutableObject) => {
mutablegaugeObject = mutableObject;
gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down Expand Up @@ -560,7 +560,7 @@ describe('Gauge plugin', () => {
mutablegaugeObject = mutableObject;

gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down Expand Up @@ -643,7 +643,7 @@ describe('Gauge plugin', () => {
mutablegaugeObject = mutableObject;

gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down Expand Up @@ -771,7 +771,7 @@ describe('Gauge plugin', () => {
return openmct.objects.getMutable(gaugeViewObject.identifier).then((mutableObject) => {
mutablegaugeObject = mutableObject;
gaugeView = gaugeViewProvider.view(mutablegaugeObject, [mutablegaugeObject]);
gaugeView.show(child);
gaugeView.show(child, false, { renderWhenVisible });

return nextTick();
});
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/gauge/GaugeViewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function GaugeViewProvider(openmct) {
let _destroy = null;

return {
show: function (element) {
show: function (element, isEditing, { renderWhenVisible }) {
const { destroy } = mount(
{
el: element,
Expand All @@ -51,7 +51,8 @@ export default function GaugeViewProvider(openmct) {
provide: {
openmct,
domainObject,
composition: openmct.composition.get(domainObject)
composition: openmct.composition.get(domainObject),
renderWhenVisible
},
template: '<gauge-component></gauge-component>'
},
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/gauge/components/GaugeComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
<script>
import stalenessMixin from '@/ui/mixins/staleness-mixin';

import NicelyCalled from '../../../api/nice/NicelyCalled';
import tooltipHelpers from '../../../api/tooltips/tooltipMixins';
import { DIAL_VALUE_DEG_OFFSET, getLimitDegree } from '../gauge-limit-util';

Expand All @@ -345,7 +344,7 @@ const DEFAULT_CURRENT_VALUE = '--';

export default {
mixins: [stalenessMixin, tooltipHelpers],
inject: ['openmct', 'domainObject', 'composition'],
inject: ['openmct', 'domainObject', 'composition', 'renderWhenVisible'],
data() {
let gaugeController = this.domainObject.configuration.gaugeController;

Expand Down Expand Up @@ -539,7 +538,6 @@ export default {
}
},
mounted() {
this.nicelyCalled = new NicelyCalled(this.$refs.gaugeWrapper);
this.composition.on('add', this.addedToComposition);
this.composition.on('remove', this.removeTelemetryObject);

Expand All @@ -563,8 +561,6 @@ export default {

this.openmct.time.off('bounds', this.refreshData);
this.openmct.time.off('timeSystem', this.setTimeSystem);

this.nicelyCalled.destroy();
},
methods: {
getLimitDegree: getLimitDegree,
Expand Down Expand Up @@ -737,7 +733,7 @@ export default {
return;
}

this.isRendering = this.nicelyCalled.execute(() => {
this.isRendering = this.renderWhenVisible(() => {
this.isRendering = false;

this.curVal = this.round(this.formats[this.valueKey].format(this.datum), this.precision);
Expand Down
23 changes: 16 additions & 7 deletions src/plugins/imagery/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,22 @@ describe('The Imagery View Layouts', () => {
imageWrapper[2].dispatchEvent(mouseDownEvent);
await nextTick();
const timestamp = imageWrapper[2].id.replace('wrapper-', '');
expect(componentView.previewAction.invoke).toHaveBeenCalledWith(
[componentView.objectPath[0]],
{
timestamp: Number(timestamp),
objectPath: componentView.objectPath
}
);
const mockInvoke = componentView.previewAction.invoke;
// Make sure the function was called
expect(mockInvoke).toHaveBeenCalled();

// Get the arguments of the first call
const firstArg = mockInvoke.calls.mostRecent().args[0];
const secondArg = mockInvoke.calls.mostRecent().args[1];

// Compare the first argument
expect(firstArg).toEqual([componentView.objectPath[0]]);

// Compare the "timestamp" property of the second argument
expect(secondArg.timestamp).toEqual(Number(timestamp));

// Compare the "objectPath" property of the second argument
expect(secondArg.objectPath).toEqual(componentView.objectPath);
});

it('should remove images when clock advances', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plot/MctPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default {
MctTicks,
MctChart
},
inject: ['openmct', 'domainObject', 'path'],
inject: ['openmct', 'domainObject', 'path', 'renderWhenVisible'],
props: {
options: {
type: Object,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/plot/PlotViewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function PlotViewProvider(openmct) {
let component = null;

return {
show: function (element) {
show: function (element, isEditing, { renderWhenVisible }) {
let isCompact = isCompactView(objectPath);
const { vNode, destroy } = mount(
{
Expand All @@ -76,7 +76,8 @@ export default function PlotViewProvider(openmct) {
provide: {
openmct,
domainObject,
path: objectPath
path: objectPath,
renderWhenVisible
},
data() {
return {
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/plot/chart/MctChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import mount from 'utils/mount';
import { toRaw } from 'vue';

import NicelyCalled from '../../../api/nice/NicelyCalled';
import configStore from '../configuration/ConfigStore';
import PlotConfigurationModel from '../configuration/PlotConfigurationModel';
import { DrawLoader } from '../draw/DrawLoader';
Expand Down Expand Up @@ -100,7 +99,7 @@ const HANDLED_ATTRIBUTES = {

export default {
components: { LimitLine, LimitLabel },
inject: ['openmct', 'domainObject', 'path'],
inject: ['openmct', 'domainObject', 'path', 'renderWhenVisible'],
props: {
rectangles: {
type: Array,
Expand Down Expand Up @@ -199,7 +198,6 @@ export default {
},
mounted() {
eventHelpers.extend(this);
this.nicelyCalled = new NicelyCalled(this.$refs.chart);
this.seriesModels = [];
this.config = this.getConfig();
this.isDestroyed = false;
Expand Down Expand Up @@ -258,7 +256,6 @@ export default {
},
beforeUnmount() {
this.destroy();
this.nicelyCalled.destroy();
},
methods: {
getConfig() {
Expand Down Expand Up @@ -650,7 +647,7 @@ export default {
},
scheduleDraw() {
if (!this.drawScheduled) {
const called = this.nicelyCalled.execute(this.draw);
const called = this.renderWhenVisible(this.draw);
this.drawScheduled = called;
}
},
Expand Down