Skip to content

Commit

Permalink
[Channel Tables] Preserve order of channels (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvigliotta authored May 17, 2023
1 parent 96690f4 commit e8846d3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
4 changes: 4 additions & 0 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ define([
aboutHtml: insertBuildInfo(AboutTemplate),
});

// do not show telemetry if it falls out of bounds
// even if there is no new telemetry
openmct.telemetry.greedyLAD(false);

persistenceLoadedPromise.then(() => {
openmct.start();
window.openmct = openmct;
Expand Down
11 changes: 4 additions & 7 deletions src/channelTable/channelTablePlugin/ChannelTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ define([
this.tableRows = new ChannelTableRowCollection(this.openmct);

let sortOptions = this.configuration.getConfiguration().sortOptions;

//If no persisted sort order, default to sorting by time system, ascending.
sortOptions = sortOptions || {
key: this.openmct.time.timeSystem().key,
direction: 'asc'
};

this.tableRows.sortBy(sortOptions);
if (sortOptions) {
this.tableRows.sortBy(sortOptions);
}

this.tableRows.on('resetRowsFromAllData', this.resetRowsFromAllData);
}

Expand Down
35 changes: 29 additions & 6 deletions src/channelTable/channelTablePlugin/ChannelTableRowCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ define(

addOrUpdateRow(row) {
if (this.isLADRow(row)) {
this.removeRowsByObject(row.objectKeyString);
super.addRows([row], 'add');
this.addRows([row]);
}
}

Expand All @@ -38,7 +37,7 @@ define(
return !isStaleData;
}

addOne (item) {
addOne(item) {
if (item.isDummyRow) {
this.ladMap.set(item.objectKeyString, this.rows.length);
this.rows.push(item);
Expand All @@ -48,28 +47,52 @@ define(

if (this.isNewerThanLAD(item)) {
let rowIndex = this.ladMap.get(item.objectKeyString);
let itemToReplace = this.rows[rowIndex];
this.rows[rowIndex] = item;
this.emit('remove', [itemToReplace]);
this.removeExistingByKeystring(item.objectKeyString);
this.emit('add', [item]);
return true;
}
return false;
}

addRows(rows) {
let rowsToAdd = this.filterRows(rows);

if (rowsToAdd.length > 0) {
rowsToAdd.forEach(this.addOne.bind(this));
this.emit('add', rowsToAdd);
}
}

removeAllRowsForObject(objectKeyString) {
super.removeAllRowsForObject(objectKeyString);
this.rebuildLadMap();
}

removeExistingByKeystring(keyString) {
let removed = [];

this.rows.forEach((row) => {
if (row.objectKeyString === keyString) {
removed.push(row);

return false;
} else {
return true;
}
});

this.emit('remove', removed);
}

rebuildLadMap() {
this.ladMap.clear();
this.rows.forEach((row, index) => {
this.ladMap.set(row.objectKeyString, index);
});
}

reorder (reorderPlan) {
reorder(reorderPlan) {
let oldRows = this.rows.slice();
reorderPlan.forEach(reorderEvent => {
let item = oldRows[reorderEvent.oldIndex];
Expand Down
3 changes: 1 addition & 2 deletions src/services/mcws/MIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ export default class MIO {
}

async getMetadata() {
const response = await this.request(this.metadataUrl, 'GET', { output: 'json' });
const metadataResponse = await response.json();
const metadataResponse = await this.request(this.metadataUrl, 'GET', { output: 'json' });

return {
get(subject, predicate) {
Expand Down

0 comments on commit e8846d3

Please sign in to comment.