diff --git a/e2e/helper/addInitDataVisualization.js b/e2e/helper/addInitDataVisualization.js new file mode 100644 index 00000000000..188b7b9031c --- /dev/null +++ b/e2e/helper/addInitDataVisualization.js @@ -0,0 +1,30 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2023, 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. + *****************************************************************************/ + +// This should be used to install the Example User +document.addEventListener('DOMContentLoaded', () => { + const openmct = window.openmct; + openmct.install(openmct.plugins.example.ExampleDataVisualizationSourcePlugin()); + openmct.install( + openmct.plugins.InspectorDataVisualization({ type: 'exampleDataVisualizationSource' }) + ); +}); diff --git a/e2e/tests/functional/plugins/inspectorDataVisualization/numericData.e2e.spec.js b/e2e/tests/functional/plugins/inspectorDataVisualization/numericData.e2e.spec.js new file mode 100644 index 00000000000..41de13334ab --- /dev/null +++ b/e2e/tests/functional/plugins/inspectorDataVisualization/numericData.e2e.spec.js @@ -0,0 +1,69 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2023, 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. + *****************************************************************************/ +/* global __dirname */ + +const { test, expect } = require('../../../../pluginFixtures'); +const { createDomainObjectWithDefaults } = require('../../../../appActions'); +const path = require('path'); + +test.describe('Testing numeric data with inspector data visualization (i.e., data pivoting)', () => { + test.beforeEach(async ({ page }) => { + // eslint-disable-next-line no-undef + await page.addInitScript({ + path: path.join(__dirname, '../../../../helper/', 'addInitDataVisualization.js') + }); + await page.goto('./', { waitUntil: 'domcontentloaded' }); + }); + + test('Can click on telemetry and see data in inspector', async ({ page }) => { + const exampleDataVisualizationSource = await createDomainObjectWithDefaults(page, { + type: 'Example Data Visualization Source' + }); + await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: 'First Sine Wave Generator', + parent: exampleDataVisualizationSource.uuid + }); + await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: 'Second Sine Wave Generator', + parent: exampleDataVisualizationSource.uuid + }); + + await page.goto(exampleDataVisualizationSource.url); + + await page.getByRole('tab', { name: 'Data Visualization' }).click(); + await page.getByRole('cell', { name: /First Sine Wave Generator/ }).click(); + await expect(page.getByText('Numeric Data')).toBeVisible(); + await expect( + page.locator('span.plot-series-name', { hasText: 'First Sine Wave Generator Hz' }) + ).toBeVisible(); + await expect(page.locator('.js-series-data-loaded')).toBeVisible(); + + await page.getByRole('cell', { name: /Second Sine Wave Generator/ }).click(); + await expect(page.getByText('Numeric Data')).toBeVisible(); + await expect( + page.locator('span.plot-series-name', { hasText: 'Second Sine Wave Generator Hz' }) + ).toBeVisible(); + await expect(page.locator('.js-series-data-loaded')).toBeVisible(); + }); +}); diff --git a/example/dataVisualization/ExampleDataVisualizationSourceViewProvider.js b/example/dataVisualization/ExampleDataVisualizationSourceViewProvider.js new file mode 100644 index 00000000000..4ccf0ddf320 --- /dev/null +++ b/example/dataVisualization/ExampleDataVisualizationSourceViewProvider.js @@ -0,0 +1,75 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2023, 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. + *****************************************************************************/ + +import mount from 'utils/mount'; + +import ExampleDataVisualizationSource from './components/ExampleDataVisualizationSource.vue'; + +export default function ExampleDataVisualizationSourceViewProvider(openmct) { + return { + key: 'exampleDataVisualizationSource', + name: 'Example Data Visualization Source', + cssClass: 'icon-telemetry', + canView: function (domainObject) { + return domainObject.type === 'exampleDataVisualizationSource'; + }, + canEdit: function (domainObject) { + if (domainObject.type === 'exampleDataVisualizationSource') { + return true; + } + }, + view: function (domainObject) { + let _destroy = null; + + return { + show: function (element, isEditing) { + const { destroy } = mount( + { + el: element, + components: { + ExampleDataVisualizationSource + }, + provide: { + openmct, + domainObject + }, + template: '' + }, + { + app: openmct.app, + element + } + ); + _destroy = destroy; + }, + destroy: function () { + if (_destroy) { + _destroy(); + } + } + }; + }, + priority: function () { + return 1; + } + }; +} diff --git a/example/dataVisualization/components/ExampleDataVisualizationSource.vue b/example/dataVisualization/components/ExampleDataVisualizationSource.vue new file mode 100644 index 00000000000..88cc2d7c778 --- /dev/null +++ b/example/dataVisualization/components/ExampleDataVisualizationSource.vue @@ -0,0 +1,128 @@ + + + + + diff --git a/example/dataVisualization/plugin.js b/example/dataVisualization/plugin.js new file mode 100644 index 00000000000..9a0ec267554 --- /dev/null +++ b/example/dataVisualization/plugin.js @@ -0,0 +1,46 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2023, 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. + *****************************************************************************/ +import ExampleDataVisualizationSourceViewProvider from './ExampleDataVisualizationSourceViewProvider'; + +export default function () { + return function install(openmct) { + openmct.objectViews.addProvider(new ExampleDataVisualizationSourceViewProvider(openmct)); + + openmct.types.addType('exampleDataVisualizationSource', { + name: 'Example Data Visualization Source', + creatable: true, + description: 'An example data visualization source to be used with an inspector.', + cssClass: 'icon-telemetry', + initialize(domainObject) { + domainObject.composition = []; + } + }); + + openmct.composition.addPolicy((parent, child) => { + if (parent.type === 'exampleDataVisualizationSource') { + return Object.prototype.hasOwnProperty.call(child, 'telemetry'); + } else { + return true; + } + }); + }; +} diff --git a/src/plugins/inspectorDataVisualization/InspectorDataVisualizationViewProvider.js b/src/plugins/inspectorDataVisualization/InspectorDataVisualizationViewProvider.js index 4f44518e919..e7b9af0f903 100644 --- a/src/plugins/inspectorDataVisualization/InspectorDataVisualizationViewProvider.js +++ b/src/plugins/inspectorDataVisualization/InspectorDataVisualizationViewProvider.js @@ -49,7 +49,8 @@ export default function InspectorDataVisualizationViewProvider(openmct, configur const context = selection[0][0].context; const domainObject = context.item; const dataVisualizationContext = context?.dataVisualization ?? {}; - const timeFormatter = openmct.telemetry.getFormatter('iso'); + const timeFormatter = + openmct.telemetry.getFormatter('iso') || openmct.telemetry.getFormatter('utc'); return { show(element) { diff --git a/src/plugins/plugins.js b/src/plugins/plugins.js index 0393a333a62..1d67390e350 100644 --- a/src/plugins/plugins.js +++ b/src/plugins/plugins.js @@ -29,6 +29,7 @@ define([ './myItems/plugin', '../../example/generator/plugin', '../../example/eventGenerator/plugin', + '../../example/dataVisualization/plugin', './autoflow/AutoflowTabularPlugin', './timeConductor/plugin', '../../example/imagery/plugin', @@ -94,6 +95,7 @@ define([ MyItems, GeneratorPlugin, EventGeneratorPlugin, + ExampleDataVisualizationSourcePlugin, AutoflowPlugin, TimeConductorPlugin, ExampleImagery, @@ -158,6 +160,8 @@ define([ plugins.example.ExampleImagery = ExampleImagery.default; plugins.example.ExampleFaultSource = ExampleFaultSource.default; plugins.example.EventGeneratorPlugin = EventGeneratorPlugin.default; + plugins.example.ExampleDataVisualizationSourcePlugin = + ExampleDataVisualizationSourcePlugin.default; plugins.example.ExampleTags = ExampleTags.default; plugins.example.Generator = () => GeneratorPlugin.default;