Skip to content

Commit 4415fe7

Browse files
davetsayozyxcharlesh88akhenry
authored
Fix complex displays not loading (nasa#7858)
Clock * pass in default timeContext in request options * observe for clock tick, instead of polling, to determine if clock has time set Progress Bars * use scale instead of move animation Plan * use a ResizeObserver instead of polling for size changes --------- Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov> Co-authored-by: Charles Hacskaylo <charlesh88@gmail.com> Co-authored-by: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Co-authored-by: Andrew Henry <akhenry@gmail.com>
1 parent 83e4a12 commit 4415fe7

File tree

8 files changed

+84
-55
lines changed

8 files changed

+84
-55
lines changed

src/api/telemetry/TelemetryAPI.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,26 +231,20 @@ export default class TelemetryAPI {
231231
* @returns {TelemetryRequestOptions} the options, with defaults filled in
232232
*/
233233
standardizeRequestOptions(options = {}) {
234-
if (!Object.hasOwn(options, 'start')) {
235-
const bounds = options.timeContext?.getBounds();
236-
if (bounds?.start) {
237-
options.start = options.timeContext.getBounds().start;
238-
} else {
239-
options.start = this.openmct.time.getBounds().start;
240-
}
234+
if (!Object.hasOwn(options, 'timeContext')) {
235+
options.timeContext = this.openmct.time;
241236
}
242237

243-
if (!Object.hasOwn(options, 'end')) {
244-
const bounds = options.timeContext?.getBounds();
245-
if (bounds?.end) {
246-
options.end = options.timeContext.getBounds().end;
247-
} else {
248-
options.end = this.openmct.time.getBounds().end;
249-
}
238+
if (!Object.hasOwn(options, 'domain')) {
239+
options.domain = options.timeContext.getTimeSystem().key;
250240
}
251241

252-
if (!Object.hasOwn(options, 'domain')) {
253-
options.domain = this.openmct.time.getTimeSystem().key;
242+
if (!Object.hasOwn(options, 'start')) {
243+
options.start = options.timeContext.getBounds().start;
244+
}
245+
246+
if (!Object.hasOwn(options, 'end')) {
247+
options.end = options.timeContext.getBounds().end;
254248
}
255249

256250
return options;

src/api/telemetry/TelemetryAPISpec.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,36 +269,40 @@ describe('Telemetry API', () => {
269269

270270
await telemetryAPI.request(domainObject);
271271
const { signal } = new AbortController();
272-
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(jasmine.any(Object), {
272+
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(domainObject, {
273273
signal,
274274
start: 0,
275275
end: 1,
276-
domain: 'system'
276+
domain: 'system',
277+
timeContext: openmct.time
277278
});
278279

279-
expect(telemetryProvider.request).toHaveBeenCalledWith(jasmine.any(Object), {
280+
expect(telemetryProvider.request).toHaveBeenCalledWith(domainObject, {
280281
signal,
281282
start: 0,
282283
end: 1,
283-
domain: 'system'
284+
domain: 'system',
285+
timeContext: openmct.time
284286
});
285287

286288
telemetryProvider.supportsRequest.calls.reset();
287289
telemetryProvider.request.calls.reset();
288290

289291
await telemetryAPI.request(domainObject, {});
290-
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(jasmine.any(Object), {
292+
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(domainObject, {
291293
signal,
292294
start: 0,
293295
end: 1,
294-
domain: 'system'
296+
domain: 'system',
297+
timeContext: openmct.time
295298
});
296299

297-
expect(telemetryProvider.request).toHaveBeenCalledWith(jasmine.any(Object), {
300+
expect(telemetryProvider.request).toHaveBeenCalledWith(domainObject, {
298301
signal,
299302
start: 0,
300303
end: 1,
301-
domain: 'system'
304+
domain: 'system',
305+
timeContext: openmct.time
302306
});
303307
});
304308

@@ -313,18 +317,20 @@ describe('Telemetry API', () => {
313317
domain: 'someDomain'
314318
});
315319
const { signal } = new AbortController();
316-
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(jasmine.any(Object), {
320+
expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith(domainObject, {
317321
start: 20,
318322
end: 30,
319323
domain: 'someDomain',
320-
signal
324+
signal,
325+
timeContext: openmct.time
321326
});
322327

323-
expect(telemetryProvider.request).toHaveBeenCalledWith(jasmine.any(Object), {
328+
expect(telemetryProvider.request).toHaveBeenCalledWith(domainObject, {
324329
start: 20,
325330
end: 30,
326331
domain: 'someDomain',
327-
signal
332+
signal,
333+
timeContext: openmct.time
328334
});
329335
});
330336
describe('telemetry batching support', () => {

src/api/telemetry/TelemetryCollection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ export default class TelemetryCollection extends EventEmitter {
6262
this.futureBuffer = [];
6363
this.parseTime = undefined;
6464
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
65-
if (!Object.hasOwn(options, 'timeContext')) {
66-
options.timeContext = this.openmct.time;
67-
}
6865
this.options = options;
6966
this.unsubscribe = undefined;
7067
this.pageState = undefined;
@@ -84,6 +81,9 @@ export default class TelemetryCollection extends EventEmitter {
8481
this._error(LOADED_ERROR);
8582
}
8683

84+
if (!Object.hasOwn(this.options, 'timeContext')) {
85+
this.options.timeContext = this.openmct.time;
86+
}
8787
this._setTimeSystem(this.options.timeContext.getTimeSystem());
8888
this.lastBounds = this.options.timeContext.getBounds();
8989
this._watchBounds();
@@ -127,7 +127,7 @@ export default class TelemetryCollection extends EventEmitter {
127127
* @private
128128
*/
129129
async _requestHistoricalTelemetry() {
130-
let options = this.openmct.telemetry.standardizeRequestOptions({ ...this.options });
130+
const options = this.openmct.telemetry.standardizeRequestOptions({ ...this.options });
131131
const historicalProvider = this.openmct.telemetry.findRequestProvider(
132132
this.domainObject,
133133
options

src/plugins/plan/components/PlanView.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const INNER_TEXT_PADDING = 15;
6969
const TEXT_LEFT_PADDING = 5;
7070
const ROW_PADDING = 5;
7171
const SWIMLANE_PADDING = 3;
72-
const RESIZE_POLL_INTERVAL = 200;
7372
const ROW_HEIGHT = 22;
7473
const MAX_TEXT_WIDTH = 300;
7574
const MIN_ACTIVITY_WIDTH = 2;
@@ -143,13 +142,15 @@ export default {
143142
this.canvasContext = canvas.getContext('2d');
144143
this.setDimensions();
145144
this.setTimeContext();
146-
this.resizeTimer = setInterval(this.resize, RESIZE_POLL_INTERVAL);
147145
this.handleConfigurationChange(this.configuration);
148146
this.planViewConfiguration.on('change', this.handleConfigurationChange);
149147
this.loadComposition();
148+
149+
this.resizeObserver = new ResizeObserver(this.resize);
150+
this.resizeObserver.observe(this.$refs.plan);
150151
},
151152
beforeUnmount() {
152-
clearInterval(this.resizeTimer);
153+
this.resizeObserver.disconnect();
153154
this.stopFollowingTimeContext();
154155
if (this.unlisten) {
155156
this.unlisten();

src/plugins/remoteClock/RemoteClock.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,18 @@ export default class RemoteClock extends DefaultClock {
152152
*/
153153
#waitForReady() {
154154
const waitForInitialTick = (resolve) => {
155-
if (this.lastTick > 0) {
156-
const offsets = this.openmct.time.getClockOffsets();
157-
resolve({
158-
start: this.lastTick + offsets.start,
159-
end: this.lastTick + offsets.end
160-
});
161-
} else {
162-
setTimeout(() => waitForInitialTick(resolve), 100);
163-
}
155+
const tickListener = () => {
156+
if (this.lastTick > 0) {
157+
const offsets = this.openmct.time.getClockOffsets();
158+
this.openmct.time.off('tick', tickListener); // Unregister the tick listener
159+
resolve({
160+
start: this.lastTick + offsets.start,
161+
end: this.lastTick + offsets.end
162+
});
163+
}
164+
};
165+
166+
this.openmct.time.on('tick', tickListener);
164167
};
165168

166169
return new Promise(waitForInitialTick);

src/plugins/remoteClock/requestInterceptor.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,43 @@
2020
* at runtime from the About dialog for additional information.
2121
*****************************************************************************/
2222

23+
/**
24+
* Intercepts requests to ensure the remote clock is ready.
25+
*
26+
* @param {import('../../openmct').OpenMCT} openmct - The OpenMCT instance.
27+
* @param {import('../../openmct').Identifier} _remoteClockIdentifier - The identifier for the remote clock.
28+
* @param {Function} waitForBounds - A function that returns a promise resolving to the initial bounds.
29+
* @returns {Object} The request interceptor.
30+
*/
2331
function remoteClockRequestInterceptor(openmct, _remoteClockIdentifier, waitForBounds) {
2432
let remoteClockLoaded = false;
2533

2634
return {
27-
appliesTo: () => {
35+
/**
36+
* Determines if the interceptor applies to the given request.
37+
*
38+
* @param {Object} _ - Unused parameter.
39+
* @param {import('../../api/telemetry/TelemetryAPI').TelemetryRequestOptions} request - The request object.
40+
* @returns {boolean} True if the interceptor applies, false otherwise.
41+
*/
42+
appliesTo: (_, request) => {
2843
// Get the activeClock from the Global Time Context
44+
/** @type {import("../../api/time/TimeContext").default} */
2945
const { activeClock } = openmct.time;
3046

47+
// this type of request does not rely on clock having bounds
48+
if (request.strategy === 'latest' && request.timeContext.isRealTime()) {
49+
return false;
50+
}
51+
3152
return activeClock?.key === 'remote-clock' && !remoteClockLoaded;
3253
},
54+
/**
55+
* Invokes the interceptor to modify the request.
56+
*
57+
* @param {Object} request - The request object.
58+
* @returns {Promise<Object>} The modified request object.
59+
*/
3360
invoke: async (request) => {
3461
const timeContext = request?.timeContext ?? openmct.time;
3562

src/plugins/timeConductor/ConductorInputsRealtime.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default {
150150
mounted() {
151151
this.handleNewBounds = _.throttle(this.handleNewBounds, 300, {
152152
leading: true,
153-
trailing: false
153+
trailing: true
154154
});
155155
this.setTimeSystem(this.copy(this.openmct.time.getTimeSystem()));
156156
this.openmct.time.on(TIME_CONTEXT_EVENTS.timeSystemChanged, this.setTimeSystem);
@@ -181,6 +181,8 @@ export default {
181181
}
182182
},
183183
stopFollowingTime() {
184+
this.handleNewBounds.cancel();
185+
184186
if (this.timeContext) {
185187
this.timeContext.off(TIME_CONTEXT_EVENTS.boundsChanged, this.handleNewBounds);
186188
this.timeContext.off(TIME_CONTEXT_EVENTS.clockOffsetsChanged, this.setViewFromOffsets);

src/ui/components/progress-bar.scss

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
/******************************************************** PROGRESS BAR */
22
@keyframes progressIndeterminate {
33
0% {
4-
left: 0;
5-
width: 0;
4+
transform:scaleX(0);
65
}
7-
70% {
8-
left: 0;
9-
width: 100%;
6+
90% {
7+
transform:scaleX(1);
108
opacity: 1;
119
}
1210
100% {
13-
left: 100%;
1411
opacity: 0;
1512
}
1613
}
@@ -24,11 +21,10 @@
2421

2522
&__bar {
2623
background: $colorProgressBar;
27-
height: 100%;
28-
min-height: $progressBarMinH;
24+
transform-origin: left;
2925

3026
&.--indeterminate {
31-
position: absolute;
27+
@include abs();
3228
animation: progressIndeterminate 1.5s ease-in infinite;
3329
}
3430
}

0 commit comments

Comments
 (0)