Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table performance paging #7399

Merged
merged 26 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba476d6
dereactifying the row before passing it to the commponent
jvigliotta Dec 14, 2023
c408530
debouncin
jvigliotta Dec 14, 2023
fbe1a68
i mean... throttle
jvigliotta Dec 14, 2023
c5761c1
initial
jvigliotta Jan 4, 2024
6c53b77
UI functionality, switching between modes, prevention of export in pe…
jvigliotta Jan 16, 2024
46f897f
added limit maintenance in table row collectins, autoscroll respectin…
jvigliotta Jan 17, 2024
cdc3f6b
updating the logic to work correctly :)
jvigliotta Jan 19, 2024
fdd3cb4
added handling for overflow rows, this way if an object is removed, w…
jvigliotta Jan 23, 2024
395a735
removing debug row numbers
jvigliotta Jan 23, 2024
46d72ad
Merge branch 'master' into table-performance-paging
jvigliotta Jan 23, 2024
08c3b14
Merge branch 'master' into table-performance-paging
jvigliotta Jan 23, 2024
d9629db
Closes #7268
charlesh88 Jan 24, 2024
6fbdf7f
Closes #7268
charlesh88 Jan 24, 2024
10b559d
moved row limiting out of table row collections and into telemetry co…
jvigliotta Jan 25, 2024
2639ab2
have swgs return enough data to fill the requested bounds
jvigliotta Jan 25, 2024
7693c70
support minmax in swgs
jvigliotta Jan 25, 2024
00fa2d5
using undefined for more clarity
jvigliotta Jan 25, 2024
2efadaf
clearing up boolean typo
jvigliotta Jan 25, 2024
6fc0022
Merge branch 'master' into table-performance-paging
jvigliotta Jan 26, 2024
088f948
Merge branch 'master' of https://github.com/nasa/openmct into table-p…
unlikelyzero Jan 26, 2024
e185270
Address lint fixes
unlikelyzero Jan 26, 2024
a922578
removing autoscroll for descending, it is not necessary
jvigliotta Jan 26, 2024
adc8ba8
Merge branch 'table-performance-paging' of https://github.com/nasa/op…
jvigliotta Jan 26, 2024
c623d01
update snapshots
unlikelyzero Jan 26, 2024
fdd390d
Merge branch 'table-performance-paging' of https://github.com/nasa/op…
unlikelyzero Jan 26, 2024
ff0d393
lint
unlikelyzero Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example/generator/GeneratorProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ GeneratorProvider.prototype.request = function (domainObject, request) {
var workerRequest = this.makeWorkerRequest(domainObject, request);
workerRequest.start = request.start;
workerRequest.end = request.end;
workerRequest.size = request.size;
workerRequest.strategy = request.strategy;

return this.workerInterface.request(workerRequest);
};
Expand Down
86 changes: 52 additions & 34 deletions example/generator/generatorWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,48 +130,37 @@
var now = Date.now();
var start = request.start;
var end = request.end > now ? now : request.end;
var amplitude = request.amplitude;
var period = request.period;
var offset = request.offset;
var dataRateInHz = request.dataRateInHz;
var phase = request.phase;
var randomness = request.randomness;
var loadDelay = Math.max(request.loadDelay, 0);
var infinityValues = request.infinityValues;
var exceedFloat32 = request.exceedFloat32;

var size = request.size;
var duration = end - start;
var step = 1000 / dataRateInHz;
var maxPoints = Math.floor(duration / step);
var nextStep = start - (start % step) + step;

var data = [];

for (; nextStep < end && data.length < 5000; nextStep += step) {
data.push({
utc: nextStep,
yesterday: nextStep - 60 * 60 * 24 * 1000,
sin: sin(
nextStep,
period,
amplitude,
offset,
phase,
randomness,
infinityValues,
exceedFloat32
),
wavelengths: wavelengths(),
intensities: intensities(),
cos: cos(
nextStep,
period,
amplitude,
offset,
phase,
randomness,
infinityValues,
exceedFloat32
)
});
if (request.strategy === 'minmax' && size) {
// Calculate the number of cycles to include based on size (2 points per cycle)
var totalCycles = Math.min(Math.floor(size / 2), Math.floor(duration / period));

for (let cycle = 0; cycle < totalCycles; cycle++) {
// Distribute cycles evenly across the time range
let cycleStart = start + (duration / totalCycles) * cycle;
let minPointTime = cycleStart; // Assuming min at the start of the cycle
let maxPointTime = cycleStart + period / 2; // Assuming max at the halfway of the cycle

data.push(createDataPoint(minPointTime, request), createDataPoint(maxPointTime, request));
}
} else {
for (let i = 0; i < maxPoints && nextStep < end; i++, nextStep += step) {
data.push(createDataPoint(nextStep, request));
}
}

if (!request.strategy === 'minmax' && size) {
data = data.slice(-size);
}

if (loadDelay === 0) {
Expand All @@ -181,6 +170,35 @@
}
}

