mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
[Telemetry Tables] Fix sort issues (#7875)
* Issue where immutable objects sort order was not being set correctly in telemetry tables. * Configuration couldn't be saved and the sort order was not being saved in memory. * Telemetry was not being re-requested when the sort order of a table was changed and the table was in performance (limited) mode. * We've moved sort order to both configuration and in-memory and we will re-request telemetry if changing sort order in performance mode. --------- Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
parent
f4cf9c756b
commit
c43ef64733
@ -25,7 +25,7 @@ import _ from 'lodash';
|
|||||||
|
|
||||||
import StalenessUtils from '../../utils/staleness.js';
|
import StalenessUtils from '../../utils/staleness.js';
|
||||||
import TableRowCollection from './collections/TableRowCollection.js';
|
import TableRowCollection from './collections/TableRowCollection.js';
|
||||||
import { MODE, ORDER } from './constants.js';
|
import { MODE } from './constants.js';
|
||||||
import TelemetryTableColumn from './TelemetryTableColumn.js';
|
import TelemetryTableColumn from './TelemetryTableColumn.js';
|
||||||
import TelemetryTableConfiguration from './TelemetryTableConfiguration.js';
|
import TelemetryTableConfiguration from './TelemetryTableConfiguration.js';
|
||||||
import TelemetryTableNameColumn from './TelemetryTableNameColumn.js';
|
import TelemetryTableNameColumn from './TelemetryTableNameColumn.js';
|
||||||
@ -130,14 +130,7 @@ export default class TelemetryTable extends EventEmitter {
|
|||||||
createTableRowCollections() {
|
createTableRowCollections() {
|
||||||
this.tableRows = new TableRowCollection();
|
this.tableRows = new TableRowCollection();
|
||||||
|
|
||||||
//Fetch any persisted default sort
|
const sortOptions = this.configuration.getSortOptions();
|
||||||
let sortOptions = 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
|
|
||||||
};
|
|
||||||
|
|
||||||
this.updateRowLimit();
|
this.updateRowLimit();
|
||||||
|
|
||||||
@ -172,8 +165,8 @@ export default class TelemetryTable extends EventEmitter {
|
|||||||
|
|
||||||
this.removeTelemetryCollection(keyString);
|
this.removeTelemetryCollection(keyString);
|
||||||
|
|
||||||
let sortOptions = this.configuration.getConfiguration().sortOptions;
|
let sortOptions = this.configuration.getSortOptions();
|
||||||
requestOptions.order = sortOptions?.direction ?? ORDER.DESCENDING; // default to descending
|
requestOptions.order = sortOptions.direction;
|
||||||
|
|
||||||
if (this.telemetryMode === MODE.PERFORMANCE) {
|
if (this.telemetryMode === MODE.PERFORMANCE) {
|
||||||
requestOptions.size = this.rowLimit;
|
requestOptions.size = this.rowLimit;
|
||||||
@ -442,12 +435,13 @@ export default class TelemetryTable extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sortBy(sortOptions) {
|
sortBy(sortOptions) {
|
||||||
this.tableRows.sortBy(sortOptions);
|
this.configuration.setSortOptions(sortOptions);
|
||||||
|
|
||||||
if (this.openmct.editor.isEditing()) {
|
if (this.telemetryMode === MODE.PERFORMANCE) {
|
||||||
let configuration = this.configuration.getConfiguration();
|
this.tableRows.setSortOptions(sortOptions);
|
||||||
configuration.sortOptions = sortOptions;
|
this.clearAndResubscribe();
|
||||||
this.configuration.updateConfiguration(configuration);
|
} else {
|
||||||
|
this.tableRows.sortBy(sortOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,11 @@
|
|||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
import { ORDER } from './constants';
|
||||||
|
|
||||||
export default class TelemetryTableConfiguration extends EventEmitter {
|
export default class TelemetryTableConfiguration extends EventEmitter {
|
||||||
|
#sortOptions;
|
||||||
|
|
||||||
constructor(domainObject, openmct, options) {
|
constructor(domainObject, openmct, options) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -44,6 +48,26 @@ export default class TelemetryTableConfiguration extends EventEmitter {
|
|||||||
this.notPersistable = !this.openmct.objects.isPersistable(this.domainObject.identifier);
|
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() {
|
getConfiguration() {
|
||||||
let configuration = this.domainObject.configuration || {};
|
let configuration = this.domainObject.configuration || {};
|
||||||
configuration.hiddenColumns = configuration.hiddenColumns || {};
|
configuration.hiddenColumns = configuration.hiddenColumns || {};
|
||||||
|
@ -273,7 +273,7 @@ export default class TableRowCollection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
sortBy(sortOptions) {
|
sortBy(sortOptions) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
this.sortOptions = sortOptions;
|
this.setSortOptions(sortOptions);
|
||||||
this.rows = _.orderBy(
|
this.rows = _.orderBy(
|
||||||
this.rows,
|
this.rows,
|
||||||
(row) => row.getParsedValue(sortOptions.key),
|
(row) => row.getParsedValue(sortOptions.key),
|
||||||
@ -286,6 +286,10 @@ export default class TableRowCollection extends EventEmitter {
|
|||||||
return Object.assign({}, this.sortOptions);
|
return Object.assign({}, this.sortOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSortOptions(sortOptions) {
|
||||||
|
this.sortOptions = sortOptions;
|
||||||
|
}
|
||||||
|
|
||||||
setColumnFilter(columnKey, filter) {
|
setColumnFilter(columnKey, filter) {
|
||||||
filter = filter.trim().toLowerCase();
|
filter = filter.trim().toLowerCase();
|
||||||
let wasBlank = this.columnFilters[columnKey] === undefined;
|
let wasBlank = this.columnFilters[columnKey] === undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user