Compare commits

...

6 Commits

Author SHA1 Message Date
9a5f8ce82f Merge branch 'release/2.0.5' into plots-fix-initialize 2022-07-07 19:38:04 -07:00
063df721ae [Remote Clock] Wait for first tick and recalculate historical request bounds (#5433)
* Updated to ES6 class
* added request intercept functionality to telemetry api, added a request interceptor for remote clock
* add remoteClock e2e test stub

Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-07-07 23:51:12 +00:00
a09db30b32 Allow endpoints with a single enum metadata value in Bar/Line graphs (#5443)
* If there is only 1 metadata value, set yKey to none. Also, fix bug for determining the name of a metadata value
* Update tests for enum metadata values

Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-07-07 16:44:09 -07:00
9d89bdd6d3 [Static Root] Static Root Plugin not loading (#5455)
* Log if hitting falsy leafValue

* Add some logging

* Remove logs and specify null/undefined

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
2022-07-07 15:00:33 -07:00
ed9ca2829b fix pathing (#5452)
Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
2022-07-07 14:33:05 -07:00
4a4d6a1038 Initialize the plot only after the chart is ready 2022-06-29 18:56:41 -07:00
18 changed files with 545 additions and 355 deletions

View File

@ -0,0 +1,41 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test } = require('../../../fixtures.js');
// eslint-disable-next-line no-unused-vars
const { expect } = require('@playwright/test');
test.describe('Remote Clock', () => {
// eslint-disable-next-line require-await
test.fixme('blocks historical requests until first tick is received', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5221'
});
// addInitScript to with remote clock
// Switch time conductor mode to 'remote clock'
// Navigate to telemetry
// Verify that the plot renders historical data within the correct bounds
// Refresh the page
// Verify again that the plot renders historical data within the correct bounds
});
});

View File