function createDataPoint(time, request) {
return {
utc: time,
yesterday: time - 60 * 60 * 24 * 1000,
sin: sin(
time,
request.period,
request.amplitude,
request.offset,
request.phase,
request.randomness,
request.infinityValues,
request.exceedFloat32
),
wavelengths: wavelengths(),
intensities: intensities(),
cos: cos(
time,
request.period,
request.amplitude,
request.offset,
request.phase,
request.randomness,
request.infinityValues,
request.exceedFloat32
)
};
}

function postOnRequest(message, request, data) {
self.postMessage({
id: message.id,
Expand Down
9 changes: 9 additions & 0 deletions src/api/telemetry/TelemetryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
let added = [];
let addedIndices = [];
let hasDataBeforeStartBound = false;
let size = this.options.size;
let enforceSize = size !== undefined && this.options.enforceSize;

// loop through, sort and dedupe
for (let datum of data) {
Expand Down Expand Up @@ -271,6 +273,13 @@
}
} else {
this.emit('add', added, addedIndices);

if (enforceSize && this.boundedTelemetry.length > size) {
const removeCount = this.boundedTelemetry.length - size;
const removed = this.boundedTelemetry.splice(0, removeCount);

Check warning on line 279 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L278-L279

Added lines #L278 - L279 were not covered by tests

this.emit('remove', removed);

Check warning on line 281 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L281

Added line #L281 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is a simple way of enforcing size with a small change

}
}
}
}
Expand Down
34 changes: 31 additions & 3 deletions src/plugins/telemetryTable/TelemetryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@

this.domainObject = domainObject;
this.openmct = openmct;
this.rowCount = 100;
this.tableComposition = undefined;
this.datumCache = [];
this.configuration = new TelemetryTableConfiguration(domainObject, openmct);
this.telemetryMode = this.configuration.getTelemetryMode();
this.rowLimit = this.configuration.getRowLimit();
this.paused = false;
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);

Expand Down Expand Up @@ -101,18 +102,40 @@
}
}

updateTelemetryMode(mode) {
if (this.telemetryMode === mode) {
return;

Check warning on line 107 in src/plugins/telemetryTable/TelemetryTable.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTable.js#L106-L107

Added lines #L106 - L107 were not covered by tests
}

this.telemetryMode = mode;

Check warning on line 110 in src/plugins/telemetryTable/TelemetryTable.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTable.js#L110

Added line #L110 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing is a little weird here. Did prettier demand it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea on autosave

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats how i would have wrote it... hehe


this.updateRowLimit();

Check warning on line 112 in src/plugins/telemetryTable/TelemetryTable.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTable.js#L112

Added line #L112 was not covered by tests

this.clearAndResubscribe();

Check warning on line 114 in src/plugins/telemetryTable/TelemetryTable.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTable.js#L114

Added line #L114 was not covered by tests
}

updateRowLimit() {
if (this.telemetryMode === 'performance') {
this.tableRows.setLimit(this.rowLimit);
} else {
this.tableRows.removeLimit();
}
}

createTableRowCollections() {
this.tableRows = new TableRowCollection();

//Fetch any persisted default sort
let sortOptions = this.configuration.getConfiguration().sortOptions;

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

this.updateRowLimit();

this.tableRows.sortBy(sortOptions);
this.tableRows.on('resetRowsFromAllData', this.resetRowsFromAllData);
}
Expand Down Expand Up @@ -144,6 +167,11 @@

this.removeTelemetryCollection(keyString);

if (this.telemetryMode === 'performance') {
requestOptions.size = this.rowLimit;
requestOptions.enforceSize = true;

Check warning on line 172 in src/plugins/telemetryTable/TelemetryTable.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTable.js#L171-L172

Added lines #L171 - L172 were not covered by tests
}

this.telemetryCollections[keyString] = this.openmct.telemetry.requestCollection(
telemetryObject,
requestOptions
Expand Down
40 changes: 40 additions & 0 deletions src/plugins/telemetryTable/TelemetryTableConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
configuration.columnOrder = configuration.columnOrder || [];
configuration.cellFormat = configuration.cellFormat || {};
configuration.autosize = configuration.autosize === undefined ? true : configuration.autosize;
// anything that doesn't have a telemetryMode existed before the change and should stay as it was for consistency
configuration.telemetryMode = configuration.telemetryMode ?? 'unlimited';
configuration.persistModeChange = configuration.persistModeChange ?? true;
configuration.rowLimit = configuration.rowLimit ?? 50;

return configuration;
}
Expand Down Expand Up @@ -136,6 +140,42 @@
return headers;
}, {});
}

