[Telemetry Table] Telemetry mode bug fixes (#7601)

* source maps

* any tables without configuration will default to either default options or configured options

* prevent double unsubscribese

* remove source maps

* update coment

* moving defaults to plugin level

* whoops

* missed a spot, updated omment

* adding config values

* lint

* typos

* fixing broken ref

* fixing broken ref

* actually fixing ref

* setting rowLimit so initial change does not trigger a resubscribe of telemetry that was not subscribed yet
This commit is contained in:
Jamie V 2024-03-18 19:34:00 -07:00 committed by GitHub
parent a01f21017f
commit fb396ac194
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 46 additions and 24 deletions

View File

@ -25,7 +25,7 @@ import mount from 'utils/mount';
import TableConfigurationComponent from './components/TableConfiguration.vue'; import TableConfigurationComponent from './components/TableConfiguration.vue';
import TelemetryTableConfiguration from './TelemetryTableConfiguration.js'; import TelemetryTableConfiguration from './TelemetryTableConfiguration.js';
export default function TableConfigurationViewProvider(openmct) { export default function TableConfigurationViewProvider(openmct, options) {
return { return {
key: 'table-configuration', key: 'table-configuration',
name: 'Config', name: 'Config',
@ -45,7 +45,7 @@ export default function TableConfigurationViewProvider(openmct) {
return { return {
show: function (element) { show: function (element) {
tableConfiguration = new TelemetryTableConfiguration(domainObject, openmct); tableConfiguration = new TelemetryTableConfiguration(domainObject, openmct, options);
const { destroy } = mount( const { destroy } = mount(
{ {
el: element, el: element,

View File

@ -32,14 +32,14 @@ import TelemetryTableRow from './TelemetryTableRow.js';
import TelemetryTableUnitColumn from './TelemetryTableUnitColumn.js'; import TelemetryTableUnitColumn from './TelemetryTableUnitColumn.js';
export default class TelemetryTable extends EventEmitter { export default class TelemetryTable extends EventEmitter {
constructor(domainObject, openmct) { constructor(domainObject, openmct, options) {
super(); super();
this.domainObject = domainObject; this.domainObject = domainObject;
this.openmct = openmct; this.openmct = openmct;
this.tableComposition = undefined; this.tableComposition = undefined;
this.datumCache = []; this.datumCache = [];
this.configuration = new TelemetryTableConfiguration(domainObject, openmct); this.configuration = new TelemetryTableConfiguration(domainObject, openmct, options);
this.telemetryMode = this.configuration.getTelemetryMode(); this.telemetryMode = this.configuration.getTelemetryMode();
this.rowLimit = this.configuration.getRowLimit(); this.rowLimit = this.configuration.getRowLimit();
this.paused = false; this.paused = false;

View File

@ -24,11 +24,12 @@ import EventEmitter from 'EventEmitter';
import _ from 'lodash'; import _ from 'lodash';
export default class TelemetryTableConfiguration extends EventEmitter { export default class TelemetryTableConfiguration extends EventEmitter {
constructor(domainObject, openmct) { constructor(domainObject, openmct, options) {
super(); super();
this.domainObject = domainObject; this.domainObject = domainObject;
this.openmct = openmct; this.openmct = openmct;
this.defaultOptions = options;
this.columns = {}; this.columns = {};
this.removeColumnsForObject = this.removeColumnsForObject.bind(this); this.removeColumnsForObject = this.removeColumnsForObject.bind(this);
@ -48,10 +49,12 @@ export default class TelemetryTableConfiguration extends EventEmitter {
configuration.columnOrder = configuration.columnOrder || []; configuration.columnOrder = configuration.columnOrder || [];
configuration.cellFormat = configuration.cellFormat || {}; configuration.cellFormat = configuration.cellFormat || {};
configuration.autosize = configuration.autosize === undefined ? true : configuration.autosize; configuration.autosize = configuration.autosize === undefined ? true : configuration.autosize;
// anything that doesn't have a telemetryMode existed before the change and should stay as it was for consistency // anything that doesn't have a telemetryMode existed before the change and should
configuration.telemetryMode = configuration.telemetryMode ?? 'unlimited'; // take the properties of any passed in defaults or the defaults from the plugin
configuration.persistModeChange = configuration.persistModeChange ?? true; configuration.telemetryMode = configuration.telemetryMode ?? this.defaultOptions.telemetryMode;
configuration.rowLimit = configuration.rowLimit ?? 50; configuration.persistModeChange =
configuration.persistModeChange ?? this.defaultOptions.persistModeChange;
configuration.rowLimit = configuration.rowLimit ?? this.defaultOptions.rowLimit;
return configuration; return configuration;
} }

View File

@ -20,8 +20,8 @@
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
export default function getTelemetryTableType(options = {}) { export default function getTelemetryTableType(options) {
const { telemetryMode = 'performance', persistModeChange = true, rowLimit = 50 } = options; let { telemetryMode, persistModeChange, rowLimit } = options;
return { return {
name: 'Telemetry Table', name: 'Telemetry Table',

View File

@ -33,7 +33,7 @@ export default class TelemetryTableView {
this.component = null; this.component = null;
Object.defineProperty(this, 'table', { Object.defineProperty(this, 'table', {
value: new TelemetryTable(domainObject, openmct), value: new TelemetryTable(domainObject, openmct, options),
enumerable: false, enumerable: false,
configurable: false configurable: false
}); });

View File

@ -398,15 +398,17 @@ export default {
totalNumberOfRows: 0, totalNumberOfRows: 0,
rowContext: {}, rowContext: {},
telemetryMode: configuration.telemetryMode, telemetryMode: configuration.telemetryMode,
rowLimit: configuration.rowLimit,
persistModeChange: configuration.persistModeChange, persistModeChange: configuration.persistModeChange,
afterLoadActions: [] afterLoadActions: [],
existingConfiguration: configuration
}; };
}, },
computed: { computed: {
dropTargetStyle() { dropTargetStyle() {
return { return {
top: this.$refs.headersTable.offsetTop + 'px', top: this.$refs.headersHolderEl.offsetTop + 'px',
height: this.totalHeight + this.$refs.headersTable.offsetHeight + 'px', height: this.totalHeight + this.$refs.headersHolderEl.offsetHeight + 'px',
left: this.dropOffsetLeft && this.dropOffsetLeft + 'px' left: this.dropOffsetLeft && this.dropOffsetLeft + 'px'
}; };
}, },
@ -595,23 +597,35 @@ export default {
}, },
handleConfigurationChanges(changes) { handleConfigurationChanges(changes) {
const { rowLimit, telemetryMode, persistModeChange } = changes; const { rowLimit, telemetryMode, persistModeChange } = changes;
const telemetryModeChanged = this.existingConfiguration.telemetryMode !== telemetryMode;
let rowLimitChanged = false;
this.persistModeChange = persistModeChange; this.persistModeChange = persistModeChange;
// both rowLimit changes and telemetryMode changes
// require a re-request of telemetry
if (this.rowLimit !== rowLimit) { if (this.rowLimit !== rowLimit) {
rowLimitChanged = true;
this.rowLimit = rowLimit; this.rowLimit = rowLimit;
this.table.updateRowLimit(rowLimit); this.table.updateRowLimit(rowLimit);
if (this.telemetryMode !== telemetryMode) {
// need to clear and resubscribe, if different, handled below
this.table.clearAndResubscribe();
}
} }
if (this.telemetryMode !== telemetryMode) { // check for telemetry mode change, because you could technically have persist mode changes
// set to false, which could create a state where the configuration saved telemetry mode is
// different from the currently set telemetry mode
if (telemetryModeChanged && this.telemetryMode !== telemetryMode) {
this.telemetryMode = telemetryMode; this.telemetryMode = telemetryMode;
// this method also re-requests telemetry
this.table.updateTelemetryMode(telemetryMode); this.table.updateTelemetryMode(telemetryMode);
} }
if (rowLimitChanged && !telemetryModeChanged) {
this.table.clearAndResubscribe();
}
this.existingConfiguration = changes;
}, },
updateVisibleRows() { updateVisibleRows() {
if (!this.updatingView) { if (!this.updatingView) {

View File

@ -25,10 +25,12 @@ import getTelemetryTableType from './TelemetryTableType.js';
import TelemetryTableViewProvider from './TelemetryTableViewProvider.js'; import TelemetryTableViewProvider from './TelemetryTableViewProvider.js';
import TelemetryTableViewActions from './ViewActions.js'; import TelemetryTableViewActions from './ViewActions.js';
export default function plugin(options) { export default function plugin(
options = { telemetryMode: 'performance', persistModeChange: true, rowLimit: 50 }
) {
return function install(openmct) { return function install(openmct) {
openmct.objectViews.addProvider(new TelemetryTableViewProvider(openmct, options)); openmct.objectViews.addProvider(new TelemetryTableViewProvider(openmct, options));
openmct.inspectorViews.addProvider(new TableConfigurationViewProvider(openmct)); openmct.inspectorViews.addProvider(new TableConfigurationViewProvider(openmct, options));
openmct.types.addType('table', getTelemetryTableType(options)); openmct.types.addType('table', getTelemetryTableType(options));
openmct.composition.addPolicy((parent, child) => { openmct.composition.addPolicy((parent, child) => {
if (parent.type === 'table') { if (parent.type === 'table') {

View File

@ -195,7 +195,10 @@ describe('the plugin', () => {
utc: false, utc: false,
'some-key': false, 'some-key': false,
'some-other-key': false 'some-other-key': false
} },
persistModeChange: true,
rowLimit: 50,
telemetryMode: 'performance'
} }
}; };
const testTelemetry = [ const testTelemetry = [