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/Collection Fixes] Clearing correctly, no mutating options, no duplicate requests #4261

Merged
merged 13 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 18 additions & 20 deletions src/api/telemetry/TelemetryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class TelemetryCollection extends EventEmitter {
this.parseTime = undefined;
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
this.unsubscribe = undefined;
this.historicalProvider = undefined;
this.options = options;
this.pageState = undefined;
this.lastBounds = undefined;
Expand All @@ -71,7 +70,7 @@ export class TelemetryCollection extends EventEmitter {
this._watchBounds();
this._watchTimeSystem();

this._initiateHistoricalRequests();
this._requestHistoricalTelemetry();
this._initiateSubscriptionTelemetry();

this.loaded = true;
Expand Down Expand Up @@ -103,41 +102,35 @@ export class TelemetryCollection extends EventEmitter {
return this.boundedTelemetry;
}

/**
* Sets up the telemetry collection for historical requests,
* this uses the "standardizeRequestOptions" from Telemetry API
* @private
*/
_initiateHistoricalRequests() {
this.openmct.telemetry.standardizeRequestOptions(this.options);
this.historicalProvider = this.openmct.telemetry.
findRequestProvider(this.domainObject, this.options);

this._requestHistoricalTelemetry();
}

/**
* If a historical provider exists, then historical requests will be made
* @private
*/
async _requestHistoricalTelemetry() {
if (!this.historicalProvider) {
let options = { ...this.options };
let historicalProvider;

this.openmct.telemetry.standardizeRequestOptions(options);
jvigliotta marked this conversation as resolved.
Show resolved Hide resolved
historicalProvider = this.openmct.telemetry.
findRequestProvider(this.domainObject, options);

if (!historicalProvider) {
return;
}

let historicalData;

this.options.onPartialResponse = this._processNewTelemetry.bind(this);
options.onPartialResponse = this._processNewTelemetry.bind(this);

try {
if (this.requestAbort) {
this.requestAbort.abort();
}

this.requestAbort = new AbortController();
this.options.signal = this.requestAbort.signal;
options.signal = this.requestAbort.signal;
this.emit('requestStarted');
historicalData = await this.historicalProvider.request(this.domainObject, this.options);
historicalData = await historicalProvider.request(this.domainObject, options);
} catch (error) {
if (error.name !== 'AbortError') {
console.error('Error requesting telemetry data...');
Expand Down Expand Up @@ -179,6 +172,10 @@ export class TelemetryCollection extends EventEmitter {
* @private
*/
_processNewTelemetry(telemetryData) {
if (telemetryData === undefined) {
return;
}

let data = Array.isArray(telemetryData) ? telemetryData : [telemetryData];
let parsedValue;
let beforeStartOfBounds;
Expand All @@ -205,9 +202,10 @@ export class TelemetryCollection extends EventEmitter {

if (endIndex > startIndex) {
let potentialDupes = this.boundedTelemetry.slice(startIndex, endIndex);

isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, datum));
}
} else if (startIndex === this.boundedTelemetry.length) {
isDuplicate = _.isEqual(datum, this.boundedTelemetry[this.boundedTelemetry.length - 1]);
}

if (!isDuplicate) {
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/timeConductor/ConductorInputsFixed.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<template>
<form ref="fixedDeltaInput"
class="c-conductor__inputs"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@submit.prevent="updateTimeFromConductor"
>
<button
ref="submitButton"
class="c-input--submit"
type="submit"
></button>
<div
class="c-ctrl-wrapper c-conductor-input c-conductor__start-fixed"
>
Expand Down Expand Up @@ -183,10 +177,7 @@ export default {
submitForm() {
// Allow Vue model to catch up to user input.
// Submitting form will cause validation messages to display (but only if triggered by button click)
this.$nextTick(() => this.$refs.submitButton.click());
},
updateTimeFromConductor() {
this.setBoundsFromView();
this.$nextTick(() => this.setBoundsFromView());
},
validateAllBounds(ref) {
if (!this.areBoundsFormatsValid()) {
Expand Down