diff --git a/.circleci/config.yml b/.circleci/config.yml index 3dfa1d6569..9656e12e99 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,59 +1,32 @@ version: 2.1 +orbs: + node: circleci/node@5.2.0 + browser-tools: circleci/browser-tools@1.3.0 executors: pw-focal-development: docker: - - image: mcr.microsoft.com/playwright:v1.36.2-focal + - image: mcr.microsoft.com/playwright:v1.39.0-focal environment: NODE_ENV: development # Needed to ensure 'dist' folder created and devDependencies installed - PERCY_POSTINSTALL_BROWSER: 'true' # Needed to store the percy browser in cache deps - PERCY_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742) + PERCY_POSTINSTALL_BROWSER: "true" # Needed to store the percy browser in cache deps + PERCY_LOGLEVEL: "debug" # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742) ubuntu: machine: image: ubuntu-2204:current docker_layer_caching: true -parameters: - BUST_CACHE: - description: 'Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!' - default: false - type: boolean commands: build_and_install: - description: 'All steps used to build and install. Will use cache if found' + description: "All steps used to build and install." parameters: node-version: type: string steps: - checkout - - restore_cache_cmd: - node-version: << parameters.node-version >> - node/install: node-version: << parameters.node-version >> - - run: npm install --no-audit --progress=false - restore_cache_cmd: - description: 'Custom command for restoring cache with the ability to bust cache. When BUST_CACHE is set to true, jobs will not restore cache' - parameters: - node-version: - type: string - steps: - - when: - condition: - equal: [false, << pipeline.parameters.BUST_CACHE >>] - steps: - - restore_cache: - key: deps--{{ arch }}--{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - save_cache_cmd: - description: 'Custom command for saving cache.' - parameters: - node-version: - type: string - steps: - - save_cache: - key: deps--{{ arch }}--{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} - paths: - - ~/.npm - - node_modules + - node/install-packages generate_and_store_version_and_filesystem_artifacts: - description: 'Track important packages and files' + description: "Track important packages and files" steps: - run: | [[ $EUID -ne 0 ]] && (sudo mkdir -p /tmp/artifacts && sudo chmod 777 /tmp/artifacts) || (mkdir -p /tmp/artifacts && chmod 777 /tmp/artifacts) @@ -64,16 +37,13 @@ commands: - store_artifacts: path: /tmp/artifacts/ generate_e2e_code_cov_report: - description: 'Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test' + description: "Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test" parameters: suite: type: string steps: - run: npm run cov:e2e:report || true - run: npm run cov:e2e:<>:publish -orbs: - node: circleci/node@5.1.0 - browser-tools: circleci/browser-tools@1.3.0 jobs: npm-audit: parameters: @@ -105,10 +75,12 @@ jobs: node-version: <> - browser-tools/install-chrome: replace-existing: false - - run: npm run test + - run: + command: | + mkdir -p dist/reports/tests/ + TESTFILES=$(circleci tests glob "src/**/*Spec.js") + echo "$TESTFILES" | circleci tests run --command="xargs npm run test" --verbose - run: npm run cov:unit:publish - - save_cache_cmd: - node-version: <> - store_test_results: path: dist/reports/tests/ - store_artifacts: @@ -120,21 +92,23 @@ jobs: - generate_and_store_version_and_filesystem_artifacts e2e-test: parameters: - node-version: - type: string suite: #stable or full type: string executor: pw-focal-development - parallelism: 4 + parallelism: 7 steps: - build_and_install: - node-version: <> + node-version: lts/hydrogen - when: #Only install chrome-beta when running the 'full' suite to save $$$ condition: - equal: ['full', <>] + equal: ["full", <>] steps: - run: npx playwright install chrome-beta - - run: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npm run test:e2e:<> -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL} + - run: + command: | + mkdir test-results + TESTFILES=$(circleci tests glob "e2e/**/*.spec.js") + echo "$TESTFILES" | circleci tests run --command="xargs npm run test:e2e:<>" --verbose --split-by=timings - when: condition: equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 @@ -154,15 +128,37 @@ jobs: equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 steps: - generate_and_store_version_and_filesystem_artifacts + e2e-mobile: + executor: pw-focal-development + steps: + - build_and_install: + node-version: lts/hydrogen + - run: npm run test:e2e:mobile + - when: + condition: + equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 + steps: + - generate_e2e_code_cov_report: + suite: full + - store_test_results: + path: test-results/results.xml + - store_artifacts: + path: test-results + - store_artifacts: + path: coverage + - store_artifacts: + path: html-test-results + - when: + condition: + equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 + steps: + - generate_and_store_version_and_filesystem_artifacts e2e-couchdb: - parameters: - node-version: - type: string executor: ubuntu steps: - build_and_install: - node-version: <> - - run: npx playwright@1.36.2 install #Necessary for bare ubuntu machine + node-version: lts/hydrogen + - run: npx playwright@1.39.0 install #Necessary for bare ubuntu machine - run: | export $(cat src/plugins/persistence/couch/.env.ci | xargs) docker-compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach @@ -189,15 +185,28 @@ jobs: equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 steps: - generate_and_store_version_and_filesystem_artifacts - perf-test: - parameters: - node-version: - type: string + mem-test: executor: pw-focal-development steps: - build_and_install: - node-version: <> + node-version: lts/hydrogen - run: npm run test:perf:memory + - store_test_results: + path: test-results/results.xml + - store_artifacts: + path: test-results + - store_artifacts: + path: html-test-results + - when: + condition: + equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 + steps: + - generate_and_store_version_and_filesystem_artifacts + perf-test: + executor: pw-focal-development + steps: + - build_and_install: + node-version: lts/hydrogen - run: npm run test:perf:localhost - run: npm run test:perf:contract - store_test_results: @@ -211,16 +220,14 @@ jobs: equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 steps: - generate_and_store_version_and_filesystem_artifacts - visual-test: + visual-a11y-tests: parameters: - node-version: - type: string suite: type: string # ci or full executor: pw-focal-development steps: - build_and_install: - node-version: <> + node-version: lts/hydrogen - run: npm run test:e2e:visual:<> - store_test_results: path: test-results/results.xml @@ -233,31 +240,29 @@ jobs: equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 steps: - generate_and_store_version_and_filesystem_artifacts + workflows: overall-circleci-commit-status: #These jobs run on every commit jobs: - lint: - name: node16-lint - node-version: lts/gallium + name: node20-lint + node-version: lts/iron - unit-test: name: node18-chrome node-version: lts/hydrogen - e2e-test: name: e2e-stable - node-version: lts/hydrogen suite: stable - - perf-test: - node-version: lts/hydrogen - - visual-test: - name: visual-test-ci + - e2e-mobile + - visual-a11y-tests: + name: visual-a11y-test-ci suite: ci - node-version: lts/hydrogen the-nightly: #These jobs do not run on PRs, but against master at night jobs: - unit-test: - name: node16-chrome-nightly - node-version: lts/gallium + name: node20-chrome-nightly + node-version: lts/iron - unit-test: name: node18-chrome node-version: lts/hydrogen @@ -265,19 +270,17 @@ workflows: node-version: lts/hydrogen - e2e-test: name: e2e-full-nightly - node-version: lts/hydrogen suite: full - - perf-test: - node-version: lts/hydrogen - - visual-test: - name: visual-test-nightly + - e2e-mobile + - perf-test + - mem-test + - visual-a11y-tests: + name: visual-a11y-test-nightly suite: full - node-version: lts/hydrogen - - e2e-couchdb: - node-version: lts/hydrogen + - e2e-couchdb triggers: - schedule: - cron: '0 0 * * *' + cron: "0 0 * * *" filters: branches: only: diff --git a/.cspell.json b/.cspell.json index d09743f357..9afde5db7c 100644 --- a/.cspell.json +++ b/.cspell.json @@ -43,7 +43,6 @@ "sharded", "perfromance", "MMOC", - "deploysentinel", "codegen", "Unfortuantely", "viewports", @@ -483,9 +482,24 @@ "websockets", "swgs", "memlab", - "devmode" + "devmode", + "blockquote", + "blockquotes", + "Blockquote", + "Blockquotes", + "oger", + "lcovonly", + "gcov", + "WCAG", + "stackedplot", + "Andale", + "unnormalized", + "checksnapshots", + "specced", + "composables", + "countup" ], - "dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US"], + "dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"], "ignorePaths": [ "package.json", "dist/**", @@ -496,4 +510,4 @@ "html-test-results", "test-results" ] -} \ No newline at end of file +} diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 94% rename from .eslintrc.js rename to .eslintrc.cjs index 66e1c13ae4..e29c587925 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -15,7 +15,8 @@ module.exports = { 'plugin:compat/recommended', 'plugin:vue/vue3-recommended', 'plugin:you-dont-need-lodash-underscore/compatible', - 'plugin:prettier/recommended' + 'plugin:prettier/recommended', + 'plugin:no-unsanitized/DOM' ], parser: 'vue-eslint-parser', parserOptions: { @@ -145,29 +146,26 @@ module.exports = { 'no-implicit-coercion': 'error', //https://eslint.org/docs/rules/no-unneeded-ternary 'no-unneeded-ternary': 'error', - "unicorn/filename-case": [ - "error", + 'unicorn/filename-case': [ + 'error', { - "cases": { - "pascalCase": true + cases: { + pascalCase: true }, - "ignore": [ - "^.*\\.js$" - ] + ignore: ['^.*\\.js$'] } ], 'vue/first-attribute-linebreak': 'error', 'vue/multiline-html-element-content-newline': 'off', 'vue/singleline-html-element-content-newline': 'off', - 'vue/multi-word-component-names': 'off', // TODO enable, align with conventions - 'vue/no-mutating-props': 'off' + 'vue/no-mutating-props': 'off' // TODO: Remove this rule and fix resulting errors }, overrides: [ { files: LEGACY_FILES, rules: { 'no-unused-vars': [ - 'warn', + 'error', { vars: 'all', args: 'none', diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 6aa1fd0665..839df6c0f9 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,6 +4,10 @@ # Requires Git > 2.23 # See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt +# vue-eslint update 2019 +14a0f84c1bcd56886d7c9e4e6afa8f7d292734e5 +# eslint changes 2022 +d80b6923541704ab925abf0047cbbc58735c27e2 # Copyright year update 2022 4a9744e916d24122a81092f6b7950054048ba860 # Copyright year update 2023 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f6728a7d26..444d552e91 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,14 +8,15 @@ Closes + + + + diff --git a/example/dataVisualization/plugin.js b/example/dataVisualization/plugin.js new file mode 100644 index 0000000000..c10a11d176 --- /dev/null +++ b/example/dataVisualization/plugin.js @@ -0,0 +1,46 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2024, 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.js'; + +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/example/eventGenerator/EventMetadataProvider.js b/example/eventGenerator/EventMetadataProvider.js index e234062bfd..c50f1fc9b3 100644 --- a/example/eventGenerator/EventMetadataProvider.js +++ b/example/eventGenerator/EventMetadataProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * diff --git a/example/eventGenerator/EventTelemetryProvider.js b/example/eventGenerator/EventTelemetryProvider.js index 701c32bcb6..2822a6a435 100644 --- a/example/eventGenerator/EventTelemetryProvider.js +++ b/example/eventGenerator/EventTelemetryProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * diff --git a/example/eventGenerator/plugin.js b/example/eventGenerator/plugin.js index 6da2c9c670..a8c051f6d0 100644 --- a/example/eventGenerator/plugin.js +++ b/example/eventGenerator/plugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -19,8 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -import EventMetadataProvider from './EventMetadataProvider'; -import EventTelemetryProvider from './EventTelemetryProvider'; +import EventMetadataProvider from './EventMetadataProvider.js'; +import EventTelemetryProvider from './EventTelemetryProvider.js'; export default function EventGeneratorPlugin(options) { return function install(openmct) { diff --git a/example/eventGenerator/pluginSpec.js b/example/eventGenerator/pluginSpec.js index 2e4caee272..03ab637366 100644 --- a/example/eventGenerator/pluginSpec.js +++ b/example/eventGenerator/pluginSpec.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -import { createOpenMct, resetApplicationState } from '../../src/utils/testing'; +import { createOpenMct, resetApplicationState } from '../../src/utils/testing.js'; import EventMessageGeneratorPlugin from './plugin.js'; describe('the plugin', () => { diff --git a/example/exampleTags/plugin.js b/example/exampleTags/plugin.js index 10b72274c0..2e2cd48060 100644 --- a/example/exampleTags/plugin.js +++ b/example/exampleTags/plugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * diff --git a/example/exampleUser/ExampleUserProvider.js b/example/exampleUser/ExampleUserProvider.js index 89f87d0e9c..d80735abd0 100644 --- a/example/exampleUser/ExampleUserProvider.js +++ b/example/exampleUser/ExampleUserProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -23,7 +23,7 @@ import EventEmitter from 'EventEmitter'; import { v4 as uuid } from 'uuid'; -import createExampleUser from './exampleUserCreator'; +import createExampleUser from './exampleUserCreator.js'; const STATUSES = [ { @@ -60,10 +60,22 @@ const STATUSES = [ statusFgColor: '#fff' } ]; + +const MISSION_STATUSES = [ + { + key: 0, + label: 'NO GO' + }, + { + key: 1, + label: 'GO' + } +]; /** * @implements {StatusUserProvider} */ export default class ExampleUserProvider extends EventEmitter { + #actionToStatusMap; constructor( openmct, { statusRoles } = { @@ -73,6 +85,11 @@ export default class ExampleUserProvider extends EventEmitter { super(); this.openmct = openmct; + this.#actionToStatusMap = { + Imagery: MISSION_STATUSES[0], + Commanding: MISSION_STATUSES[0], + Driving: MISSION_STATUSES[0] + }; this.user = undefined; this.loggedIn = false; this.autoLoginUser = undefined; @@ -110,6 +127,11 @@ export default class ExampleUserProvider extends EventEmitter { canSetPollQuestion() { return Promise.resolve(true); } + + canSetMissionStatus() { + return Promise.resolve(true); + } + hasRole(roleId) { if (!this.loggedIn) { Promise.resolve(undefined); @@ -122,6 +144,28 @@ export default class ExampleUserProvider extends EventEmitter { return this.user.getRoles(); } + getPossibleMissionActions() { + return Promise.resolve(Object.keys(this.#actionToStatusMap)); + } + + getPossibleMissionActionStatuses() { + return Promise.resolve(MISSION_STATUSES); + } + + getStatusForMissionAction(action) { + return Promise.resolve(this.#actionToStatusMap[action]); + } + + setStatusForMissionAction(action, status) { + this.#actionToStatusMap[action] = status; + this.emit('missionStatusChange', { + action, + status + }); + + return true; + } + getAllStatusRoles() { return Promise.resolve(this.statusRoles); } diff --git a/example/exampleUser/exampleUserCreator.js b/example/exampleUser/exampleUserCreator.js index 581ea10b7e..67d52d524c 100644 --- a/example/exampleUser/exampleUserCreator.js +++ b/example/exampleUser/exampleUserCreator.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * diff --git a/example/exampleUser/plugin.js b/example/exampleUser/plugin.js index ffbcae08ba..cd0469e2ed 100644 --- a/example/exampleUser/plugin.js +++ b/example/exampleUser/plugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import ExampleUserProvider from './ExampleUserProvider'; +import ExampleUserProvider from './ExampleUserProvider.js'; const AUTO_LOGIN_USER = 'mct-user'; const STATUS_ROLES = ['flight', 'driver']; diff --git a/example/exampleUser/pluginSpec.js b/example/exampleUser/pluginSpec.js index 0beddf32b9..199f7d00e8 100644 --- a/example/exampleUser/pluginSpec.js +++ b/example/exampleUser/pluginSpec.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,8 +20,8 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import { createOpenMct, resetApplicationState } from '../../src/utils/testing'; -import ExampleUserProvider from './ExampleUserProvider'; +import { createOpenMct, resetApplicationState } from '../../src/utils/testing.js'; +import ExampleUserProvider from './ExampleUserProvider.js'; describe('The Example User Plugin', () => { let openmct; diff --git a/example/faultManagement/exampleFaultSource.js b/example/faultManagement/exampleFaultSource.js index 20002b5221..17592ba4b9 100644 --- a/example/faultManagement/exampleFaultSource.js +++ b/example/faultManagement/exampleFaultSource.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,13 +20,13 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import utils from './utils'; +import { acknowledgeFault, randomFaults, shelveFault } from './utils.js'; export default function (staticFaults = false) { return function install(openmct) { openmct.install(openmct.plugins.FaultManagement()); - const faultsData = utils.randomFaults(staticFaults); + const faultsData = randomFaults(staticFaults); openmct.faults.addProvider({ request(domainObject, options) { @@ -44,14 +44,14 @@ export default function (staticFaults = false) { return domainObject.type === 'faultManagement'; }, acknowledgeFault(fault, { comment = '' }) { - utils.acknowledgeFault(fault); + acknowledgeFault(fault); return Promise.resolve({ success: true }); }, shelveFault(fault, duration) { - utils.shelveFault(fault, duration); + shelveFault(fault, duration); return Promise.resolve({ success: true diff --git a/example/faultManagement/pluginSpec.js b/example/faultManagement/pluginSpec.js index fa5e698ea8..e7751fee11 100644 --- a/example/faultManagement/pluginSpec.js +++ b/example/faultManagement/pluginSpec.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import { createOpenMct, resetApplicationState } from '../../src/utils/testing'; +import { createOpenMct, resetApplicationState } from '../../src/utils/testing.js'; describe('The Example Fault Source Plugin', () => { let openmct; diff --git a/example/faultManagement/utils.js b/example/faultManagement/utils.js index 4a38cd9e71..ed5de3f0e0 100644 --- a/example/faultManagement/utils.js +++ b/example/faultManagement/utils.js @@ -43,7 +43,7 @@ const getRandom = { } }; -function shelveFault( +export function shelveFault( fault, opts = { shelved: true, @@ -58,11 +58,11 @@ function shelveFault( }, opts.shelveDuration); } -function acknowledgeFault(fault) { +export function acknowledgeFault(fault) { fault.acknowledged = true; } -function randomFaults(staticFaults, count = 5) { +export function randomFaults(staticFaults, count = 5) { let faults = []; for (let x = 1, y = count + 1; x < y; x++) { @@ -71,9 +71,3 @@ function randomFaults(staticFaults, count = 5) { return faults; } - -export default { - randomFaults, - shelveFault, - acknowledgeFault -}; diff --git a/example/generator/GeneratorMetadataProvider.js b/example/generator/GeneratorMetadataProvider.js index fd12a1a7d0..51ec3cc88c 100644 --- a/example/generator/GeneratorMetadataProvider.js +++ b/example/generator/GeneratorMetadataProvider.js @@ -1,138 +1,134 @@ -define(['lodash'], function (_) { - var METADATA_BY_TYPE = { - generator: { - values: [ - { - key: 'name', - name: 'Name', - format: 'string' - }, - { - key: 'utc', - name: 'Time', - format: 'utc', - hints: { - domain: 1 - } - }, - { - key: 'yesterday', - name: 'Yesterday', - format: 'utc', - hints: { - domain: 2 - } - }, - { - key: 'wavelengths', - name: 'Wavelength', - unit: 'nm', - format: 'string[]', - hints: { - range: 4 - } - }, - // Need to enable "LocalTimeSystem" plugin to make use of this - // { - // key: "local", - // name: "Time", - // format: "local-format", - // source: "utc", - // hints: { - // domain: 3 - // } - // }, - { - key: 'sin', - name: 'Sine', - unit: 'Hz', - formatString: '%0.2f', - hints: { - range: 1 - } - }, - { - key: 'cos', - name: 'Cosine', - unit: 'deg', - formatString: '%0.2f', - hints: { - range: 2 - } - }, - { - key: 'intensities', - name: 'Intensities', - format: 'number[]', - hints: { - range: 3 - } +const METADATA_BY_TYPE = { + generator: { + values: [ + { + key: 'name', + name: 'Name', + format: 'string' + }, + { + key: 'utc', + name: 'Time', + format: 'utc', + hints: { + domain: 1 } - ] - }, - 'example.state-generator': { - values: [ - { - key: 'name', - name: 'Name', - format: 'string' - }, - { - key: 'utc', - name: 'Time', - format: 'utc', - hints: { - domain: 1 - } - }, - { - key: 'local', - name: 'Time', - format: 'utc', - source: 'utc', - hints: { - domain: 2 - } - }, - { - key: 'state', - source: 'value', - name: 'State', - format: 'enum', - enumerations: [ - { - value: 0, - string: 'OFF' - }, - { - value: 1, - string: 'ON' - } - ], - hints: { - range: 1 - } - }, - { - key: 'value', - name: 'Value', - hints: { - range: 2 - } + }, + { + key: 'yesterday', + name: 'Yesterday', + format: 'utc', + hints: { + domain: 2 } - ] - } - }; + }, + { + key: 'wavelengths', + name: 'Wavelength', + unit: 'nm', + format: 'string[]', + hints: { + range: 4 + } + }, + // Need to enable "LocalTimeSystem" plugin to make use of this + // { + // key: "local", + // name: "Time", + // format: "local-format", + // source: "utc", + // hints: { + // domain: 3 + // } + // }, + { + key: 'sin', + name: 'Sine', + unit: 'Hz', + formatString: '%0.2f', + hints: { + range: 1 + } + }, + { + key: 'cos', + name: 'Cosine', + unit: 'deg', + formatString: '%0.2f', + hints: { + range: 2 + } + }, + { + key: 'intensities', + name: 'Intensities', + format: 'number[]', + hints: { + range: 3 + } + } + ] + }, + 'example.state-generator': { + values: [ + { + key: 'name', + name: 'Name', + format: 'string' + }, + { + key: 'utc', + name: 'Time', + format: 'utc', + hints: { + domain: 1 + } + }, + { + key: 'local', + name: 'Time', + format: 'utc', + source: 'utc', + hints: { + domain: 2 + } + }, + { + key: 'state', + source: 'value', + name: 'State', + format: 'enum', + enumerations: [ + { + value: 0, + string: 'OFF' + }, + { + value: 1, + string: 'ON' + } + ], + hints: { + range: 1 + } + }, + { + key: 'value', + name: 'Value', + hints: { + range: 2 + } + } + ] + } +}; - function GeneratorMetadataProvider() {} +export default function GeneratorMetadataProvider() {} - GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) { - return Object.prototype.hasOwnProperty.call(METADATA_BY_TYPE, domainObject.type); - }; +GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) { + return Object.prototype.hasOwnProperty.call(METADATA_BY_TYPE, domainObject.type); +}; - GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) { - return Object.assign({}, domainObject.telemetry, METADATA_BY_TYPE[domainObject.type]); - }; - - return GeneratorMetadataProvider; -}); +GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) { + return Object.assign({}, domainObject.telemetry, METADATA_BY_TYPE[domainObject.type]); +}; diff --git a/example/generator/GeneratorProvider.js b/example/generator/GeneratorProvider.js index b74915ef12..42289e8cc9 100644 --- a/example/generator/GeneratorProvider.js +++ b/example/generator/GeneratorProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,84 +20,86 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define(['./WorkerInterface'], function (WorkerInterface) { - var REQUEST_DEFAULTS = { - amplitude: 1, - period: 10, - offset: 0, - dataRateInHz: 1, - randomness: 0, - phase: 0, - loadDelay: 0, - infinityValues: false - }; +import WorkerInterface from './WorkerInterface.js'; - function GeneratorProvider(openmct, StalenessProvider) { - this.openmct = openmct; - this.workerInterface = new WorkerInterface(openmct, StalenessProvider); - } +const REQUEST_DEFAULTS = { + amplitude: 1, + period: 10, + offset: 0, + dataRateInHz: 1, + randomness: 0, + phase: 0, + loadDelay: 0, + infinityValues: false, + exceedFloat32: false +}; - GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) { - return domainObject.type === 'generator'; - }; +export default function GeneratorProvider(openmct, StalenessProvider) { + this.openmct = openmct; + this.workerInterface = new WorkerInterface(openmct, StalenessProvider); +} - GeneratorProvider.prototype.supportsRequest = GeneratorProvider.prototype.supportsSubscribe = - GeneratorProvider.prototype.canProvideTelemetry; +GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) { + return domainObject.type === 'generator'; +}; - GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) { - var props = [ - 'amplitude', - 'period', - 'offset', - 'dataRateInHz', - 'randomness', - 'phase', - 'loadDelay', - 'infinityValues' - ]; +GeneratorProvider.prototype.supportsRequest = GeneratorProvider.prototype.supportsSubscribe = + GeneratorProvider.prototype.canProvideTelemetry; - request = request || {}; +GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) { + var props = [ + 'amplitude', + 'period', + 'offset', + 'dataRateInHz', + 'randomness', + 'phase', + 'loadDelay', + 'infinityValues', + 'exceedFloat32' + ]; - var workerRequest = {}; + request = request || {}; - props.forEach(function (prop) { - if ( - domainObject.telemetry && - Object.prototype.hasOwnProperty.call(domainObject.telemetry, prop) - ) { - workerRequest[prop] = domainObject.telemetry[prop]; - } + var workerRequest = {}; - if (request && Object.prototype.hasOwnProperty.call(request, prop)) { - workerRequest[prop] = request[prop]; - } + props.forEach(function (prop) { + if ( + domainObject.telemetry && + Object.prototype.hasOwnProperty.call(domainObject.telemetry, prop) + ) { + workerRequest[prop] = domainObject.telemetry[prop]; + } - if (!Object.prototype.hasOwnProperty.call(workerRequest, prop)) { - workerRequest[prop] = REQUEST_DEFAULTS[prop]; - } + if (request && Object.prototype.hasOwnProperty.call(request, prop)) { + workerRequest[prop] = request[prop]; + } - workerRequest[prop] = Number(workerRequest[prop]); - }); + if (!Object.prototype.hasOwnProperty.call(workerRequest, prop)) { + workerRequest[prop] = REQUEST_DEFAULTS[prop]; + } - workerRequest.id = this.openmct.objects.makeKeyString(domainObject.identifier); - workerRequest.name = domainObject.name; + workerRequest[prop] = Number(workerRequest[prop]); + }); - return workerRequest; - }; + workerRequest.id = this.openmct.objects.makeKeyString(domainObject.identifier); + workerRequest.name = domainObject.name; - GeneratorProvider.prototype.request = function (domainObject, request) { - var workerRequest = this.makeWorkerRequest(domainObject, request); - workerRequest.start = request.start; - workerRequest.end = request.end; + return workerRequest; +}; - return this.workerInterface.request(workerRequest); - }; +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; - GeneratorProvider.prototype.subscribe = function (domainObject, callback) { - var workerRequest = this.makeWorkerRequest(domainObject, {}); + return this.workerInterface.request(workerRequest); +}; - return this.workerInterface.subscribe(workerRequest, callback); - }; +GeneratorProvider.prototype.subscribe = function (domainObject, callback) { + var workerRequest = this.makeWorkerRequest(domainObject, {}); - return GeneratorProvider; -}); + return this.workerInterface.subscribe(workerRequest, callback); +}; diff --git a/example/generator/SinewaveLimitProvider.js b/example/generator/SinewaveLimitProvider.js index 3f71747f8f..961955ee2d 100644 --- a/example/generator/SinewaveLimitProvider.js +++ b/example/generator/SinewaveLimitProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,147 +20,143 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define([], function () { - var PURPLE = { - sin: 2.2, - cos: 2.2 +var PURPLE = { + sin: 2.2, + cos: 2.2 + }, + RED = { + sin: 0.9, + cos: 0.9 + }, + ORANGE = { + sin: 0.7, + cos: 0.7 + }, + YELLOW = { + sin: 0.5, + cos: 0.5 + }, + CYAN = { + sin: 0.45, + cos: 0.45 + }, + LIMITS = { + rh: { + cssClass: 'is-limit--upr is-limit--red', + low: RED, + high: Number.POSITIVE_INFINITY, + name: 'Red High' }, - RED = { - sin: 0.9, - cos: 0.9 + rl: { + cssClass: 'is-limit--lwr is-limit--red', + high: -RED, + low: Number.NEGATIVE_INFINITY, + name: 'Red Low' }, - ORANGE = { - sin: 0.7, - cos: 0.7 + yh: { + cssClass: 'is-limit--upr is-limit--yellow', + low: YELLOW, + high: RED, + name: 'Yellow High' }, - YELLOW = { - sin: 0.5, - cos: 0.5 - }, - CYAN = { - sin: 0.45, - cos: 0.45 - }, - LIMITS = { - rh: { - cssClass: 'is-limit--upr is-limit--red', - low: RED, - high: Number.POSITIVE_INFINITY, - name: 'Red High' - }, - rl: { - cssClass: 'is-limit--lwr is-limit--red', - high: -RED, - low: Number.NEGATIVE_INFINITY, - name: 'Red Low' - }, - yh: { - cssClass: 'is-limit--upr is-limit--yellow', - low: YELLOW, - high: RED, - name: 'Yellow High' - }, - yl: { - cssClass: 'is-limit--lwr is-limit--yellow', - low: -RED, - high: -YELLOW, - name: 'Yellow Low' - } - }; - - function SinewaveLimitProvider() {} - - SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) { - return domainObject.type === 'generator'; + yl: { + cssClass: 'is-limit--lwr is-limit--yellow', + low: -RED, + high: -YELLOW, + name: 'Yellow Low' + } }; - SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) { - return { - evaluate: function (datum, valueMetadata) { - var range = valueMetadata && valueMetadata.key; +export default function SinewaveLimitProvider() {} - if (datum[range] > RED[range]) { - return LIMITS.rh; - } +SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) { + return domainObject.type === 'generator'; +}; - if (datum[range] < -RED[range]) { - return LIMITS.rl; - } +SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) { + return { + evaluate: function (datum, valueMetadata) { + var range = valueMetadata && valueMetadata.key; - if (datum[range] > YELLOW[range]) { - return LIMITS.yh; - } - - if (datum[range] < -YELLOW[range]) { - return LIMITS.yl; - } + if (datum[range] > RED[range]) { + return LIMITS.rh; } - }; - }; - SinewaveLimitProvider.prototype.getLimits = function (domainObject) { - return { - limits: function () { - return Promise.resolve({ - WATCH: { - low: { - color: 'cyan', - sin: -CYAN.sin, - cos: -CYAN.cos - }, - high: { - color: 'cyan', - ...CYAN - } + if (datum[range] < -RED[range]) { + return LIMITS.rl; + } + + if (datum[range] > YELLOW[range]) { + return LIMITS.yh; + } + + if (datum[range] < -YELLOW[range]) { + return LIMITS.yl; + } + } + }; +}; + +SinewaveLimitProvider.prototype.getLimits = function (domainObject) { + return { + limits: function () { + return Promise.resolve({ + WATCH: { + low: { + color: 'cyan', + sin: -CYAN.sin, + cos: -CYAN.cos }, - WARNING: { - low: { - color: 'yellow', - sin: -YELLOW.sin, - cos: -YELLOW.cos - }, - high: { - color: 'yellow', - ...YELLOW - } - }, - DISTRESS: { - low: { - color: 'orange', - sin: -ORANGE.sin, - cos: -ORANGE.cos - }, - high: { - color: 'orange', - ...ORANGE - } - }, - CRITICAL: { - low: { - color: 'red', - sin: -RED.sin, - cos: -RED.cos - }, - high: { - color: 'red', - ...RED - } - }, - SEVERE: { - low: { - color: 'purple', - sin: -PURPLE.sin, - cos: -PURPLE.cos - }, - high: { - color: 'purple', - ...PURPLE - } + high: { + color: 'cyan', + ...CYAN } - }); - } - }; + }, + WARNING: { + low: { + color: 'yellow', + sin: -YELLOW.sin, + cos: -YELLOW.cos + }, + high: { + color: 'yellow', + ...YELLOW + } + }, + DISTRESS: { + low: { + color: 'orange', + sin: -ORANGE.sin, + cos: -ORANGE.cos + }, + high: { + color: 'orange', + ...ORANGE + } + }, + CRITICAL: { + low: { + color: 'red', + sin: -RED.sin, + cos: -RED.cos + }, + high: { + color: 'red', + ...RED + } + }, + SEVERE: { + low: { + color: 'purple', + sin: -PURPLE.sin, + cos: -PURPLE.cos + }, + high: { + color: 'purple', + ...PURPLE + } + } + }); + } }; - - return SinewaveLimitProvider; -}); +}; diff --git a/example/generator/SinewaveStalenessProvider.js b/example/generator/SinewaveStalenessProvider.js index 8819ae28ca..27f6ce96d4 100644 --- a/example/generator/SinewaveStalenessProvider.js +++ b/example/generator/SinewaveStalenessProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * diff --git a/example/generator/StateGeneratorProvider.js b/example/generator/StateGeneratorProvider.js index c840e6bb99..5da3b650c5 100644 --- a/example/generator/StateGeneratorProvider.js +++ b/example/generator/StateGeneratorProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,56 +20,52 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define([], function () { - function StateGeneratorProvider() {} +export default function StateGeneratorProvider() {} - function pointForTimestamp(timestamp, duration, name) { - return { - name: name, - utc: Math.floor(timestamp / duration) * duration, - value: Math.floor(timestamp / duration) % 2 - }; +function pointForTimestamp(timestamp, duration, name) { + return { + name: name, + utc: Math.floor(timestamp / duration) * duration, + value: Math.floor(timestamp / duration) % 2 + }; +} + +StateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) { + return domainObject.type === 'example.state-generator'; +}; + +StateGeneratorProvider.prototype.subscribe = function (domainObject, callback) { + var duration = domainObject.telemetry.duration * 1000; + + var interval = setInterval(function () { + var now = Date.now(); + var datum = pointForTimestamp(now, duration, domainObject.name); + datum.value = String(datum.value); + callback(datum); + }, duration); + + return function () { + clearInterval(interval); + }; +}; + +StateGeneratorProvider.prototype.supportsRequest = function (domainObject, options) { + return domainObject.type === 'example.state-generator'; +}; + +StateGeneratorProvider.prototype.request = function (domainObject, options) { + var start = options.start; + var end = Math.min(Date.now(), options.end); // no future values + var duration = domainObject.telemetry.duration * 1000; + if (options.strategy === 'latest' || options.size === 1) { + start = end; } - StateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) { - return domainObject.type === 'example.state-generator'; - }; + var data = []; + while (start <= end && data.length < 5000) { + data.push(pointForTimestamp(start, duration, domainObject.name)); + start += duration; + } - StateGeneratorProvider.prototype.subscribe = function (domainObject, callback) { - var duration = domainObject.telemetry.duration * 1000; - - var interval = setInterval(function () { - var now = Date.now(); - var datum = pointForTimestamp(now, duration, domainObject.name); - datum.value = String(datum.value); - callback(datum); - }, duration); - - return function () { - clearInterval(interval); - }; - }; - - StateGeneratorProvider.prototype.supportsRequest = function (domainObject, options) { - return domainObject.type === 'example.state-generator'; - }; - - StateGeneratorProvider.prototype.request = function (domainObject, options) { - var start = options.start; - var end = Math.min(Date.now(), options.end); // no future values - var duration = domainObject.telemetry.duration * 1000; - if (options.strategy === 'latest' || options.size === 1) { - start = end; - } - - var data = []; - while (start <= end && data.length < 5000) { - data.push(pointForTimestamp(start, duration, domainObject.name)); - start += duration; - } - - return Promise.resolve(data); - }; - - return StateGeneratorProvider; -}); + return Promise.resolve(data); +}; diff --git a/example/generator/WorkerInterface.js b/example/generator/WorkerInterface.js index d02546d34a..c5b8e85d61 100644 --- a/example/generator/WorkerInterface.js +++ b/example/generator/WorkerInterface.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,88 +20,86 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define(['uuid'], function ({ v4: uuid }) { - function WorkerInterface(openmct, StalenessProvider) { - // eslint-disable-next-line no-undef - const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`; - this.StalenessProvider = StalenessProvider; - this.worker = new Worker(workerUrl); - this.worker.onmessage = this.onMessage.bind(this); - this.callbacks = {}; - this.staleTelemetryIds = {}; +import { v4 as uuid } from 'uuid'; - this.watchStaleness(); +export default function WorkerInterface(openmct, StalenessProvider) { + // eslint-disable-next-line no-undef + const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`; + this.StalenessProvider = StalenessProvider; + this.worker = new Worker(workerUrl); + this.worker.onmessage = this.onMessage.bind(this); + this.callbacks = {}; + this.staleTelemetryIds = {}; + + this.watchStaleness(); +} + +WorkerInterface.prototype.watchStaleness = function () { + this.StalenessProvider.on('stalenessEvent', ({ id, isStale }) => { + this.staleTelemetryIds[id] = isStale; + }); +}; + +WorkerInterface.prototype.onMessage = function (message) { + message = message.data; + var callback = this.callbacks[message.id]; + if (callback) { + callback(message); + } +}; + +WorkerInterface.prototype.dispatch = function (request, data, callback) { + var message = { + request: request, + data: data, + id: uuid() + }; + + if (callback) { + this.callbacks[message.id] = callback; } - WorkerInterface.prototype.watchStaleness = function () { - this.StalenessProvider.on('stalenessEvent', ({ id, isStale }) => { - this.staleTelemetryIds[id] = isStale; - }); - }; + this.worker.postMessage(message); - WorkerInterface.prototype.onMessage = function (message) { - message = message.data; - var callback = this.callbacks[message.id]; - if (callback) { - callback(message); - } - }; + return message.id; +}; - WorkerInterface.prototype.dispatch = function (request, data, callback) { - var message = { - request: request, - data: data, - id: uuid() - }; +WorkerInterface.prototype.request = function (request) { + var deferred = {}; + var promise = new Promise(function (resolve, reject) { + deferred.resolve = resolve; + deferred.reject = reject; + }); + var messageId; - if (callback) { - this.callbacks[message.id] = callback; + let self = this; + function callback(message) { + if (message.error) { + deferred.reject(message.error); + } else { + deferred.resolve(message.data); } - this.worker.postMessage(message); + delete self.callbacks[messageId]; + } - return message.id; - }; + messageId = this.dispatch('request', request, callback.bind(this)); - WorkerInterface.prototype.request = function (request) { - var deferred = {}; - var promise = new Promise(function (resolve, reject) { - deferred.resolve = resolve; - deferred.reject = reject; - }); - var messageId; + return promise; +}; - let self = this; - function callback(message) { - if (message.error) { - deferred.reject(message.error); - } else { - deferred.resolve(message.data); - } - - delete self.callbacks[messageId]; +WorkerInterface.prototype.subscribe = function (request, cb) { + const { id, loadDelay } = request; + const messageId = this.dispatch('subscribe', request, (message) => { + if (!this.staleTelemetryIds[id]) { + setTimeout(() => cb(message.data), Math.max(loadDelay, 0)); } + }); - messageId = this.dispatch('request', request, callback.bind(this)); - - return promise; - }; - - WorkerInterface.prototype.subscribe = function (request, cb) { - const { id, loadDelay } = request; - const messageId = this.dispatch('subscribe', request, (message) => { - if (!this.staleTelemetryIds[id]) { - setTimeout(() => cb(message.data), Math.max(loadDelay, 0)); - } + return function () { + this.dispatch('unsubscribe', { + id: messageId }); - - return function () { - this.dispatch('unsubscribe', { - id: messageId - }); - delete this.callbacks[messageId]; - }.bind(this); - }; - - return WorkerInterface; -}); + delete this.callbacks[messageId]; + }.bind(this); +}; diff --git a/example/generator/generatorWorker.js b/example/generator/generatorWorker.js index 6a83fe2ba8..d103a25895 100644 --- a/example/generator/generatorWorker.js +++ b/example/generator/generatorWorker.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -85,7 +85,8 @@ data.offset, data.phase, data.randomness, - data.infinityValues + data.infinityValues, + data.exceedFloat32 ), wavelengths: wavelengths(), intensities: intensities(), @@ -96,7 +97,8 @@ data.offset, data.phase, data.randomness, - data.infinityValues + data.infinityValues, + data.exceedFloat32 ) } }); @@ -128,29 +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 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), - wavelengths: wavelengths(), - intensities: intensities(), - cos: cos(nextStep, period, amplitude, offset, phase, randomness, infinityValues) - }); + 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) { @@ -160,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, @@ -176,9 +215,26 @@ }); } - function cos(timestamp, period, amplitude, offset, phase, randomness, infinityValues) { - if (infinityValues && Math.random() > 0.5) { + function cos( + timestamp, + period, + amplitude, + offset, + phase, + randomness, + infinityValues, + exceedFloat32 + ) { + if (infinityValues && exceedFloat32) { + if (Math.random() > 0.5) { + return Number.POSITIVE_INFINITY; + } else if (Math.random() < 0.01) { + return getRandomFloat32OverflowValue(); + } + } else if (infinityValues && Math.random() > 0.5) { return Number.POSITIVE_INFINITY; + } else if (exceedFloat32 && Math.random() < 0.01) { + return getRandomFloat32OverflowValue(); } return ( @@ -188,9 +244,26 @@ ); } - function sin(timestamp, period, amplitude, offset, phase, randomness, infinityValues) { - if (infinityValues && Math.random() > 0.5) { + function sin( + timestamp, + period, + amplitude, + offset, + phase, + randomness, + infinityValues, + exceedFloat32 + ) { + if (infinityValues && exceedFloat32) { + if (Math.random() > 0.5) { + return Number.POSITIVE_INFINITY; + } else if (Math.random() < 0.01) { + return getRandomFloat32OverflowValue(); + } + } else if (infinityValues && Math.random() > 0.5) { return Number.POSITIVE_INFINITY; + } else if (exceedFloat32 && Math.random() < 0.01) { + return getRandomFloat32OverflowValue(); } return ( @@ -200,6 +273,13 @@ ); } + // Values exceeding float32 range (Positive: 3.4+38, Negative: -3.4+38) + function getRandomFloat32OverflowValue() { + const sign = Math.random() > 0.5 ? 1 : -1; + + return sign * 3.4e39; + } + function wavelengths() { let values = []; while (values.length < 5) { diff --git a/example/generator/plugin.js b/example/generator/plugin.js index d419196156..175bda4150 100644 --- a/example/generator/plugin.js +++ b/example/generator/plugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,11 +20,11 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import GeneratorMetadataProvider from './GeneratorMetadataProvider'; -import GeneratorProvider from './GeneratorProvider'; -import SinewaveLimitProvider from './SinewaveLimitProvider'; -import SinewaveStalenessProvider from './SinewaveStalenessProvider'; -import StateGeneratorProvider from './StateGeneratorProvider'; +import GeneratorMetadataProvider from './GeneratorMetadataProvider.js'; +import GeneratorProvider from './GeneratorProvider.js'; +import SinewaveLimitProvider from './SinewaveLimitProvider.js'; +import SinewaveStalenessProvider from './SinewaveStalenessProvider.js'; +import StateGeneratorProvider from './StateGeneratorProvider.js'; export default function (openmct) { openmct.types.addType('example.state-generator', { @@ -122,6 +122,13 @@ export default function (openmct) { key: 'infinityValues', property: ['telemetry', 'infinityValues'] }, + { + name: 'Exceed Float32 Limits', + control: 'toggleSwitch', + cssClass: 'l-input', + key: 'exceedFloat32', + property: ['telemetry', 'exceedFloat32'] + }, { name: 'Provide Staleness Updates', control: 'toggleSwitch', @@ -140,6 +147,7 @@ export default function (openmct) { randomness: 0, loadDelay: 0, infinityValues: false, + exceedFloat32: false, staleness: false }; } diff --git a/example/imagery/plugin.js b/example/imagery/plugin.js index ee2fe33f8c..9d37bbc925 100644 --- a/example/imagery/plugin.js +++ b/example/imagery/plugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -21,24 +21,24 @@ *****************************************************************************/ const DEFAULT_IMAGE_SAMPLES = [ - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18731.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18732.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18733.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18734.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18735.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18736.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18737.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18738.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18739.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18740.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18741.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18742.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18743.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18744.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18745.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18746.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18747.jpg', - 'https://www.hq.nasa.gov/alsj/a16/AS16-117-18748.jpg' + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18731.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18732.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18733.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18734.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18735.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18736.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18737.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18738.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18739.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18740.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18741.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18742.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18743.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18744.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18745.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18746.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18747.jpg', + 'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18748.jpg' ]; const DEFAULT_IMAGE_LOAD_DELAY_IN_MILLISECONDS = 20000; const MIN_IMAGE_LOAD_DELAY_IN_MILLISECONDS = 5000; diff --git a/example/simpleVuePlugin/HelloWorld.vue b/example/simpleVuePlugin/HelloWorld.vue deleted file mode 100644 index dc6b4272cc..0000000000 --- a/example/simpleVuePlugin/HelloWorld.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/example/simpleVuePlugin/plugin.js b/example/simpleVuePlugin/plugin.js deleted file mode 100644 index 9ff73043f8..0000000000 --- a/example/simpleVuePlugin/plugin.js +++ /dev/null @@ -1,36 +0,0 @@ -import Vue from 'vue'; - -import HelloWorld from './HelloWorld.vue'; - -function SimpleVuePlugin() { - return function install(openmct) { - openmct.types.addType('hello-world', { - name: 'Hello World', - description: 'An introduction object', - creatable: true - }); - openmct.objectViews.addProvider({ - name: 'demo-provider', - key: 'hello-world', - cssClass: 'icon-packet', - canView: function (d) { - return d.type === 'hello-world'; - }, - view: function (domainObject) { - var vm; - - return { - show: function (container) { - vm = new Vue(HelloWorld); - container.appendChild(vm.$mount().$el); - }, - destroy: function (container) { - //vm.$destroy(); - } - }; - } - }); - }; -} - -export default SimpleVuePlugin; diff --git a/index-test.js b/index-test.cjs similarity index 100% rename from index-test.js rename to index-test.cjs diff --git a/index.html b/index.html index 9233eadfbd..da07198cfd 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + - + + Open MCT @@ -91,157 +89,157 @@ width: 100px; } +
- diff --git a/karma.conf.js b/karma.conf.cjs similarity index 92% rename from karma.conf.js rename to karma.conf.cjs index b169af51dd..33e11e3eda 100644 --- a/karma.conf.js +++ b/karma.conf.cjs @@ -22,17 +22,17 @@ /*global module,process*/ -module.exports = (config) => { +module.exports = async (config) => { let webpackConfig; let browsers; let singleRun; if (process.env.KARMA_DEBUG) { - webpackConfig = require('./.webpack/webpack.dev.js'); + webpackConfig = (await import('./.webpack/webpack.dev.js')).default; browsers = ['ChromeDebugging']; singleRun = false; } else { - webpackConfig = require('./.webpack/webpack.coverage.js'); + webpackConfig = (await import('./.webpack/webpack.coverage.js')).default; browsers = ['ChromeHeadless']; singleRun = true; } @@ -45,7 +45,7 @@ module.exports = (config) => { basePath: '', frameworks: ['jasmine', 'webpack'], files: [ - 'index-test.js', + 'index-test.cjs', // included means: should the files be included in the browser using diff --git a/src/api/menu/components/SuperMenu.vue b/src/api/menu/components/SuperMenu.vue index 808750d8ca..cd8d72f7be 100644 --- a/src/api/menu/components/SuperMenu.vue +++ b/src/api/menu/components/SuperMenu.vue @@ -1,5 +1,5 @@ diff --git a/src/plugins/faultManagement/FaultManagementObjectProvider.js b/src/plugins/faultManagement/FaultManagementObjectProvider.js index 9d973ea895..1c7fa56613 100644 --- a/src/plugins/faultManagement/FaultManagementObjectProvider.js +++ b/src/plugins/faultManagement/FaultManagementObjectProvider.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -24,7 +24,7 @@ import { FAULT_MANAGEMENT_NAMESPACE, FAULT_MANAGEMENT_TYPE, FAULT_MANAGEMENT_VIEW -} from './constants'; +} from './constants.js'; export default class FaultManagementObjectProvider { constructor(openmct) { diff --git a/src/plugins/faultManagement/FaultManagementPlugin.js b/src/plugins/faultManagement/FaultManagementPlugin.js index cea1a08882..c84da63c83 100644 --- a/src/plugins/faultManagement/FaultManagementPlugin.js +++ b/src/plugins/faultManagement/FaultManagementPlugin.js @@ -1,5 +1,5 @@ /***************************************************************************** - * Open MCT, Copyright (c) 2014-2023, United States Government + * Open MCT, Copyright (c) 2014-2024, United States Government * as represented by the Administrator of the National Aeronautics and Space * Administration. All rights reserved. * @@ -20,10 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import { FAULT_MANAGEMENT_NAMESPACE, FAULT_MANAGEMENT_TYPE } from './constants'; -import FaultManagementInspectorViewProvider from './FaultManagementInspectorViewProvider'; -import FaultManagementObjectProvider from './FaultManagementObjectProvider'; -import FaultManagementViewProvider from './FaultManagementViewProvider'; +import { FAULT_MANAGEMENT_NAMESPACE, FAULT_MANAGEMENT_TYPE } from './constants.js'; +import FaultManagementInspectorViewProvider from './FaultManagementInspectorViewProvider.js'; +import FaultManagementObjectProvider from './FaultManagementObjectProvider.js'; +import FaultManagementViewProvider from './FaultManagementViewProvider.js'; export default function FaultManagementPlugin() { return function (openmct) { diff --git a/src/plugins/faultManagement/FaultManagementSearch.vue b/src/plugins/faultManagement/FaultManagementSearch.vue index 13221819b9..358c6c203d 100644 --- a/src/plugins/faultManagement/FaultManagementSearch.vue +++ b/src/plugins/faultManagement/FaultManagementSearch.vue @@ -1,5 +1,5 @@ diff --git a/src/plugins/folderView/components/ListItem.vue b/src/plugins/folderView/components/ListItem.vue index 72044a1968..c9332487a9 100644 --- a/src/plugins/folderView/components/ListItem.vue +++ b/src/plugins/folderView/components/ListItem.vue @@ -1,5 +1,5 @@