getTelemetryMode() {
let configuration = this.getConfiguration();

return configuration.telemetryMode;
}

setTelemetryMode(mode) {
let configuration = this.getConfiguration();
configuration.telemetryMode = mode;
this.updateConfiguration(configuration);

Check warning on line 153 in src/plugins/telemetryTable/TelemetryTableConfiguration.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTableConfiguration.js#L151-L153

Added lines #L151 - L153 were not covered by tests
}

getRowLimit() {
let configuration = this.getConfiguration();

return configuration.rowLimit;
}

setRowLimit(limit) {
let configuration = this.getConfiguration();
configuration.rowLimit = limit;
this.updateConfiguration(configuration);

Check warning on line 165 in src/plugins/telemetryTable/TelemetryTableConfiguration.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTableConfiguration.js#L163-L165

Added lines #L163 - L165 were not covered by tests
}

getPersistModeChange() {
let configuration = this.getConfiguration();

Check warning on line 169 in src/plugins/telemetryTable/TelemetryTableConfiguration.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTableConfiguration.js#L169

Added line #L169 was not covered by tests

return configuration.persistModeChange;

Check warning on line 171 in src/plugins/telemetryTable/TelemetryTableConfiguration.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTableConfiguration.js#L171

Added line #L171 was not covered by tests
}

setPersistModeChange(value) {
let configuration = this.getConfiguration();
configuration.persistModeChange = value;
this.updateConfiguration(configuration);

Check warning on line 177 in src/plugins/telemetryTable/TelemetryTableConfiguration.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/telemetryTable/TelemetryTableConfiguration.js#L175-L177

Added lines #L175 - L177 were not covered by tests
}

getColumnWidths() {
let configuration = this.getConfiguration();
Expand Down
68 changes: 54 additions & 14 deletions src/plugins/telemetryTable/TelemetryTableType.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,57 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/

export default {
name: 'Telemetry Table',
description:
'Display values for one or more telemetry end points in a scrolling table. Each row is a time-stamped value.',
creatable: true,
cssClass: 'icon-tabular-scrolling',
initialize(domainObject) {
domainObject.composition = [];
domainObject.configuration = {
columnWidths: {},
hiddenColumns: {}
};
}
};
export default function getTelemetryTableType(options = {}) {
const { telemetryMode = 'performance', persistModeChanges = true, rowLimit = 50 } = options;

return {
name: 'Telemetry Table',
description:
'Display values for one or more telemetry end points in a scrolling table. Each row is a time-stamped value.',
creatable: true,
cssClass: 'icon-tabular-scrolling',
form: [
{
key: 'telemetryMode',
name: 'Telemetry Mode',
control: 'select',
options: [
{
value: 'performance',
name: 'Performance Mode'
},
{
value: 'unlimited',
name: 'Unlimited Mode'
}
],
cssClass: 'l-inline',
property: ['configuration', 'telemetryMode']
},
{
name: 'Persist Telemetry Mode Changes',
control: 'toggleSwitch',
cssClass: 'l-input',
key: 'persistModeChanges',
property: ['configuration', 'persistModeChanges']
},
{
name: 'Performance Mode Row Limit',
control: 'toggleSwitch',
cssClass: 'l-input',
key: 'rowLimit',
property: ['configuration', 'rowLimit']
}
],
initialize(domainObject) {
domainObject.composition = [];
domainObject.configuration = {
columnWidths: {},
hiddenColumns: {},
telemetryMode,
persistModeChanges,
rowLimit
};
}
};
}
2 changes: 1 addition & 1 deletion src/plugins/telemetryTable/TelemetryTableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import TableComponent from './components/TableComponent.vue';
import TelemetryTable from './TelemetryTable.js';

export default class TelemetryTableView {
constructor(openmct, domainObject, objectPath) {
constructor(openmct, domainObject, objectPath, options) {
this.openmct = openmct;
this.domainObject = domainObject;
this.objectPath = objectPath;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/telemetryTable/TelemetryTableViewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import TelemetryTableView from './TelemetryTableView.js';

export default function TelemetryTableViewProvider(openmct) {
export default function TelemetryTableViewProvider(openmct, options) {
function hasTelemetry(domainObject) {
if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) {
return false;
Expand All @@ -44,7 +44,7 @@ export default function TelemetryTableViewProvider(openmct) {
return domainObject.type === 'table';
},
view(domainObject, objectPath) {
return new TelemetryTableView(openmct, domainObject, objectPath);
return new TelemetryTableView(openmct, domainObject, objectPath, options);
},
priority() {
return 1;
Expand Down
Loading
Loading