Tables - Maintain stable sort. Requery for historical data on time system change. Parse telemetry time values before comparing to bounds. (#2322)

This commit is contained in:
Andrew Henry 2019-03-21 11:00:48 -07:00 committed by Deep Tailor
parent 019d108bb2
commit 7ff5febae0
3 changed files with 15 additions and 6 deletions

View File

@ -60,6 +60,7 @@ define([
this.createTableRowCollections(); this.createTableRowCollections();
openmct.time.on('bounds', this.refreshData); openmct.time.on('bounds', this.refreshData);
openmct.time.on('timeSystem', this.refreshData);
} }
initialize() { initialize() {
@ -166,6 +167,7 @@ define([
if (!isTick) { if (!isTick) {
this.filteredRows.clear(); this.filteredRows.clear();
this.boundedRows.clear(); this.boundedRows.clear();
this.boundedRows.sortByTimeSystem(this.openmct.time.timeSystem());
this.telemetryObjects.forEach(this.requestDataFor); this.telemetryObjects.forEach(this.requestDataFor);
} }
} }
@ -213,6 +215,7 @@ define([
this.filteredRows.destroy(); this.filteredRows.destroy();
Object.keys(this.subscriptions).forEach(this.unsubscribe, this); Object.keys(this.subscriptions).forEach(this.unsubscribe, this);
this.openmct.time.off('bounds', this.refreshData); this.openmct.time.off('bounds', this.refreshData);
this.openmct.time.on('timeSystem', this.refreshData);
if (this.filterObserver) { if (this.filterObserver) {
this.filterObserver(); this.filterObserver();
} }

View File

@ -41,7 +41,6 @@ define(
this.bounds = this.bounds.bind(this) this.bounds = this.bounds.bind(this)
this.sortByTimeSystem(openmct.time.timeSystem()); this.sortByTimeSystem(openmct.time.timeSystem());
openmct.time.on('timeSystem', this.sortByTimeSystem);
this.lastBounds = openmct.time.bounds(); this.lastBounds = openmct.time.bounds();
openmct.time.on('bounds', this.bounds); openmct.time.on('bounds', this.bounds);
@ -51,8 +50,8 @@ define(
// Insert into either in-bounds array, or the future buffer. // Insert into either in-bounds array, or the future buffer.
// Data in the future buffer will be re-evaluated for possible // Data in the future buffer will be re-evaluated for possible
// insertion on next bounds change // insertion on next bounds change
let beforeStartOfBounds = item.datum[this.sortOptions.key] < this.lastBounds.start; let beforeStartOfBounds = this.parseTime(item.datum[this.sortOptions.key]) < this.lastBounds.start;
let afterEndOfBounds = item.datum[this.sortOptions.key] > this.lastBounds.end; let afterEndOfBounds = this.parseTime(item.datum[this.sortOptions.key]) > this.lastBounds.end;
if (!afterEndOfBounds && !beforeStartOfBounds) { if (!afterEndOfBounds && !beforeStartOfBounds) {
return super.addOne(item); return super.addOne(item);
@ -64,6 +63,12 @@ define(
sortByTimeSystem(timeSystem) { sortByTimeSystem(timeSystem) {
this.sortBy({key: timeSystem.key, direction: 'asc'}); this.sortBy({key: timeSystem.key, direction: 'asc'});
let formatter = this.openmct.telemetry.getValueFormatter({
key: timeSystem.key,
source: timeSystem.key,
format: timeSystem.timeFormat
});
this.parseTime = formatter.parse.bind(formatter);
this.futureBuffer.sortBy({key: timeSystem.key, direction: 'asc'}); this.futureBuffer.sortBy({key: timeSystem.key, direction: 'asc'});
} }
@ -131,7 +136,6 @@ define(
} }
destroy() { destroy() {
this.openmct.time.off('timeSystem', this.sortByTimeSystem);
this.openmct.time.off('bounds', this.bounds); this.openmct.time.off('bounds', this.bounds);
} }
} }

View File

@ -127,7 +127,8 @@ define(
if (testRowValue > lastValue) { if (testRowValue > lastValue) {
return this.rows.length; return this.rows.length;
} else if (testRowValue === lastValue) { } else if (testRowValue === lastValue) {
return this.rows.length - 1; // Maintain stable sort
return this.rows.length;
} else if (testRowValue <= firstValue) { } else if (testRowValue <= firstValue) {
return 0; return 0;
} else { } else {
@ -141,7 +142,8 @@ define(
} else if (testRowValue < lastValue) { } else if (testRowValue < lastValue) {
return this.rows.length; return this.rows.length;
} else if (testRowValue === lastValue) { } else if (testRowValue === lastValue) {
return this.rows.length - 1; // Maintain stable sort
return this.rows.length;
} else { } else {
// Use a custom comparison function to support descending sort. // Use a custom comparison function to support descending sort.
return lodashFunction(rows, testRow, (thisRow) => { return lodashFunction(rows, testRow, (thisRow) => {