mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 08:25:31 +00:00
Emit indices of out of order telemetry collection items (#6342)
* Emit the indices of items added by the telemetry collections * Handle added item indices for imagery
This commit is contained in:
parent
8de24a109a
commit
64f300d466
@ -180,6 +180,7 @@ export default class TelemetryCollection extends EventEmitter {
|
||||
let beforeStartOfBounds;
|
||||
let afterEndOfBounds;
|
||||
let added = [];
|
||||
let addedIndices = [];
|
||||
|
||||
// loop through, sort and dedupe
|
||||
for (let datum of data) {
|
||||
@ -212,6 +213,7 @@ export default class TelemetryCollection extends EventEmitter {
|
||||
let index = endIndex || startIndex;
|
||||
|
||||
this.boundedTelemetry.splice(index, 0, datum);
|
||||
addedIndices.push(index);
|
||||
added.push(datum);
|
||||
}
|
||||
|
||||
@ -230,7 +232,7 @@ export default class TelemetryCollection extends EventEmitter {
|
||||
this.emit('add', this.boundedTelemetry);
|
||||
}
|
||||
} else {
|
||||
this.emit('add', added);
|
||||
this.emit('add', added, addedIndices);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,7 +332,8 @@ export default class TelemetryCollection extends EventEmitter {
|
||||
this.boundedTelemetry = added;
|
||||
}
|
||||
|
||||
this.emit('add', added);
|
||||
// Assumption is that added will be of length 1 here, so just send the last index of the boundedTelemetry in the add event
|
||||
this.emit('add', added, [this.boundedTelemetry.length]);
|
||||
}
|
||||
} else {
|
||||
// user bounds change, reset
|
||||
|
@ -76,9 +76,14 @@ export default {
|
||||
this.telemetryCollection.destroy();
|
||||
},
|
||||
methods: {
|
||||
dataAdded(dataToAdd) {
|
||||
const normalizedDataToAdd = dataToAdd.map(datum => this.normalizeDatum(datum));
|
||||
this.imageHistory = this.imageHistory.concat(normalizedDataToAdd);
|
||||
dataAdded(addedItems, addedItemIndices) {
|
||||
const normalizedDataToAdd = addedItems.map(datum => this.normalizeDatum(datum));
|
||||
let newImageHistory = this.imageHistory.slice();
|
||||
normalizedDataToAdd.forEach(((datum, index) => {
|
||||
newImageHistory.splice(addedItemIndices[index] ?? -1, 0, datum);
|
||||
}));
|
||||
//Assign just once so imageHistory watchers don't get called too often
|
||||
this.imageHistory = newImageHistory;
|
||||
},
|
||||
dataCleared() {
|
||||
this.imageHistory = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user