From 341fbe558ecd38fd54fd846f1b0f960f77a0dc06 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 15:00:49 -0700 Subject: [PATCH 1/9] store sort in memory if not able to be stored on config --- src/plugins/telemetryTable/TelemetryTable.js | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index dceaa9e6056..1ad87d9ce71 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -53,6 +53,11 @@ export default class TelemetryTable extends EventEmitter { this.outstandingRequests = 0; this.stalenessSubscription = {}; + this.sortOptions = { + key: this.openmct.time.getTimeSystem().key, + direction: ORDER.DESCENDING + }; + this.addTelemetryObject = this.addTelemetryObject.bind(this); this.removeTelemetryObject = this.removeTelemetryObject.bind(this); this.removeTelemetryCollection = this.removeTelemetryCollection.bind(this); @@ -131,17 +136,14 @@ export default class TelemetryTable extends EventEmitter { this.tableRows = new TableRowCollection(); //Fetch any persisted default sort - let sortOptions = this.configuration.getConfiguration().sortOptions; + let configSortOptions = this.configuration.getConfiguration().sortOptions; - //If no persisted sort order, default to sorting by time system, descending. - sortOptions = sortOptions || { - key: this.openmct.time.getTimeSystem().key, - direction: ORDER.DESCENDING - }; + //If no persisted sort order, use the in-memory sort options + this.sortOptions = configSortOptions || this.sortOptions; this.updateRowLimit(); - this.tableRows.sortBy(sortOptions); + this.tableRows.sortBy(this.sortOptions); this.tableRows.on('resetRowsFromAllData', this.resetRowsFromAllData); } @@ -442,11 +444,12 @@ export default class TelemetryTable extends EventEmitter { } sortBy(sortOptions) { - this.tableRows.sortBy(sortOptions); + this.sortOptions = sortOptions; + this.tableRows.sortBy(this.sortOptions); if (this.openmct.editor.isEditing()) { let configuration = this.configuration.getConfiguration(); - configuration.sortOptions = sortOptions; + configuration.sortOptions = this.sortOptions; this.configuration.updateConfiguration(configuration); } } @@ -496,4 +499,4 @@ export default class TelemetryTable extends EventEmitter { this.tableComposition.off('remove', this.removeTelemetryObject); } } -} +} \ No newline at end of file From 69c974cafae0b92f7afc1527fbe92edafe67bd6e Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 16:03:51 -0700 Subject: [PATCH 2/9] maps for debuggin --- .webpack/webpack.prod.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.webpack/webpack.prod.mjs b/.webpack/webpack.prod.mjs index f0656b67e09..0b2e7921517 100644 --- a/.webpack/webpack.prod.mjs +++ b/.webpack/webpack.prod.mjs @@ -15,5 +15,5 @@ export default merge(common, { __OPENMCT_ROOT_RELATIVE__: '""' }) ], - devtool: 'source-map' + devtool: 'eval-source-map' }); From a29fbc6736977930cf48b8185c933a1bce67eac0 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 16:23:57 -0700 Subject: [PATCH 3/9] missed a spot for in memory sort --- src/plugins/telemetryTable/TelemetryTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index 1ad87d9ce71..dd9d8f5b776 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -175,7 +175,7 @@ export default class TelemetryTable extends EventEmitter { this.removeTelemetryCollection(keyString); let sortOptions = this.configuration.getConfiguration().sortOptions; - requestOptions.order = sortOptions?.direction ?? ORDER.DESCENDING; // default to descending + requestOptions.order = sortOptions?.direction ?? this.sortOptions.direction; // default to descending if (this.telemetryMode === MODE.PERFORMANCE) { requestOptions.size = this.rowLimit; From 7f41b55cbdb7458d1a53f440f8c930d7d162ea34 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 16:43:22 -0700 Subject: [PATCH 4/9] if in performance mode and sorting, rerequest telemetry --- src/plugins/telemetryTable/TelemetryTable.js | 8 +++++++- .../telemetryTable/collections/TableRowCollection.js | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index dd9d8f5b776..ad9ecf4f201 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -445,7 +445,13 @@ export default class TelemetryTable extends EventEmitter { sortBy(sortOptions) { this.sortOptions = sortOptions; - this.tableRows.sortBy(this.sortOptions); + + if (this.telemetryMode === MODE.PERFORMANCE) { + this.tableRows.setSortOptions(this.sortOptions); + this.clearAndResubscribe(); + } else { + this.tableRows.sortBy(this.sortOptions); + } if (this.openmct.editor.isEditing()) { let configuration = this.configuration.getConfiguration(); diff --git a/src/plugins/telemetryTable/collections/TableRowCollection.js b/src/plugins/telemetryTable/collections/TableRowCollection.js index d82c3831364..6658f67c54f 100644 --- a/src/plugins/telemetryTable/collections/TableRowCollection.js +++ b/src/plugins/telemetryTable/collections/TableRowCollection.js @@ -273,7 +273,7 @@ export default class TableRowCollection extends EventEmitter { */ sortBy(sortOptions) { if (arguments.length > 0) { - this.sortOptions = sortOptions; + this.setSortOptions(sortOptions); this.rows = _.orderBy( this.rows, (row) => row.getParsedValue(sortOptions.key), @@ -286,6 +286,10 @@ export default class TableRowCollection extends EventEmitter { return Object.assign({}, this.sortOptions); } + setSortOptions(sortOptions) { + this.sortOptions = sortOptions; + } + setColumnFilter(columnKey, filter) { filter = filter.trim().toLowerCase(); let wasBlank = this.columnFilters[columnKey] === undefined; From 62fdc86d64ece7814f102fbc76b42af661eb81ba Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 16:56:28 -0700 Subject: [PATCH 5/9] removing maps --- .webpack/webpack.prod.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.webpack/webpack.prod.mjs b/.webpack/webpack.prod.mjs index 0b2e7921517..f0656b67e09 100644 --- a/.webpack/webpack.prod.mjs +++ b/.webpack/webpack.prod.mjs @@ -15,5 +15,5 @@ export default merge(common, { __OPENMCT_ROOT_RELATIVE__: '""' }) ], - devtool: 'eval-source-map' + devtool: 'source-map' }); From deb73ae9bffc3b1812aa6037e925fc1ae75e7564 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 8 Oct 2024 16:59:03 -0700 Subject: [PATCH 6/9] adding trailing space that was removed by accident --- src/plugins/telemetryTable/TelemetryTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index ad9ecf4f201..a4b5edc3fdf 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -505,4 +505,4 @@ export default class TelemetryTable extends EventEmitter { this.tableComposition.off('remove', this.removeTelemetryObject); } } -} \ No newline at end of file +} From 142805b827b81657646db73fe0945c2a753e10dd Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 10 Oct 2024 10:55:29 -0700 Subject: [PATCH 7/9] const instead of let and remove irrelevant comment --- src/plugins/telemetryTable/TelemetryTable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index a4b5edc3fdf..a72ce89d9f3 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -136,7 +136,7 @@ export default class TelemetryTable extends EventEmitter { this.tableRows = new TableRowCollection(); //Fetch any persisted default sort - let configSortOptions = this.configuration.getConfiguration().sortOptions; + const configSortOptions = this.configuration.getConfiguration().sortOptions; //If no persisted sort order, use the in-memory sort options this.sortOptions = configSortOptions || this.sortOptions; @@ -175,7 +175,7 @@ export default class TelemetryTable extends EventEmitter { this.removeTelemetryCollection(keyString); let sortOptions = this.configuration.getConfiguration().sortOptions; - requestOptions.order = sortOptions?.direction ?? this.sortOptions.direction; // default to descending + requestOptions.order = sortOptions?.direction ?? this.sortOptions.direction; if (this.telemetryMode === MODE.PERFORMANCE) { requestOptions.size = this.rowLimit; From bffae446bafe56b7974c3918acaed404bc2d3ccf Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Thu, 10 Oct 2024 13:48:08 -0700 Subject: [PATCH 8/9] Move sort order boilerplate to configuration class --- src/plugins/telemetryTable/TelemetryTable.js | 29 +++++-------------- .../TelemetryTableConfiguration.js | 24 +++++++++++++++ 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index a72ce89d9f3..917cd9f5648 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -53,11 +53,6 @@ export default class TelemetryTable extends EventEmitter { this.outstandingRequests = 0; this.stalenessSubscription = {}; - this.sortOptions = { - key: this.openmct.time.getTimeSystem().key, - direction: ORDER.DESCENDING - }; - this.addTelemetryObject = this.addTelemetryObject.bind(this); this.removeTelemetryObject = this.removeTelemetryObject.bind(this); this.removeTelemetryCollection = this.removeTelemetryCollection.bind(this); @@ -135,15 +130,11 @@ export default class TelemetryTable extends EventEmitter { createTableRowCollections() { this.tableRows = new TableRowCollection(); - //Fetch any persisted default sort - const configSortOptions = this.configuration.getConfiguration().sortOptions; - - //If no persisted sort order, use the in-memory sort options - this.sortOptions = configSortOptions || this.sortOptions; + const sortOptions = this.configuration.getSortOptions(); this.updateRowLimit(); - this.tableRows.sortBy(this.sortOptions); + this.tableRows.sortBy(sortOptions); this.tableRows.on('resetRowsFromAllData', this.resetRowsFromAllData); } @@ -174,8 +165,8 @@ export default class TelemetryTable extends EventEmitter { this.removeTelemetryCollection(keyString); - let sortOptions = this.configuration.getConfiguration().sortOptions; - requestOptions.order = sortOptions?.direction ?? this.sortOptions.direction; + let sortOptions = this.configuration.getSortOptions(); + requestOptions.order = sortOptions.direction; if (this.telemetryMode === MODE.PERFORMANCE) { requestOptions.size = this.rowLimit; @@ -444,19 +435,13 @@ export default class TelemetryTable extends EventEmitter { } sortBy(sortOptions) { - this.sortOptions = sortOptions; + this.configuration.setSortOptions(sortOptions); if (this.telemetryMode === MODE.PERFORMANCE) { - this.tableRows.setSortOptions(this.sortOptions); + this.tableRows.setSortOptions(sortOptions); this.clearAndResubscribe(); } else { - this.tableRows.sortBy(this.sortOptions); - } - - if (this.openmct.editor.isEditing()) { - let configuration = this.configuration.getConfiguration(); - configuration.sortOptions = this.sortOptions; - this.configuration.updateConfiguration(configuration); + this.tableRows.sortBy(sortOptions); } } diff --git a/src/plugins/telemetryTable/TelemetryTableConfiguration.js b/src/plugins/telemetryTable/TelemetryTableConfiguration.js index 6b9af55f148..1a94c96d239 100644 --- a/src/plugins/telemetryTable/TelemetryTableConfiguration.js +++ b/src/plugins/telemetryTable/TelemetryTableConfiguration.js @@ -23,7 +23,11 @@ import { EventEmitter } from 'eventemitter3'; import _ from 'lodash'; +import { ORDER } from './constants'; + export default class TelemetryTableConfiguration extends EventEmitter { + #sortOptions; + constructor(domainObject, openmct, options) { super(); @@ -44,6 +48,26 @@ export default class TelemetryTableConfiguration extends EventEmitter { this.notPersistable = !this.openmct.objects.isPersistable(this.domainObject.identifier); } + getSortOptions() { + return ( + this.#sortOptions || + this.getConfiguration().sortOptions || { + key: this.openmct.time.getTimeSystem().key, + direction: ORDER.DESCENDING + } + ); + } + + setSortOptions(sortOptions) { + this.#sortOptions = sortOptions; + + if (this.openmct.editor.isEditing()) { + let configuration = this.getConfiguration(); + configuration.sortOptions = sortOptions; + this.updateConfiguration(configuration); + } + } + getConfiguration() { let configuration = this.domainObject.configuration || {}; configuration.hiddenColumns = configuration.hiddenColumns || {}; From 76f2fdba79676d3f25bf08e45a02d79e323f60c7 Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Thu, 10 Oct 2024 14:06:13 -0700 Subject: [PATCH 9/9] Fix linting error --- src/plugins/telemetryTable/TelemetryTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index 917cd9f5648..028c706fc6d 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -25,7 +25,7 @@ import _ from 'lodash'; import StalenessUtils from '../../utils/staleness.js'; import TableRowCollection from './collections/TableRowCollection.js'; -import { MODE, ORDER } from './constants.js'; +import { MODE } from './constants.js'; import TelemetryTableColumn from './TelemetryTableColumn.js'; import TelemetryTableConfiguration from './TelemetryTableConfiguration.js'; import TelemetryTableNameColumn from './TelemetryTableNameColumn.js';