mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 13:17:53 +00:00
Discard old telemetry values in tables when date is formatted as a string (#2400)
* Parse date values before comparison in BoundedTableRowCollection * Reset table size when filter changes
This commit is contained in:
parent
abd7506b45
commit
35d0c02bc5
@ -31,9 +31,9 @@ define(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
class BoundedTableRowCollection extends SortedTableRowCollection {
|
class BoundedTableRowCollection extends SortedTableRowCollection {
|
||||||
constructor (openmct) {
|
constructor(openmct) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.futureBuffer = new SortedTableRowCollection();
|
this.futureBuffer = new SortedTableRowCollection();
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
|
|
||||||
@ -46,12 +46,13 @@ define(
|
|||||||
openmct.time.on('bounds', this.bounds);
|
openmct.time.on('bounds', this.bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
addOne (item) {
|
addOne(item) {
|
||||||
|
let parsedValue = this.getValueForSortColumn(item);
|
||||||
// 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 = this.parseTime(item.datum[this.sortOptions.key]) < this.lastBounds.start;
|
let beforeStartOfBounds = parsedValue < this.lastBounds.start;
|
||||||
let afterEndOfBounds = this.parseTime(item.datum[this.sortOptions.key]) > this.lastBounds.end;
|
let afterEndOfBounds = parsedValue > this.lastBounds.end;
|
||||||
|
|
||||||
if (!afterEndOfBounds && !beforeStartOfBounds) {
|
if (!afterEndOfBounds && !beforeStartOfBounds) {
|
||||||
return super.addOne(item);
|
return super.addOne(item);
|
||||||
@ -86,13 +87,13 @@ define(
|
|||||||
* @fires TelemetryCollection#discarded
|
* @fires TelemetryCollection#discarded
|
||||||
* @param bounds
|
* @param bounds
|
||||||
*/
|
*/
|
||||||
bounds (bounds) {
|
bounds(bounds) {
|
||||||
let startChanged = this.lastBounds.start !== bounds.start;
|
let startChanged = this.lastBounds.start !== bounds.start;
|
||||||
let endChanged = this.lastBounds.end !== bounds.end;
|
let endChanged = this.lastBounds.end !== bounds.end;
|
||||||
|
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
let endIndex = 0;
|
let endIndex = 0;
|
||||||
|
|
||||||
let discarded = [];
|
let discarded = [];
|
||||||
let added = [];
|
let added = [];
|
||||||
let testValue = {
|
let testValue = {
|
||||||
@ -135,9 +136,13 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValueForSortColumn(row) {
|
||||||
|
return this.parseTime(row.datum[this.sortOptions.key]);
|
||||||
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.openmct.time.off('bounds', this.bounds);
|
this.openmct.time.off('bounds', this.bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BoundedTableRowCollection;
|
return BoundedTableRowCollection;
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,7 @@ define(
|
|||||||
if (rowsAdded.length > 0) {
|
if (rowsAdded.length > 0) {
|
||||||
this.emit('add', rowsAdded);
|
this.emit('add', rowsAdded);
|
||||||
}
|
}
|
||||||
this.dupeCheck = true;
|
this.dupeCheck = true;
|
||||||
} else {
|
} else {
|
||||||
let wasAdded = this.addOne(rows);
|
let wasAdded = this.addOne(rows);
|
||||||
if (wasAdded) {
|
if (wasAdded) {
|
||||||
@ -115,11 +115,10 @@ define(
|
|||||||
if (this.rows.length === 0) {
|
if (this.rows.length === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortOptionsKey = this.sortOptions.key;
|
const testRowValue = this.getValueForSortColumn(testRow);
|
||||||
const testRowValue = testRow.datum[sortOptionsKey];
|
const firstValue = this.getValueForSortColumn(this.rows[0]);
|
||||||
const firstValue = this.rows[0].datum[sortOptionsKey];
|
const lastValue = this.getValueForSortColumn(this.rows[this.rows.length - 1]);
|
||||||
const lastValue = this.rows[this.rows.length - 1].datum[sortOptionsKey];
|
|
||||||
|
|
||||||
lodashFunction = lodashFunction || _.sortedIndex;
|
lodashFunction = lodashFunction || _.sortedIndex;
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ define(
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return lodashFunction(rows, testRow, (thisRow) => {
|
return lodashFunction(rows, testRow, (thisRow) => {
|
||||||
return thisRow.datum[sortOptionsKey];
|
return this.getValueForSortColumn(thisRow);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -147,7 +146,7 @@ define(
|
|||||||
} 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) => {
|
||||||
const thisRowValue = thisRow.datum[sortOptionsKey];
|
const thisRowValue = this.getValueForSortColumn(thisRow);
|
||||||
if (testRowValue === thisRowValue) {
|
if (testRowValue === thisRowValue) {
|
||||||
return EQUAL;
|
return EQUAL;
|
||||||
} else if (testRowValue < thisRowValue) {
|
} else if (testRowValue < thisRowValue) {
|
||||||
@ -206,7 +205,7 @@ define(
|
|||||||
this.emit('sort');
|
this.emit('sort');
|
||||||
}
|
}
|
||||||
// Return duplicate to avoid direct modification of underlying object
|
// Return duplicate to avoid direct modification of underlying object
|
||||||
return Object.assign({}, this.sortOptions);
|
return Object.assign({}, this.sortOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAllRowsForObject(objectKeyString) {
|
removeAllRowsForObject(objectKeyString) {
|
||||||
@ -218,25 +217,32 @@ define(
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.emit('remove', removed);
|
this.emit('remove', removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValueForSortColumn(row) {
|
||||||
|
return row.datum[this.sortOptions.key];
|
||||||
|
}
|
||||||
|
|
||||||
remove(removedRows) {
|
remove(removedRows) {
|
||||||
this.rows = this.rows.filter(row => {
|
this.rows = this.rows.filter(row => {
|
||||||
return removedRows.indexOf(row) === -1;
|
return removedRows.indexOf(row) === -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.emit('remove', removedRows);
|
this.emit('remove', removedRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRows () {
|
getRows() {
|
||||||
return this.rows;
|
return this.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
let removedRows = this.rows;
|
let removedRows = this.rows;
|
||||||
this.rows = [];
|
this.rows = [];
|
||||||
|
|
||||||
this.emit('remove', removedRows);
|
this.emit('remove', removedRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SortedTableRowCollection;
|
return SortedTableRowCollection;
|
||||||
});
|
});
|
||||||
|
@ -472,10 +472,12 @@ export default {
|
|||||||
},
|
},
|
||||||
filterChanged(columnKey) {
|
filterChanged(columnKey) {
|
||||||
this.table.filteredRows.setColumnFilter(columnKey, this.filters[columnKey]);
|
this.table.filteredRows.setColumnFilter(columnKey, this.filters[columnKey]);
|
||||||
|
this.setHeight();
|
||||||
},
|
},
|
||||||
clearFilter(columnKey) {
|
clearFilter(columnKey) {
|
||||||
this.filters[columnKey] = '';
|
this.filters[columnKey] = '';
|
||||||
this.table.filteredRows.setColumnFilter(columnKey, '');
|
this.table.filteredRows.setColumnFilter(columnKey, '');
|
||||||
|
this.setHeight();
|
||||||
},
|
},
|
||||||
rowsAdded (rows) {
|
rowsAdded (rows) {
|
||||||
this.setHeight();
|
this.setHeight();
|
||||||
|
Loading…
Reference in New Issue
Block a user