@ -24,7 +24,7 @@ const { test } = require('../../../fixtures');
const { expect } = require('@playwright/test');
test.describe('Telemetry Table', () => {
test('unpauses when paused by button and user changes bounds', async ({ page }) => {
test('unpauses and filters data when paused by button and user changes bounds', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5113'
@ -71,25 +71,34 @@ test.describe('Telemetry Table', () => {
]);
// Click pause button
const pauseButton = await page.locator('button.c-button.icon-pause');
const pauseButton = page.locator('button.c-button.icon-pause');
await pauseButton.click();
const tableWrapper = await page.locator('div.c-table-wrapper');
const tableWrapper = page.locator('div.c-table-wrapper');
await expect(tableWrapper).toHaveClass(/is-paused/);
// Arbitrarily change end date to some time in the future
// Subtract 5 minutes from the current end bound datetime and set it
const endTimeInput = page.locator('input[type="text"].c-input--datetime').nth(1);
await endTimeInput.click();
let endDate = await endTimeInput.inputValue();
endDate = new Date(endDate);
endDate.setUTCDate(endDate.getUTCDate() + 1);
endDate = endDate.toISOString().replace(/T.*/, '');
endDate.setUTCMinutes(endDate.getUTCMinutes() - 5);
endDate = endDate.toISOString().replace(/T/, ' ');
await endTimeInput.fill('');
await endTimeInput.fill(endDate);
await page.keyboard.press('Enter');
await expect(tableWrapper).not.toHaveClass(/is-paused/);
// Get the most recent telemetry date
const latestTelemetryDate = await page.locator('table.c-telemetry-table__body > tbody > tr').last().locator('td').nth(1).getAttribute('title');
// Verify that it is <= our new end bound
const latestMilliseconds = Date.parse(latestTelemetryDate);
const endBoundMilliseconds = Date.parse(endDate);
expect(latestMilliseconds).toBeLessThanOrEqual(endBoundMilliseconds);
});
});

View File

@ -56,7 +56,7 @@ test.beforeEach(async ({ context }) => {
test('Visual - Restricted Notebook is visually correct @addInit', async ({ page }) => {
// eslint-disable-next-line no-undef
await page.addInitScript({ path: path.join(__dirname, '../plugins/notebook', './addRestrictedNotebook.js') });
await page.addInitScript({ path: path.join(__dirname, '../plugins/notebook', './addInitRestrictedNotebook.js') });
//Go to baseURL
await page.goto('/', { waitUntil: 'networkidle' });
//Click the Create button

View File

@ -203,7 +203,7 @@ define([
* @memberof module:openmct.MCT#
* @name telemetry
*/
this.telemetry = new api.TelemetryAPI(this);
this.telemetry = new api.TelemetryAPI.default(this);
/**
* An interface for creating new indicators and changing them dynamically.

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
*****************************************************************************/
import { createOpenMct, resetApplicationState } from 'utils/testing';
import TelemetryAPI from './TelemetryAPI';
const { TelemetryCollection } = require("./TelemetryCollection");
import TelemetryCollection from './TelemetryCollection';
describe('Telemetry API', function () {
let openmct;

View File

@ -26,7 +26,7 @@ import { LOADED_ERROR, TIMESYSTEM_KEY_NOTIFICATION, TIMESYSTEM_KEY_WARNING } fro
/** Class representing a Telemetry Collection. */
export class TelemetryCollection extends EventEmitter {
export default class TelemetryCollection extends EventEmitter {
/**
* Creates a Telemetry Collection
*
@ -127,7 +127,8 @@ export class TelemetryCollection extends EventEmitter {
this.requestAbort = new AbortController();
options.signal = this.requestAbort.signal;
this.emit('requestStarted');
historicalData = await historicalProvider.request(this.domainObject, options);
const modifiedOptions = await this.openmct.telemetry.applyRequestInterceptors(this.domainObject, options);
historicalData = await historicalProvider.request(this.domainObject, modifiedOptions);
} catch (error) {
if (error.name !== 'AbortError') {
console.error('Error requesting telemetry data...');

View File

@ -0,0 +1,68 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
export default class TelemetryRequestInterceptorRegistry {
/**
* A TelemetryRequestInterceptorRegistry maintains the definitions for different interceptors that may be invoked on telemetry
* requests.
* @interface TelemetryRequestInterceptorRegistry
* @memberof module:openmct
*/
constructor() {
this.interceptors = [];
}
/**
* @interface TelemetryRequestInterceptorDef
* @property {function} appliesTo function that determines if this interceptor should be called for the given identifier/request
* @property {function} invoke function that transforms the provided request and returns the transformed request
* @property {function} priority the priority for this interceptor. A higher number returned has more weight than a lower number
* @memberof module:openmct TelemetryRequestInterceptorRegistry#
*/
/**
* Register a new telemetry request interceptor.
*
* @param {module:openmct.RequestInterceptorDef} requestInterceptorDef the interceptor to add
* @method addInterceptor
* @memberof module:openmct.TelemetryRequestInterceptorRegistry#
*/
addInterceptor(interceptorDef) {
//TODO: sort by priority
this.interceptors.push(interceptorDef);
}
/**
* Retrieve all interceptors applicable to a domain object/request.
* @method getInterceptors
* @returns [module:openmct.RequestInterceptorDef] the registered interceptors for this identifier/request
* @memberof module:openmct.TelemetryRequestInterceptorRegistry#
*/
getInterceptors(identifier, request) {
return this.interceptors.filter(interceptor => {
return typeof interceptor.appliesTo === 'function'
&& interceptor.appliesTo(identifier, request);
});
}
}

View File

@ -281,11 +281,11 @@ export default {
this.xKeyOptions.push(
metadataValues.reduce((previousValue, currentValue) => {
return {
name: `${previousValue.name}, ${currentValue.name}`,
name: previousValue?.name ? `${previousValue.name}, ${currentValue.name}` : `${currentValue.name}`,
value: currentValue.key,
isArrayValue: currentValue.isArrayValue
};
})
}, {name: ''})
);
}
@ -336,6 +336,8 @@ export default {
return option;
});
} else if (this.xKey !== undefined && this.domainObject.configuration.axes.yKey === undefined) {
this.domainObject.configuration.axes.yKey = 'none';
}
this.xKeyOptions = this.xKeyOptions.map((option, index) => {

View File

@ -367,15 +367,22 @@ describe("the plugin", function () {
type: "test-object",
name: "Test Object",
telemetry: {
values: [{
values: [
{
key: "some-key",
source: "some-key",
name: "Some attribute",
hints: {
domain: 1
format: "enum",
enumerations: [
{
value: 0,
string: "OFF"
},
{
value: 1,
string: "ON"
}
}, {
key: "some-other-key",
name: "Another attribute",
],
hints: {
range: 1
}

View File

@ -373,39 +373,30 @@ describe("The Imagery View Layouts", () => {
return Vue.nextTick();
});
it("on mount should show the the most recent image", () => {
it("on mount should show the the most recent image", async () => {
//Looks like we need Vue.nextTick here so that computed properties settle down
return Vue.nextTick(() => {
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 1].timeId)).not.toEqual(-1);
});
});
it("on mount should show the any image layers", (done) => {
it("on mount should show the any image layers", async () => {
//Looks like we need Vue.nextTick here so that computed properties settle down
Vue.nextTick().then(() => {
Vue.nextTick(() => {
await Vue.nextTick();
const layerEls = parent.querySelectorAll('.js-layer-image');
console.log(layerEls);
expect(layerEls.length).toEqual(1);
done();
});
});
});
it("should show the clicked thumbnail as the main image", (done) => {
it("should show the clicked thumbnail as the main image", async () => {
//Looks like we need Vue.nextTick here so that computed properties settle down
Vue.nextTick(() => {
await Vue.nextTick();
const target = imageTelemetry[5].url;
parent.querySelectorAll(`img[src='${target}']`)[0].click();
Vue.nextTick(() => {
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[5].timeId)).not.toEqual(-1);
done();
});
});
});
xit("should show that an image is new", (done) => {
@ -424,23 +415,20 @@ describe("The Imagery View Layouts", () => {
});
});
it("should show that an image is not new", (done) => {
Vue.nextTick(() => {
it("should show that an image is not new", async () => {
await Vue.nextTick();
const target = imageTelemetry[4].url;
parent.querySelectorAll(`img[src='${target}']`)[0].click();
Vue.nextTick(() => {
await Vue.nextTick();
const imageIsNew = isNew(parent);
expect(imageIsNew).toBeFalse();
done();
});
});
});
it("should navigate via arrow keys", (done) => {
Vue.nextTick(() => {
let keyOpts = {
it("should navigate via arrow keys", async () => {
await Vue.nextTick();
const keyOpts = {
element: parent.querySelector('.c-imagery'),
key: 'ArrowLeft',
keyCode: 37,
@ -449,26 +437,22 @@ describe("The Imagery View Layouts", () => {
simulateKeyEvent(keyOpts);
Vue.nextTick(() => {
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 2].timeId)).not.toEqual(-1);
done();
});
});
});
it("should navigate via numerous arrow keys", (done) => {
Vue.nextTick(() => {
let element = parent.querySelector('.c-imagery');
let type = 'keyup';
let leftKeyOpts = {
it("should navigate via numerous arrow keys", async () => {
await Vue.nextTick();
const element = parent.querySelector('.c-imagery');
const type = 'keyup';
const leftKeyOpts = {
element,
type,
key: 'ArrowLeft',
keyCode: 37
};
let rightKeyOpts = {
const rightKeyOpts = {
element,
type,
key: 'ArrowRight',
@ -482,13 +466,9 @@ describe("The Imagery View Layouts", () => {
// right once
simulateKeyEvent(rightKeyOpts);
Vue.nextTick(() => {
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 3].timeId)).not.toEqual(-1);
done();
});
});
});
it ('shows an auto scroll button when scroll to left', (done) => {
Vue.nextTick(() => {

View File

@ -87,6 +87,7 @@
:highlights="highlights"
:show-limit-line-labels="showLimitLineLabels"
@plotReinitializeCanvas="initCanvas"
@chartLoaded="initialize"
/>
</div>
@ -359,11 +360,6 @@ export default {
this.setTimeContext();
this.loaded = true;
//We're referencing the canvas elements from the mct-chart in the initialize method.
// So we need $nextTick to ensure the component is fully mounted before we can initialize stuff.
this.$nextTick(this.initialize);
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleKeyDown);

View File

@ -115,6 +115,7 @@ export default {
this.listenTo(this.config.yAxis, 'change', this.updateLimitsAndDraw);
this.listenTo(this.config.xAxis, 'change', this.updateLimitsAndDraw);
this.config.series.forEach(this.onSeriesAdd, this);
this.$emit('chartLoaded');
},
beforeDestroy() {
this.destroy();

View File

@ -20,6 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import DefaultClock from '../../utils/clock/DefaultClock';
import remoteClockRequestInterceptor from './requestInterceptor';
/**
* A {@link openmct.TimeAPI.Clock} that updates the temporal bounds of the
@ -49,6 +50,14 @@ export default class RemoteClock extends DefaultClock {
this.lastTick = 0;
this.openmct.telemetry.addRequestInterceptor(
remoteClockRequestInterceptor(
this.openmct,
this.identifier,
this.#waitForReady.bind(this)
)
);
this._processDatum = this._processDatum.bind(this);
}
@ -129,4 +138,25 @@ export default class RemoteClock extends DefaultClock {
return timeFormatter.parse(datum);
};
}
/**
* Waits for the clock to have a non-default tick value.
*
* @private
*/
#waitForReady() {
const waitForInitialTick = (resolve) => {
if (this.lastTick > 0) {
const offsets = this.openmct.time.clockOffsets();
resolve({
start: this.lastTick + offsets.start,
end: this.lastTick + offsets.end
});
} else {
setTimeout(() => waitForInitialTick(resolve), 100);
}
};
return new Promise(waitForInitialTick);
}
}

View File

@ -0,0 +1,46 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
function remoteClockRequestInterceptor(openmct, remoteClockIdentifier, waitForBounds) {
let remoteClockLoaded = false;
return {
appliesTo: () => {
// Get the activeClock from the Global Time Context
const { activeClock } = openmct.time.getContextForView();
return activeClock !== undefined
&& activeClock.key === 'remote-clock'
&& !remoteClockLoaded;
},
invoke: async (request) => {
const { start, end } = await waitForBounds();
remoteClockLoaded = true;
request[1].start = start;
request[1].end = end;
return request;
}
};
}
export default remoteClockRequestInterceptor;

View File

@ -78,7 +78,7 @@ class StaticModelProvider {
}
parseTreeLeaf(leafKey, leafValue, idMap, namespace) {
if (!leafValue) {
if (leafValue === null || leafValue === undefined) {
return leafValue;
}

View File

@ -135,7 +135,7 @@ describe("the plugin", () => {
let tableInstance;
let mockClock;
beforeEach(() => {
beforeEach(async () => {
openmct.time.timeSystem('utc', {
start: 0,
end: 4
@ -210,16 +210,8 @@ describe("the plugin", () => {
'some-other-key': 'some-other-value 3'
}
];
let telemetryPromiseResolve;
let telemetryPromise = new Promise((resolve) => {
telemetryPromiseResolve = resolve;
});
historicalProvider.request = () => {
telemetryPromiseResolve(testTelemetry);
return telemetryPromise;
};
historicalProvider.request = () => Promise.resolve(testTelemetry);
openmct.router.path = [testTelemetryObject];
@ -230,7 +222,7 @@ describe("the plugin", () => {
tableInstance = tableView.getTable();
return telemetryPromise.then(() => Vue.nextTick());
await Vue.nextTick();
});
afterEach(() => {
@ -255,13 +247,10 @@ describe("the plugin", () => {
});
it("Renders a row for every telemetry datum returned", (done) => {
it("Renders a row for every telemetry datum returned", async () => {
let rows = element.querySelectorAll('table.c-telemetry-table__body tr');
Vue.nextTick(() => {
await Vue.nextTick();
expect(rows.length).toBe(3);
done();
});
});
it("Renders a column for every item in telemetry metadata", () => {
@ -273,7 +262,7 @@ describe("the plugin", () => {
expect(headers[3].innerText).toBe('Another attribute');
});
it("Supports column reordering via drag and drop", () => {
it("Supports column reordering via drag and drop", async () => {
let columns = element.querySelectorAll('tr.c-telemetry-table__headers__labels th');
let fromColumn = columns[0];
let toColumn = columns[1];
@ -292,55 +281,44 @@ describe("the plugin", () => {
toColumn.dispatchEvent(dragOverEvent);
toColumn.dispatchEvent(dropEvent);
return Vue.nextTick().then(() => {
await Vue.nextTick();
columns = element.querySelectorAll('tr.c-telemetry-table__headers__labels th');
let firstColumn = columns[0];
let secondColumn = columns[1];
let firstColumnText = firstColumn.querySelector('span.c-telemetry-table__headers__label').innerText;
let secondColumnText = secondColumn.querySelector('span.c-telemetry-table__headers__label').innerText;
expect(fromColumnText).not.toEqual(firstColumnText);
expect(fromColumnText).toEqual(secondColumnText);
expect(toColumnText).not.toEqual(secondColumnText);
expect(toColumnText).toEqual(firstColumnText);
});
});
it("Supports filtering telemetry by regular text search", () => {
it("Supports filtering telemetry by regular text search", async () => {
tableInstance.tableRows.setColumnFilter("some-key", "1");
return Vue.nextTick().then(() => {
await Vue.nextTick();
let filteredRowElements = element.querySelectorAll('table.c-telemetry-table__body tr');
expect(filteredRowElements.length).toEqual(1);
tableInstance.tableRows.setColumnFilter("some-key", "");
await Vue.nextTick();
return Vue.nextTick().then(() => {
let allRowElements = element.querySelectorAll('table.c-telemetry-table__body tr');
expect(allRowElements.length).toEqual(3);
});
});
});
it("Supports filtering using Regex", () => {
it("Supports filtering using Regex", async () => {
tableInstance.tableRows.setColumnRegexFilter("some-key", "^some-value$");
return Vue.nextTick().then(() => {
await Vue.nextTick();
let filteredRowElements = element.querySelectorAll('table.c-telemetry-table__body tr');
expect(filteredRowElements.length).toEqual(0);
tableInstance.tableRows.setColumnRegexFilter("some-key", "^some-value");
return Vue.nextTick().then(() => {
await Vue.nextTick();
let allRowElements = element.querySelectorAll('table.c-telemetry-table__body tr');
expect(allRowElements.length).toEqual(3);
});
});
});
it("displays the correct number of column headers when the configuration is mutated", async () => {
const tableInstanceConfiguration = tableInstance.domainObject.configuration;
@ -402,7 +380,7 @@ describe("the plugin", () => {
expect(element.querySelector('div.c-table.is-paused')).not.toBeNull();
const currentBounds = openmct.time.bounds();
await Vue.nextTick();
const newBounds = {
start: currentBounds.start,
end: currentBounds.end - 3
@ -410,17 +388,10 @@ describe("the plugin", () => {
// Manually change the time bounds
openmct.time.bounds(newBounds);
await Vue.nextTick();
// Verify table is no longer paused
expect(element.querySelector('div.c-table.is-paused')).toBeNull();
await Vue.nextTick();
// Verify table displays the correct number of rows within the new bounds
const tableRows = element.querySelectorAll('table.c-telemetry-table__body > tbody > tr');
expect(tableRows.length).toEqual(2);
});
it("Unpauses the table on user bounds change if paused by button", async () => {
@ -428,19 +399,18 @@ describe("the plugin", () => {
// Pause by button
viewContext.togglePauseByButton();
await Vue.nextTick();
// Verify table is paused
expect(element.querySelector('div.c-table.is-paused')).not.toBeNull();
const currentBounds = openmct.time.bounds();
await Vue.nextTick();
const newBounds = {
start: currentBounds.start,
end: currentBounds.end - 3
end: currentBounds.end - 1
};
// Manually change the time bounds
openmct.time.bounds(newBounds);
@ -448,12 +418,6 @@ describe("the plugin", () => {
// Verify table is no longer paused
expect(element.querySelector('div.c-table.is-paused')).toBeNull();
await Vue.nextTick();
// Verify table displays the correct number of rows within the new bounds
const tableRows = element.querySelectorAll('table.c-telemetry-table__body > tbody > tr');
expect(tableRows.length).toEqual(2);
});
it("Does not unpause the table on tick", async () => {

View File

@ -7,12 +7,19 @@ const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const {VueLoaderPlugin} = require('vue-loader');
const gitRevision = require('child_process')
let gitRevision = 'error-retrieving-revision';
let gitBranch = 'error-retrieving-branch';
try {
gitRevision = require('child_process')
.execSync('git rev-parse HEAD')
.toString().trim();
const gitBranch = require('child_process')
gitBranch = require('child_process')
.execSync('git rev-parse --abbrev-ref HEAD')
.toString().trim();
} catch (err) {
console.warn(err);
}
/** @type {import('webpack').Configuration} */
const config = {