mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
move get/set of sort options to where it should be in table configuration class
This commit is contained in:
parent
142805b827
commit
978b2ee3f9
@ -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';
|
||||
@ -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,9 @@ 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;
|
||||
|
||||
this.updateRowLimit();
|
||||
|
||||
this.tableRows.sortBy(this.sortOptions);
|
||||
this.tableRows.sortBy(this.configuration.getSortOptions());
|
||||
this.tableRows.on('resetRowsFromAllData', this.resetRowsFromAllData);
|
||||
}
|
||||
|
||||
@ -174,8 +163,7 @@ export default class TelemetryTable extends EventEmitter {
|
||||
|
||||
this.removeTelemetryCollection(keyString);
|
||||
|
||||
let sortOptions = this.configuration.getConfiguration().sortOptions;
|
||||
requestOptions.order = sortOptions?.direction ?? this.sortOptions.direction;
|
||||
requestOptions.order = this.configuration.getSortOptions().direction;
|
||||
|
||||
if (this.telemetryMode === MODE.PERFORMANCE) {
|
||||
requestOptions.size = this.rowLimit;
|
||||
@ -444,19 +432,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
@ -211,6 +215,26 @@ export default class TelemetryTableConfiguration extends EventEmitter {
|
||||
this.updateConfiguration(configuration);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.unlistenFromMutation();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user