diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000000..98f45f4da8 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1 @@ +name: 'Custom CodeQL config' diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 70d43361db..5201e89b87 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,14 +13,18 @@ updates: - "pr:daveit" - "pr:platform" ignore: - #We have to source the container which is not detected by Dependabot + #We have to source the playwright container which is not detected by Dependabot - dependency-name: "@playwright/test" - #Lots of noise in these type patch releases. + - dependency-name: "playwright-core" + #Lots of noise in these type patch releases. - dependency-name: "@babel/eslint-parser" - update-types: ["version-update:semver-patch"] + update-types: ["version-update:semver-patch"] - dependency-name: "eslint-plugin-vue" update-types: ["version-update:semver-patch"] - + - dependency-name: "babel-loader" + update-types: ["version-update:semver-patch"] + - dependency-name: "sinon" + update-types: ["version-update:semver-patch"] - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index eb834fd9d9..9b7e0d9195 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,11 +1,10 @@ - -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ master ] + branches: [master, 'release/*'] pull_request: - branches: [ master ] + branches: [master, 'release/*'] paths-ignore: - '**/*Spec.js' - '**/*.md' @@ -27,17 +26,19 @@ jobs: security-events: write steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: javascript + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + config-file: ./.github/codeql/codeql-config.yml + languages: javascript + queries: security-and-quality - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml deleted file mode 100644 index a2df653447..0000000000 --- a/.github/workflows/lighthouse.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: lighthouse -on: - workflow_dispatch: - inputs: - version: - description: 'Which branch do you want to test?' # Limited to branch for now - required: false - default: 'master' - pull_request: - types: - - labeled -jobs: - lighthouse-pr: - if: ${{ github.event.label.name == 'pr:lighthouse' }} - runs-on: ubuntu-latest - steps: - - name: Checkout Master for Baseline - uses: actions/checkout@v3 - with: - ref: master #explicitly checkout master for baseline - - name: Install Node 16 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - - name: npm install with lighthouse cli - run: npm install && npm install -g @lhci/cli - - name: Run lhci against master to generate baseline and ignore exit codes - run: lhci autorun || true - - name: Perform clean checkout of PR - uses: actions/checkout@v3 - with: - clean: true - - name: Install Node version which is compatible with PR - uses: actions/setup-node@v3 - - name: npm install with lighthouse cli - run: npm install && npm install -g @lhci/cli - - name: Run lhci with PR - run: lhci autorun - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - lighthouse-nightly: - if: ${{ github.event.schedule }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Node 16 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - - name: npm install with lighthouse cli - run: npm install && npm install -g @lhci/cli - - name: Run lhci against master to generate baseline - run: lhci autorun - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - lighthouse-dispatch: - if: ${{ github.event.workflow_dispatch }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.inputs.version }} - - name: Install Node 14 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - - name: npm install with lighthouse cli - run: npm install && npm install -g @lhci/cli - - name: Run lhci against master to generate baseline - run: lhci autorun - \ No newline at end of file diff --git a/.github/workflows/npm-prerelease.yml b/.github/workflows/npm-prerelease.yml index b92d217902..a9321ac569 100644 --- a/.github/workflows/npm-prerelease.yml +++ b/.github/workflows/npm-prerelease.yml @@ -16,7 +16,11 @@ jobs: with: node-version: 16 - run: npm install - - run: npm test + - run: | + echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc + npm whoami + npm publish --access=public --tag unstable openmct + # - run: npm test publish-npm-prerelease: needs: build @@ -28,6 +32,6 @@ jobs: node-version: 16 registry-url: https://registry.npmjs.org/ - run: npm install - - run: npm publish --access public --tag unstable + - run: npm publish --access=public --tag unstable env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.npmignore b/.npmignore index 57b7d8d12b..1bdde6a5f5 100644 --- a/.npmignore +++ b/.npmignore @@ -21,4 +21,10 @@ !copyright-notice.html !index.html !openmct.js -!SECURITY.md \ No newline at end of file +!SECURITY.md + +# Add e2e tests to npm package +!/e2e/**/* + +# ... except our test-data folder files. +/e2e/test-data/*.json diff --git a/API.md b/API.md index 0603e898c7..8f5dc55260 100644 --- a/API.md +++ b/API.md @@ -1,11 +1,14 @@ -**Table of Contents** +**Table of Contents** -- [Building Applications With Open MCT](#building-applications-with-open-mct) +- [Building Applications With Open MCT](#developing-applications-with-open-mct) - [Scope and purpose of this document](#scope-and-purpose-of-this-document) - [Building From Source](#building-from-source) - [Starting an Open MCT application](#starting-an-open-mct-application) + - [Types](#types) + - [Using Types](#using-types) + - [Limitations](#limitations) - [Plugins](#plugins) - [Defining and Installing a New Plugin](#defining-and-installing-a-new-plugin) - [Domain Objects and Identifiers](#domain-objects-and-identifiers) @@ -61,18 +64,18 @@ ## Scope and purpose of this document -This document is intended to serve as a reference for developing an application -based on Open MCT. It will provide details of the API functions necessary to -extend the Open MCT platform meet common use cases such as integrating with a telemetry source. +This document is intended to serve as a reference for developing an application +based on Open MCT. It will provide details of the API functions necessary to +extend the Open MCT platform meet common use cases such as integrating with a telemetry source. -The best place to start is with the [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial). -These will walk you through the process of getting up and running with Open +The best place to start is with the [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial). +These will walk you through the process of getting up and running with Open MCT, as well as addressing some common developer use cases. -## Building From Source +## Building From Source -The latest version of Open MCT is available from [our GitHub repository](https://github.com/nasa/openmct). -If you have `git`, and `node` installed, you can build Open MCT with the commands +The latest version of Open MCT is available from [our GitHub repository](https://github.com/nasa/openmct). +If you have `git`, and `node` installed, you can build Open MCT with the commands ```bash git clone https://github.com/nasa/openmct.git @@ -80,28 +83,28 @@ cd openmct npm install ``` -These commands will fetch the Open MCT source from our GitHub repository, and -build a minified version that can be included in your application. The output -of the build process is placed in a `dist` folder under the openmct source -directory, which can be copied out to another location as needed. The contents -of this folder will include a minified javascript file named `openmct.js` as +These commands will fetch the Open MCT source from our GitHub repository, and +build a minified version that can be included in your application. The output +of the build process is placed in a `dist` folder under the openmct source +directory, which can be copied out to another location as needed. The contents +of this folder will include a minified javascript file named `openmct.js` as well as assets such as html, css, and images necessary for the UI. ## Starting an Open MCT application -To start a minimally functional Open MCT application, it is necessary to -include the Open MCT distributable, enable some basic plugins, and bootstrap -the application. The tutorials walk through the process of getting Open MCT up -and running from scratch, but provided below is a minimal HTML template that -includes Open MCT, installs some basic plugins, and bootstraps the application. -It assumes that Open MCT is installed under an `openmct` subdirectory, as -described in [Building From Source](#building-from-source). +To start a minimally functional Open MCT application, it is necessary to +include the Open MCT distributable, enable some basic plugins, and bootstrap +the application. The tutorials walk through the process of getting Open MCT up +and running from scratch, but provided below is a minimal HTML template that +includes Open MCT, installs some basic plugins, and bootstraps the application. +It assumes that Open MCT is installed under an `openmct` subdirectory, as +described in [Building From Source](#building-from-source). -This approach includes openmct using a simple script tag, resulting in a global -variable named `openmct`. This `openmct` object is used subsequently to make -API calls. +This approach includes openmct using a simple script tag, resulting in a global +variable named `openmct`. This `openmct` object is used subsequently to make +API calls. -Open MCT is packaged as a UMD (Universal Module Definition) module, so common +Open MCT is packaged as a UMD (Universal Module Definition) module, so common script loaders are also supported. ```html @@ -122,17 +125,59 @@ script loaders are also supported. ``` -The Open MCT library included above requires certain assets such as html -templates, images, and css. If you installed Open MCT from GitHub as described +The Open MCT library included above requires certain assets such as html +templates, images, and css. If you installed Open MCT from GitHub as described in the section on [Building from Source](#building-from-source) then these -assets will have been downloaded along with the Open MCT javascript library. +assets will have been downloaded along with the Open MCT javascript library. -There are some plugins bundled with the application that provide UI, -persistence, and other default configuration which are necessary to be able to -do anything with the application initially. Any of these plugins can, in -principle, be replaced with a custom plugin. The included plugins are +There are some plugins bundled with the application that provide UI, +persistence, and other default configuration which are necessary to be able to +do anything with the application initially. Any of these plugins can, in +principle, be replaced with a custom plugin. The included plugins are documented in the [Included Plugins](#included-plugins) section. +## Types + +The Open MCT library includes its own TypeScript declaration files which can be +used to provide code hints and typechecking in your own Open MCT application. + +Open MCT's type declarations are generated via `tsc` from JSDoc-style comment +blocks. For more information on this, [check out TypeScript's documentation](https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html). + +### Using Types + +In order to use Open MCT's provided types in your own application, create a +`jsconfig.js` at the root of your project with this minimal configuration: + +```json +{ + "compilerOptions": { + "baseUrl": "./", + "target": "es6", + "checkJs": true, + "moduleResolution": "node", + "paths": { + "openmct": ["node_modules/openmct/dist/openmct.d.ts"] + } + } +} +``` + +Then, simply import and use `openmct` in your application: + +```js +import openmct from "openmct"; +``` + +### Limitations + +The effort to add types for Open MCT's public API is ongoing, and the provided +type declarations may be incomplete. + +If you would like to contribute types to Open MCT, please check out +[TypeScript's documentation](https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html) on generating type declarations from JSDoc-style comment blocks. +Then read through our [contributing guide](https://github.com/nasa/openmct/blob/f7cf3f72c2efd46da7ce5719c5e52c8806d166f0/CONTRIBUTING.md) and open a PR! + ## Plugins ### Defining and Installing a New Plugin @@ -145,10 +190,10 @@ openmct.install(function install(openmctAPI) { ``` New plugins are installed in Open MCT by calling `openmct.install`, and -providing a plugin installation function. This function will be invoked on -application startup with one parameter - the openmct API object. A common -approach used in the Open MCT codebase is to define a plugin as a function that -returns this installation function. This allows configuration to be specified +providing a plugin installation function. This function will be invoked on +application startup with one parameter - the openmct API object. A common +approach used in the Open MCT codebase is to define a plugin as a function that +returns this installation function. This allows configuration to be specified when the plugin is included. eg. @@ -161,16 +206,16 @@ This approach can be seen in all of the [plugins provided with Open MCT](https:/ ## Domain Objects and Identifiers -_Domain Objects_ are the basic entities that represent domain knowledge in Open -MCT. The temperature sensor on a solar panel, an overlay plot comparing the -results of all temperature sensors, the command dictionary for a spacecraft, -the individual commands in that dictionary, the "My Items" folder: All of these +_Domain Objects_ are the basic entities that represent domain knowledge in Open +MCT. The temperature sensor on a solar panel, an overlay plot comparing the +results of all temperature sensors, the command dictionary for a spacecraft, +the individual commands in that dictionary, the "My Items" folder: All of these things are domain objects. A _Domain Object_ is simply a javascript object with some standard attributes. -An example of a _Domain Object_ is the "My Items" object which is a folder in -which a user can persist any objects that they create. The My Items object -looks like this: +An example of a _Domain Object_ is the "My Items" object which is a folder in +which a user can persist any objects that they create. The My Items object +looks like this: ```javascript { @@ -189,23 +234,24 @@ looks like this: The main attributes to note are the `identifier`, and `type` attributes. -* `identifier`: A composite key that provides a universally unique identifier +- `identifier`: A composite key that provides a universally unique identifier for this object. The `namespace` and `key` are used to identify the object. - The `key` must be unique within the namespace. -* `type`: All objects in Open MCT have a type. Types allow you to form an - ontology of knowledge and provide an abstraction for grouping, visualizing, - and interpreting data. Details on how to define a new object type are - provided below. + The `key` must be unique within the namespace. +- `type`: All objects in Open MCT have a type. Types allow you to form an + ontology of knowledge and provide an abstraction for grouping, visualizing, + and interpreting data. Details on how to define a new object type are + provided below. -Open MCT uses a number of builtin types. Typically you are going to want to +Open MCT uses a number of builtin types. Typically you are going to want to define your own when extending Open MCT. ### Domain Object Types -Custom types may be registered via the `addType` function on the Open MCT Type +Custom types may be registered via the `addType` function on the Open MCT Type registry. eg. + ```javascript openmct.types.addType('example.my-type', { name: "My Type", @@ -215,37 +261,39 @@ openmct.types.addType('example.my-type', { ``` The `addType` function accepts two arguments: -* A `string` key identifying the type. This key is used when specifying a type + +- A `string` key identifying the type. This key is used when specifying a type for an object. We recommend prefixing your types with a namespace to avoid conflicts with other plugins. -* An object type specification. An object type definition supports the following -attributes - * `name`: a `string` naming this object type - * `description`: a `string` specifying a longer-form description of this type - * `initialize`: a `function` which initializes the model for new domain objects - of this type. This can be used for setting default values on an object when +- An object type specification. An object type definition supports the following +attributes + - `name`: a `string` naming this object type + - `description`: a `string` specifying a longer-form description of this type + - `initialize`: a `function` which initializes the model for new domain objects + of this type. This can be used for setting default values on an object when it is instantiated. - * `creatable`: A `boolean` indicating whether users should be allowed to create - this type (default: `false`). This will determine whether the type appears + - `creatable`: A `boolean` indicating whether users should be allowed to create + this type (default: `false`). This will determine whether the type appears in the `Create` menu. - * `cssClass`: A `string` specifying a CSS class to apply to each representation - of this object. This is used for specifying an icon to appear next to each + - `cssClass`: A `string` specifying a CSS class to apply to each representation + of this object. This is used for specifying an icon to appear next to each object of this type. -The [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial) provide a -step-by-step examples of writing code for Open MCT that includes a [section on +The [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial) provide a +step-by-step examples of writing code for Open MCT that includes a [section on defining a new object type](https://github.com/nasa/openmct-tutorial#step-3---providing-objects). ## Root Objects -In many cases, you'd like a certain object (or a certain hierarchy of objects) -to be accessible from the top level of the application (the tree on the left-hand -side of Open MCT.) For example, it is typical to expose a telemetry dictionary +In many cases, you'd like a certain object (or a certain hierarchy of objects) +to be accessible from the top level of the application (the tree on the left-hand +side of Open MCT.) For example, it is typical to expose a telemetry dictionary as a hierarchy of telemetry-providing domain objects in this fashion. To do so, use the `addRoot` method of the object API. eg. + ```javascript openmct.objects.addRoot({ namespace: "example.namespace", @@ -254,12 +302,13 @@ openmct.objects.addRoot({ openmct.priority.HIGH); ``` -The `addRoot` function takes a two arguments, the first can be an [object identifier](#domain-objects-and-identifiers) for a root level object, or an array of identifiers for root +The `addRoot` function takes a two arguments, the first can be an [object identifier](#domain-objects-and-identifiers) for a root level object, or an array of identifiers for root level objects, or a function that returns a promise for an identifier or an array of root level objects, the second is a [priority](#priority-api) or numeric value. When using the `getAll` method of the object API, they will be returned in order of priority. eg. + ```javascript openmct.objects.addRoot(identifier, openmct.priority.LOW); // low = -1000, will appear last in composition or tree openmct.objects.addRoot(otherIdentifier, openmct.priority.HIGH); // high = 1000, will appear first in composition or tree @@ -269,11 +318,11 @@ Root objects are loaded just like any other objects, i.e. via an object provider ## Object Providers -An Object Provider is used to build _Domain Objects_, typically retrieved from -some source such as a persistence store or telemetry dictionary. In order to -integrate telemetry from a new source an object provider will need to be created -that can build objects representing telemetry points exposed by the telemetry -source. The API call to define a new object provider is fairly straightforward. +An Object Provider is used to build _Domain Objects_, typically retrieved from +some source such as a persistence store or telemetry dictionary. In order to +integrate telemetry from a new source an object provider will need to be created +that can build objects representing telemetry points exposed by the telemetry +source. The API call to define a new object provider is fairly straightforward. Here's a very simple example: ```javascript @@ -287,14 +336,15 @@ openmct.objects.addProvider('example.namespace', { } }); ``` + The `addProvider` function takes two arguments: -* `namespace`: A `string` representing the namespace that this object provider +- `namespace`: A `string` representing the namespace that this object provider will provide objects for. -* `provider`: An `object` with a single function, `get`. This function accepts an -[Identifier](#domain-objects-and-identifiers) for the object to be provided. -It is expected that the `get` function will return a -[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) +- `provider`: An `object` with a single function, `get`. This function accepts an +[Identifier](#domain-objects-and-identifiers) for the object to be provided. +It is expected that the `get` function will return a +[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with the object being requested. In future, object providers will support other methods to enable other operations with persistence stores, such as creating, updating, and deleting objects. @@ -309,8 +359,8 @@ may be cases where you want to provide the composition of a certain object ### Adding Composition Providers -You may want to populate a hierarchy under a custom root-level object based on -the contents of a telemetry dictionary. To do this, you can add a new +You may want to populate a hierarchy under a custom root-level object based on +the contents of a telemetry dictionary. To do this, you can add a new Composition Provider: ```javascript @@ -323,19 +373,20 @@ openmct.composition.addProvider({ } }); ``` -The `addProvider` function accepts a Composition Provider object as its sole + +The `addProvider` function accepts a Composition Provider object as its sole argument. A Composition Provider is a javascript object exposing two functions: -* `appliesTo`: A `function` that accepts a `domainObject` argument, and returns -a `boolean` value indicating whether this composition provider applies to the +- `appliesTo`: A `function` that accepts a `domainObject` argument, and returns +a `boolean` value indicating whether this composition provider applies to the given object. -* `load`: A `function` that accepts a `domainObject` as an argument, and returns +- `load`: A `function` that accepts a `domainObject` as an argument, and returns a `Promise` that resolves with an array of [Identifier](#domain-objects-and-identifiers). These identifiers will be used to fetch Domain Objects from an [Object Provider](#object-provider) ### Default Composition Provider -The default composition provider applies to any domain object with a -`composition` property. The value of `composition` should be an array of +The default composition provider applies to any domain object with a +`composition` property. The value of `composition` should be an array of identifiers, e.g.: ```javascript @@ -369,7 +420,7 @@ Open MCT are stable and documentation is included below. There are two main tasks for integrating telemetry sources-- describing telemetry objects with relevant metadata, and then providing telemetry data for those objects. You'll use an [Object Provider](#object-providers) to provide objects with the necessary [Telemetry Metadata](#telemetry-metadata), and then register a [Telemetry Provider](#telemetry-providers) to retrieve telemetry data for those objects. Alternatively, you can register a telemetry metadata provider to provide the necessary telemetry metadata. -For a step-by-step guide to building a telemetry adapter, please see the +For a step-by-step guide to building a telemetry adapter, please see the [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial). #### Telemetry Metadata @@ -429,24 +480,22 @@ attribute | type | flags | notes `max` | number | optional | the maximum possible value of this measurement. Will be used by plots, gauges, etc to automatically set a max value. `enumerations` | array | optional | for objects where `format` is `"enum"`, this array tracks all possible enumerations of the value. Each entry in this array is an object, with a `value` property that is the numerical value of the enumeration, and a `string` property that is the text value of the enumeration. ex: `{"value": 0, "string": "OFF"}`. If you use an enumerations array, `min` and `max` will be set automatically for you. - ###### Value Hints Each telemetry value description has an object defining hints. Keys in this object represent the hint itself, and the value represents the weight of that hint. A lower weight means the hint has a higher priority. For example, multiple values could be hinted for use as the y-axis of a plot (raw, engineering), but the highest priority would be the default choice. Likewise, a table will use hints to determine the default order of columns. Known hints: -* `domain`: Values with a `domain` hint will be used for the x-axis of a plot, and tables will render columns for these values first. -* `range`: Values with a `range` hint will be used as the y-axis on a plot, and tables will render columns for these values after the `domain` values. -* `image`: Indicates that the value may be interpreted as the URL to an image file, in which case appropriate views will be made available. -* `imageDownloadName`: Indicates that the value may be interpreted as the name of the image file. +- `domain`: Values with a `domain` hint will be used for the x-axis of a plot, and tables will render columns for these values first. +- `range`: Values with a `range` hint will be used as the y-axis on a plot, and tables will render columns for these values after the `domain` values. +- `image`: Indicates that the value may be interpreted as the URL to an image file, in which case appropriate views will be made available. +- `imageDownloadName`: Indicates that the value may be interpreted as the name of the image file. -##### The Time Conductor and Telemetry +##### The Time Conductor and Telemetry Open MCT provides a number of ways to pivot through data and link data via time. The Time Conductor helps synchronize multiple views around the same time. -In order for the time conductor to work, there will always be an active "time system". All telemetry metadata *must* have a telemetry value with a `key` that matches the `key` of the active time system. You can use the `source` attribute on the value metadata to remap this to a different field in the telemetry datum-- especially useful if you are working with disparate datasources that have different field mappings. - +In order for the time conductor to work, there will always be an active "time system". All telemetry metadata _must_ have a telemetry value with a `key` that matches the `key` of the active time system. You can use the `source` attribute on the value metadata to remap this to a different field in the telemetry datum-- especially useful if you are working with disparate datasources that have different field mappings. #### Telemetry Providers @@ -454,14 +503,14 @@ Telemetry providers are responsible for providing historical and real-time telem A telemetry provider is a javascript object with up to four methods: -* `supportsSubscribe(domainObject, callback, options)` optional. Must be implemented to provide realtime telemetry. Should return `true` if the provider supports subscriptions for the given domain object (and request options). -* `subscribe(domainObject, callback, options)` required if `supportsSubscribe` is implemented. Establish a subscription for realtime data for the given domain object. Should invoke `callback` with a single telemetry datum every time data is received. Must return an unsubscribe function. Multiple views can subscribe to the same telemetry object, so it should always return a new unsubscribe function. -* `supportsRequest(domainObject, options)` optional. Must be implemented to provide historical telemetry. Should return `true` if the provider supports historical requests for the given domain object. -* `request(domainObject, options)` required if `supportsRequest` is implemented. Must return a promise for an array of telemetry datums that fulfills the request. The `options` argument will include a `start`, `end`, and `domain` attribute representing the query bounds. See [Telemetry Requests and Responses](#telemetry-requests-and-responses) for more info on how to respond to requests. -* `supportsMetadata(domainObject)` optional. Implement and return `true` for objects that you want to provide dynamic metadata for. -* `getMetadata(domainObject)` required if `supportsMetadata` is implemented. Must return a valid telemetry metadata definition that includes at least one valueMetadata definition. -* `supportsLimits(domainObject)` optional. Implement and return `true` for domain objects that you want to provide a limit evaluator for. -* `getLimitEvaluator(domainObject)` required if `supportsLimits` is implemented. Must return a valid LimitEvaluator for a given domain object. +- `supportsSubscribe(domainObject, callback, options)` optional. Must be implemented to provide realtime telemetry. Should return `true` if the provider supports subscriptions for the given domain object (and request options). +- `subscribe(domainObject, callback, options)` required if `supportsSubscribe` is implemented. Establish a subscription for realtime data for the given domain object. Should invoke `callback` with a single telemetry datum every time data is received. Must return an unsubscribe function. Multiple views can subscribe to the same telemetry object, so it should always return a new unsubscribe function. +- `supportsRequest(domainObject, options)` optional. Must be implemented to provide historical telemetry. Should return `true` if the provider supports historical requests for the given domain object. +- `request(domainObject, options)` required if `supportsRequest` is implemented. Must return a promise for an array of telemetry datums that fulfills the request. The `options` argument will include a `start`, `end`, and `domain` attribute representing the query bounds. See [Telemetry Requests and Responses](#telemetry-requests-and-responses) for more info on how to respond to requests. +- `supportsMetadata(domainObject)` optional. Implement and return `true` for objects that you want to provide dynamic metadata for. +- `getMetadata(domainObject)` required if `supportsMetadata` is implemented. Must return a valid telemetry metadata definition that includes at least one valueMetadata definition. +- `supportsLimits(domainObject)` optional. Implement and return `true` for domain objects that you want to provide a limit evaluator for. +- `getLimitEvaluator(domainObject)` required if `supportsLimits` is implemented. Must return a valid LimitEvaluator for a given domain object. Telemetry providers are registered by calling `openmct.telemetry.addProvider(provider)`, e.g. @@ -474,7 +523,7 @@ openmct.telemetry.addProvider({ Note: it is not required to implement all of the methods on every provider. Depending on the complexity of your implementation, it may be helpful to instantiate and register your realtime, historical, and metadata providers separately. -#### Telemetry Requests and Responses. +#### Telemetry Requests and Responses Telemetry requests support time bounded queries. A call to a _Telemetry Provider_'s `request` function will include an `options` argument. These are simply javascript objects with attributes for the request parameters. An example of a telemetry request object with a start and end time is included below: @@ -507,6 +556,7 @@ the number of results it desires. The `size` parameter is a hint; views must not assume the response will have the exact number of results requested. example: + ```javascript { start: 1487981997240, @@ -522,6 +572,7 @@ This strategy says "I want the latest data point in this time range". A provide ##### `minmax` request strategy example: + ```javascript { start: 1487981997240, @@ -536,28 +587,28 @@ MinMax queries are issued by plots, and may be issued by other types as well. T #### Telemetry Formats -Telemetry format objects define how to interpret and display telemetry data. +Telemetry format objects define how to interpret and display telemetry data. They have a simple structure: -* `key`: A `string` that uniquely identifies this formatter. -* `format`: A `function` that takes a raw telemetry value, and returns a - human-readable `string` representation of that value. It has one required - argument, and three optional arguments that provide context and can be used - for returning scaled representations of a value. An example of this is - representing time values in a scale such as the time conductor scale. There +- `key`: A `string` that uniquely identifies this formatter. +- `format`: A `function` that takes a raw telemetry value, and returns a + human-readable `string` representation of that value. It has one required + argument, and three optional arguments that provide context and can be used + for returning scaled representations of a value. An example of this is + representing time values in a scale such as the time conductor scale. There are multiple ways of representing a point in time, and by providing a minimum scale value, maximum scale value, and a count, it's possible to provide more useful representations of time given the provided limitations. - * `value`: The raw telemetry value in its native type. - * `minValue`: An __optional__ argument specifying the minimum displayed + - `value`: The raw telemetry value in its native type. + - `minValue`: An **optional** argument specifying the minimum displayed value. - * `maxValue`: An __optional__ argument specifying the maximum displayed + - `maxValue`: An **optional** argument specifying the maximum displayed value. - * `count`: An __optional__ argument specifying the number of displayed + - `count`: An **optional** argument specifying the number of displayed values. -* `parse`: A `function` that takes a `string` representation of a telemetry +- `parse`: A `function` that takes a `string` representation of a telemetry value, and returns the value in its native type. **Note** parse might receive an already-parsed value. This function should be idempotent. -* `validate`: A `function` that takes a `string` representation of a telemetry +- `validate`: A `function` that takes a `string` representation of a telemetry value, and returns a `boolean` value indicating whether the provided string can be parsed. @@ -583,9 +634,9 @@ openmct.telemetry.addFormat({ #### Telemetry Data A single telemetry point is considered a Datum, and is represented by a standard -javascript object. Realtime subscriptions (obtained via __subscribe__) will +javascript object. Realtime subscriptions (obtained via **subscribe**) will invoke the supplied callback once for each telemetry datum recieved. Telemetry -requests (obtained via __request__) will return a promise for an array of +requests (obtained via **request**) will return a promise for an array of telemetry datums. ##### Telemetry Datums @@ -606,14 +657,14 @@ section. #### Limit Evaluators **draft** -Limit evaluators allow a telemetry integrator to define which limits exist for a +Limit evaluators allow a telemetry integrator to define which limits exist for a telemetry endpoint and how limits should be applied to telemetry from a given domain object. A limit evaluator can implement the `evalute` method which is used to define how limits -should be applied to telemetry and the `getLimits` method which is used to specify +should be applied to telemetry and the `getLimits` method which is used to specify what the limit values are for different limit levels. -Limit levels can be mapped to one of 5 colors for visualization: +Limit levels can be mapped to one of 5 colors for visualization: `purple`, `red`, `orange`, `yellow` and `cyan`. For an example of a limit evaluator, take a look at `examples/generator/SinewaveLimitProvider.js`. @@ -622,30 +673,29 @@ For an example of a limit evaluator, take a look at `examples/generator/Sinewave The APIs for requesting telemetry from Open MCT -- e.g. for use in custom views -- are currently in draft state and are being revised. If you'd like to experiment with them before they are finalized, please contact the team via the contact-us link on our website. - ## Time API Open MCT provides API for managing the temporal state of the application. -Central to this is the concept of "time bounds". Views in Open MCT will -typically show telemetry data for some prescribed date range, and the Time API +Central to this is the concept of "time bounds". Views in Open MCT will +typically show telemetry data for some prescribed date range, and the Time API provides a way to centrally manage these bounds. -The Time API exposes a number of methods for querying and setting the temporal +The Time API exposes a number of methods for querying and setting the temporal state of the application, and emits events to inform listeners when the state changes. -Because the data displayed tends to be time domain data, Open MCT must always +Because the data displayed tends to be time domain data, Open MCT must always have at least one time system installed and activated. When you download Open -MCT, it will be pre-configured to use the UTC time system, which is installed and activated, along with other default plugins, in `index.html`. Installing and activating a time system is simple, and is covered -[in the next section](#defining-and-registering-time-systems). +MCT, it will be pre-configured to use the UTC time system, which is installed and activated, along with other default plugins, in `index.html`. Installing and activating a time system is simple, and is covered +[in the next section](#defining-and-registering-time-systems). ### Time Systems and Bounds #### Defining and Registering Time Systems -The time bounds of an Open MCT application are defined as numbers, and a Time -System gives meaning and context to these numbers so that they can be correctly -interpreted. Time Systems are JavaScript objects that provide some information -about the current time reference frame. An example of defining and registering +The time bounds of an Open MCT application are defined as numbers, and a Time +System gives meaning and context to these numbers so that they can be correctly +interpreted. Time Systems are JavaScript objects that provide some information +about the current time reference frame. An example of defining and registering a new time system is given below: ``` javascript @@ -659,31 +709,31 @@ openmct.time.addTimeSystem({ }); ``` -The example above defines a new utc based time system. In fact, this time system -is configured and activated by default from `index.html` in the default -installation of Open MCT if you download the source from GitHub. Some details of +The example above defines a new utc based time system. In fact, this time system +is configured and activated by default from `index.html` in the default +installation of Open MCT if you download the source from GitHub. Some details of each of the required properties is provided below. -* `key`: A `string` that uniquely identifies this time system. -* `name`: A `string` providing a brief human readable label. If the [Time Conductor](#the-time-conductor) +- `key`: A `string` that uniquely identifies this time system. +- `name`: A `string` providing a brief human readable label. If the [Time Conductor](#the-time-conductor) plugin is enabled, this name will identify the time system in a dropdown menu. -* `cssClass`: A class name `string` that will be applied to the time system when -it appears in the UI. This will be used to represent the time system with an icon. -There are a number of built-in icon classes [available in Open MCT](https://github.com/nasa/openmct/blob/master/platform/commonUI/general/res/sass/_glyphs.scss), -or a custom class can be used here. -* `timeFormat`: A `string` corresponding to the key of a registered -[telemetry time format](#telemetry-formats). The format will be used for -displaying discrete timestamps from telemetry streams when this time system is -activated. If the [UTCTimeSystem](#included-plugins) is enabled, then the `utc` +- `cssClass`: A class name `string` that will be applied to the time system when +it appears in the UI. This will be used to represent the time system with an icon. +There are a number of built-in icon classes [available in Open MCT](https://github.com/nasa/openmct/blob/master/platform/commonUI/general/res/sass/_glyphs.scss), +or a custom class can be used here. +- `timeFormat`: A `string` corresponding to the key of a registered +[telemetry time format](#telemetry-formats). The format will be used for +displaying discrete timestamps from telemetry streams when this time system is +activated. If the [UTCTimeSystem](#included-plugins) is enabled, then the `utc` format can be used if this is a utc-based time system -* `durationFormat`: A `string` corresponding to the key of a registered -[telemetry time format](#telemetry-formats). The format will be used for -displaying time ranges, for example `00:15:00` might be used to represent a time +- `durationFormat`: A `string` corresponding to the key of a registered +[telemetry time format](#telemetry-formats). The format will be used for +displaying time ranges, for example `00:15:00` might be used to represent a time period of fifteen minutes. These are used by the Time Conductor plugin to specify -relative time offsets. If the [UTCTimeSystem](#included-plugins) is enabled, +relative time offsets. If the [UTCTimeSystem](#included-plugins) is enabled, then the `duration` format can be used if this is a utc-based time system -* `isUTCBased`: A `boolean` that defines whether this time system represents -numbers in UTC terrestrial time. +- `isUTCBased`: A `boolean` that defines whether this time system represents +numbers in UTC terrestrial time. #### Getting and Setting the Active Time System @@ -696,30 +746,30 @@ timeSystem. openmct.time.timeSystem('utc', bounds); ``` -A time system can be immediately activated after registration: +A time system can be immediately activated after registration: ```javascript openmct.time.addTimeSystem(utcTimeSystem); openmct.time.timeSystem(utcTimeSystem, bounds); ``` -Setting the active time system will trigger a [`'timeSystem'`](#time-events) +Setting the active time system will trigger a [`'timeSystem'`](#time-events) event. If you supplied bounds, a [`'bounds'`](#time-events) event will be triggered afterwards with your newly supplied bounds. #### Time Bounds -The TimeAPI provides a getter/setter for querying and setting time bounds. Time +The TimeAPI provides a getter/setter for querying and setting time bounds. Time bounds are simply an object with a `start` and an end `end` attribute. -* `start`: A `number` representing a moment in time in the active [Time System](#defining-and-registering-time-systems). +- `start`: A `number` representing a moment in time in the active [Time System](#defining-and-registering-time-systems). This will be used as the beginning of the time period displayed by time-responsive telemetry views. -* `end`: A `number` representing a moment in time in the active [Time System](#defining-and-registering-time-systems). +- `end`: A `number` representing a moment in time in the active [Time System](#defining-and-registering-time-systems). This will be used as the end of the time period displayed by time-responsive telemetry views. -If invoked with bounds, it will set the new time bounds system-wide. If invoked -without any parameters, it will return the current application-wide time bounds. +If invoked with bounds, it will set the new time bounds system-wide. If invoked +without any parameters, it will return the current application-wide time bounds. ``` javascript const ONE_HOUR = 60 * 60 * 1000; @@ -734,16 +784,16 @@ event. The Time API can be set to follow a clock source which will cause the bounds to be updated automatically whenever the clock source "ticks". A clock is simply -an object that supports registration of listeners and periodically invokes its -listeners with a number. Open MCT supports registration of new clock sources that -tick on almost anything. A tick occurs when the clock invokes callback functions +an object that supports registration of listeners and periodically invokes its +listeners with a number. Open MCT supports registration of new clock sources that +tick on almost anything. A tick occurs when the clock invokes callback functions registered by its listeners with a new time value. -An example of a clock source is the [LocalClock](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/LocalClock.js) -which emits the current time in UTC every 100ms. Clocks can tick on anything. For -example, a clock could be defined to provide the timestamp of any new data -received via a telemetry subscription. This would have the effect of advancing -the bounds of views automatically whenever data is received. A clock could also +An example of a clock source is the [LocalClock](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/LocalClock.js) +which emits the current time in UTC every 100ms. Clocks can tick on anything. For +example, a clock could be defined to provide the timestamp of any new data +received via a telemetry subscription. This would have the effect of advancing +the bounds of views automatically whenever data is received. A clock could also be defined to tick on some remote timing source. The values provided by clocks are simple `number`s, which are interpreted in the @@ -753,32 +803,32 @@ context of the active [Time System](#defining-and-registering-time-systems). A clock is an object that defines certain required metadata and functions: -* `key`: A `string` uniquely identifying this clock. This can be used later to +- `key`: A `string` uniquely identifying this clock. This can be used later to reference the clock in places such as the [Time Conductor configuration](#time-conductor-configuration) -* `cssClass`: A `string` identifying a CSS class to apply to this clock when it's -displayed in the UI. This will be used to represent the time system with an icon. -There are a number of built-in icon classes [available in Open MCT](https://github.com/nasa/openmct/blob/master/platform/commonUI/general/res/sass/_glyphs.scss), -or a custom class can be used here. -* `name`: A `string` providing a human-readable identifier for the clock source. -This will be displayed in the clock selector menu in the Time Conductor UI -component, if active. -* `description`: An __optional__ `string` providing a longer description of the -clock. The description will be visible in the clock selection menu in the Time +- `cssClass`: A `string` identifying a CSS class to apply to this clock when it's +displayed in the UI. This will be used to represent the time system with an icon. +There are a number of built-in icon classes [available in Open MCT](https://github.com/nasa/openmct/blob/master/platform/commonUI/general/res/sass/_glyphs.scss), +or a custom class can be used here. +- `name`: A `string` providing a human-readable identifier for the clock source. +This will be displayed in the clock selector menu in the Time Conductor UI +component, if active. +- `description`: An **optional** `string` providing a longer description of the +clock. The description will be visible in the clock selection menu in the Time Conductor plugin. -* `on`: A `function` supporting registration of a new callback that will be +- `on`: A `function` supporting registration of a new callback that will be invoked when the clock next ticks. It will be invoked with two arguments: - * `eventName`: A `string` specifying the event to listen on. For now, clocks + - `eventName`: A `string` specifying the event to listen on. For now, clocks support one event - `tick`. - * `callback`: A `function` that will be invoked when this clock ticks. The + - `callback`: A `function` that will be invoked when this clock ticks. The function must be invoked with one parameter - a `number` representing a valid time in the current time system. -* `off`: A `function` that allows deregistration of a tick listener. It accepts +- `off`: A `function` that allows deregistration of a tick listener. It accepts the same arguments as `on`. -* `currentValue`: A `function` that returns a `number` representing a point in -time in the active time system. It should be the last value provided by a tick, +- `currentValue`: A `function` that returns a `number` representing a point in +time in the active time system. It should be the last value provided by a tick, or some default value if no ticking has yet occurred. -A new clock can be registered using the `addClock` function exposed by the Time +A new clock can be registered using the `addClock` function exposed by the Time API: ```javascript @@ -805,26 +855,25 @@ An example clock implementation is provided in the form of the [LocalClock](http #### Getting and setting active clock -Once registered a clock can be activated by calling the `clock` function on the -Time API passing in the key or instance of a registered clock. Only one clock -may be active at once, so activating a clock will deactivate any currently +Once registered a clock can be activated by calling the `clock` function on the +Time API passing in the key or instance of a registered clock. Only one clock +may be active at once, so activating a clock will deactivate any currently active clock. [`clockOffsets`](#clock-offsets) must be specified when changing a clock. Setting the clock triggers a [`'clock'`](#time-events) event, followed by a [`'clockOffsets'`](#time-events) event, and then a [`'bounds'`](#time-events) event as the offsets are applied to the clock's currentValue(). - ``` openmct.time.clock(someClock, clockOffsets); ``` Upon being activated, the time API will listen for tick events on the clock by calling `clock.on`. -The currently active clock (if any) can be retrieved by calling the same +The currently active clock (if any) can be retrieved by calling the same function without any arguments. #### Stopping an active clock -The `stopClock` method can be used to stop an active clock, and to clear it. It +The `stopClock` method can be used to stop an active clock, and to clear it. It will stop the clock from ticking, and set the active clock to `undefined`. ``` javascript @@ -833,22 +882,22 @@ openmct.time.stopClock(); #### Clock Offsets -When a clock is active, the time bounds of the application will be updated -automatically each time the clock "ticks". The bounds are calculated based on -the current value provided by the active clock (via its `tick` event, or its -`currentValue()` method). +When a clock is active, the time bounds of the application will be updated +automatically each time the clock "ticks". The bounds are calculated based on +the current value provided by the active clock (via its `tick` event, or its +`currentValue()` method). Unlike bounds, which represent absolute time values, clock offsets represent relative time spans. Offsets are defined as an object with two properties: -* `start`: A `number` that must be < 0 and which is used to calculate the start -bounds on each clock tick. The start offset will be calculated relative to the +- `start`: A `number` that must be < 0 and which is used to calculate the start +bounds on each clock tick. The start offset will be calculated relative to the value provided by a clock's tick callback, or its `currentValue()` function. -* `end`: A `number` that must be >= 0 and which is used to calculate the end +- `end`: A `number` that must be >= 0 and which is used to calculate the end bounds on each clock tick. -The `clockOffsets` function can be used to get or set clock offsets. For example, -to show the last fifteen minutes in a ms-based time system: +The `clockOffsets` function can be used to get or set clock offsets. For example, +to show the last fifteen minutes in a ms-based time system: ```javascript var FIFTEEN_MINUTES = 15 * 60 * 1000; @@ -859,8 +908,8 @@ openmct.time.clockOffsets({ }) ``` -__Note:__ Setting the clock offsets will trigger an immediate bounds change, as -new bounds will be calculated based on the `currentValue()` of the active clock. +**Note:** Setting the clock offsets will trigger an immediate bounds change, as +new bounds will be calculated based on the `currentValue()` of the active clock. Clock offsets are only relevant when a clock source is active. ### Time Events @@ -879,89 +928,88 @@ openmct.time.on('bounds', function callback (newBounds, tick) { The events emitted by the Time API are: -* `bounds`: emitted whenever the bounds change. The callback will be invoked +- `bounds`: emitted whenever the bounds change. The callback will be invoked with two arguments: - * `bounds`: A [bounds](#getting-and-setting-bounds) bounds object + - `bounds`: A [bounds](#getting-and-setting-bounds) bounds object representing a new time period bound by the specified start and send times. - * `tick`: A `boolean` indicating whether or not this bounds change is due to - a "tick" from a [clock source](#clocks). This information can be useful - when determining a strategy for fetching telemetry data in response to a - bounds change event. For example, if the bounds change was automatic, and - is due to a tick then it's unlikely that you would need to perform a - historical data query. It should be sufficient to just show any new - telemetry received via subscription since the last tick, and optionally to - discard any older data that now falls outside of the currently set bounds. - If `tick` is false,then the bounds change was not due to an automatic tick, - and a query for historical data may be necessary, depending on your data + - `tick`: A `boolean` indicating whether or not this bounds change is due to + a "tick" from a [clock source](#clocks). This information can be useful + when determining a strategy for fetching telemetry data in response to a + bounds change event. For example, if the bounds change was automatic, and + is due to a tick then it's unlikely that you would need to perform a + historical data query. It should be sufficient to just show any new + telemetry received via subscription since the last tick, and optionally to + discard any older data that now falls outside of the currently set bounds. + If `tick` is false,then the bounds change was not due to an automatic tick, + and a query for historical data may be necessary, depending on your data caching strategy, and how significantly the start bound has changed. -* `timeSystem`: emitted whenever the active time system changes. The callback will be invoked with a single argument: - * `timeSystem`: The newly active [time system](#defining-and-registering-time-systems). -* `clock`: emitted whenever the clock changes. The callback will be invoked +- `timeSystem`: emitted whenever the active time system changes. The callback will be invoked with a single argument: + - `timeSystem`: The newly active [time system](#defining-and-registering-time-systems). +- `clock`: emitted whenever the clock changes. The callback will be invoked with a single argument: - * `clock`: The newly active [clock](#clocks), or `undefined` if an active + - `clock`: The newly active [clock](#clocks), or `undefined` if an active clock has been deactivated. -* `clockOffsets`: emitted whenever the active clock offsets change. The +- `clockOffsets`: emitted whenever the active clock offsets change. The callback will be invoked with a single argument: - * `clockOffsets`: The new [clock offsets](#clock-offsets). - + - `clockOffsets`: The new [clock offsets](#clock-offsets). ### The Time Conductor -The Time Conductor provides a user interface for managing time bounds in Open +The Time Conductor provides a user interface for managing time bounds in Open MCT. It allows a user to select from configured time systems and clocks, and to set bounds and clock offsets. -If activated, the time conductor must be provided with configuration options, +If activated, the time conductor must be provided with configuration options, detailed below. #### Time Conductor Configuration -The time conductor is configured by specifying the options that will be -available to the user from the menus in the time conductor. These will determine -the clocks available from the conductor, the time systems available for each -clock, and some default bounds and clock offsets for each combination of clock -and time system. By default, the conductor always supports a `fixed` mode where +The time conductor is configured by specifying the options that will be +available to the user from the menus in the time conductor. These will determine +the clocks available from the conductor, the time systems available for each +clock, and some default bounds and clock offsets for each combination of clock +and time system. By default, the conductor always supports a `fixed` mode where no clock is active. To specify configuration for fixed mode, simply leave out a `clock` attribute in the configuration entry object. -Configuration is provided as an `array` of menu options. Each entry of the +Configuration is provided as an `array` of menu options. Each entry of the array is an object with some properties specifying configuration. The configuration -options specified are slightly different depending on whether or not it is for +options specified are slightly different depending on whether or not it is for an active clock mode. -__Configuration for Fixed Time Mode (no active clock)__ +**Configuration for Fixed Time Mode (no active clock)** -* `timeSystem`: A `string`, the key for the time system that this configuration +- `timeSystem`: A `string`, the key for the time system that this configuration relates to. -* `bounds`: A [`Time Bounds`](#time-bounds) object. These bounds will be applied -when the user selects the time system specified in the previous `timeSystem` +- `bounds`: A [`Time Bounds`](#time-bounds) object. These bounds will be applied +when the user selects the time system specified in the previous `timeSystem` property. -* `zoomOutLimit`: An __optional__ `number` specifying the longest period of time -that can be represented by the conductor when zooming. If a `zoomOutLimit` is -provided, then a `zoomInLimit` must also be provided. If provided, the zoom +- `zoomOutLimit`: An **optional** `number` specifying the longest period of time +that can be represented by the conductor when zooming. If a `zoomOutLimit` is +provided, then a `zoomInLimit` must also be provided. If provided, the zoom slider will automatically become available in the Time Conductor UI. -* `zoomInLimit`: An __optional__ `number` specifying the shortest period of time -that can be represented by the conductor when zooming. If a `zoomInLimit` is -provided, then a `zoomOutLimit` must also be provided. If provided, the zoom +- `zoomInLimit`: An **optional** `number` specifying the shortest period of time +that can be represented by the conductor when zooming. If a `zoomInLimit` is +provided, then a `zoomOutLimit` must also be provided. If provided, the zoom slider will automatically become available in the Time Conductor UI. -__Configuration for Active Clock__ +**Configuration for Active Clock** -* `clock`: A `string`, the `key` of the clock that this configuration applies to. -* `timeSystem`: A `string`, the key for the time system that this configuration -relates to. Separate configuration must be provided for each time system that you +- `clock`: A `string`, the `key` of the clock that this configuration applies to. +- `timeSystem`: A `string`, the key for the time system that this configuration +relates to. Separate configuration must be provided for each time system that you wish to be available to users when they select the specified clock. -* `clockOffsets`: A [`clockOffsets`](#clock-offsets) object that will be -automatically applied when the combination of clock and time system specified in +- `clockOffsets`: A [`clockOffsets`](#clock-offsets) object that will be +automatically applied when the combination of clock and time system specified in this configuration is selected from the UI. #### Example conductor configuration -An example time conductor configuration is provided below. It sets up some -default options for the [UTCTimeSystem](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/UTCTimeSystem.js) -and [LocalTimeSystem](https://github.com/nasa/openmct/blob/master/src/plugins/localTimeSystem/LocalTimeSystem.js), -in both fixed mode, and for the [LocalClock](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/LocalClock.js) -source. In this configutation, the local clock supports both the UTCTimeSystem -and LocalTimeSystem. Configuration for fixed bounds mode is specified by omitting +An example time conductor configuration is provided below. It sets up some +default options for the [UTCTimeSystem](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/UTCTimeSystem.js) +and [LocalTimeSystem](https://github.com/nasa/openmct/blob/master/src/plugins/localTimeSystem/LocalTimeSystem.js), +in both fixed mode, and for the [LocalClock](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/LocalClock.js) +source. In this configutation, the local clock supports both the UTCTimeSystem +and LocalTimeSystem. Configuration for fixed bounds mode is specified by omitting a clock key. ``` javascript @@ -997,26 +1045,27 @@ openmct.install(openmct.plugins.Conductor({ ## Indicators -Indicators are small widgets that reside at the bottom of the screen and are visible from +Indicators are small widgets that reside at the bottom of the screen and are visible from every screen in Open MCT. They can be used to convey system state using an icon and text. -Typically an indicator will display an icon (customizable with a CSS class) that will +Typically an indicator will display an icon (customizable with a CSS class) that will reveal additional information when the mouse cursor is hovered over it. ### The URL Status Indicator -A common use case for indicators is to convey the state of some external system such as a -persistence backend or HTTP server. So long as this system is accessible via HTTP request, -Open MCT provides a general purpose indicator to show whether the server is available and +A common use case for indicators is to convey the state of some external system such as a +persistence backend or HTTP server. So long as this system is accessible via HTTP request, +Open MCT provides a general purpose indicator to show whether the server is available and returning a 2xx status code. The URL Status Indicator is made available as a default plugin. See -the [documentation](./src/plugins/URLIndicatorPlugin) for details on how to install and configure the +the [documentation](./src/plugins/URLIndicatorPlugin) for details on how to install and configure the URL Status Indicator. ### Creating a Simple Indicator -A simple indicator with an icon and some text can be created and added with minimal code. An indicator +A simple indicator with an icon and some text can be created and added with minimal code. An indicator of this type exposes functions for customizing the text, icon, and style of the indicator. eg. + ``` javascript var myIndicator = openmct.indicators.simpleIndicator(); myIndicator.text("Hello World!"); @@ -1025,24 +1074,24 @@ openmct.indicators.add(myIndicator); This will create a new indicator and add it to the bottom of the screen in Open MCT. By default, the indicator will appear as an information icon. Hovering over the icon will -reveal the text set via the call to `.text()`. The Indicator object returned by the API +reveal the text set via the call to `.text()`. The Indicator object returned by the API call exposes a number of functions for customizing the content and appearance of the indicator: -* `.text([text])`: Gets or sets the text shown when the user hovers over the indicator. -Accepts an __optional__ `string` argument that, if provided, will be used to set the text. -Hovering over the indicator will expand it to its full size, revealing this text alongside +- `.text([text])`: Gets or sets the text shown when the user hovers over the indicator. +Accepts an **optional** `string` argument that, if provided, will be used to set the text. +Hovering over the indicator will expand it to its full size, revealing this text alongside the icon. Returns the currently set text as a `string`. -* `.description([description])`: Gets or sets the indicator's description. Accepts an -__optional__ `string` argument that, if provided, will be used to set the text. The description -allows for more detail to be provided in a tooltip when the user hovers over the indicator. +- `.description([description])`: Gets or sets the indicator's description. Accepts an +**optional** `string` argument that, if provided, will be used to set the text. The description +allows for more detail to be provided in a tooltip when the user hovers over the indicator. Returns the currently set text as a `string`. -* `.iconClass([className])`: Gets or sets the CSS class used to define the icon. Accepts an __optional__ -`string` parameter to be used to set the class applied to the indicator. Any of -[the built-in glyphs](https://nasa.github.io/openmct/style-guide/#/browse/styleguide:home/glyphs?view=styleguide.glyphs) -may be used here, or a custom CSS class can be provided. Returns the currently defined CSS +- `.iconClass([className])`: Gets or sets the CSS class used to define the icon. Accepts an **optional** +`string` parameter to be used to set the class applied to the indicator. Any of +[the built-in glyphs](https://nasa.github.io/openmct/style-guide/#/browse/styleguide:home/glyphs?view=styleguide.glyphs) +may be used here, or a custom CSS class can be provided. Returns the currently defined CSS class as a `string`. -* `.statusClass([className])`: Gets or sets the CSS class used to determine status. Accepts an __optional __ -`string` parameter to be used to set a status class applied to the indicator. May be used to apply +- `.statusClass([className])`: Gets or sets the CSS class used to determine status. Accepts an __optional__ +`string` parameter to be used to set a status class applied to the indicator. May be used to apply different colors to indicate status. ### Custom Indicators @@ -1068,6 +1117,7 @@ Open MCT provides some built-in priority values that can be used in the applicat ### Priority Types Currently, the Open MCT Priority API provides (type: numeric value): + - HIGH: 1000 - Default: 0 - LOW: -1000 diff --git a/README.md b/README.md index 463961d333..7287a4a157 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ To run the performance tests: The test suite is configured to all tests localed in `e2e/tests/` ending in `*.e2e.spec.js`. For more about the e2e test suite, please see the [README](./e2e/README.md) ### Security Tests -Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/) and our overall security report is available on [LGTM](https://lgtm.com/projects/g/nasa/openmct/) +Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/) and our overall security report is available on [LGTM](https://lgtm.com/projects/g/nasa/openmct/). The list of CWE coverage items is avaiable in the [CodeQL docs](https://codeql.github.com/codeql-query-help/javascript-cwe/). The CodeQL workflow is specified in the [CodeQL analysis file](./.github/workflows/codeql-analysis.yml) and the custom [CodeQL config](./.github/codeql/codeql-config.yml). ### Test Reporting and Code Coverage diff --git a/e2e/appActions.js b/e2e/appActions.js index 3064ecf079..bc1b1a212a 100644 --- a/e2e/appActions.js +++ b/e2e/appActions.js @@ -46,6 +46,7 @@ */ const Buffer = require('buffer').Buffer; +const genUuid = require('uuid').v4; /** * This common function creates a domain object with the default options. It is the preferred way of creating objects @@ -56,6 +57,10 @@ const Buffer = require('buffer').Buffer; * @returns {Promise} An object containing information about the newly created domain object. */ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine' }) { + if (!name) { + name = `${type}:${genUuid()}`; + } + const parentUrl = await getHashUrlToDomainObject(page, parent); // Navigate to the parent object. This is necessary to create the object @@ -70,11 +75,14 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine await page.click(`li:text("${type}")`); // Modify the name input field of the domain object to accept 'name' - if (name) { - const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]'); - await nameInput.fill(""); - await nameInput.fill(name); - } + const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]'); + await nameInput.fill(""); + await nameInput.fill(name); + + // Fill the "Notes" section with information about the + // currently running test and its project. + const notesInput = page.locator('form[name="mctForm"] #notes-textarea'); + await notesInput.fill(page.testNotes); // Click OK button and wait for Navigate event await Promise.all([ @@ -96,8 +104,8 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine } return { - name: name || `Unnamed ${type}`, - uuid: uuid, + name, + uuid, url: objectUrl }; } @@ -225,15 +233,14 @@ async function getHashUrlToDomainObject(page, uuid) { } /** - * Utilizes the OpenMCT API to detect if the given object has an active transaction (is in Edit mode). + * Utilizes the OpenMCT API to detect if the UI is in Edit mode. * @private * @param {import('@playwright/test').Page} page - * @param {string | import('../src/api/objects/ObjectAPI').Identifier} identifier - * @return {Promise} true if the object has an active transaction, false otherwise + * @return {Promise} true if the Open MCT is in Edit Mode */ async function _isInEditMode(page, identifier) { // eslint-disable-next-line no-return-await - return await page.evaluate((objectIdentifier) => window.openmct.objects.isTransactionActive(objectIdentifier), identifier); + return await page.evaluate(() => window.openmct.editor.isEditing()); } /** diff --git a/e2e/helper/notebookUtils.js b/e2e/helper/notebookUtils.js index 5fdd973630..4a26fcd098 100644 --- a/e2e/helper/notebookUtils.js +++ b/e2e/helper/notebookUtils.js @@ -20,6 +20,8 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ +const { createDomainObjectWithDefaults } = require('../appActions'); + const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area'; /** @@ -38,24 +40,17 @@ async function enterTextEntry(page, text) { /** * @param {import('@playwright/test').Page} page */ -async function dragAndDropEmbed(page, myItemsFolderName) { - // Click button:has-text("Create") - await page.locator('button:has-text("Create")').click(); - // Click li:has-text("Sine Wave Generator") - await page.locator('li:has-text("Sine Wave Generator")').click(); - // Click form[name="mctForm"] >> text=My Items - await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click(); - // Click text=OK - await page.locator('text=OK').click(); - // Click text=Open MCT My Items >> span >> nth=3 - await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); - // Click text=Unnamed CUSTOM_NAME - await Promise.all([ - page.waitForNavigation(), - page.locator('text=Unnamed CUSTOM_NAME').click() - ]); - - await page.dragAndDrop('text=UNNAMED SINE WAVE GENERATOR', NOTEBOOK_DROP_AREA); +async function dragAndDropEmbed(page, notebookObject) { + // Create example telemetry object + const swg = await createDomainObjectWithDefaults(page, { + type: "Sine Wave Generator" + }); + // Navigate to notebook + await page.goto(notebookObject.url); + // Expand the tree to reveal the notebook + await page.click('button[title="Show selected item in tree"]'); + // Drag and drop the SWG into the notebook + await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA); } // eslint-disable-next-line no-undef diff --git a/e2e/pluginFixtures.js b/e2e/pluginFixtures.js index a3250054d4..90d9a3a25f 100644 --- a/e2e/pluginFixtures.js +++ b/e2e/pluginFixtures.js @@ -126,13 +126,21 @@ exports.test = test.extend({ // This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js theme: [theme, { option: true }], // eslint-disable-next-line no-shadow - page: async ({ page, theme }, use) => { + page: async ({ page, theme }, use, testInfo) => { // eslint-disable-next-line playwright/no-conditional-in-test if (theme === 'snow') { //inject snow theme await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') }); } + // Attach info about the currently running test and its project. + // This will be used by appActions to fill in the created + // domain object's notes. + page.testNotes = [ + `${testInfo.titlePath.join('\n')}`, + `${testInfo.project.name}` + ].join('\n'); + await use(page); }, myItemsFolderName: [myItemsFolderName, { option: true }], @@ -140,22 +148,5 @@ exports.test = test.extend({ openmctConfig: async ({ myItemsFolderName }, use) => { await use({ myItemsFolderName }); } - // objectCreateOptions: [objectCreateOptions, {option: true}], - // eslint-disable-next-line no-shadow - // domainObject: [async ({ page, objectCreateOptions }, use) => { - // // FIXME: This is a false-positive caused by a bug in the eslint-plugin-playwright rule. - // // eslint-disable-next-line playwright/no-conditional-in-test - // if (objectCreateOptions === null) { - // await use(page); - - // return; - // } - - // //Go to baseURL - // await page.goto('./', { waitUntil: 'networkidle' }); - - // const uuid = await getOrCreateDomainObject(page, objectCreateOptions); - // await use({ uuid }); - // }, { auto: true }] }); exports.expect = expect; diff --git a/e2e/test-data/ExampleLayouts.json b/e2e/test-data/ExampleLayouts.json new file mode 100644 index 0000000000..0d5dc07f79 --- /dev/null +++ b/e2e/test-data/ExampleLayouts.json @@ -0,0 +1,2207 @@ +{ + "openmct": { + "45b24009-dfed-4023-a30b-d31f5e3a2d87": { + "identifier": { + "key": "45b24009-dfed-4023-a30b-d31f5e3a2d87", + "namespace": "" + }, + "name": "Open MCT Examples 10-05-22", + "type": "folder", + "composition": [ + { + "key": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "namespace": "" + }, + { + "key": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "namespace": "" + } + ], + "modified": 1664993018467, + "location": "mine", + "persisted": 1664993018469 + }, + "832cd297-38ab-478a-a5ff-f3bfd278e41b": { + "identifier": { + "key": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "namespace": "" + }, + "name": "Display Layout Example 1", + "type": "layout", + "composition": [ + { + "key": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "namespace": "" + }, + { + "key": "da187902-64f6-460e-bfbe-c84bd628e126", + "namespace": "" + }, + { + "key": "03d9a461-8bcd-4821-b405-46b03d6da9b0", + "namespace": "" + }, + { + "key": "c68ff290-5891-41bd-bfc1-84734fb86a19", + "namespace": "" + }, + { + "key": "8f72d5f7-7074-4745-9a0b-c5854d31790b", + "namespace": "" + }, + { + "key": "caf64735-99c2-4906-a2fa-bb47912b2a79", + "namespace": "" + }, + { + "key": "4b6f1b0d-8a70-4dee-bb6c-36af255bc139", + "namespace": "" + }, + { + "key": "ee70fbec-2890-4eb5-9e15-15e5890b3138", + "namespace": "" + }, + { + "key": "152d2a9f-f0f3-408e-bf55-af007840cdef", + "namespace": "" + }, + { + "key": "6fed1053-3e10-44e3-8e60-4655d19266e0", + "namespace": "" + }, + { + "key": "e940f59d-e6ef-4a2b-bf82-d81d94627da2", + "namespace": "" + } + ], + "configuration": { + "items": [ + { + "width": 29, + "height": 54, + "x": 0, + "y": 5, + "identifier": { + "key": "e230c105-b961-4e01-a056-8f2e8630e185", + "namespace": "" + }, + "hasFrame": false, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "e04ae658-c538-464b-a042-363da827717e" + }, + { + "stroke": "transparent", + "x": 30, + "y": 5, + "width": 27, + "height": 15, + "url": "https://s.abcnews.com/images/Technology/mars-rover-2020-illustration-nasa-ht-jc-200305_hpMain_16x9_992.jpg", + "type": "image-view", + "id": "ed63cc29-80e2-4e2b-a472-3d6d4adbf310" + }, + { + "identifier": { + "key": "e3131777-c0ef-44f3-9202-4c9c7b864dcc", + "namespace": "" + }, + "x": 30, + "y": 21, + "width": 27, + "height": 3, + "displayMode": "all", + "value": "sin", + "stroke": "", + "fill": "", + "color": "", + "fontSize": "default", + "font": "default", + "type": "telemetry-view", + "id": "a212530c-2c8c-4c46-b8e3-62452832d749" + }, + { + "identifier": { + "key": "6f0c1a8f-cefa-4783-a79e-9f123e8718ba", + "namespace": "" + }, + "x": 30, + "y": 25, + "width": 27, + "height": 3, + "displayMode": "all", + "value": "sin", + "stroke": "", + "fill": "", + "color": "", + "fontSize": "default", + "font": "default", + "type": "telemetry-view", + "id": "06c90c9c-6982-4aba-a89d-588530592fa4" + }, + { + "width": 27, + "height": 30, + "x": 30, + "y": 29, + "identifier": { + "key": "8ae9193d-2f79-43bc-a39f-4f89a52da5a3", + "namespace": "" + }, + "hasFrame": true, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "b50b1748-ec6f-4ed8-a3d0-065b9f421aed" + }, + { + "width": 33, + "height": 23, + "x": 58, + "y": 5, + "identifier": { + "key": "8f72d5f7-7074-4745-9a0b-c5854d31790b", + "namespace": "" + }, + "hasFrame": true, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "bbb714a8-545e-460e-85e8-43a70fa2fd80" + }, + { + "width": 39, + "height": 10, + "x": 92, + "y": 49, + "identifier": { + "key": "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d", + "namespace": "" + }, + "hasFrame": true, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "1a52971a-60c3-4bfa-900d-3344f2703e2c" + }, + { + "width": 15, + "height": 4, + "x": 52, + "y": 0, + "identifier": { + "key": "d776581d-443c-47e4-9d5a-f04950842981", + "namespace": "" + }, + "hasFrame": false, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "d627e236-b63a-48d0-b12d-942ab9594b98" + }, + { + "width": 39, + "height": 43, + "x": 92, + "y": 5, + "identifier": { + "key": "136523e4-ae71-4ebd-bd75-5394855d7708", + "namespace": "" + }, + "hasFrame": true, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "da2dfd37-84d3-4b4d-98f4-133a565b6a2c" + }, + { + "width": 33, + "height": 30, + "x": 58, + "y": 29, + "identifier": { + "key": "152d2a9f-f0f3-408e-bf55-af007840cdef", + "namespace": "" + }, + "hasFrame": true, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "35d4375c-8e2b-4feb-896c-c76b1a9b5c9e" + }, + { + "width": 19, + "height": 4, + "x": 16, + "y": 0, + "identifier": { + "key": "6fed1053-3e10-44e3-8e60-4655d19266e0", + "namespace": "" + }, + "hasFrame": false, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "09683b4b-474a-479b-bc47-6105c78e14e7" + }, + { + "fill": "", + "stroke": "", + "color": "", + "x": 0, + "y": 0, + "width": 15, + "height": 4, + "text": "MISSION TIME", + "fontSize": "20", + "font": "default", + "type": "text-view", + "id": "b9321c44-0c82-4687-b115-948678276e62" + }, + { + "width": 15, + "height": 4, + "x": 36, + "y": 0, + "identifier": { + "key": "a07a2210-5c85-4fa7-8f83-14979fbf0beb", + "namespace": "" + }, + "hasFrame": false, + "fontSize": "default", + "font": "default", + "type": "subobject-view", + "id": "ac0d7eb1-b485-458f-bd2a-a63aa87a3a8a" + } + ], + "layoutGrid": [ + 10, + 10 + ], + "objectStyles": { + "ed63cc29-80e2-4e2b-a472-3d6d4adbf310": { + "staticStyle": { + "style": { + "imageUrl": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBUPEBIVFRUVFQ8PFRUVFhUVFRUVFRUWFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OFQ8QFysdHR0rMC0rLS0tLTArLSsrLS4rKzEtLS0tLS0rKy0tKy0tLSsuKy4rLS0tKy0tLS0rKysrOP/AABEIAKgBLAMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAAAQIDBAUGB//EADsQAAIBAgQCCAQFAwIHAAAAAAABAgMRBBIhMQVRBhNBYXGBkaEiMrHBFCNC0fBScoIH4RUWU2KDkvH/xAAYAQEBAQEBAAAAAAAAAAAAAAAAAQIDBP/EACERAQEBAQABBAMBAQAAAAAAAAABEQISAxMhMUFRYSJC/9oADAMBAAIRAxEAPwD4eA0hFAAAAwEADAAAAAAAAAAEMAEAwAQDEADEMAAAAAACgABpAIdhgUIYWHYIVgGACAYgpWAYECAAsBEYgIAYhgIBiAYJAIBgIAGAXEAwEMAAQAMDbQ4ZOdNVE0k5Tgr3XyqLbv8A5GjBcIq16KdNJuMqsrN2zK0VZd94smjkjBoCgABpFAFh2AoLAOw7ARsMdh2KhAOw7ARAkFhgiA7BYCNgJWFYCIxgRVQDAyAAABAMAEAAAxAAAAxAAAAASi7O7V+4iX4LDSq1IUo7zlGC82B0MQ6ippRbVKr+YorRafDKy5pqcb9uvM+g9HuHRhBZYtaJK+u3aX4r/TPF4JxjVrKrh4xk4zinLqk3eTUbXvd5rXs9b23Wno/wqtRlJVK9OpBSnFLSNRNOy+GW0fN7m+eLms2vC9PeBdTUWIi1lquzVrNTtdu3J2v43PKZT3PSLC8TxK6urSuoXrZYJSaS+HM2uz4tF3nk54SUXZpp8mrP0ZrwprHlHY1LDPkP8Ox4U1lsGU1dQHUjxNZso8po6oXVjxFGUdi7ILIMFWULFuUWUYK7BYsyisMELCsTsFiKrsFidhWAhYCVgJgoAAMKBAADEAAAAADEMQAAAAAAAa8LgnOLqbJXS72rXS8FJM70eiM5YSGJpz/MlqqTtdxausjv8zXYc2ipdRGjGPxSzT79db+GWMX5HseIYqvhqipU5OEYwopR00+CKb5a2uakS16b/TPprJ4dYTEScoxWWObW1tou/Yd7F4XDzjKplckmlZSaer3VvqfIKmJVDE1Gr3k41GmmrZ4xm7J83K67mj23BeJylRqNvROmrd9/2Z6+edmxx6+EeJpZbxdSNRKtCLUvgy1I5G5R/VJRvZ7a7HoOE8A4Zj8NH8p0q1OMKTbleU8sUnOT/U2+3c4deopC4diXSneLsdLxs+GZ0q4t0OVJvLqjz2I4Pl7D6NLHqpHU5GNoJkn9NeBq4C3YZp4U9bicKjm1sMW8xqdPPSoFbpHZqUDPOiYvLWuY6RFwN8qRVKmYvLTG4EcprdMg4GbBmyicS9xIuJnFUOJFxL3Ei4kFNhWLconEgqsKxY0KxBjEMDm0QDABAOwgAAAAAYWAAN0cJBdrk/KK+7fsaqas1GKUL22Vna19Xv6s6T0r+fhNc2OFn2q392ntu/I24HhSnrKTavZ5V3X0b3ItnR4Z8v8AnL2jH9zXXpTmamuhgqapZ3CpJOdOVF3g2owmrTirKyurK/cdGeJzyjKq6U7JbycJSfY5X3ty+phhU+n8+5dGp7O30JEX4rARr1JVqtPO5ZdYyf6YqK1jLlGK8jThXKlhauZWcq0IpbNpXd7eSME+r0vGPojo8IwSl8U03BNtJvS72S7tjv6dxiunT4dNwU09HFSV1a91ey1MUKx1ni9d7PwTyrlZ6MFll81Oi/8ABxfrGSO86/bGM+HxJoda4PDU2nanldnZxqSettPhktr95zYVi/aY01tTDWpmh1CqbBHPq0jLUpHSqIzVIma3HOnTKZ0zfOBROJzrUYZQK5QNkolUomK0yOJBxNMokHE52qzOJFxNDiQcTOihxItFziRaJopcRWLXEjYmq5gElTb7PdFiw0vD3+lzCqQL1Rj2yflH92voN0qfY5ewGcRa6S7JeuhCVNrsAQER3AZOgryXj9NSu5owS+LwT/Y1xN6hW4jN3JMgz3YwidXh0fy13yqP2gvscyx18Ivy6fhN9n9cl9jPqz/KNMGWwWnuyqD+/wBS+zu+768vc88ElH6XOvhdFCV3puru3ocuS1Vu9e7NuHnol5nXlmtUtHoy2M9ClvYcHr4fY7ystlKraUW+xwb9UcjNlbi+xuPo7HSh89v5pocbHztWn3yc/KfxL6mp0mNcag85hhVLVUJejF0mVSDOQcjnempEJoomi+TKpHO9NSKJIplE6FPBVJ7Rfi9F7mmnwXtqVFHuisz+yRzvTThNFckenXC8PF65n/c7fQ2YaVCD+Cmrrtsl6vdnO9NPIUsBVn8tOT78rt67GilwDES1cVFbfE19rnp6mO1t28rFX4iW19PV+S7DPkOJS6NSfzVErcot+7aNlHotSau5zl3Ky9dDo0qsX3+Ip1G9NSaMv/L+FhrJX5XlJl64Xh1tRhbvWvuEZc5eisNVF2t+5NV84dn2DghSTEqnNAOVMqdP/wCl8ZpjlTAyuK5/YFCS2LZR7iENAFlv8y+z9RSw3J+TL4vmWxsUc2dNrdGrh63fgjWgcUtkueh09Kf6iUmxA2NHtjASOzRj8FNf9jfrUm/uchHSdRQjG938ENlz15mfX+OYNNMvpPV+FvdfsYsNXjN5VdXtuv2O5xDhVTDWdVpJ2s0ptWdn2RPNCqIfz7/Quw99E91p/PJIpwyVTN1LUlHLf5lbNtvFcpehdCjUTzNLW3abjNbf5sizDvK1K12ndcr9mnbrZ+RmlUyRzTVrXbemi0sV0+LUP+rBf5JO3ba7OnkmOnQaS8FL1VmvdI4HHllr/wB0KcvSORr1gzs4CtGu+royjOVnJRjKLdllWyZzOmeFnRqUushKEnTkrSVnlUm0/PM/Ql6WRz4VC6NQ59Ft6JN+Bvo4aW8mo+O5jzXFimXUaM57LTm9F6joqnHsv3v9tidTHrYxe1xpp4CK+aV/DReu/wBC5OlD5Ur9y19XqcmWKb1IOs2YvTWOtUx0dtblDxHfbw/c56mv92JVIJ6sxqt0aut2wlVXYm/OyMTxsVsrmSpOUv1NLlHT3IOnOuk9WOGJOVDKv99S38Ql2gdB4iX7IOulzOV+Jv8AYX4h9rIOnGtYnGuzkxrD65cwPOykRlLQWZizdxcVFOxfTkVacg0LgulETiytSJqYwSUe4FT5Dzk4+JZymiOZFsP7U7+w435/QvjJLex055qWrqfC5OCd7Sla3wx0vtujvdFuFRjVyV1KrJ/HClGKp5nFawlPk156GPjWLSjTjTX9K0bfJdp1a2GhQrRxFOUFUpzVSL6p9j2bvs9U+5nS5P6y2Yrozh6eInWxE3Cn1XWKlGUIycpznkUVOom4RSs2tbpXPBYqgpVJdW5Zb7N89tdT3nSXjC4oljKdNU6co9VGFSphoyvByzS/MadrtrTkeY6IYDrMRVp1Jxp5XbNKDqxvmatHK7Nabp2OP219HwbCSvbLd2Tu3F2Tbtqmet4fRnN06VSMZwjUhNwaeVxi3mjo1ozpYjhWFwE6VatW62M6dWOWjh+pk5Zqbirzl8S+Z37Ld5bg+lOFdVSjhZreNusW7lzyvQ68Rjpk43Cgqk/w+HhRjFUYvLdZ23N7NvZL3Zzet1NPTjjkFBTp4ecVKUYueZSi5JStHZc2/I8PPpLNX+Ffx+xfKc/CZr21HqpxnCtBzg4TvFSyvROV0+atp376XPL8X6I1KKbptzg7TTas2rN/EuxpN9252+gFeWOqygoNuOXMoq7s738rJrzPecYWHg44ac4xqu9WNN2VRpxnmlkeuXKp93wk66lmrJY+JYKrWwlSNalNwnG+WSyytdNPR3T0b3Rq4t0gxOMnGpiqrrShHJFyjCNo3va0Ipb8zrcfoxcG76q36bbtbcjytSNjHfNlal1uXEZpWTSXJKxJY+XccvOSjUMK6n4mT3Y1WfP2Oaqv8sPrSK6Drd7F1rMSrskq75kGvMxMzdfLmyLqvvA1OYs/eZesH1ncTFaHMi5FHWdwOp3BFzmRlMpcwzsotu+fsTsv4mZ88hqUuZMHMykkSyBlZ0xNK40NRZJXLgSiTjTfIFJklUfM1MRZDCye0WaaXDKr2j6uK+rMirvmJ15f1M3LzE+XWhwPEPZU/OrSX1kU4jg9aPzSor/z0ftI5cqr5lTkS9z9Eldb8VkcHNxeS3yTjO7W2z7l2kcZxlzTSurpq77O/c5NwOfkuO/wXj0qVBYfM45ak6kXe11UUFKL07HBNf3SN8OOwlJN1mraX/Mu/RPTz7WeSRdSoylsi89WFj0PEuPzqVVaTqRhpHM5Nduquk1uwocXlF5sq3vv33MeE4NXlqo+6NNXgtaKu8v/ALI78+X3jnc+mTjXE5V5ZnFLRRtZPZt3zNX7djjz1N2IwzTs2vUrhgHLaS9Uce5bW5kPhONdCebVpqzSbT02ejX8Z3qXSSnGTrZZda4SoxdrqMJfM23K7k1eK7EpS56cyj0erT+VxfmaY9Dsa9VTb8BOOs+jyijFcRnV0Sdr3em77O1keqm18r9GXvovj4a9TPyTLqT4hR3jUXirm5L/ANSs7+nLqUJL9L9ClwfI9NT45itpe8S6GNz/ADxg/GKL7fN+qeVeSuxqR7OHC6VTsgvYtXQ1z+WUfUX0anuR4lSHmPZVOgGJ3iovwZgr9DcVDek/KzM+3WvKPO5kGh0q3A60PmpyXkzLPBSW6fozN5v6XWe4XJuiyLgTFIQxXQwIWpLMGYmBahdhmDMMGbMwzMQE1UrsakQuNMaJ3AgJsaYmRZDODkTQ2hWFcaIGo9yLYUBQiaaRqFXYbCJnWw+FS7Dn0p2NdPEtHbnI53XQTcdk/Uy4rFvZkXimZ69e5u9MyMGKqXMirWZqrNMxzijh1XSN2Hx7Xadzh/H5w+WbXgzyNicZtF59SwvMr6pwzp3WhZOamt7TSf2PS4TpzQqK1ShBX3cVf2Z8Op4l8zTTxrXa15m/cl+4x419mxVXAV9bKPcowXuo3Zw8dwGg23Tn6pHgaPFZL9RthxyXM6T1OWbzXZr8Icfll6GVyr09psyf8ab7SufErlvfP4JL+XQjx/Ew2qSXg2XQ6Y4hbzk/FnCniUzPOaMXutTl6ldL5v5nfxRCpx2nPeMeWyPJTZTJk92w8I9RVxNCX6ImOtCk9oo4HWMOvlzM31NXxdOrQgZp0I9hm/EyE8QzOxcqcqXeVuAdcJ1CNFYQ8wrkGYVwAyouK4AQK4rgAAIAIGicQAotiWwlYAKLo1GTVWXMANspdfLmVzqAA0Z5yKJMAM1YrYXADKhMkmAANSZJTYAUWRqssVVgBdE1VYdaMC6hdYJzAAIZhZgAgVwEAAxDAKiAAB//2Q==" + } + } + } + } + }, + "modified": 1664992567772, + "location": "45b24009-dfed-4023-a30b-d31f5e3a2d87", + "persisted": 1664992594970 + }, + "5f6760b7-85c5-4f90-a8b1-c6ba8382a684": { + "identifier": { + "key": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "namespace": "" + }, + "name": "Flexible Layout Example 1", + "type": "flexible-layout", + "configuration": { + "containers": [ + { + "id": "3c8aedca-7413-494a-b389-a4d657c7103c", + "frames": [ + { + "id": "19cd7f7d-3cc6-4c97-b832-e178b2c75602", + "domainObjectIdentifier": { + "key": "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d", + "namespace": "" + }, + "size": 10, + "noFrame": false + }, + { + "id": "8dd99a22-99a9-4e0c-8384-4e5072f11c74", + "domainObjectIdentifier": { + "key": "1c96da17-bce6-4ddf-bde0-70a5031f9399", + "namespace": "" + }, + "size": 30, + "noFrame": false + }, + { + "id": "27918937-a5f7-48f3-8c97-ad904da6f885", + "domainObjectIdentifier": { + "key": "8ae9193d-2f79-43bc-a39f-4f89a52da5a3", + "namespace": "" + }, + "size": 30, + "noFrame": false + }, + { + "id": "872e1cc1-a955-40f9-a67a-d65aca32d420", + "domainObjectIdentifier": { + "key": "c03cbe46-c5f0-40a8-a703-813ad663e900", + "namespace": "" + }, + "size": 30, + "noFrame": false + } + ], + "size": 18 + }, + { + "id": "3c3f9f05-112e-433b-a6f2-c01bbc6a8f4d", + "frames": [ + { + "id": "fd1aea5b-6fe8-40fe-b315-e8313a37d56e", + "domainObjectIdentifier": { + "key": "e230c105-b961-4e01-a056-8f2e8630e185", + "namespace": "" + }, + "size": 59, + "noFrame": false + }, + { + "id": "b9bdc867-492e-4c6f-b963-813908e3a259", + "domainObjectIdentifier": { + "key": "136523e4-ae71-4ebd-bd75-5394855d7708", + "namespace": "" + }, + "size": 37, + "noFrame": false + } + ], + "size": 66 + }, + { + "id": "2f145353-b742-4172-b07d-7e2bb8ce17fc", + "frames": [ + { + "id": "7d6a2b96-ff11-47ec-a690-0495c7525ff9", + "domainObjectIdentifier": { + "key": "d776581d-443c-47e4-9d5a-f04950842981", + "namespace": "" + }, + "size": 5, + "noFrame": true + }, + { + "id": "5f9b34f9-db81-48fc-84e2-2a1709ecc065", + "domainObjectIdentifier": { + "key": "a07a2210-5c85-4fa7-8f83-14979fbf0beb", + "namespace": "" + }, + "size": 5, + "noFrame": true + }, + { + "id": "c22e76f8-fc29-4685-a5a8-ff088c2ee3ee", + "domainObjectIdentifier": { + "key": "4ae303e9-8edb-490b-93c3-cfaadfcdb64a", + "namespace": "" + }, + "size": 45, + "noFrame": false + }, + { + "id": "c6426188-aec7-466c-a800-10653a3fade6", + "domainObjectIdentifier": { + "key": "2a84d91e-8612-43ed-9477-61b9cfbf5c2c", + "namespace": "" + }, + "size": 45, + "noFrame": false + } + ], + "size": 16 + } + ], + "rowsLayout": false, + "objectStyles": {} + }, + "composition": [ + { + "key": "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d", + "namespace": "" + }, + { + "key": "1c96da17-bce6-4ddf-bde0-70a5031f9399", + "namespace": "" + }, + { + "key": "8ae9193d-2f79-43bc-a39f-4f89a52da5a3", + "namespace": "" + }, + { + "key": "4ae303e9-8edb-490b-93c3-cfaadfcdb64a", + "namespace": "" + }, + { + "key": "2a84d91e-8612-43ed-9477-61b9cfbf5c2c", + "namespace": "" + }, + { + "key": "c03cbe46-c5f0-40a8-a703-813ad663e900", + "namespace": "" + }, + { + "key": "e230c105-b961-4e01-a056-8f2e8630e185", + "namespace": "" + }, + { + "key": "136523e4-ae71-4ebd-bd75-5394855d7708", + "namespace": "" + }, + { + "key": "d776581d-443c-47e4-9d5a-f04950842981", + "namespace": "" + }, + { + "key": "a07a2210-5c85-4fa7-8f83-14979fbf0beb", + "namespace": "" + } + ], + "modified": 1664992971253, + "location": "45b24009-dfed-4023-a30b-d31f5e3a2d87", + "persisted": 1664992976071 + }, + "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2": { + "identifier": { + "key": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "namespace": "" + }, + "type": "telemetry.plot.stacked", + "composition": [ + { + "key": "017ddbe2-1bec-46d2-acc9-5c2ad8fad79d", + "namespace": "" + }, + { + "key": "b5c72c1c-03fc-42d5-97c4-a34c7dacf872", + "namespace": "" + }, + { + "key": "b95ad884-7c92-4789-b6e0-e8e90155482e", + "namespace": "" + }, + { + "key": "10532581-1b49-438f-a2fe-843d412bf201", + "namespace": "" + } + ], + "configuration": { + "series": [ + { + "identifier": { + "key": "6f0c1a8f-cefa-4783-a79e-9f123e8718ba", + "namespace": "" + }, + "series": { + "markers": true + } + } + ], + "yAxis": {}, + "xAxis": {} + }, + "name": "Merged Telemetry Views", + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1658875540107, + "modified": 1658875512306 + }, + "da187902-64f6-460e-bfbe-c84bd628e126": { + "identifier": { + "key": "da187902-64f6-460e-bfbe-c84bd628e126", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "modified": 1657232414748, + "persisted": 1657232414748 + }, + "03d9a461-8bcd-4821-b405-46b03d6da9b0": { + "identifier": { + "key": "03d9a461-8bcd-4821-b405-46b03d6da9b0", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1657232414746 + }, + "c68ff290-5891-41bd-bfc1-84734fb86a19": { + "identifier": { + "key": "c68ff290-5891-41bd-bfc1-84734fb86a19", + "namespace": "" + }, + "name": "Gauge Needle Dial SWG Large", + "type": "gauge", + "composition": [ + { + "key": "135df6d8-080a-40b8-89b0-301c96174e18", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "dial-needle", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -1000000, + "limitHigh": 1000000, + "max": 2000000, + "min": -2000000, + "precision": 2 + }, + "objectStyles": { + "staticStyle": { + "style": { + "backgroundColor": "__no_value", + "border": "", + "color": "" + } + }, + "styles": [], + "selectedConditionId": "" + } + }, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "modified": 1658421115305, + "persisted": 1658421118049 + }, + "8f72d5f7-7074-4745-9a0b-c5854d31790b": { + "identifier": { + "key": "8f72d5f7-7074-4745-9a0b-c5854d31790b", + "namespace": "" + }, + "type": "table", + "composition": [ + { + "key": "f4da3027-8296-4faf-b8c1-30b8919c53f4", + "namespace": "" + } + ], + "configuration": { + "columnWidths": {}, + "hiddenColumns": { + "yesterday": true, + "wavelengths": true, + "wavelengths-unit": true, + "cos": true, + "cos-unit": true, + "intensities": true + }, + "columnOrder": [], + "cellFormat": {}, + "autosize": true + }, + "name": "SWG Small", + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1657660214977, + "modified": 1657660199738 + }, + "caf64735-99c2-4906-a2fa-bb47912b2a79": { + "identifier": { + "key": "caf64735-99c2-4906-a2fa-bb47912b2a79", + "namespace": "" + }, + "name": "Gauge Meter Horz SWG Small", + "type": "gauge", + "composition": [ + { + "key": "7ef88d73-8a2d-4b8f-92de-6abb76dd02e9", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "meter-horizontal", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -4.8, + "limitHigh": 4, + "max": 4.3, + "min": -5, + "precision": 2 + } + }, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "modified": 1657232414736, + "persisted": 1657232414736 + }, + "4b6f1b0d-8a70-4dee-bb6c-36af255bc139": { + "identifier": { + "key": "4b6f1b0d-8a70-4dee-bb6c-36af255bc139", + "namespace": "" + }, + "name": "CW 210", + "type": "conditionWidget", + "configuration": { + "objectStyles": { + "styles": [ + { + "conditionId": "6248211a-5164-4657-8c86-3484601d5e3c", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#a61c00", + "border": "", + "color": "#ffffff", + "output": "" + } + }, + { + "conditionId": "80708a88-b282-4524-8160-4e73546bff6a", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#38761d", + "border": "", + "color": "#00ff00", + "output": "" + } + }, + { + "conditionId": "14d676d6-5a38-4276-9d15-134f0afa6231", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#cc4125", + "border": "", + "color": "#f3f3f3", + "output": "" + } + }, + { + "conditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "style": { + "isStyleInvisible": "", + "backgroundColor": "", + "border": "", + "color": "", + "output": "" + } + } + ], + "staticStyle": { + "style": { + "backgroundColor": "", + "border": "", + "color": "" + } + }, + "selectedConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "defaultConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "conditionSetIdentifier": { + "key": "056bbcb6-1a45-4429-97e6-a8ae74cf55e3", + "namespace": "" + } + }, + "useConditionSetOutputAsLabel": false + }, + "label": "CW_210 BUS B", + "conditionalLabel": "", + "modified": 1664992949199, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1664992949199 + }, + "ee70fbec-2890-4eb5-9e15-15e5890b3138": { + "identifier": { + "key": "ee70fbec-2890-4eb5-9e15-15e5890b3138", + "namespace": "" + }, + "name": "Example Imagery", + "type": "example.imagery", + "configuration": { + "imageLocation": "", + "imageLoadDelayInMilliSeconds": "50000", + "imageSamples": [], + "layers": [ + { + "source": "dist/imagery/example-imagery-layer-16x9.png", + "name": "16:9", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-safe.png", + "name": "Safe", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-scale.png", + "name": "Scale", + "visible": true + } + ] + }, + "telemetry": { + "values": [ + { + "name": "Name", + "key": "name", + "source": "name", + "hints": { + "priority": 0 + } + }, + { + "name": "Time", + "key": "utc", + "format": "utc", + "hints": { + "domain": 2, + "priority": 1 + }, + "source": "utc" + }, + { + "name": "Local Time", + "key": "local", + "format": "local-format", + "hints": { + "domain": 1, + "priority": 2 + }, + "source": "local" + }, + { + "name": "Image", + "key": "url", + "format": "image", + "hints": { + "image": 1, + "priority": 3 + }, + "layers": [ + { + "source": "dist/imagery/example-imagery-layer-16x9.png", + "name": "16:9", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-safe.png", + "name": "Safe", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-scale.png", + "name": "Scale", + "visible": true + } + ], + "source": "url" + }, + { + "name": "Image Download Name", + "key": "imageDownloadName", + "format": "imageDownloadName", + "hints": { + "imageDownloadName": 1, + "priority": 4 + }, + "source": "imageDownloadName" + } + ] + }, + "modified": 1664993420994, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1664993420997 + }, + "152d2a9f-f0f3-408e-bf55-af007840cdef": { + "identifier": { + "key": "152d2a9f-f0f3-408e-bf55-af007840cdef", + "namespace": "" + }, + "name": "Gauge Auto Range", + "type": "gauge", + "composition": [ + { + "key": "4625b5f5-415b-42c6-9d97-4f86d5d7a4ef", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "dial-filled", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -12, + "limitHigh": 12, + "max": 15, + "min": -15, + "precision": 2 + } + }, + "modified": 1664991952387, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1664991968607 + }, + "6fed1053-3e10-44e3-8e60-4655d19266e0": { + "identifier": { + "key": "6fed1053-3e10-44e3-8e60-4655d19266e0", + "namespace": "" + }, + "name": "Mission Time", + "type": "timer", + "configuration": { + "timerFormat": "long", + "timestamp": 1664755200000, + "timezone": "UTC", + "timerState": "started", + "fontStyle": { + "fontSize": "20", + "font": "default" + }, + "objectStyles": { + "styles": [], + "staticStyle": { + "style": { + "backgroundColor": "", + "border": "", + "color": "#ffffff" + } + }, + "selectedConditionId": "" + } + }, + "modified": 1664992594980, + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1664992594980 + }, + "e940f59d-e6ef-4a2b-bf82-d81d94627da2": { + "identifier": { + "key": "e940f59d-e6ef-4a2b-bf82-d81d94627da2", + "namespace": "" + }, + "name": "CW 210 2", + "type": "conditionWidget", + "configuration": { + "objectStyles": { + "styles": [ + { + "conditionId": "6248211a-5164-4657-8c86-3484601d5e3c", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#cc4125", + "border": "", + "color": "#f3f3f3", + "output": "" + } + }, + { + "conditionId": "80708a88-b282-4524-8160-4e73546bff6a", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#38761d", + "border": "", + "color": "#00ff00", + "output": "" + } + }, + { + "conditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "style": { + "isStyleInvisible": "", + "backgroundColor": "", + "border": "", + "color": "", + "output": "" + } + } + ], + "staticStyle": { + "style": { + "backgroundColor": "", + "border": "", + "color": "" + } + }, + "selectedConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "defaultConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "conditionSetIdentifier": { + "key": "a62b89ea-0fa0-46c5-beac-53d1009ac48c", + "namespace": "" + } + }, + "useConditionSetOutputAsLabel": false, + "fontStyle": { + "fontSize": "default", + "font": "default" + } + }, + "label": "CW_210 BUS A", + "conditionalLabel": "", + "location": "832cd297-38ab-478a-a5ff-f3bfd278e41b", + "persisted": 1664992949203, + "modified": 1664992949203 + }, + "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d": { + "identifier": { + "key": "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d", + "namespace": "" + }, + "name": "Gauge Meter Horz SWG Small", + "type": "gauge", + "composition": [ + { + "key": "ec3b4a3b-97f0-405e-be5a-d0ac15313df9", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "meter-horizontal", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -4.8, + "limitHigh": 4, + "max": 4.3, + "min": -5, + "precision": 2 + } + }, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "modified": 1657232414736, + "persisted": 1657232414736 + }, + "1c96da17-bce6-4ddf-bde0-70a5031f9399": { + "identifier": { + "key": "1c96da17-bce6-4ddf-bde0-70a5031f9399", + "namespace": "" + }, + "name": "Gauge Filled Dial SWG Small", + "type": "gauge", + "composition": [ + { + "key": "7a87b0a0-8a37-4c59-ac29-4d2861a55110", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "dial-filled", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -4.8, + "limitHigh": 4, + "max": 4.3, + "min": -5, + "precision": 2 + } + }, + "modified": 1657232414736, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1657232414736 + }, + "8ae9193d-2f79-43bc-a39f-4f89a52da5a3": { + "identifier": { + "key": "8ae9193d-2f79-43bc-a39f-4f89a52da5a3", + "namespace": "" + }, + "name": "Gauge Needle Dial SWG Large", + "type": "gauge", + "composition": [ + { + "key": "3984ca34-8512-4857-8a4e-56e9be074e00", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "dial-needle", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -1000000, + "limitHigh": 1000000, + "max": 2000000, + "min": -2000000, + "precision": 2 + }, + "objectStyles": { + "staticStyle": { + "style": { + "backgroundColor": "__no_value", + "border": "", + "color": "" + } + }, + "styles": [], + "selectedConditionId": "" + } + }, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "modified": 1658421115305, + "persisted": 1658421118049 + }, + "4ae303e9-8edb-490b-93c3-cfaadfcdb64a": { + "identifier": { + "key": "4ae303e9-8edb-490b-93c3-cfaadfcdb64a", + "namespace": "" + }, + "name": "Gauge Meter Vert SWG Large", + "type": "gauge", + "composition": [ + { + "key": "6c530559-b285-40b3-8e76-52f08c112f34", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "meter-vertical", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -1000000, + "limitHigh": 1000000, + "max": 2000000, + "min": -2000000, + "precision": 2 + } + }, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "modified": 1657232414737, + "persisted": 1657232414737 + }, + "2a84d91e-8612-43ed-9477-61b9cfbf5c2c": { + "identifier": { + "key": "2a84d91e-8612-43ed-9477-61b9cfbf5c2c", + "namespace": "" + }, + "name": "Gauge Vertical Meter Inverted", + "type": "gauge", + "composition": [ + { + "key": "691c802f-c53b-4938-8881-f421d02b2770", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "meter-vertical-inverted", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -9, + "limitHigh": 9, + "max": 10, + "min": -10, + "precision": 2 + } + }, + "modified": 1664993313837, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1664993321002 + }, + "c03cbe46-c5f0-40a8-a703-813ad663e900": { + "identifier": { + "key": "c03cbe46-c5f0-40a8-a703-813ad663e900", + "namespace": "" + }, + "name": "SWG 100 Gauge", + "type": "gauge", + "composition": [ + { + "key": "c1b9f83b-a7db-4047-8dc3-37a2186b9c43", + "namespace": "" + } + ], + "configuration": { + "gaugeController": { + "gaugeType": "dial-needle", + "isDisplayMinMax": true, + "isDisplayCurVal": true, + "isDisplayUnits": true, + "isUseTelemetryLimits": false, + "limitLow": -20, + "limitHigh": 120, + "max": 200, + "min": -100, + "precision": 2 + }, + "objectStyles": {} + }, + "modified": 1660006343021, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1660006343021 + }, + "e230c105-b961-4e01-a056-8f2e8630e185": { + "identifier": { + "key": "e230c105-b961-4e01-a056-8f2e8630e185", + "namespace": "" + }, + "type": "telemetry.plot.stacked", + "composition": [ + { + "key": "6f0c1a8f-cefa-4783-a79e-9f123e8718ba", + "namespace": "" + }, + { + "key": "e3131777-c0ef-44f3-9202-4c9c7b864dcc", + "namespace": "" + }, + { + "key": "fe903b87-0d52-475b-a858-624fa67c378f", + "namespace": "" + }, + { + "key": "00326dab-02c5-4522-9f68-e9e73758a272", + "namespace": "" + } + ], + "configuration": { + "series": [ + { + "identifier": { + "key": "6f0c1a8f-cefa-4783-a79e-9f123e8718ba", + "namespace": "" + }, + "series": { + "markers": true + } + } + ], + "yAxis": {}, + "xAxis": {} + }, + "name": "Merged Telemetry Views", + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1658875540107, + "modified": 1658875512306 + }, + "136523e4-ae71-4ebd-bd75-5394855d7708": { + "identifier": { + "key": "136523e4-ae71-4ebd-bd75-5394855d7708", + "namespace": "" + }, + "name": "Example Imagery", + "type": "example.imagery", + "configuration": { + "imageLocation": "", + "imageLoadDelayInMilliSeconds": "50000", + "imageSamples": [], + "layers": [ + { + "source": "dist/imagery/example-imagery-layer-16x9.png", + "name": "16:9", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-safe.png", + "name": "Safe", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-scale.png", + "name": "Scale", + "visible": true + } + ] + }, + "telemetry": { + "values": [ + { + "name": "Name", + "key": "name", + "source": "name", + "hints": { + "priority": 0 + } + }, + { + "name": "Time", + "key": "utc", + "format": "utc", + "hints": { + "domain": 2, + "priority": 1 + }, + "source": "utc" + }, + { + "name": "Local Time", + "key": "local", + "format": "local-format", + "hints": { + "domain": 1, + "priority": 2 + }, + "source": "local" + }, + { + "name": "Image", + "key": "url", + "format": "image", + "hints": { + "image": 1, + "priority": 3 + }, + "layers": [ + { + "source": "dist/imagery/example-imagery-layer-16x9.png", + "name": "16:9", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-safe.png", + "name": "Safe", + "visible": true + }, + { + "source": "dist/imagery/example-imagery-layer-scale.png", + "name": "Scale", + "visible": true + } + ], + "source": "url" + }, + { + "name": "Image Download Name", + "key": "imageDownloadName", + "format": "imageDownloadName", + "hints": { + "imageDownloadName": 1, + "priority": 4 + }, + "source": "imageDownloadName" + } + ] + }, + "modified": 1664993420994, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1664993420997 + }, + "d776581d-443c-47e4-9d5a-f04950842981": { + "identifier": { + "key": "d776581d-443c-47e4-9d5a-f04950842981", + "namespace": "" + }, + "name": "CW 210", + "type": "conditionWidget", + "configuration": { + "objectStyles": { + "styles": [ + { + "conditionId": "6248211a-5164-4657-8c86-3484601d5e3c", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#a61c00", + "border": "", + "color": "#ffffff", + "output": "" + } + }, + { + "conditionId": "80708a88-b282-4524-8160-4e73546bff6a", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#38761d", + "border": "", + "color": "#00ff00", + "output": "" + } + }, + { + "conditionId": "14d676d6-5a38-4276-9d15-134f0afa6231", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#cc4125", + "border": "", + "color": "#f3f3f3", + "output": "" + } + }, + { + "conditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "style": { + "isStyleInvisible": "", + "backgroundColor": "", + "border": "", + "color": "", + "output": "" + } + } + ], + "staticStyle": { + "style": { + "backgroundColor": "", + "border": "", + "color": "" + } + }, + "selectedConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "defaultConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "conditionSetIdentifier": { + "key": "0e4342e3-06db-4e13-ba48-b391879b37b6", + "namespace": "" + } + }, + "useConditionSetOutputAsLabel": false + }, + "label": "CW_210 BUS B", + "conditionalLabel": "", + "modified": 1664992949199, + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1664992949199 + }, + "a07a2210-5c85-4fa7-8f83-14979fbf0beb": { + "identifier": { + "key": "a07a2210-5c85-4fa7-8f83-14979fbf0beb", + "namespace": "" + }, + "name": "CW 210 2", + "type": "conditionWidget", + "configuration": { + "objectStyles": { + "styles": [ + { + "conditionId": "6248211a-5164-4657-8c86-3484601d5e3c", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#cc4125", + "border": "", + "color": "#f3f3f3", + "output": "" + } + }, + { + "conditionId": "80708a88-b282-4524-8160-4e73546bff6a", + "style": { + "isStyleInvisible": "", + "backgroundColor": "#38761d", + "border": "", + "color": "#00ff00", + "output": "" + } + }, + { + "conditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "style": { + "isStyleInvisible": "", + "backgroundColor": "", + "border": "", + "color": "", + "output": "" + } + } + ], + "staticStyle": { + "style": { + "backgroundColor": "", + "border": "", + "color": "" + } + }, + "selectedConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "defaultConditionId": "7af9f52f-e402-4782-ab28-01d450d506f0", + "conditionSetIdentifier": { + "key": "ee7ca7b3-04e2-4c91-b73f-01280a92d1cc", + "namespace": "" + } + }, + "useConditionSetOutputAsLabel": false, + "fontStyle": { + "fontSize": "default", + "font": "default" + } + }, + "label": "CW_210 BUS A", + "conditionalLabel": "", + "location": "5f6760b7-85c5-4f90-a8b1-c6ba8382a684", + "persisted": 1664992949203, + "modified": 1664992949203 + }, + "056bbcb6-1a45-4429-97e6-a8ae74cf55e3": { + "identifier": { + "key": "056bbcb6-1a45-4429-97e6-a8ae74cf55e3", + "namespace": "" + }, + "name": "210 Condition Set", + "type": "conditionSet", + "configuration": { + "conditionTestData": [], + "conditionCollection": [ + { + "id": "6248211a-5164-4657-8c86-3484601d5e3c", + "configuration": { + "name": "High", + "output": "HIGH", + "trigger": "any", + "criteria": [ + { + "id": "64e49fe7-5b36-43db-8347-4550b910de4c", + "telemetry": "any", + "operation": "greaterThan", + "input": [ + "120" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine > 120 " + }, + { + "id": "80708a88-b282-4524-8160-4e73546bff6a", + "configuration": { + "name": "Nom", + "output": "NOMINAL", + "trigger": "any", + "criteria": [ + { + "id": "59f1c4bf-5d36-450c-9668-6546955fc066", + "telemetry": "any", + "operation": "between", + "input": [ + "120", + "-20" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine is between 120 and -20 " + }, + { + "id": "14d676d6-5a38-4276-9d15-134f0afa6231", + "configuration": { + "name": "Low", + "output": "LOW", + "trigger": "any", + "criteria": [ + { + "id": "6707be12-6a6e-4535-bb97-ab5c86f99934", + "telemetry": "any", + "operation": "lessThan", + "input": [ + "-20" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine < -20 " + }, + { + "isDefault": true, + "id": "7af9f52f-e402-4782-ab28-01d450d506f0", + "configuration": { + "name": "Default", + "output": "Default", + "trigger": "all", + "criteria": [] + }, + "summary": "" + } + ] + }, + "composition": [ + { + "key": "10987a9e-74ed-4e31-b820-806deadc9425", + "namespace": "" + } + ], + "telemetry": {}, + "modified": 1660006307115, + "location": null, + "persisted": 1660006307759 + }, + "0e4342e3-06db-4e13-ba48-b391879b37b6": { + "identifier": { + "key": "0e4342e3-06db-4e13-ba48-b391879b37b6", + "namespace": "" + }, + "name": "210 Condition Set", + "type": "conditionSet", + "configuration": { + "conditionTestData": [], + "conditionCollection": [ + { + "id": "6248211a-5164-4657-8c86-3484601d5e3c", + "configuration": { + "name": "High", + "output": "HIGH", + "trigger": "any", + "criteria": [ + { + "id": "64e49fe7-5b36-43db-8347-4550b910de4c", + "telemetry": "any", + "operation": "greaterThan", + "input": [ + "120" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine > 120 " + }, + { + "id": "80708a88-b282-4524-8160-4e73546bff6a", + "configuration": { + "name": "Nom", + "output": "NOMINAL", + "trigger": "any", + "criteria": [ + { + "id": "59f1c4bf-5d36-450c-9668-6546955fc066", + "telemetry": "any", + "operation": "between", + "input": [ + "120", + "-20" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine is between 120 and -20 " + }, + { + "id": "14d676d6-5a38-4276-9d15-134f0afa6231", + "configuration": { + "name": "Low", + "output": "LOW", + "trigger": "any", + "criteria": [ + { + "id": "6707be12-6a6e-4535-bb97-ab5c86f99934", + "telemetry": "any", + "operation": "lessThan", + "input": [ + "-20" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine < -20 " + }, + { + "isDefault": true, + "id": "7af9f52f-e402-4782-ab28-01d450d506f0", + "configuration": { + "name": "Default", + "output": "Default", + "trigger": "all", + "criteria": [] + }, + "summary": "" + } + ] + }, + "composition": [ + { + "key": "1a15f3e4-99a9-4afd-a6fa-dcc822b39cbc", + "namespace": "" + } + ], + "telemetry": {}, + "modified": 1660006307115, + "location": null, + "persisted": 1660006307759 + }, + "a62b89ea-0fa0-46c5-beac-53d1009ac48c": { + "identifier": { + "key": "a62b89ea-0fa0-46c5-beac-53d1009ac48c", + "namespace": "" + }, + "name": "210 Condition Set 2", + "type": "conditionSet", + "configuration": { + "conditionTestData": [], + "conditionCollection": [ + { + "id": "6248211a-5164-4657-8c86-3484601d5e3c", + "configuration": { + "name": "High", + "output": "HIGH", + "trigger": "any", + "criteria": [ + { + "id": "64e49fe7-5b36-43db-8347-4550b910de4c", + "telemetry": "any", + "operation": "greaterThan", + "input": [ + "150" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine > 150 " + }, + { + "id": "80708a88-b282-4524-8160-4e73546bff6a", + "configuration": { + "name": "Nom", + "output": "NOMINAL", + "trigger": "any", + "criteria": [ + { + "id": "59f1c4bf-5d36-450c-9668-6546955fc066", + "telemetry": "any", + "operation": "between", + "input": [ + "50", + "-50" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine is between 50 and -50 " + }, + { + "isDefault": true, + "id": "7af9f52f-e402-4782-ab28-01d450d506f0", + "configuration": { + "name": "Default", + "output": "Default", + "trigger": "all", + "criteria": [] + }, + "summary": "" + } + ] + }, + "composition": [ + { + "key": "b8b2d336-cdc2-42de-bb6b-c2033e691b35", + "namespace": "" + } + ], + "telemetry": {}, + "location": null, + "persisted": 1664992259247, + "modified": 1664992250791 + }, + "ee7ca7b3-04e2-4c91-b73f-01280a92d1cc": { + "identifier": { + "key": "ee7ca7b3-04e2-4c91-b73f-01280a92d1cc", + "namespace": "" + }, + "name": "210 Condition Set 2", + "type": "conditionSet", + "configuration": { + "conditionTestData": [], + "conditionCollection": [ + { + "id": "6248211a-5164-4657-8c86-3484601d5e3c", + "configuration": { + "name": "High", + "output": "HIGH", + "trigger": "any", + "criteria": [ + { + "id": "64e49fe7-5b36-43db-8347-4550b910de4c", + "telemetry": "any", + "operation": "greaterThan", + "input": [ + "150" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine > 150 " + }, + { + "id": "80708a88-b282-4524-8160-4e73546bff6a", + "configuration": { + "name": "Nom", + "output": "NOMINAL", + "trigger": "any", + "criteria": [ + { + "id": "59f1c4bf-5d36-450c-9668-6546955fc066", + "telemetry": "any", + "operation": "between", + "input": [ + "50", + "-50" + ], + "metadata": "sin" + } + ] + }, + "summary": "Match if any criteria are met: any telemetry Sine is between 50 and -50 " + }, + { + "isDefault": true, + "id": "7af9f52f-e402-4782-ab28-01d450d506f0", + "configuration": { + "name": "Default", + "output": "Default", + "trigger": "all", + "criteria": [] + }, + "summary": "" + } + ] + }, + "composition": [ + { + "key": "17e8e842-c4f0-4c11-b4c6-e729f4018120", + "namespace": "" + } + ], + "telemetry": {}, + "location": null, + "persisted": 1664992259247, + "modified": 1664992250791 + }, + "7a87b0a0-8a37-4c59-ac29-4d2861a55110": { + "identifier": { + "key": "7a87b0a0-8a37-4c59-ac29-4d2861a55110", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "1c96da17-bce6-4ddf-bde0-70a5031f9399", + "persisted": 1657232414746 + }, + "6c530559-b285-40b3-8e76-52f08c112f34": { + "identifier": { + "key": "6c530559-b285-40b3-8e76-52f08c112f34", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "location": "4ae303e9-8edb-490b-93c3-cfaadfcdb64a", + "modified": 1657232414748, + "persisted": 1657232414748 + }, + "4625b5f5-415b-42c6-9d97-4f86d5d7a4ef": { + "identifier": { + "key": "4625b5f5-415b-42c6-9d97-4f86d5d7a4ef", + "namespace": "" + }, + "name": "SWG 10", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "10", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0, + "loadDelay": 0 + }, + "modified": 1657236492163, + "location": "152d2a9f-f0f3-408e-bf55-af007840cdef", + "persisted": 1657236492163 + }, + "017ddbe2-1bec-46d2-acc9-5c2ad8fad79d": { + "identifier": { + "key": "017ddbe2-1bec-46d2-acc9-5c2ad8fad79d", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "persisted": 1657232414746 + }, + "b5c72c1c-03fc-42d5-97c4-a34c7dacf872": { + "identifier": { + "key": "b5c72c1c-03fc-42d5-97c4-a34c7dacf872", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "location": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "modified": 1657232414748, + "persisted": 1657232414748 + }, + "b95ad884-7c92-4789-b6e0-e8e90155482e": { + "identifier": { + "key": "b95ad884-7c92-4789-b6e0-e8e90155482e", + "namespace": "" + }, + "name": "SWG 10", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "10", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0, + "loadDelay": 0 + }, + "modified": 1657236492163, + "location": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "persisted": 1657236492163 + }, + "10532581-1b49-438f-a2fe-843d412bf201": { + "identifier": { + "key": "10532581-1b49-438f-a2fe-843d412bf201", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "modified": 1657149026977, + "location": "d78ec1fd-2cea-4b73-8bb6-ba44b09dc3b2", + "persisted": 1657149026977 + }, + "c1b9f83b-a7db-4047-8dc3-37a2186b9c43": { + "identifier": { + "key": "c1b9f83b-a7db-4047-8dc3-37a2186b9c43", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "modified": 1657149026977, + "location": "c03cbe46-c5f0-40a8-a703-813ad663e900", + "persisted": 1657149026977 + }, + "6f0c1a8f-cefa-4783-a79e-9f123e8718ba": { + "identifier": { + "key": "6f0c1a8f-cefa-4783-a79e-9f123e8718ba", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "e230c105-b961-4e01-a056-8f2e8630e185", + "persisted": 1657232414746 + }, + "e3131777-c0ef-44f3-9202-4c9c7b864dcc": { + "identifier": { + "key": "e3131777-c0ef-44f3-9202-4c9c7b864dcc", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "location": "e230c105-b961-4e01-a056-8f2e8630e185", + "modified": 1657232414748, + "persisted": 1657232414748 + }, + "fe903b87-0d52-475b-a858-624fa67c378f": { + "identifier": { + "key": "fe903b87-0d52-475b-a858-624fa67c378f", + "namespace": "" + }, + "name": "SWG 10", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "10", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0, + "loadDelay": 0 + }, + "modified": 1657236492163, + "location": "e230c105-b961-4e01-a056-8f2e8630e185", + "persisted": 1657236492163 + }, + "00326dab-02c5-4522-9f68-e9e73758a272": { + "identifier": { + "key": "00326dab-02c5-4522-9f68-e9e73758a272", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "modified": 1657149026977, + "location": "e230c105-b961-4e01-a056-8f2e8630e185", + "persisted": 1657149026977 + }, + "135df6d8-080a-40b8-89b0-301c96174e18": { + "identifier": { + "key": "135df6d8-080a-40b8-89b0-301c96174e18", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414747, + "location": "c68ff290-5891-41bd-bfc1-84734fb86a19", + "persisted": 1657232414747 + }, + "3984ca34-8512-4857-8a4e-56e9be074e00": { + "identifier": { + "key": "3984ca34-8512-4857-8a4e-56e9be074e00", + "namespace": "" + }, + "name": "SWG Large", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "1000000", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414747, + "location": "8ae9193d-2f79-43bc-a39f-4f89a52da5a3", + "persisted": 1657232414747 + }, + "f4da3027-8296-4faf-b8c1-30b8919c53f4": { + "identifier": { + "key": "f4da3027-8296-4faf-b8c1-30b8919c53f4", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "8f72d5f7-7074-4745-9a0b-c5854d31790b", + "persisted": 1657232414746 + }, + "7ef88d73-8a2d-4b8f-92de-6abb76dd02e9": { + "identifier": { + "key": "7ef88d73-8a2d-4b8f-92de-6abb76dd02e9", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "caf64735-99c2-4906-a2fa-bb47912b2a79", + "persisted": 1657232414746 + }, + "ec3b4a3b-97f0-405e-be5a-d0ac15313df9": { + "identifier": { + "key": "ec3b4a3b-97f0-405e-be5a-d0ac15313df9", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "cdbbaf4f-ddaf-42c3-8e5e-51aef81d665d", + "persisted": 1657232414746 + }, + "691c802f-c53b-4938-8881-f421d02b2770": { + "identifier": { + "key": "691c802f-c53b-4938-8881-f421d02b2770", + "namespace": "" + }, + "name": "SWG Small", + "type": "generator", + "telemetry": { + "period": "5", + "amplitude": "5", + "offset": 0, + "dataRateInHz": "5", + "phase": 0, + "randomness": 0 + }, + "modified": 1657232414746, + "location": "2a84d91e-8612-43ed-9477-61b9cfbf5c2c", + "persisted": 1657232414746 + }, + "10987a9e-74ed-4e31-b820-806deadc9425": { + "identifier": { + "key": "10987a9e-74ed-4e31-b820-806deadc9425", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "modified": 1657149026977, + "location": "056bbcb6-1a45-4429-97e6-a8ae74cf55e3", + "persisted": 1657149026977 + }, + "1a15f3e4-99a9-4afd-a6fa-dcc822b39cbc": { + "identifier": { + "key": "1a15f3e4-99a9-4afd-a6fa-dcc822b39cbc", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "modified": 1657149026977, + "location": "0e4342e3-06db-4e13-ba48-b391879b37b6", + "persisted": 1657149026977 + }, + "b8b2d336-cdc2-42de-bb6b-c2033e691b35": { + "identifier": { + "key": "b8b2d336-cdc2-42de-bb6b-c2033e691b35", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "location": "a62b89ea-0fa0-46c5-beac-53d1009ac48c", + "persisted": 1664992205660, + "modified": 1664992205660 + }, + "17e8e842-c4f0-4c11-b4c6-e729f4018120": { + "identifier": { + "key": "17e8e842-c4f0-4c11-b4c6-e729f4018120", + "namespace": "" + }, + "name": "SWG 100", + "type": "generator", + "telemetry": { + "period": 10, + "amplitude": "100", + "offset": 0, + "dataRateInHz": 1, + "phase": 0, + "randomness": "1", + "loadDelay": 0 + }, + "location": "ee7ca7b3-04e2-4c91-b73f-01280a92d1cc", + "persisted": 1664992205660, + "modified": 1664992205660 + } + }, + "rootId": "45b24009-dfed-4023-a30b-d31f5e3a2d87" +} \ No newline at end of file diff --git a/e2e/tests/framework/appActions.e2e.spec.js b/e2e/tests/framework/appActions.e2e.spec.js index 3a95000ba7..cb8772e274 100644 --- a/e2e/tests/framework/appActions.e2e.spec.js +++ b/e2e/tests/framework/appActions.e2e.spec.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -const { test, expect } = require('../../baseFixtures.js'); +const { test, expect } = require('../../pluginFixtures.js'); const { createDomainObjectWithDefaults } = require('../../appActions.js'); test.describe('AppActions', () => { @@ -50,11 +50,11 @@ test.describe('AppActions', () => { }); await page.goto(timer1.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Foo'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer1.name); await page.goto(timer2.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Bar'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer2.name); await page.goto(timer3.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Baz'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name); }); await test.step('Create multiple nested objects in a row', async () => { @@ -74,11 +74,11 @@ test.describe('AppActions', () => { parent: folder2.uuid }); await page.goto(folder1.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Foo'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder1.name); await page.goto(folder2.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Bar'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder2.name); await page.goto(folder3.url, { waitUntil: 'networkidle' }); - await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Baz'); + await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder3.name); expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`); expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`); diff --git a/e2e/tests/framework/exampleTemplate.e2e.spec.js b/e2e/tests/framework/exampleTemplate.e2e.spec.js index 1b8ac44909..d042bebdc5 100644 --- a/e2e/tests/framework/exampleTemplate.e2e.spec.js +++ b/e2e/tests/framework/exampleTemplate.e2e.spec.js @@ -45,7 +45,7 @@ */ // Structure: Some standard Imports. Please update the required pathing. -const { test, expect } = require('../../baseFixtures'); +const { test, expect } = require('../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../appActions'); /** @@ -144,5 +144,5 @@ async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) { await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer); // Click Ok button to Save - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); } diff --git a/e2e/tests/framework/generateVisualTestData.e2e.spec.js b/e2e/tests/framework/generateVisualTestData.e2e.spec.js index 7cb37719f9..3d304982db 100644 --- a/e2e/tests/framework/generateVisualTestData.e2e.spec.js +++ b/e2e/tests/framework/generateVisualTestData.e2e.spec.js @@ -43,14 +43,14 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => { await page.locator('button:has-text("Create")').click(); // add sine wave generator with defaults - await page.locator('li:has-text("Sine Wave Generator")').click(); + await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); //Add a 5000 ms Delay await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000'); await Promise.all([ page.waitForNavigation(), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -58,7 +58,7 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => { // focus the overlay plot await page.goto(overlayPlot.url); - await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Overlay Plot'); + await expect(page.locator('.l-browse-bar__object-name')).toContainText(overlayPlot.name); //Save localStorage for future test execution await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' }); }); diff --git a/e2e/tests/functional/couchdb.e2e.spec.js b/e2e/tests/functional/couchdb.e2e.spec.js index b3c2fd918b..9641dbc137 100644 --- a/e2e/tests/functional/couchdb.e2e.spec.js +++ b/e2e/tests/functional/couchdb.e2e.spec.js @@ -25,7 +25,7 @@ * */ -const { test, expect } = require('../../baseFixtures'); +const { test, expect } = require('../../pluginFixtures'); test.describe("CouchDB Status Indicator @couchdb", () => { test.use({ failOnConsoleError: false }); diff --git a/e2e/tests/functional/example/eventGenerator.e2e.spec.js b/e2e/tests/functional/example/eventGenerator.e2e.spec.js index 0db74c480a..2dd7d5061c 100644 --- a/e2e/tests/functional/example/eventGenerator.e2e.spec.js +++ b/e2e/tests/functional/example/eventGenerator.e2e.spec.js @@ -24,7 +24,7 @@ This test suite is dedicated to tests which verify the basic operations surrounding the example event generator. */ -const { test, expect } = require('../../../baseFixtures'); +const { test, expect } = require('../../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../../appActions'); test.describe('Example Event Generator CRUD Operations', () => { diff --git a/e2e/tests/functional/example/generator/sineWaveLimitProvider.e2e.spec.js b/e2e/tests/functional/example/generator/sineWaveLimitProvider.e2e.spec.js index 7675406928..ac6f36e3b7 100644 --- a/e2e/tests/functional/example/generator/sineWaveLimitProvider.e2e.spec.js +++ b/e2e/tests/functional/example/generator/sineWaveLimitProvider.e2e.spec.js @@ -96,7 +96,7 @@ test.describe('Sine Wave Generator', () => { //Click text=OK await Promise.all([ page.waitForNavigation(), - page.click('text=OK') + page.click('button:has-text("OK")') ]); // Verify that the Sine Wave Generator is displayed and correct diff --git a/e2e/tests/functional/forms.e2e.spec.js b/e2e/tests/functional/forms.e2e.spec.js index 9da49274ac..dff694a949 100644 --- a/e2e/tests/functional/forms.e2e.spec.js +++ b/e2e/tests/functional/forms.e2e.spec.js @@ -25,6 +25,7 @@ This test suite is dedicated to tests which verify form functionality in isolati */ const { test, expect } = require('../../baseFixtures'); +const { createDomainObjectWithDefaults } = require('../../appActions'); const path = require('path'); const TEST_FOLDER = 'test folder'; @@ -43,7 +44,7 @@ test.describe('Form Validation Behavior', () => { await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab'); //Required Field Form Validation - await expect(page.locator('text=OK')).toBeDisabled(); + await expect(page.locator('button:has-text("OK")')).toBeDisabled(); await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/); //Correct Form Validation for missing title and trigger validation with 'Tab' @@ -52,13 +53,13 @@ test.describe('Form Validation Behavior', () => { await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab'); //Required Field Form Validation is corrected - await expect(page.locator('text=OK')).toBeEnabled(); + await expect(page.locator('button:has-text("OK")')).toBeEnabled(); await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/); //Finish Creating Domain Object await Promise.all([ page.waitForNavigation(), - page.click('text=OK') + page.click('button:has-text("OK")') ]); //Verify that the Domain Object has been created with the corrected title property @@ -91,6 +92,44 @@ test.describe('Persistence operations @addInit', () => { }); }); +test.describe('Persistence operations @couchdb', () => { + test.use({ failOnConsoleError: false }); + test('Editing object properties should generate a single persistence operation', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/5616' + }); + + await page.goto('./', { waitUntil: 'networkidle' }); + + // Create a new 'Clock' object with default settings + const clock = await createDomainObjectWithDefaults(page, { + type: 'Clock' + }); + + // Count all persistence operations (PUT requests) for this specific object + let putRequestCount = 0; + page.on('request', req => { + if (req.method() === 'PUT' && req.url().endsWith(clock.uuid)) { + putRequestCount += 1; + } + }); + + // Open the edit form for the clock object + await page.click('button[title="More options"]'); + await page.click('li[title="Edit properties of this object."]'); + + // Modify the display format from default 12hr -> 24hr and click 'Save' + await page.locator('select[aria-label="12 or 24 hour clock"]').selectOption({ value: 'clock24' }); + await page.click('button[aria-label="Save"]'); + + await expect.poll(() => putRequestCount, { + message: 'Verify a single PUT request was made to persist the object', + timeout: 1000 + }).toEqual(1); + }); +}); + test.describe('Form Correctness by Object Type', () => { test.fixme('Verify correct behavior of number object (SWG)', async ({page}) => {}); test.fixme('Verify correct behavior of number object Timer', async ({page}) => {}); diff --git a/e2e/tests/functional/moveAndLinkObjects.e2e.spec.js b/e2e/tests/functional/moveAndLinkObjects.e2e.spec.js index 78f20cb65f..6804032673 100644 --- a/e2e/tests/functional/moveAndLinkObjects.e2e.spec.js +++ b/e2e/tests/functional/moveAndLinkObjects.e2e.spec.js @@ -81,7 +81,7 @@ test.describe('Move & link item tests', () => { await page.locator('li.icon-move').click(); await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click(); - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); // Expect that Child Folder is in My Items, the root folder expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy(); @@ -95,11 +95,11 @@ test.describe('Move & link item tests', () => { // Create Telemetry Table let telemetryTable = 'Test Telemetry Table'; await page.locator('button:has-text("Create")').click(); - await page.locator('li:has-text("Telemetry Table")').click(); + await page.locator('li[role="menuitem"]:has-text("Telemetry Table")').click(); await page.locator('text=Properties Title Notes >> input[type="text"]').click(); await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable); - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); // Finish editing and save Telemetry Table await page.locator('.c-button--menu.c-button--major.icon-save').click(); @@ -108,7 +108,7 @@ test.describe('Move & link item tests', () => { // Create New Folder Basic Domain Object let folder = 'Test Folder'; await page.locator('button:has-text("Create")').click(); - await page.locator('li:has-text("Folder")').click(); + await page.locator('li[role="menuitem"]:has-text("Folder")').click(); await page.locator('text=Properties Title Notes >> input[type="text"]').click(); await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder); @@ -120,7 +120,7 @@ test.describe('Move & link item tests', () => { // Continue test regardless of assertion and create it in My Items await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click(); - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); // Open My Items await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); @@ -196,7 +196,7 @@ test.describe('Move & link item tests', () => { await page.locator('li.icon-link').click(); await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click(); - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); // Expect that Child Folder is in My Items, the root folder expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy(); diff --git a/e2e/tests/functional/plugins/conditionSet/conditionSet.e2e.spec.js b/e2e/tests/functional/plugins/conditionSet/conditionSet.e2e.spec.js index f3f9826aea..0cb927466d 100644 --- a/e2e/tests/functional/plugins/conditionSet/conditionSet.e2e.spec.js +++ b/e2e/tests/functional/plugins/conditionSet/conditionSet.e2e.spec.js @@ -40,11 +40,11 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => { await page.goto('./', { waitUntil: 'networkidle' }); await page.click('button:has-text("Create")'); - await page.locator('li:has-text("Condition Set")').click(); + await page.locator('li[role="menuitem"]:has-text("Condition Set")').click(); await Promise.all([ page.waitForNavigation(), - page.click('text=OK') + page.click('button:has-text("OK")') ]); //Save localStorage for future test execution @@ -163,9 +163,9 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => { // Click hamburger button await page.locator('[title="More options"]').click(); - // Click text=Remove - await page.locator('text=Remove').click(); - await page.locator('text=OK').click(); + // Click 'Remove' and press OK + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); + await page.locator('button:has-text("OK")').click(); //Expect Unnamed Condition Set to be removed in Main View const numberOfConditionSetsAtEnd = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count(); diff --git a/e2e/tests/functional/plugins/displayLayout/displayLayout.e2e.spec.js b/e2e/tests/functional/plugins/displayLayout/displayLayout.e2e.spec.js index 3d6456e2e0..a88d1a70a4 100644 --- a/e2e/tests/functional/plugins/displayLayout/displayLayout.e2e.spec.js +++ b/e2e/tests/functional/plugins/displayLayout/displayLayout.e2e.spec.js @@ -23,7 +23,7 @@ const { test, expect } = require('../../../../pluginFixtures'); const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions'); -test.describe('Testing Display Layout @unstable', () => { +test.describe('Display Layout', () => { let sineWaveObject; test.beforeEach(async ({ page }) => { await page.goto('./', { waitUntil: 'networkidle' }); @@ -55,12 +55,12 @@ test.describe('Testing Display Layout @unstable', () => { // On getting data, check if the value found in the Display Layout is the most recent value // from the Sine Wave Generator const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid); - const formattedTelemetryValue = await getTelemValuePromise; + const formattedTelemetryValue = getTelemValuePromise; const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`); const displayLayoutValue = await displayLayoutValuePromise.textContent(); const trimmedDisplayValue = displayLayoutValue.trim(); - await expect(trimmedDisplayValue).toBe(formattedTelemetryValue); + expect(trimmedDisplayValue).toBe(formattedTelemetryValue); }); test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => { // Create a Display Layout @@ -86,12 +86,12 @@ test.describe('Testing Display Layout @unstable', () => { // On getting data, check if the value found in the Display Layout is the most recent value // from the Sine Wave Generator - const formattedTelemetryValue = await getTelemValuePromise; + const formattedTelemetryValue = getTelemValuePromise; const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`); const displayLayoutValue = await displayLayoutValuePromise.textContent(); const trimmedDisplayValue = displayLayoutValue.trim(); - await expect(trimmedDisplayValue).toBe(formattedTelemetryValue); + expect(trimmedDisplayValue).toBe(formattedTelemetryValue); }); test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({ page }) => { // Create a Display Layout @@ -116,16 +116,20 @@ test.describe('Testing Display Layout @unstable', () => { // Bring up context menu and remove await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' }); - await page.locator('text=Remove').click(); - await page.locator('text=OK').click(); + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); + await page.locator('button:has-text("OK")').click(); // delete - expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0); + expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0); }); test('items in a display layout can be removed with object tree context menu when viewing another item', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/3117' + }); // Create a Display Layout - await createDomainObjectWithDefaults(page, { + const displayLayout = await createDomainObjectWithDefaults(page, { type: 'Display Layout', name: "Test Display Layout" }); @@ -144,18 +148,18 @@ test.describe('Testing Display Layout @unstable', () => { // Expand the Display Layout so we can remove the sine wave generator await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click(); - // Click the original Sine Wave Generator to navigate away from the Display Layout - await page.locator('.c-tree__item .c-tree__item__name:text("Test Sine Wave Generator")').click(); + // Go to the original Sine Wave Generator to navigate away from the Display Layout + await page.goto(sineWaveObject.url); // Bring up context menu and remove await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' }); - await page.locator('text=Remove').click(); - await page.locator('text=OK').click(); + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); + await page.locator('button:has-text("OK")').click(); // navigate back to the display layout to confirm it has been removed - await page.locator('.c-tree__item .c-tree__item__name:text("Test Display Layout")').click(); + await page.goto(displayLayout.url); - expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0); + expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0); }); }); diff --git a/e2e/tests/functional/plugins/flexibleLayout/flexibleLayout.e2e.spec.js b/e2e/tests/functional/plugins/flexibleLayout/flexibleLayout.e2e.spec.js index 484091d7ce..b6949e4fc7 100644 --- a/e2e/tests/functional/plugins/flexibleLayout/flexibleLayout.e2e.spec.js +++ b/e2e/tests/functional/plugins/flexibleLayout/flexibleLayout.e2e.spec.js @@ -23,12 +23,13 @@ const { test, expect } = require('../../../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../../../appActions'); -test.describe('Testing Flexible Layout @unstable', () => { +test.describe('Flexible Layout', () => { + let sineWaveObject; test.beforeEach(async ({ page }) => { await page.goto('./', { waitUntil: 'networkidle' }); // Create Sine Wave Generator - await createDomainObjectWithDefaults(page, { + sineWaveObject = await createDomainObjectWithDefaults(page, { type: 'Sine Wave Generator', name: "Test Sine Wave Generator" }); @@ -54,13 +55,81 @@ test.describe('Testing Flexible Layout @unstable', () => { await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty'); await page.dragAndDrop('text=Test Clock', '.c-fl__container.is-empty'); // Check that panes can be dragged while Flexible Layout is in Edit mode - let dragWrapper = await page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first(); + let dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first(); await expect(dragWrapper).toHaveAttribute('draggable', 'true'); // Save Flexible Layout await page.locator('button[title="Save"]').click(); await page.locator('text=Save and Finish Editing').click(); // Check that panes are not draggable while Flexible Layout is in Browse mode - dragWrapper = await page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first(); + dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first(); await expect(dragWrapper).toHaveAttribute('draggable', 'false'); }); + test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({ page }) => { + // Create a Display Layout + await createDomainObjectWithDefaults(page, { + type: 'Flexible Layout', + name: "Test Flexible Layout" + }); + // Edit Flexible Layout + await page.locator('[title="Edit"]').click(); + + // Expand the 'My Items' folder in the left tree + await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click(); + // Add the Sine Wave Generator to the Flexible Layout and save changes + await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty'); + await page.locator('button[title="Save"]').click(); + await page.locator('text=Save and Finish Editing').click(); + + expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1); + + // Expand the Flexible Layout so we can remove the sine wave generator + await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click(); + + // Bring up context menu and remove + await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' }); + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); + await page.locator('button:has-text("OK")').click(); + + // Verify that the item has been removed from the layout + expect(await page.locator('.c-fl-container__frame').count()).toEqual(0); + }); + test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/3117' + }); + // Create a Flexible Layout + const flexibleLayout = await createDomainObjectWithDefaults(page, { + type: 'Flexible Layout', + name: "Test Flexible Layout" + }); + // Edit Flexible Layout + await page.locator('[title="Edit"]').click(); + + // Expand the 'My Items' folder in the left tree + await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click(); + // Add the Sine Wave Generator to the Flexible Layout and save changes + await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty'); + await page.locator('button[title="Save"]').click(); + await page.locator('text=Save and Finish Editing').click(); + + expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1); + + // Expand the Flexible Layout so we can remove the sine wave generator + await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click(); + + // Go to the original Sine Wave Generator to navigate away from the Flexible Layout + await page.goto(sineWaveObject.url); + + // Bring up context menu and remove + await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' }); + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); + await page.locator('button:has-text("OK")').click(); + + // navigate back to the display layout to confirm it has been removed + await page.goto(flexibleLayout.url); + + // Verify that the item has been removed from the layout + expect(await page.locator('.c-fl-container__frame').count()).toEqual(0); + }); }); diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js new file mode 100644 index 0000000000..1e36449a54 --- /dev/null +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -0,0 +1,93 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +/* +* This test suite is dedicated to testing the Gauge component. +*/ + +const { test, expect } = require('../../../../baseFixtures'); +const { createDomainObjectWithDefaults } = require('../../../../appActions'); +const uuid = require('uuid').v4; + +test.describe('Gauge', () => { + let gauge; + + test.beforeEach(async ({ page }) => { + // Open a browser, navigate to the main page, and wait until all networkevents to resolve + await page.goto('./', { waitUntil: 'networkidle' }); + + // Create the gauge + gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' }); + }); + + test('Can add and remove telemetry sources @unstable', async ({ page }) => { + const editButtonLocator = page.locator('button[title="Edit"]'); + const saveButtonLocator = page.locator('button[title="Save"]'); + + // Create a sine wave generator within the gauge + const swg1 = await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: `swg-${uuid()}`, + parent: gauge.uuid + }); + + // Navigate to the gauge and verify that + // the SWG appears in the elements pool + await page.goto(gauge.url); + await editButtonLocator.click(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible(); + await saveButtonLocator.click(); + await page.locator('li[title="Save and Finish Editing"]').click(); + + // Create another sine wave generator within the gauge + const swg2 = await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: `swg-${uuid()}`, + parent: gauge.uuid + }); + + // Verify that the 'Replace telemetry source' modal appears and accept it + await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible(); + await page.click('text=Ok'); + + // Navigate to the gauge and verify that the new SWG + // appears in the elements pool and the old one is gone + await page.goto(gauge.url); + await editButtonLocator.click(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible(); + await saveButtonLocator.click(); + + // Right click on the new SWG in the elements pool and delete it + await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({ + button: 'right' + }); + await page.locator('li[title="Remove this object from its containing object."]').click(); + + // Verify that the 'Remove object' confirmation modal appears and accept it + await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible(); + await page.click('text=Ok'); + + // Verify that the elements pool shows no elements + await expect(page.locator('text="No contained elements"')).toBeVisible(); + }); +}); diff --git a/e2e/tests/functional/plugins/imagery/exampleImagery.e2e.spec.js b/e2e/tests/functional/plugins/imagery/exampleImagery.e2e.spec.js index f399daee01..d8ecbf9624 100644 --- a/e2e/tests/functional/plugins/imagery/exampleImagery.e2e.spec.js +++ b/e2e/tests/functional/plugins/imagery/exampleImagery.e2e.spec.js @@ -40,10 +40,10 @@ test.describe('Example Imagery Object', () => { await page.goto('./', { waitUntil: 'networkidle' }); // Create a default 'Example Imagery' object - await createDomainObjectWithDefaults(page, { type: 'Example Imagery' }); + const exampleImagery = await createDomainObjectWithDefaults(page, { type: 'Example Imagery' }); // Verify that the created object is focused - await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery'); + await expect(page.locator('.l-browse-bar__object-name')).toContainText(exampleImagery.name); await page.locator(backgroundImageSelector).hover({trial: true}); }); @@ -188,7 +188,7 @@ test.describe('Example Imagery in Display Layout', () => { await page.click('button:has-text("Create")'); // Click text=Example Imagery - await page.click('text=Example Imagery'); + await page.click('li[role="menuitem"]:has-text("Example Imagery")'); // Clear and set Image load delay to minimum value await page.locator('input[type="number"]').fill(''); @@ -197,7 +197,7 @@ test.describe('Example Imagery in Display Layout', () => { // Click text=OK await Promise.all([ page.waitForNavigation({waitUntil: 'networkidle'}), - page.click('text=OK'), + page.click('button:has-text("OK")'), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -275,7 +275,7 @@ test.describe('Example Imagery in Flexible layout', () => { await page.click('button:has-text("Create")'); // Click text=Example Imagery - await page.click('text=Example Imagery'); + await page.click('li[role="menuitem"]:has-text("Example Imagery")'); // Clear and set Image load delay to minimum value await page.locator('input[type="number"]').fill(''); @@ -284,7 +284,7 @@ test.describe('Example Imagery in Flexible layout', () => { // Click text=OK await Promise.all([ page.waitForNavigation({waitUntil: 'networkidle'}), - page.click('text=OK'), + page.click('button:has-text("OK")'), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -317,7 +317,7 @@ test.describe('Example Imagery in Tabs View', () => { await page.click('button:has-text("Create")'); // Click text=Example Imagery - await page.click('text=Example Imagery'); + await page.click('li[role="menuitem"]:has-text("Example Imagery")'); // Clear and set Image load delay to minimum value await page.locator('input[type="number"]').fill(''); @@ -326,7 +326,7 @@ test.describe('Example Imagery in Tabs View', () => { // Click text=OK await Promise.all([ page.waitForNavigation({waitUntil: 'networkidle'}), - page.click('text=OK'), + page.click('button:has-text("OK")'), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); diff --git a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js index 58e3e0f38d..f44140fe4e 100644 --- a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js @@ -26,7 +26,7 @@ This test suite is dedicated to tests which verify the basic operations surround // FIXME: Remove this eslint exception once tests are implemented // eslint-disable-next-line no-unused-vars -const { test, expect } = require('../../../../baseFixtures'); +const { test, expect } = require('../../../../pluginFixtures'); const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions'); const nbUtils = require('../../../../helper/notebookUtils'); diff --git a/e2e/tests/functional/plugins/notebook/notebookWithCouchDB.e2e.spec.js b/e2e/tests/functional/plugins/notebook/notebookWithCouchDB.e2e.spec.js index 4edb1ff28c..87a352797d 100644 --- a/e2e/tests/functional/plugins/notebook/notebookWithCouchDB.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/notebookWithCouchDB.e2e.spec.js @@ -24,10 +24,10 @@ This test suite is dedicated to tests which verify the basic operations surrounding Notebooks with CouchDB. */ -const { test, expect } = require('../../../../baseFixtures'); +const { test, expect } = require('../../../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../../../appActions'); -test.describe('Notebook Network Request Inspection @couchdb', () => { +test.describe('Notebook Tests with CouchDB @couchdb', () => { let testNotebook; test.beforeEach(async ({ page }) => { //Navigate to baseURL @@ -221,6 +221,45 @@ test.describe('Notebook Network Request Inspection @couchdb', () => { expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4); }); + + test('Search tests', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/akhenry/openmct-yamcs/issues/69' + }); + await page.locator('text=To start a new entry, click here or drag and drop any object').click(); + await page.locator('[aria-label="Notebook Entry Input"]').click(); + await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`); + await page.locator('[aria-label="Notebook Entry Input"]').press('Enter'); + + // Add three tags + await page.hover(`button:has-text("Add Tag")`); + await page.locator(`button:has-text("Add Tag")`).click(); + await page.locator('[placeholder="Type to select tag"]').click(); + await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click(); + await page.waitForSelector('[aria-label="Tag"]:has-text("Science")'); + + await page.hover(`button:has-text("Add Tag")`); + await page.locator(`button:has-text("Add Tag")`).click(); + await page.locator('[placeholder="Type to select tag"]').click(); + await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click(); + await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")'); + + await page.hover(`button:has-text("Add Tag")`); + await page.locator(`button:has-text("Add Tag")`).click(); + await page.locator('[placeholder="Type to select tag"]').click(); + await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click(); + await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")'); + + await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); + await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc'); + await expect(page.locator('[aria-label="Search Result"]').first()).toContainText("Science"); + await expect(page.locator('[aria-label="Search Result"]').first()).not.toContainText("Driving"); + + await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); + await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq'); + await expect(page.locator('text=No results found')).toBeVisible(); + }); }); // Try to reduce indeterminism of browser requests by only returning fetch requests. diff --git a/e2e/tests/functional/plugins/notebook/restrictedNotebook.e2e.spec.js b/e2e/tests/functional/plugins/notebook/restrictedNotebook.e2e.spec.js index 8594f58665..6a51238fd2 100644 --- a/e2e/tests/functional/plugins/notebook/restrictedNotebook.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/restrictedNotebook.e2e.spec.js @@ -36,27 +36,27 @@ test.describe('Restricted Notebook', () => { }); test('Can be renamed @addInit', async ({ page }) => { - await expect(page.locator('.l-browse-bar__object-name')).toContainText(`Unnamed ${CUSTOM_NAME}`); + await expect(page.locator('.l-browse-bar__object-name')).toContainText(`${notebook.name}`); }); - test('Can be deleted if there are no locked pages @addInit', async ({ page, openmctConfig }) => { + test('Can be deleted if there are no locked pages @addInit', async ({ page }) => { await openObjectTreeContextMenu(page, notebook.url); const menuOptions = page.locator('.c-menu ul'); await expect.soft(menuOptions).toContainText('Remove'); - const restrictedNotebookTreeObject = page.locator(`a:has-text("Unnamed ${CUSTOM_NAME}")`); + const restrictedNotebookTreeObject = page.locator(`a:has-text("${notebook.name}")`); // notebook tree object exists expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1); // Click Remove Text - await page.locator('text=Remove').click(); + await page.locator('li[role="menuitem"]:has-text("Remove")').click(); // Click 'OK' on confirmation window and wait for save banner to appear await Promise.all([ page.waitForNavigation(), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), page.waitForSelector('.c-message-banner__message') ]); @@ -134,7 +134,7 @@ test.describe('Restricted Notebook with at least one entry and with the page loc // Click text=Ok await Promise.all([ page.waitForNavigation(), - page.locator('text=Ok').click() + page.locator('button:has-text("OK")').click() ]); // deleted page, should no longer exist @@ -145,10 +145,9 @@ test.describe('Restricted Notebook with at least one entry and with the page loc test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => { - test.beforeEach(async ({ page, openmctConfig }) => { - const { myItemsFolderName } = openmctConfig; - await startAndAddRestrictedNotebookObject(page); - await nbUtils.dragAndDropEmbed(page, myItemsFolderName); + test.beforeEach(async ({ page }) => { + const notebook = await startAndAddRestrictedNotebookObject(page); + await nbUtils.dragAndDropEmbed(page, notebook); }); test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => { diff --git a/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js b/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js index e2cda186a6..a8a3dd239b 100644 --- a/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js @@ -36,15 +36,17 @@ async function createNotebookAndEntry(page, iterations = 1) { //Go to baseURL await page.goto('./', { waitUntil: 'networkidle' }); - createDomainObjectWithDefaults(page, { type: 'Notebook' }); + const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' }); for (let iteration = 0; iteration < iterations; iteration++) { - // Click text=To start a new entry, click here or drag and drop any object + // Create an entry await page.locator('text=To start a new entry, click here or drag and drop any object').click(); const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`; await page.locator(entryLocator).click(); await page.locator(entryLocator).fill(`Entry ${iteration}`); } + + return notebook; } /** @@ -53,7 +55,7 @@ async function createNotebookAndEntry(page, iterations = 1) { * @param {number} [iterations = 1] - the number of entries (and tags) to create */ async function createNotebookEntryAndTags(page, iterations = 1) { - await createNotebookAndEntry(page, iterations); + const notebook = await createNotebookAndEntry(page, iterations); for (let iteration = 0; iteration < iterations; iteration++) { // Hover and click "Add Tag" button @@ -75,6 +77,8 @@ async function createNotebookEntryAndTags(page, iterations = 1) { // Select the "Science" tag await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click(); } + + return notebook; } test.describe('Tagging in Notebooks @addInit', () => { @@ -116,7 +120,7 @@ test.describe('Tagging in Notebooks @addInit', () => { await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq'); - await expect(page.locator('[aria-label="Search Result"]')).toBeHidden(); + await expect(page.locator('text=No results found')).toBeVisible(); }); test('Can delete tags', async ({ page }) => { @@ -133,6 +137,27 @@ test.describe('Tagging in Notebooks @addInit', () => { await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving"); }); + test('Can delete entries without tags', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/5823' + }); + + await createNotebookEntryAndTags(page); + + await page.locator('text=To start a new entry, click here or drag and drop any object').click(); + const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = 1`; + await page.locator(entryLocator).click(); + await page.locator(entryLocator).fill(`An entry without tags`); + await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').press('Enter'); + + await page.hover('[aria-label="Notebook Entry Input"] >> nth=1'); + await page.locator('button[title="Delete this entry"]').last().click(); + await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeVisible(); + await page.locator('button:has-text("Ok")').click(); + await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeHidden(); + }); + test('Can delete objects with tags and neither return in search', async ({ page }) => { await createNotebookEntryAndTags(page); // Delete Notebook @@ -152,10 +177,10 @@ test.describe('Tagging in Notebooks @addInit', () => { //Go to baseURL await page.goto('./', { waitUntil: 'networkidle' }); - await createDomainObjectWithDefaults(page, { type: 'Clock' }); + const clock = await createDomainObjectWithDefaults(page, { type: 'Clock' }); const ITERATIONS = 4; - await createNotebookEntryAndTags(page, ITERATIONS); + const notebook = await createNotebookEntryAndTags(page, ITERATIONS); for (let iteration = 0; iteration < ITERATIONS; iteration++) { const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`; @@ -168,11 +193,11 @@ test.describe('Tagging in Notebooks @addInit', () => { page.goto('./#/browse/mine?hideTree=false'), page.click('.c-disclosure-triangle') ]); - // Click Unnamed Clock - await page.click('text="Unnamed Clock"'); + // Click Clock + await page.click(`text=${clock.name}`); - // Click Unnamed Notebook - await page.click('text="Unnamed Notebook"'); + // Click Notebook + await page.click(`text=${notebook.name}`); for (let iteration = 0; iteration < ITERATIONS; iteration++) { const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`; @@ -186,14 +211,13 @@ test.describe('Tagging in Notebooks @addInit', () => { page.waitForLoadState('networkidle') ]); - // Click Unnamed Notebook - await page.click('text="Unnamed Notebook"'); + // Click Notebook + await page.click(`text="${notebook.name}"`); for (let iteration = 0; iteration < ITERATIONS; iteration++) { const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`; await expect(page.locator(entryLocator)).toContainText("Science"); await expect(page.locator(entryLocator)).toContainText("Driving"); } - }); }); diff --git a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js index 81640b95c1..a615254194 100644 --- a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js @@ -110,10 +110,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) { await page.locator('button:has-text("Create")').click(); // add overlay plot with defaults - await page.locator('li:has-text("Overlay Plot")').click(); + await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click(); await Promise.all([ page.waitForNavigation(), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear1 page.waitForSelector('.c-message-banner__message') ]); @@ -129,10 +129,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) { await page.locator('button:has-text("Create")').click(); // add sine wave generator with defaults - await page.locator('li:has-text("Sine Wave Generator")').click(); + await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await Promise.all([ page.waitForNavigation(), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear1 page.waitForSelector('.c-message-banner__message') ]); diff --git a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-darwin b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-darwin index d6d4dd21e5..072218f3f3 100644 Binary files a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-darwin and b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-darwin differ diff --git a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-linux.png b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-linux.png index 4a882660e0..145d4e54c4 100644 Binary files a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-linux.png and b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-panned-chrome-linux.png differ diff --git a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-darwin b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-darwin index ef5455e5c4..b6c7ba2fcf 100644 Binary files a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-darwin and b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-darwin differ diff --git a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-linux.png b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-linux.png index ffdedffd2b..3b1a664ade 100644 Binary files a/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-linux.png and b/e2e/tests/functional/plugins/plot/autoscale.e2e.spec.js-snapshots/autoscale-canvas-prepan-chrome-linux.png differ diff --git a/e2e/tests/functional/plugins/plot/logPlot.e2e.spec.js b/e2e/tests/functional/plugins/plot/logPlot.e2e.spec.js index c76bf82cc9..fa6b43eec1 100644 --- a/e2e/tests/functional/plugins/plot/logPlot.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/logPlot.e2e.spec.js @@ -88,10 +88,10 @@ async function makeOverlayPlot(page, myItemsFolderName) { // create overlay plot await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Overlay Plot")').click(); + await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click(); await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -106,7 +106,7 @@ async function makeOverlayPlot(page, myItemsFolderName) { // create a sinewave generator await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Sine Wave Generator")').click(); + await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); // set amplitude to 6, offset 4, period 2 @@ -123,7 +123,7 @@ async function makeOverlayPlot(page, myItemsFolderName) { await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); diff --git a/e2e/tests/functional/plugins/plot/missingPlotObj.e2e.spec.js b/e2e/tests/functional/plugins/plot/missingPlotObj.e2e.spec.js index 0e1eec5c72..a6bdd622e8 100644 --- a/e2e/tests/functional/plugins/plot/missingPlotObj.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/missingPlotObj.e2e.spec.js @@ -88,11 +88,11 @@ async function makeStackedPlot(page, myItemsFolderName) { // create stacked plot await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Stacked Plot")').click(); + await page.locator('li[role="menuitem"]:has-text("Stacked Plot")').click(); await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -146,11 +146,11 @@ async function saveStackedPlot(page) { async function createSineWaveGenerator(page) { //Create sine wave generator await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Sine Wave Generator")').click(); + await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); diff --git a/e2e/tests/functional/plugins/plot/plotLegendSwatch.e2e.spec.js b/e2e/tests/functional/plugins/plot/plotLegendSwatch.e2e.spec.js index 25a5e348d7..86381f3a85 100644 --- a/e2e/tests/functional/plugins/plot/plotLegendSwatch.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/plotLegendSwatch.e2e.spec.js @@ -68,10 +68,10 @@ async function makeOverlayPlot(page) { // create overlay plot await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Overlay Plot")').click(); + await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click(); await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); @@ -86,13 +86,13 @@ async function makeOverlayPlot(page) { // create a sinewave generator await page.locator('button.c-create-button').click(); - await page.locator('li:has-text("Sine Wave Generator")').click(); + await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); // Click OK to make generator await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle'}), - page.locator('text=OK').click(), + page.locator('button:has-text("OK")').click(), //Wait for Save Banner to appear page.waitForSelector('.c-message-banner__message') ]); diff --git a/e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js b/e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js index 30e8633220..2979a9a3bc 100644 --- a/e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js @@ -25,7 +25,7 @@ * */ -const { test, expect } = require('../../../../baseFixtures'); +const { test, expect } = require('../../../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../../../appActions'); test.describe('Plot Integrity Testing @unstable', () => { diff --git a/e2e/tests/functional/plugins/plot/scatterPlot.e2e.spec.js b/e2e/tests/functional/plugins/plot/scatterPlot.e2e.spec.js new file mode 100644 index 0000000000..ccc47fa8b0 --- /dev/null +++ b/e2e/tests/functional/plugins/plot/scatterPlot.e2e.spec.js @@ -0,0 +1,93 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +/* +* This test suite is dedicated to testing the Scatter Plot component. +*/ + +const { test, expect } = require('../../../../pluginFixtures'); +const { createDomainObjectWithDefaults } = require('../../../../appActions'); +const uuid = require('uuid').v4; + +test.describe('Scatter Plot', () => { + let scatterPlot; + + test.beforeEach(async ({ page }) => { + // Open a browser, navigate to the main page, and wait until all networkevents to resolve + await page.goto('./', { waitUntil: 'networkidle' }); + + // Create the Scatter Plot + scatterPlot = await createDomainObjectWithDefaults(page, { type: 'Scatter Plot' }); + }); + + test('Can add and remove telemetry sources', async ({ page }) => { + const editButtonLocator = page.locator('button[title="Edit"]'); + const saveButtonLocator = page.locator('button[title="Save"]'); + + // Create a sine wave generator within the scatter plot + const swg1 = await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: `swg-${uuid()}`, + parent: scatterPlot.uuid + }); + + // Navigate to the scatter plot and verify that + // the SWG appears in the elements pool + await page.goto(scatterPlot.url); + await editButtonLocator.click(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible(); + await saveButtonLocator.click(); + await page.locator('li[title="Save and Finish Editing"]').click(); + + // Create another sine wave generator within the scatter plot + const swg2 = await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: `swg-${uuid()}`, + parent: scatterPlot.uuid + }); + + // Verify that the 'Replace telemetry source' modal appears and accept it + await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible(); + await page.click('text=Ok'); + + // Navigate to the scatter plot and verify that the new SWG + // appears in the elements pool and the old one is gone + await page.goto(scatterPlot.url); + await editButtonLocator.click(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden(); + await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible(); + await saveButtonLocator.click(); + + // Right click on the new SWG in the elements pool and delete it + await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({ + button: 'right' + }); + await page.locator('li[title="Remove this object from its containing object."]').click(); + + // Verify that the 'Remove object' confirmation modal appears and accept it + await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible(); + await page.click('text=Ok'); + + // Verify that the elements pool shows no elements + await expect(page.locator('text="No contained elements"')).toBeVisible(); + }); +}); diff --git a/e2e/tests/functional/plugins/timeConductor/timeConductor.e2e.spec.js b/e2e/tests/functional/plugins/timeConductor/timeConductor.e2e.spec.js index 645c4fc915..14494b5d92 100644 --- a/e2e/tests/functional/plugins/timeConductor/timeConductor.e2e.spec.js +++ b/e2e/tests/functional/plugins/timeConductor/timeConductor.e2e.spec.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -const { test, expect } = require('../../../../baseFixtures'); +const { test, expect } = require('../../../../pluginFixtures'); const { setFixedTimeMode, setRealTimeMode, setStartOffset, setEndOffset } = require('../../../../appActions'); test.describe('Time conductor operations', () => { diff --git a/e2e/tests/functional/plugins/timer/timer.e2e.spec.js b/e2e/tests/functional/plugins/timer/timer.e2e.spec.js index 16c6b5defc..9269c0cac2 100644 --- a/e2e/tests/functional/plugins/timer/timer.e2e.spec.js +++ b/e2e/tests/functional/plugins/timer/timer.e2e.spec.js @@ -30,7 +30,7 @@ test.describe('Timer', () => { timer = await createDomainObjectWithDefaults(page, { type: 'timer' }); }); - test('Can perform actions on the Timer', async ({ page, openmctConfig }) => { + test('Can perform actions on the Timer', async ({ page }) => { test.info().annotations.push({ type: 'issue', description: 'https://github.com/nasa/openmct/issues/4313' diff --git a/e2e/tests/functional/search.e2e.spec.js b/e2e/tests/functional/search.e2e.spec.js index a944599691..2aa4116563 100644 --- a/e2e/tests/functional/search.e2e.spec.js +++ b/e2e/tests/functional/search.e2e.spec.js @@ -31,7 +31,7 @@ test.describe('Grand Search', () => { test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => { const { myItemsFolderName } = openmctConfig; - await createObjectsForSearch(page, myItemsFolderName); + const createdObjects = await createObjectsForSearch(page); // Click [aria-label="OpenMCT Search"] input[type="search"] await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); @@ -41,8 +41,8 @@ test.describe('Grand Search', () => { await expect(page.locator('[aria-label="Search Result"] >> nth=1')).toContainText(`Clock B ${myItemsFolderName} Red Folder Blue Folder`); await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`); await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`); - // Click text=Elements >> nth=0 - await page.locator('text=Elements').first().click(); + // Click the Elements pool to dismiss the search menu + await page.locator('.l-pane__label:has-text("Elements")').click(); await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden(); await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').click(); @@ -77,7 +77,7 @@ test.describe('Grand Search', () => { await expect(page.locator('.is-object-type-clock')).toBeVisible(); await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Disp'); - await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText('Unnamed Display Layout'); + await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText(createdObjects.displayLayout.name); await expect(page.locator('[aria-label="Search Result"] >> nth=0')).not.toContainText('Folder'); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Clock C'); @@ -185,7 +185,7 @@ async function createFolderObject(page, folderName) { await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folderName); // Create folder object - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); } async function waitForSearchCompletion(page) { @@ -197,75 +197,56 @@ async function waitForSearchCompletion(page) { * Creates some domain objects for searching * @param {import('@playwright/test').Page} page */ -async function createObjectsForSearch(page, myItemsFolderName) { +async function createObjectsForSearch(page) { //Go to baseURL await page.goto('./', { waitUntil: 'networkidle' }); - await page.locator('button:has-text("Create")').click(); - await page.locator('li:has-text("Folder") >> nth=1').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Red Folder'), - await page.locator(`text=Save In Open MCT ${myItemsFolderName} >> span`).nth(3).click(), - page.locator('button:has-text("OK")').click() - ]); + const redFolder = await createDomainObjectWithDefaults(page, { + type: 'Folder', + name: 'Red Folder' + }); - await page.locator('button:has-text("Create")').click(); - await page.locator('li:has-text("Folder") >> nth=2').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Blue Folder'), - await page.locator('form[name="mctForm"] >> text=Red Folder').click(), - page.locator('button:has-text("OK")').click() - ]); + const blueFolder = await createDomainObjectWithDefaults(page, { + type: 'Folder', + name: 'Blue Folder', + parent: redFolder.uuid + }); - await page.locator('button:has-text("Create")').click(); - await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock A'), - await page.locator('form[name="mctForm"] >> text=Blue Folder').click(), - page.locator('button:has-text("OK")').click() - ]); + const clockA = await createDomainObjectWithDefaults(page, { + type: 'Clock', + name: 'Clock A', + parent: blueFolder.uuid + }); + const clockB = await createDomainObjectWithDefaults(page, { + type: 'Clock', + name: 'Clock B', + parent: blueFolder.uuid + }); + const clockC = await createDomainObjectWithDefaults(page, { + type: 'Clock', + name: 'Clock C', + parent: blueFolder.uuid + }); + const clockD = await createDomainObjectWithDefaults(page, { + type: 'Clock', + name: 'Clock D', + parent: blueFolder.uuid + }); - await page.locator('button:has-text("Create")').click(); - await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock B'), - await page.locator('form[name="mctForm"] >> text=Blue Folder').click(), - page.locator('button:has-text("OK")').click() - ]); + const displayLayout = await createDomainObjectWithDefaults(page, { + type: 'Display Layout' + }); - await page.locator('button:has-text("Create")').click(); - await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock C'), - await page.locator('form[name="mctForm"] >> text=Blue Folder').click(), - page.locator('button:has-text("OK")').click() - ]); + // Go back into edit mode for the display layout + await page.locator('button[title="Edit"]').click(); - await page.locator('button:has-text("Create")').click(); - await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click(); - await Promise.all([ - page.waitForNavigation(), - await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock D'), - await page.locator('form[name="mctForm"] >> text=Blue Folder').click(), - page.locator('button:has-text("OK")').click() - ]); - - await Promise.all([ - page.waitForNavigation(), - page.locator(`a:has-text("${myItemsFolderName}") >> nth=0`).click() - ]); - // Click button:has-text("Create") - await page.locator('button:has-text("Create")').click(); - // Click li:has-text("Notebook") - await page.locator('li:has-text("Display Layout")').click(); - // Click button:has-text("OK") - await Promise.all([ - page.waitForNavigation(), - page.locator('button:has-text("OK")').click() - ]); + return { + redFolder, + blueFolder, + clockA, + clockB, + clockC, + clockD, + displayLayout + }; } diff --git a/e2e/tests/performance/imagery.perf.spec.js b/e2e/tests/performance/imagery.perf.spec.js index 396f249afd..0cbe35bb82 100644 --- a/e2e/tests/performance/imagery.perf.spec.js +++ b/e2e/tests/performance/imagery.perf.spec.js @@ -53,7 +53,7 @@ test.describe('Performance tests', () => { await page.setInputFiles('#fileElem', filePath); // Click text=OK - await page.locator('text=OK').click(); + await page.locator('button:has-text("OK")').click(); await expect(page.locator('a:has-text("Performance Display Layout Display Layout")')).toBeVisible(); diff --git a/openmct.js b/openmct.js index fe4ce8e628..e8ec87c070 100644 --- a/openmct.js +++ b/openmct.js @@ -30,8 +30,53 @@ if (document.currentScript) { } } +/** + * @typedef {object} BuildInfo + * @property {string} version + * @property {string} buildDate + * @property {string} revision + * @property {string} branch + */ + +/** + * @typedef {object} OpenMCT + * @property {BuildInfo} buildInfo + * @property {*} selection + * @property {import('./src/api/time/TimeAPI').default} time + * @property {import('./src/api/composition/CompositionAPI').default} composition + * @property {*} objectViews + * @property {*} inspectorViews + * @property {*} propertyEditors + * @property {*} toolbars + * @property {*} types + * @property {import('./src/api/objects/ObjectAPI').default} objects + * @property {import('./src/api/telemetry/TelemetryAPI').default} telemetry + * @property {import('./src/api/indicators/IndicatorAPI').default} indicators + * @property {import('./src/api/user/UserAPI').default} user + * @property {import('./src/api/notifications/NotificationAPI').default} notifications + * @property {import('./src/api/Editor').default} editor + * @property {import('./src/api/overlays/OverlayAPI')} overlays + * @property {import('./src/api/menu/MenuAPI').default} menus + * @property {import('./src/api/actions/ActionsAPI').default} actions + * @property {import('./src/api/status/StatusAPI').default} status + * @property {*} priority + * @property {import('./src/ui/router/ApplicationRouter')} router + * @property {import('./src/api/faultmanagement/FaultManagementAPI').default} faults + * @property {import('./src/api/forms/FormsAPI').default} forms + * @property {import('./src/api/Branding').default} branding + * @property {import('./src/api/annotation/AnnotationAPI').default} annotation + * @property {{(plugin: OpenMCTPlugin) => void}} install + * @property {{() => string}} getAssetPath + * @property {{(domElement: HTMLElement, isHeadlessMode: boolean) => void}} start + * @property {{() => void}} startHeadless + * @property {{() => void}} destroy + * @property {OpenMCTPlugin[]} plugins + * @property {OpenMCTComponent[]} components + */ + const MCT = require('./src/MCT'); +/** @type {OpenMCT} */ const openmct = new MCT(); module.exports = openmct; diff --git a/package.json b/package.json index 1293f0ef08..98bab93411 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,16 @@ { "name": "openmct", - "version": "2.1.1-SNAPSHOT", + "version": "2.1.3-SNAPSHOT", "description": "The Open MCT core platform", "devDependencies": { "@babel/eslint-parser": "7.18.9", "@braintree/sanitize-url": "6.0.0", - "@percy/cli": "1.10.3", + "@percy/cli": "1.13.0", "@percy/playwright": "1.0.4", "@playwright/test": "1.25.2", - "@types/eventemitter3": "^1.0.0", - "@types/jasmine": "^4.0.1", - "@types/karma": "^6.3.2", - "@types/lodash": "^4.14.178", - "@types/mocha": "^9.1.0", - "babel-loader": "8.2.5", + "@types/jasmine": "4.3.0", + "@types/lodash": "4.14.188", + "babel-loader": "9.0.0", "babel-plugin-istanbul": "6.1.1", "codecov": "3.8.3", "comma-separated-values": "3.6.4", @@ -22,17 +19,17 @@ "d3-axis": "3.0.0", "d3-scale": "3.3.0", "d3-selection": "3.0.0", - "eslint": "8.24.0", + "eslint": "8.27.0", "eslint-plugin-compat": "4.0.2", "eslint-plugin-playwright": "0.11.2", - "eslint-plugin-vue": "9.3.0", + "eslint-plugin-vue": "9.7.0", "eslint-plugin-you-dont-need-lodash-underscore": "6.12.0", "eventemitter3": "1.2.0", "file-saver": "2.0.5", "git-rev-sync": "3.0.2", "html2canvas": "1.4.1", "imports-loader": "4.0.1", - "jasmine-core": "4.4.0", + "jasmine-core": "4.5.0", "karma": "6.3.20", "karma-chrome-launcher": "3.1.1", "karma-cli": "2.0.0", @@ -48,18 +45,19 @@ "mini-css-extract-plugin": "2.6.1", "moment": "2.29.4", "moment-duration-format": "2.3.2", - "moment-timezone": "0.5.37", + "moment-timezone": "0.5.38", "nyc": "15.1.0", "painterro": "1.2.78", - "playwright-core": "1.26.1", + "playwright-core": "1.25.2", "plotly.js-basic-dist": "2.14.0", "plotly.js-gl2d-dist": "2.14.0", "printj": "1.3.1", "resolve-url-loader": "5.0.0", - "sass": "1.55.0", + "sass": "1.56.1", "sass-loader": "13.0.2", - "sinon": "14.0.0", + "sinon": "14.0.1", "style-loader": "^3.3.1", + "typescript": "4.8.4", "uuid": "9.0.0", "vue": "2.6.14", "vue-eslint-parser": "9.1.0", @@ -99,7 +97,7 @@ "cov:e2e:full:publish": "codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-full", "cov:e2e:stable:publish": "codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-stable", "cov:unit:publish": "codecov --disable=gcov -f ./coverage/unit/lcov.info -F unit", - "prepare": "npm run build:prod" + "prepare": "npm run build:prod && npx tsc" }, "repository": { "type": "git", @@ -116,6 +114,5 @@ "ios_saf > 15" ], "author": "", - "license": "Apache-2.0", - "private": true + "license": "Apache-2.0" } diff --git a/src/MCT.js b/src/MCT.js index 595afa7b05..1609f65881 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ - +/* eslint-disable no-undef */ define([ 'EventEmitter', './api/api', @@ -81,13 +81,11 @@ define([ /** * The Open MCT application. This may be configured by installing plugins * or registering extensions before the application is started. - * @class MCT + * @constructor * @memberof module:openmct - * @augments {EventEmitter} */ function MCT() { EventEmitter.call(this); - /* eslint-disable no-undef */ this.buildInfo = { version: __OPENMCT_VERSION__, buildDate: __OPENMCT_BUILD_DATE__, @@ -101,7 +99,7 @@ define([ * Tracks current selection state of the application. * @private */ - ['selection', () => new Selection(this)], + ['selection', () => new Selection.default(this)], /** * MCT's time conductor, which may be used to synchronize view contents @@ -125,7 +123,7 @@ define([ * @memberof module:openmct.MCT# * @name composition */ - ['composition', () => new api.CompositionAPI(this)], + ['composition', () => new api.CompositionAPI.default(this)], /** * Registry for views of domain objects which should appear in the diff --git a/src/api/Branding.js b/src/api/Branding.js index c448217415..26de8f1979 100644 --- a/src/api/Branding.js +++ b/src/api/Branding.js @@ -23,8 +23,7 @@ let brandingOptions = {}; /** - * @typedef {Object} BrandingOptions - * @memberOf openmct/branding + * @typedef {object} BrandingOptions * @property {string} smallLogoImage URL to the image to use as the applications logo. * This logo will appear on every screen and when clicked will launch the about dialog. * @property {string} aboutHtml Custom content for the about screen. When defined the diff --git a/src/api/Editor.js b/src/api/Editor.js index d919da3837..53c7310246 100644 --- a/src/api/Editor.js +++ b/src/api/Editor.js @@ -56,18 +56,12 @@ export default class Editor extends EventEmitter { * Save any unsaved changes from this editing session. This will * end the current transaction. */ - save() { + async save() { const transaction = this.openmct.objects.getActiveTransaction(); - - return transaction.commit() - .then(() => { - this.editing = false; - this.emit('isEditing', false); - }).catch(error => { - throw error; - }).finally(() => { - this.openmct.objects.endTransaction(); - }); + await transaction.commit(); + this.editing = false; + this.emit('isEditing', false); + this.openmct.objects.endTransaction(); } /** diff --git a/src/api/EditorSpec.js b/src/api/EditorSpec.js new file mode 100644 index 0000000000..104a4f6eb8 --- /dev/null +++ b/src/api/EditorSpec.js @@ -0,0 +1,80 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +import { + createOpenMct, resetApplicationState +} from '../utils/testing'; + +describe('The Editor API', () => { + let openmct; + + beforeEach((done) => { + openmct = createOpenMct(); + openmct.on('start', done); + + spyOn(openmct.objects, 'endTransaction'); + + openmct.startHeadless(); + }); + + afterEach(() => { + return resetApplicationState(openmct); + }); + + it('opens a transaction on edit', () => { + expect( + openmct.objects.isTransactionActive() + ).toBeFalse(); + openmct.editor.edit(); + expect( + openmct.objects.isTransactionActive() + ).toBeTrue(); + }); + + it('closes an open transaction on successful save', async () => { + spyOn(openmct.objects, 'getActiveTransaction') + .and.returnValue({ + commit: () => Promise.resolve(true) + }); + + openmct.editor.edit(); + await openmct.editor.save(); + + expect( + openmct.objects.endTransaction + ).toHaveBeenCalled(); + }); + + it('does not close an open transaction on failed save', async () => { + spyOn(openmct.objects, 'getActiveTransaction') + .and.returnValue({ + commit: () => Promise.reject() + }); + + openmct.editor.edit(); + await openmct.editor.save().catch(() => {}); + + expect( + openmct.objects.endTransaction + ).not.toHaveBeenCalled(); + }); +}); diff --git a/src/api/annotation/AnnotationAPI.js b/src/api/annotation/AnnotationAPI.js index 148b1d3c4b..618d6f874f 100644 --- a/src/api/annotation/AnnotationAPI.js +++ b/src/api/annotation/AnnotationAPI.js @@ -346,6 +346,10 @@ export default class AnnotationAPI extends EventEmitter { */ async searchForTags(query, abortController) { const matchingTagKeys = this.#getMatchingTags(query); + if (!matchingTagKeys.length) { + return []; + } + const searchResults = (await Promise.all(this.openmct.objects.search(matchingTagKeys, abortController, this.openmct.objects.SEARCH_TYPES.TAGS))).flat(); const filteredDeletedResults = searchResults.filter((result) => { return !(result._deleted); diff --git a/src/api/annotation/AnnotationAPISpec.js b/src/api/annotation/AnnotationAPISpec.js index a7e2a162dd..b8464a35d7 100644 --- a/src/api/annotation/AnnotationAPISpec.js +++ b/src/api/annotation/AnnotationAPISpec.js @@ -94,7 +94,6 @@ describe("The Annotation API", () => { openmct.startHeadless(); }); afterEach(async () => { - openmct.objects.providers = {}; await resetApplicationState(openmct); }); it("is defined", () => { @@ -185,5 +184,10 @@ describe("The Annotation API", () => { expect(results).toBeDefined(); expect(results.length).toEqual(1); }); + it("returns no tags for empty search", async () => { + const results = await openmct.annotation.searchForTags('q'); + expect(results).toBeDefined(); + expect(results.length).toEqual(0); + }); }); }); diff --git a/src/api/api.js b/src/api/api.js index 505213476a..24a35ee462 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -37,7 +37,9 @@ define([ './types/TypeRegistry', './user/UserAPI', './annotation/AnnotationAPI' -], function ( +], + +function ( ActionsAPI, CompositionAPI, EditorAPI, diff --git a/src/api/composition/CompositionAPI.js b/src/api/composition/CompositionAPI.js index 02dfb0315e..96bc1faadf 100644 --- a/src/api/composition/CompositionAPI.js +++ b/src/api/composition/CompositionAPI.js @@ -20,34 +20,41 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define([ - 'lodash', - 'EventEmitter', - './DefaultCompositionProvider', - './CompositionCollection' -], function ( - _, - EventEmitter, - DefaultCompositionProvider, - CompositionCollection -) { +import DefaultCompositionProvider from './DefaultCompositionProvider'; +import CompositionCollection from './CompositionCollection'; + +/** + * @typedef {import('./CompositionProvider').default} CompositionProvider + */ + +/** + * @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject + */ + +/** + * @typedef {import('../../../openmct').OpenMCT} OpenMCT + */ + +/** + * An interface for interacting with the composition of domain objects. + * The composition of a domain object is the list of other domain objects + * it "contains" (for instance, that should be displayed beneath it + * in the tree.) + * @constructor + */ +export default class CompositionAPI { /** - * An interface for interacting with the composition of domain objects. - * The composition of a domain object is the list of other domain objects - * it "contains" (for instance, that should be displayed beneath it - * in the tree.) - * - * @interface CompositionAPI - * @returns {module:openmct.CompositionCollection} - * @memberof module:openmct + * @param {OpenMCT} publicAPI */ - function CompositionAPI(publicAPI) { + constructor(publicAPI) { + /** @type {CompositionProvider[]} */ this.registry = []; + /** @type {CompositionPolicy[]} */ this.policies = []; this.addProvider(new DefaultCompositionProvider(publicAPI, this)); + /** @type {OpenMCT} */ this.publicAPI = publicAPI; } - /** * Add a composition provider. * @@ -55,21 +62,19 @@ define([ * behavior for certain domain objects. * * @method addProvider - * @param {module:openmct.CompositionProvider} provider the provider to add - * @memberof module:openmct.CompositionAPI# + * @param {CompositionProvider} provider the provider to add */ - CompositionAPI.prototype.addProvider = function (provider) { + addProvider(provider) { this.registry.unshift(provider); - }; - + } /** * Retrieve the composition (if any) of this domain object. * * @method get - * @returns {module:openmct.CompositionCollection} - * @memberof module:openmct.CompositionAPI# + * @param {DomainObject} domainObject + * @returns {CompositionCollection} */ - CompositionAPI.prototype.get = function (domainObject) { + get(domainObject) { const provider = this.registry.find(p => { return p.appliesTo(domainObject); }); @@ -79,8 +84,7 @@ define([ } return new CompositionCollection(domainObject, provider, this.publicAPI); - }; - + } /** * A composition policy is a function which either allows or disallows * placing one object in another's composition. @@ -90,52 +94,51 @@ define([ * generally be written to return true in the default case. * * @callback CompositionPolicy - * @memberof module:openmct.CompositionAPI~ - * @param {module:openmct.DomainObject} containingObject the object which + * @param {DomainObject} containingObject the object which * would act as a container - * @param {module:openmct.DomainObject} containedObject the object which + * @param {DomainObject} containedObject the object which * would be contained * @returns {boolean} false if this composition should be disallowed */ - /** * Add a composition policy. Composition policies may disallow domain * objects from containing other domain objects. * * @method addPolicy - * @param {module:openmct.CompositionAPI~CompositionPolicy} policy + * @param {CompositionPolicy} policy * the policy to add - * @memberof module:openmct.CompositionAPI# */ - CompositionAPI.prototype.addPolicy = function (policy) { + addPolicy(policy) { this.policies.push(policy); - }; - + } /** * Check whether or not a domain object is allowed to contain another * domain object. * * @private * @method checkPolicy - * @param {module:openmct.DomainObject} containingObject the object which + * @param {DomainObject} container the object which * would act as a container - * @param {module:openmct.DomainObject} containedObject the object which + * @param {DomainObject} containee the object which * would be contained * @returns {boolean} false if this composition should be disallowed - - * @param {module:openmct.CompositionAPI~CompositionPolicy} policy + * @param {CompositionPolicy} policy * the policy to add - * @memberof module:openmct.CompositionAPI# */ - CompositionAPI.prototype.checkPolicy = function (container, containee) { + checkPolicy(container, containee) { return this.policies.every(function (policy) { return policy(container, containee); }); - }; + } - CompositionAPI.prototype.supportsComposition = function (domainObject) { + /** + * Check whether or not a domainObject supports composition + * + * @param {DomainObject} domainObject + * @returns {boolean} true if the domainObject supports composition + */ + supportsComposition(domainObject) { return this.get(domainObject) !== undefined; - }; + } +} - return CompositionAPI; -}); diff --git a/src/api/composition/CompositionAPISpec.js b/src/api/composition/CompositionAPISpec.js index 822e3fd020..f8d33ed072 100644 --- a/src/api/composition/CompositionAPISpec.js +++ b/src/api/composition/CompositionAPISpec.js @@ -1,325 +1,319 @@ -define([ - './CompositionAPI', - './CompositionCollection' -], function ( - CompositionAPI, - CompositionCollection -) { +import CompositionAPI from './CompositionAPI'; +import CompositionCollection from './CompositionCollection'; - describe('The Composition API', function () { - let publicAPI; - let compositionAPI; - let topicService; - let mutationTopic; +describe('The Composition API', function () { + let publicAPI; + let compositionAPI; + let topicService; + let mutationTopic; + + beforeEach(function () { + + mutationTopic = jasmine.createSpyObj('mutationTopic', [ + 'listen' + ]); + topicService = jasmine.createSpy('topicService'); + topicService.and.returnValue(mutationTopic); + publicAPI = {}; + publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [ + 'get', + 'mutate', + 'observe', + 'areIdsEqual' + ]); + + publicAPI.objects.areIdsEqual.and.callFake(function (id1, id2) { + return id1.namespace === id2.namespace && id1.key === id2.key; + }); + + publicAPI.composition = jasmine.createSpyObj('CompositionAPI', [ + 'checkPolicy' + ]); + publicAPI.composition.checkPolicy.and.returnValue(true); + + publicAPI.objects.eventEmitter = jasmine.createSpyObj('eventemitter', [ + 'on' + ]); + publicAPI.objects.get.and.callFake(function (identifier) { + return Promise.resolve({identifier: identifier}); + }); + publicAPI.$injector = jasmine.createSpyObj('$injector', [ + 'get' + ]); + publicAPI.$injector.get.and.returnValue(topicService); + compositionAPI = new CompositionAPI(publicAPI); + }); + + it('returns falsy if an object does not support composition', function () { + expect(compositionAPI.get({})).toBeFalsy(); + }); + + describe('default composition', function () { + let domainObject; + let composition; beforeEach(function () { - - mutationTopic = jasmine.createSpyObj('mutationTopic', [ - 'listen' - ]); - topicService = jasmine.createSpy('topicService'); - topicService.and.returnValue(mutationTopic); - publicAPI = {}; - publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [ - 'get', - 'mutate', - 'observe', - 'areIdsEqual' - ]); - - publicAPI.objects.areIdsEqual.and.callFake(function (id1, id2) { - return id1.namespace === id2.namespace && id1.key === id2.key; - }); - - publicAPI.composition = jasmine.createSpyObj('CompositionAPI', [ - 'checkPolicy' - ]); - publicAPI.composition.checkPolicy.and.returnValue(true); - - publicAPI.objects.eventEmitter = jasmine.createSpyObj('eventemitter', [ - 'on' - ]); - publicAPI.objects.get.and.callFake(function (identifier) { - return Promise.resolve({identifier: identifier}); - }); - publicAPI.$injector = jasmine.createSpyObj('$injector', [ - 'get' - ]); - publicAPI.$injector.get.and.returnValue(topicService); - compositionAPI = new CompositionAPI(publicAPI); + domainObject = { + name: 'test folder', + identifier: { + namespace: 'test', + key: '1' + }, + composition: [ + { + namespace: 'test', + key: 'a' + }, + { + namespace: 'test', + key: 'b' + }, + { + namespace: 'test', + key: 'c' + } + ] + }; + composition = compositionAPI.get(domainObject); }); - it('returns falsy if an object does not support composition', function () { - expect(compositionAPI.get({})).toBeFalsy(); + it('returns composition collection', function () { + expect(composition).toBeDefined(); + expect(composition).toEqual(jasmine.any(CompositionCollection)); }); - describe('default composition', function () { - let domainObject; - let composition; + it('correctly reflects composability', function () { + expect(compositionAPI.supportsComposition(domainObject)).toBe(true); + delete domainObject.composition; + expect(compositionAPI.supportsComposition(domainObject)).toBe(false); + }); - beforeEach(function () { - domainObject = { - name: 'test folder', + it('loads composition from domain object', function () { + const listener = jasmine.createSpy('addListener'); + composition.on('add', listener); + + return composition.load().then(function () { + expect(listener.calls.count()).toBe(3); + expect(listener).toHaveBeenCalledWith({ identifier: { namespace: 'test', - key: '1' - }, - composition: [ - { - namespace: 'test', - key: 'a' - }, - { - namespace: 'test', - key: 'b' - }, - { - namespace: 'test', - key: 'c' - } - ] - }; - composition = compositionAPI.get(domainObject); - }); - - it('returns composition collection', function () { - expect(composition).toBeDefined(); - expect(composition).toEqual(jasmine.any(CompositionCollection)); - }); - - it('correctly reflects composability', function () { - expect(compositionAPI.supportsComposition(domainObject)).toBe(true); - delete domainObject.composition; - expect(compositionAPI.supportsComposition(domainObject)).toBe(false); - }); - - it('loads composition from domain object', function () { - const listener = jasmine.createSpy('addListener'); - composition.on('add', listener); - - return composition.load().then(function () { - expect(listener.calls.count()).toBe(3); - expect(listener).toHaveBeenCalledWith({ - identifier: { - namespace: 'test', - key: 'a' - } - }); + key: 'a' + } }); }); - describe('supports reordering of composition', function () { - let listener; - beforeEach(function () { - listener = jasmine.createSpy('reorderListener'); - composition.on('reorder', listener); + }); + describe('supports reordering of composition', function () { + let listener; + beforeEach(function () { + listener = jasmine.createSpy('reorderListener'); + composition.on('reorder', listener); - return composition.load(); - }); - it('', function () { - composition.reorder(1, 0); - let newComposition = + return composition.load(); + }); + it('', function () { + composition.reorder(1, 0); + let newComposition = publicAPI.objects.mutate.calls.mostRecent().args[2]; - let reorderPlan = listener.calls.mostRecent().args[0][0]; + let reorderPlan = listener.calls.mostRecent().args[0][0]; - expect(reorderPlan.oldIndex).toBe(1); - expect(reorderPlan.newIndex).toBe(0); - expect(newComposition[0].key).toEqual('b'); - expect(newComposition[1].key).toEqual('a'); - expect(newComposition[2].key).toEqual('c'); - }); - it('', function () { - composition.reorder(0, 2); - let newComposition = + expect(reorderPlan.oldIndex).toBe(1); + expect(reorderPlan.newIndex).toBe(0); + expect(newComposition[0].key).toEqual('b'); + expect(newComposition[1].key).toEqual('a'); + expect(newComposition[2].key).toEqual('c'); + }); + it('', function () { + composition.reorder(0, 2); + let newComposition = publicAPI.objects.mutate.calls.mostRecent().args[2]; - let reorderPlan = listener.calls.mostRecent().args[0][0]; + let reorderPlan = listener.calls.mostRecent().args[0][0]; - expect(reorderPlan.oldIndex).toBe(0); - expect(reorderPlan.newIndex).toBe(2); - expect(newComposition[0].key).toEqual('b'); - expect(newComposition[1].key).toEqual('c'); - expect(newComposition[2].key).toEqual('a'); + expect(reorderPlan.oldIndex).toBe(0); + expect(reorderPlan.newIndex).toBe(2); + expect(newComposition[0].key).toEqual('b'); + expect(newComposition[1].key).toEqual('c'); + expect(newComposition[2].key).toEqual('a'); + }); + }); + it('supports adding an object to composition', function () { + let addListener = jasmine.createSpy('addListener'); + let mockChildObject = { + identifier: { + key: 'mock-key', + namespace: '' + } + }; + composition.on('add', addListener); + composition.add(mockChildObject); + + expect(domainObject.composition.length).toBe(4); + expect(domainObject.composition[3]).toEqual(mockChildObject.identifier); + }); + }); + + describe('static custom composition', function () { + let customProvider; + let domainObject; + let composition; + + beforeEach(function () { + // A simple custom provider, returns the same composition for + // all objects of a given type. + customProvider = { + appliesTo: function (object) { + return object.type === 'custom-object-type'; + }, + load: function (object) { + return Promise.resolve([ + { + namespace: 'custom', + key: 'thing' + } + ]); + }, + add: jasmine.createSpy('add'), + remove: jasmine.createSpy('remove') + }; + domainObject = { + identifier: { + namespace: 'test', + key: '1' + }, + type: 'custom-object-type' + }; + compositionAPI.addProvider(customProvider); + composition = compositionAPI.get(domainObject); + }); + + it('supports listening and loading', function () { + const addListener = jasmine.createSpy('addListener'); + composition.on('add', addListener); + + return composition.load().then(function (children) { + let listenObject; + const loadedObject = children[0]; + + expect(addListener).toHaveBeenCalled(); + + listenObject = addListener.calls.mostRecent().args[0]; + expect(listenObject).toEqual(loadedObject); + expect(loadedObject).toEqual({ + identifier: { + namespace: 'custom', + key: 'thing' + } }); }); - it('supports adding an object to composition', function () { - let addListener = jasmine.createSpy('addListener'); - let mockChildObject = { + }); + describe('Calling add or remove', function () { + let mockChildObject; + + beforeEach(function () { + mockChildObject = { identifier: { key: 'mock-key', namespace: '' } }; - composition.on('add', addListener); composition.add(mockChildObject); - - expect(domainObject.composition.length).toBe(4); - expect(domainObject.composition[3]).toEqual(mockChildObject.identifier); - }); - }); - - describe('static custom composition', function () { - let customProvider; - let domainObject; - let composition; - - beforeEach(function () { - // A simple custom provider, returns the same composition for - // all objects of a given type. - customProvider = { - appliesTo: function (object) { - return object.type === 'custom-object-type'; - }, - load: function (object) { - return Promise.resolve([ - { - namespace: 'custom', - key: 'thing' - } - ]); - }, - add: jasmine.createSpy('add'), - remove: jasmine.createSpy('remove') - }; - domainObject = { - identifier: { - namespace: 'test', - key: '1' - }, - type: 'custom-object-type' - }; - compositionAPI.addProvider(customProvider); - composition = compositionAPI.get(domainObject); }); - it('supports listening and loading', function () { - const addListener = jasmine.createSpy('addListener'); - composition.on('add', addListener); - - return composition.load().then(function (children) { - let listenObject; - const loadedObject = children[0]; - - expect(addListener).toHaveBeenCalled(); - - listenObject = addListener.calls.mostRecent().args[0]; - expect(listenObject).toEqual(loadedObject); - expect(loadedObject).toEqual({ - identifier: { - namespace: 'custom', - key: 'thing' - } - }); - }); - }); - describe('Calling add or remove', function () { - let mockChildObject; - - beforeEach(function () { - mockChildObject = { - identifier: { - key: 'mock-key', - namespace: '' - } - }; - composition.add(mockChildObject); - }); - - it('calls add on the provider', function () { - expect(customProvider.add).toHaveBeenCalledWith(domainObject, mockChildObject.identifier); - }); - - it('calls remove on the provider', function () { - composition.remove(mockChildObject); - expect(customProvider.remove).toHaveBeenCalledWith(domainObject, mockChildObject.identifier); - }); - }); - }); - - describe('dynamic custom composition', function () { - let customProvider; - let domainObject; - let composition; - - beforeEach(function () { - // A dynamic provider, loads an empty composition and exposes - // listener functions. - customProvider = jasmine.createSpyObj('dynamicProvider', [ - 'appliesTo', - 'load', - 'on', - 'off' - ]); - - customProvider.appliesTo.and.returnValue('true'); - customProvider.load.and.returnValue(Promise.resolve([])); - - domainObject = { - identifier: { - namespace: 'test', - key: '1' - }, - type: 'custom-object-type' - }; - compositionAPI.addProvider(customProvider); - composition = compositionAPI.get(domainObject); + it('calls add on the provider', function () { + expect(customProvider.add).toHaveBeenCalledWith(domainObject, mockChildObject.identifier); }); - it('supports listening and loading', function () { - const addListener = jasmine.createSpy('addListener'); - const removeListener = jasmine.createSpy('removeListener'); - const addPromise = new Promise(function (resolve) { - addListener.and.callFake(resolve); - }); - const removePromise = new Promise(function (resolve) { - removeListener.and.callFake(resolve); - }); - - composition.on('add', addListener); - composition.on('remove', removeListener); - - expect(customProvider.on).toHaveBeenCalledWith( - domainObject, - 'add', - jasmine.any(Function), - jasmine.any(CompositionCollection) - ); - expect(customProvider.on).toHaveBeenCalledWith( - domainObject, - 'remove', - jasmine.any(Function), - jasmine.any(CompositionCollection) - ); - const add = customProvider.on.calls.all()[0].args[2]; - const remove = customProvider.on.calls.all()[1].args[2]; - - return composition.load() - .then(function () { - expect(addListener).not.toHaveBeenCalled(); - expect(removeListener).not.toHaveBeenCalled(); - add({ - namespace: 'custom', - key: 'thing' - }); - - return addPromise; - }).then(function () { - expect(addListener).toHaveBeenCalledWith({ - identifier: { - namespace: 'custom', - key: 'thing' - } - }); - remove(addListener.calls.mostRecent().args[0]); - - return removePromise; - }).then(function () { - expect(removeListener).toHaveBeenCalledWith({ - identifier: { - namespace: 'custom', - key: 'thing' - } - }); - }); + it('calls remove on the provider', function () { + composition.remove(mockChildObject); + expect(customProvider.remove).toHaveBeenCalledWith(domainObject, mockChildObject.identifier); }); }); }); + + describe('dynamic custom composition', function () { + let customProvider; + let domainObject; + let composition; + + beforeEach(function () { + // A dynamic provider, loads an empty composition and exposes + // listener functions. + customProvider = jasmine.createSpyObj('dynamicProvider', [ + 'appliesTo', + 'load', + 'on', + 'off' + ]); + + customProvider.appliesTo.and.returnValue('true'); + customProvider.load.and.returnValue(Promise.resolve([])); + + domainObject = { + identifier: { + namespace: 'test', + key: '1' + }, + type: 'custom-object-type' + }; + compositionAPI.addProvider(customProvider); + composition = compositionAPI.get(domainObject); + }); + + it('supports listening and loading', function () { + const addListener = jasmine.createSpy('addListener'); + const removeListener = jasmine.createSpy('removeListener'); + const addPromise = new Promise(function (resolve) { + addListener.and.callFake(resolve); + }); + const removePromise = new Promise(function (resolve) { + removeListener.and.callFake(resolve); + }); + + composition.on('add', addListener); + composition.on('remove', removeListener); + + expect(customProvider.on).toHaveBeenCalledWith( + domainObject, + 'add', + jasmine.any(Function), + jasmine.any(CompositionCollection) + ); + expect(customProvider.on).toHaveBeenCalledWith( + domainObject, + 'remove', + jasmine.any(Function), + jasmine.any(CompositionCollection) + ); + const add = customProvider.on.calls.all()[0].args[2]; + const remove = customProvider.on.calls.all()[1].args[2]; + + return composition.load() + .then(function () { + expect(addListener).not.toHaveBeenCalled(); + expect(removeListener).not.toHaveBeenCalled(); + add({ + namespace: 'custom', + key: 'thing' + }); + + return addPromise; + }).then(function () { + expect(addListener).toHaveBeenCalledWith({ + identifier: { + namespace: 'custom', + key: 'thing' + } + }); + remove(addListener.calls.mostRecent().args[0]); + + return removePromise; + }).then(function () { + expect(removeListener).toHaveBeenCalledWith({ + identifier: { + namespace: 'custom', + key: 'thing' + } + }); + }); + }); + }); }); diff --git a/src/api/composition/CompositionCollection.js b/src/api/composition/CompositionCollection.js index 78a0a0c8a1..7d8345362c 100644 --- a/src/api/composition/CompositionCollection.js +++ b/src/api/composition/CompositionCollection.js @@ -20,75 +20,98 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define([ - 'lodash' -], function ( - _ -) { +/** + * @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject + */ + +/** + * @typedef {import('./CompositionAPI').default} CompositionAPI + */ + +/** + * @typedef {import('../../../openmct').OpenMCT} OpenMCT + */ + +/** + * @typedef {object} ListenerMap + * @property {Array.} add + * @property {Array.} remove + * @property {Array.} load + * @property {Array.} reorder + */ + +/** + * A CompositionCollection represents the list of domain objects contained + * by another domain object. It provides methods for loading this + * list asynchronously, modifying this list, and listening for changes to + * this list. + * + * Usage: + * ```javascript + * var myViewComposition = MCT.composition.get(myViewObject); + * myViewComposition.on('add', addObjectToView); + * myViewComposition.on('remove', removeObjectFromView); + * myViewComposition.load(); // will trigger `add` for all loaded objects. + * ``` + */ +export default class CompositionCollection { + domainObject; + #provider; + #publicAPI; + #listeners; + #mutables; /** - * A CompositionCollection represents the list of domain objects contained - * by another domain object. It provides methods for loading this - * list asynchronously, modifying this list, and listening for changes to - * this list. - * - * Usage: - * ```javascript - * var myViewComposition = MCT.composition.get(myViewObject); - * myViewComposition.on('add', addObjectToView); - * myViewComposition.on('remove', removeObjectFromView); - * myViewComposition.load(); // will trigger `add` for all loaded objects. - * ``` - * - * @interface CompositionCollection - * @param {module:openmct.DomainObject} domainObject the domain object + * @constructor + * @param {DomainObject} domainObject the domain object * whose composition will be contained - * @param {module:openmct.CompositionProvider} provider the provider + * @param {import('./CompositionProvider').default} provider the provider * to use to retrieve other domain objects - * @param {module:openmct.CompositionAPI} api the composition API, for + * @param {OpenMCT} publicAPI the composition API, for * policy checks - * @memberof module:openmct */ - function CompositionCollection(domainObject, provider, publicAPI) { + constructor(domainObject, provider, publicAPI) { this.domainObject = domainObject; - this.provider = provider; - this.publicAPI = publicAPI; - this.listeners = { + /** @type {import('./CompositionProvider').default} */ + this.#provider = provider; + /** @type {OpenMCT} */ + this.#publicAPI = publicAPI; + /** @type {ListenerMap} */ + this.#listeners = { add: [], remove: [], load: [], reorder: [] }; - this.onProviderAdd = this.onProviderAdd.bind(this); - this.onProviderRemove = this.onProviderRemove.bind(this); - this.mutables = {}; + this.onProviderAdd = this.#onProviderAdd.bind(this); + this.onProviderRemove = this.#onProviderRemove.bind(this); + this.#mutables = {}; if (this.domainObject.isMutable) { this.returnMutables = true; let unobserve = this.domainObject.$on('$_destroy', () => { - Object.values(this.mutables).forEach(mutable => { - this.publicAPI.objects.destroyMutable(mutable); + Object.values(this.#mutables).forEach(mutable => { + this.#publicAPI.objects.destroyMutable(mutable); }); unobserve(); }); } } - /** * Listen for changes to this composition. Supports 'add', 'remove', and * 'load' events. * - * @param event event to listen for, either 'add', 'remove' or 'load'. - * @param callback to trigger when event occurs. - * @param [context] context to use when invoking callback, optional. + * @param {string} event event to listen for, either 'add', 'remove' or 'load'. + * @param {(...args: any[]) => void} callback to trigger when event occurs. + * @param {any} [context] to use when invoking callback, optional. */ - CompositionCollection.prototype.on = function (event, callback, context) { - if (!this.listeners[event]) { + on(event, callback, context) { + if (!this.#listeners[event]) { throw new Error('Event not supported by composition: ' + event); } - if (this.provider.on && this.provider.off) { + if (this.#provider.on && this.#provider.off) { if (event === 'add') { - this.provider.on( + this.#provider.on( this.domainObject, 'add', this.onProviderAdd, @@ -97,7 +120,7 @@ define([ } if (event === 'remove') { - this.provider.on( + this.#provider.on( this.domainObject, 'remove', this.onProviderRemove, @@ -106,36 +129,34 @@ define([ } if (event === 'reorder') { - this.provider.on( + this.#provider.on( this.domainObject, 'reorder', - this.onProviderReorder, + this.#onProviderReorder, this ); } } - this.listeners[event].push({ + this.#listeners[event].push({ callback: callback, context: context }); - }; - + } /** * Remove a listener. Must be called with same exact parameters as * `off`. * - * @param event - * @param callback - * @param [context] + * @param {string} event + * @param {(...args: any[]) => void} callback + * @param {any} [context] */ - - CompositionCollection.prototype.off = function (event, callback, context) { - if (!this.listeners[event]) { + off(event, callback, context) { + if (!this.#listeners[event]) { throw new Error('Event not supported by composition: ' + event); } - const index = this.listeners[event].findIndex(l => { + const index = this.#listeners[event].findIndex(l => { return l.callback === callback && l.context === context; }); @@ -143,125 +164,116 @@ define([ throw new Error('Tried to remove a listener that does not exist'); } - this.listeners[event].splice(index, 1); - if (this.listeners[event].length === 0) { + this.#listeners[event].splice(index, 1); + if (this.#listeners[event].length === 0) { this._destroy(); // Remove provider listener if this is the last callback to // be removed. - if (this.provider.off && this.provider.on) { + if (this.#provider.off && this.#provider.on) { if (event === 'add') { - this.provider.off( + this.#provider.off( this.domainObject, 'add', this.onProviderAdd, this ); } else if (event === 'remove') { - this.provider.off( + this.#provider.off( this.domainObject, 'remove', this.onProviderRemove, this ); } else if (event === 'reorder') { - this.provider.off( + this.#provider.off( this.domainObject, 'reorder', - this.onProviderReorder, + this.#onProviderReorder, this ); } } } - }; - + } /** * Add a domain object to this composition. * * A call to [load]{@link module:openmct.CompositionCollection#load} * must have resolved before using this method. * - * @param {module:openmct.DomainObject} child the domain object to add - * @param {boolean} skipMutate true if the underlying provider should - * not be updated - * @memberof module:openmct.CompositionCollection# - * @name add + * **TODO:** Remove `skipMutate` parameter. + * + * @param {DomainObject} child the domain object to add + * @param {boolean} skipMutate + * **Intended for internal use ONLY.** + * true if the underlying provider should not be updated. */ - CompositionCollection.prototype.add = function (child, skipMutate) { + add(child, skipMutate) { if (!skipMutate) { - if (!this.publicAPI.composition.checkPolicy(this.domainObject, child)) { + if (!this.#publicAPI.composition.checkPolicy(this.domainObject, child)) { throw `Object of type ${child.type} cannot be added to object of type ${this.domainObject.type}`; } - this.provider.add(this.domainObject, child.identifier); + this.#provider.add(this.domainObject, child.identifier); } else { - if (this.returnMutables && this.publicAPI.objects.supportsMutation(child.identifier)) { - let keyString = this.publicAPI.objects.makeKeyString(child.identifier); + if (this.returnMutables && this.#publicAPI.objects.supportsMutation(child.identifier)) { + let keyString = this.#publicAPI.objects.makeKeyString(child.identifier); - child = this.publicAPI.objects.toMutable(child); - this.mutables[keyString] = child; + child = this.#publicAPI.objects.toMutable(child); + this.#mutables[keyString] = child; } - this.emit('add', child); + this.#emit('add', child); } - }; - + } /** * Load the domain objects in this composition. * - * @returns {Promise.>} a promise for + * @param {AbortSignal} abortSignal + * @returns {Promise.>} a promise for * the domain objects in this composition * @memberof {module:openmct.CompositionCollection#} * @name load */ - CompositionCollection.prototype.load = function (abortSignal) { - this.cleanUpMutables(); - - return this.provider.load(this.domainObject) - .then(function (children) { - return Promise.all(children.map((c) => this.publicAPI.objects.get(c, abortSignal))); - }.bind(this)) - .then(function (childObjects) { - childObjects.forEach(c => this.add(c, true)); - - return childObjects; - }.bind(this)) - .then(function (children) { - this.emit('load'); - - return children; - }.bind(this)); - }; + async load(abortSignal) { + this.#cleanUpMutables(); + const children = await this.#provider.load(this.domainObject); + const childObjects = await Promise.all(children.map((c) => this.#publicAPI.objects.get(c, abortSignal))); + childObjects.forEach(c => this.add(c, true)); + this.#emit('load'); + return childObjects; + } /** * Remove a domain object from this composition. * * A call to [load]{@link module:openmct.CompositionCollection#load} * must have resolved before using this method. * - * @param {module:openmct.DomainObject} child the domain object to remove - * @param {boolean} skipMutate true if the underlying provider should - * not be updated - * @memberof module:openmct.CompositionCollection# + * **TODO:** Remove `skipMutate` parameter. + * + * @param {DomainObject} child the domain object to remove + * @param {boolean} skipMutate + * **Intended for internal use ONLY.** + * true if the underlying provider should not be updated. * @name remove */ - CompositionCollection.prototype.remove = function (child, skipMutate) { + remove(child, skipMutate) { if (!skipMutate) { - this.provider.remove(this.domainObject, child.identifier); + this.#provider.remove(this.domainObject, child.identifier); } else { if (this.returnMutables) { - let keyString = this.publicAPI.objects.makeKeyString(child); - if (this.mutables[keyString] !== undefined && this.mutables[keyString].isMutable) { - this.publicAPI.objects.destroyMutable(this.mutables[keyString]); - delete this.mutables[keyString]; + let keyString = this.#publicAPI.objects.makeKeyString(child); + if (this.#mutables[keyString] !== undefined && this.#mutables[keyString].isMutable) { + this.#publicAPI.objects.destroyMutable(this.#mutables[keyString]); + delete this.#mutables[keyString]; } } - this.emit('remove', child); + this.#emit('remove', child); } - }; - + } /** * Reorder the domain objects in this composition. * @@ -270,67 +282,75 @@ define([ * * @param {number} oldIndex * @param {number} newIndex - * @memberof module:openmct.CompositionCollection# * @name remove */ - CompositionCollection.prototype.reorder = function (oldIndex, newIndex, skipMutate) { - this.provider.reorder(this.domainObject, oldIndex, newIndex); - }; - + reorder(oldIndex, newIndex, _skipMutate) { + this.#provider.reorder(this.domainObject, oldIndex, newIndex); + } /** - * Handle reorder from provider. - * @private + * Destroy mutationListener */ - CompositionCollection.prototype.onProviderReorder = function (reorderMap) { - this.emit('reorder', reorderMap); - }; - - /** - * Handle adds from provider. - * @private - */ - CompositionCollection.prototype.onProviderAdd = function (childId) { - return this.publicAPI.objects.get(childId).then(function (child) { - this.add(child, true); - - return child; - }.bind(this)); - }; - - /** - * Handle removal from provider. - * @private - */ - CompositionCollection.prototype.onProviderRemove = function (child) { - this.remove(child, true); - }; - - CompositionCollection.prototype._destroy = function () { + _destroy() { if (this.mutationListener) { this.mutationListener(); delete this.mutationListener; } - }; + } + /** + * Handle reorder from provider. + * @private + * @param {object} reorderMap + */ + #onProviderReorder(reorderMap) { + this.#emit('reorder', reorderMap); + } + + /** + * Handle adds from provider. + * @private + * @param {import('../objects/ObjectAPI').Identifier} childId + * @returns {DomainObject} + */ + #onProviderAdd(childId) { + return this.#publicAPI.objects.get(childId).then(function (child) { + this.add(child, true); + + return child; + }.bind(this)); + } + + /** + * Handle removal from provider. + * @param {DomainObject} child + */ + #onProviderRemove(child) { + this.remove(child, true); + } /** * Emit events. + * * @private + * @param {string} event + * @param {...args.} payload */ - CompositionCollection.prototype.emit = function (event, ...payload) { - this.listeners[event].forEach(function (l) { + #emit(event, ...payload) { + this.#listeners[event].forEach(function (l) { if (l.context) { l.callback.apply(l.context, payload); } else { l.callback(...payload); } }); - }; + } - CompositionCollection.prototype.cleanUpMutables = function () { - Object.values(this.mutables).forEach(mutable => { - this.publicAPI.objects.destroyMutable(mutable); + /** + * Destroy all mutables. + * @private + */ + #cleanUpMutables() { + Object.values(this.#mutables).forEach(mutable => { + this.#publicAPI.objects.destroyMutable(mutable); }); - }; - - return CompositionCollection; -}); + } +} diff --git a/src/api/composition/CompositionProvider.js b/src/api/composition/CompositionProvider.js new file mode 100644 index 0000000000..792a3db480 --- /dev/null +++ b/src/api/composition/CompositionProvider.js @@ -0,0 +1,262 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ +import _ from 'lodash'; +import objectUtils from "../objects/object-utils"; + +/** + * @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject + */ + +/** + * @typedef {import('../objects/ObjectAPI').Identifier} Identifier + */ + +/** + * @typedef {import('./CompositionAPI').default} CompositionAPI + */ + +/** + * @typedef {import('../../../openmct').OpenMCT} OpenMCT + */ + +/** + * A CompositionProvider provides the underlying implementation of + * composition-related behavior for certain types of domain object. + * + * By default, a composition provider will not support composition + * modification. You can add support for mutation of composition by + * defining `add` and/or `remove` methods. + * + * If the composition of an object can change over time-- perhaps via + * server updates or mutation via the add/remove methods, then one must + * trigger events as necessary. + * + */ +export default class CompositionProvider { + #publicAPI; + #listeningTo; + + /** + * @param {OpenMCT} publicAPI + * @param {CompositionAPI} compositionAPI + */ + constructor(publicAPI, compositionAPI) { + this.#publicAPI = publicAPI; + this.#listeningTo = {}; + + compositionAPI.addPolicy(this.#cannotContainItself.bind(this)); + compositionAPI.addPolicy(this.#supportsComposition.bind(this)); + } + + get listeningTo() { + return this.#listeningTo; + } + + get establishTopicListener() { + return this.#establishTopicListener.bind(this); + } + + get publicAPI() { + return this.#publicAPI; + } + + /** + * Check if this provider should be used to load composition for a + * particular domain object. + * @method appliesTo + * @param {import('../objects/ObjectAPI').DomainObject} domainObject the domain object + * to check + * @returns {boolean} true if this provider can provide composition for a given domain object + */ + appliesTo(domainObject) { + throw new Error("This method must be implemented by a subclass."); + } + /** + * Load any domain objects contained in the composition of this domain + * object. + * @param {DomainObject} domainObject the domain object + * for which to load composition + * @returns {Promise} a promise for + * the Identifiers in this composition + * @method load + */ + load(domainObject) { + throw new Error("This method must be implemented by a subclass."); + } + /** + * Attach listeners for changes to the composition of a given domain object. + * Supports `add` and `remove` events. + * + * @param {DomainObject} domainObject to listen to + * @param {string} event the event to bind to, either `add` or `remove`. + * @param {Function} callback callback to invoke when event is triggered. + * @param {any} [context] to use when invoking callback. + */ + on(domainObject, + event, + callback, + context) { + throw new Error("This method must be implemented by a subclass."); + } + /** + * Remove a listener that was previously added for a given domain object. + * event name, callback, and context must be the same as when the listener + * was originally attached. + * + * @param {DomainObject} domainObject to remove listener for + * @param {string} event event to stop listening to: `add` or `remove`. + * @param {Function} callback callback to remove. + * @param {any} context of callback to remove. + */ + off(domainObject, + event, + callback, + context) { + throw new Error("This method must be implemented by a subclass."); + } + /** + * Remove a domain object from another domain object's composition. + * + * This method is optional; if not present, adding to a domain object's + * composition using this provider will be disallowed. + * + * @param {DomainObject} domainObject the domain object + * which should have its composition modified + * @param {Identifier} childId the domain object to remove + * @method remove + */ + remove(domainObject, childId) { + throw new Error("This method must be implemented by a subclass."); + } + /** + * Add a domain object to another domain object's composition. + * + * This method is optional; if not present, adding to a domain object's + * composition using this provider will be disallowed. + * + * @param {DomainObject} parent the domain object + * which should have its composition modified + * @param {Identifier} childId the domain object to add + * @method add + */ + add(parent, childId) { + throw new Error("This method must be implemented by a subclass."); + } + + /** + * @param {DomainObject} parent + * @param {Identifier} childId + * @returns {boolean} + */ + includes(parent, childId) { + throw new Error("This method must be implemented by a subclass."); + } + + /** + * @param {DomainObject} domainObject + * @param {number} oldIndex + * @param {number} newIndex + * @returns + */ + reorder(domainObject, oldIndex, newIndex) { + throw new Error("This method must be implemented by a subclass."); + } + + /** + * Listens on general mutation topic, using injector to fetch to avoid + * circular dependencies. + * @private + */ + #establishTopicListener() { + if (this.topicListener) { + return; + } + + this.#publicAPI.objects.eventEmitter.on('mutation', this.#onMutation.bind(this)); + this.topicListener = () => { + this.#publicAPI.objects.eventEmitter.off('mutation', this.#onMutation.bind(this)); + }; + } + + /** + * @private + * @param {DomainObject} parent + * @param {DomainObject} child + * @returns {boolean} + */ + #cannotContainItself(parent, child) { + return !(parent.identifier.namespace === child.identifier.namespace + && parent.identifier.key === child.identifier.key); + } + + /** + * @private + * @param {DomainObject} parent + * @returns {boolean} + */ + #supportsComposition(parent, _child) { + return this.#publicAPI.composition.supportsComposition(parent); + } + + /** + * Handles mutation events. If there are active listeners for the mutated + * object, detects changes to composition and triggers necessary events. + * + * @private + * @param {DomainObject} oldDomainObject + */ + #onMutation(oldDomainObject) { + const id = objectUtils.makeKeyString(oldDomainObject.identifier); + const listeners = this.#listeningTo[id]; + + if (!listeners) { + return; + } + + const oldComposition = listeners.composition.map(objectUtils.makeKeyString); + const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString); + + const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString); + const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString); + + function notify(value) { + return function (listener) { + if (listener.context) { + listener.callback.call(listener.context, value); + } else { + listener.callback(value); + } + }; + } + + listeners.composition = newComposition.map(objectUtils.parseKeyString); + + added.forEach(function (addedChild) { + listeners.add.forEach(notify(addedChild)); + }); + + removed.forEach(function (removedChild) { + listeners.remove.forEach(notify(removedChild)); + }); + } +} + diff --git a/src/api/composition/DefaultCompositionProvider.js b/src/api/composition/DefaultCompositionProvider.js index 3a46b127fb..6c242a25cd 100644 --- a/src/api/composition/DefaultCompositionProvider.js +++ b/src/api/composition/DefaultCompositionProvider.js @@ -19,102 +19,79 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ +import objectUtils from "../objects/object-utils"; +import CompositionProvider from './CompositionProvider'; -define([ - 'lodash', - 'objectUtils' -], function ( - _, - objectUtils -) { - /** - * A CompositionProvider provides the underlying implementation of - * composition-related behavior for certain types of domain object. - * - * By default, a composition provider will not support composition - * modification. You can add support for mutation of composition by - * defining `add` and/or `remove` methods. - * - * If the composition of an object can change over time-- perhaps via - * server updates or mutation via the add/remove methods, then one must - * trigger events as necessary. - * - * @interface CompositionProvider - * @memberof module:openmct - */ +/** + * @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject + */ - function DefaultCompositionProvider(publicAPI, compositionAPI) { - this.publicAPI = publicAPI; - this.listeningTo = {}; - this.onMutation = this.onMutation.bind(this); +/** + * @typedef {import('../objects/ObjectAPI').Identifier} Identifier + */ - this.cannotContainItself = this.cannotContainItself.bind(this); - this.supportsComposition = this.supportsComposition.bind(this); +/** + * @typedef {import('./CompositionAPI').default} CompositionAPI + */ - compositionAPI.addPolicy(this.cannotContainItself); - compositionAPI.addPolicy(this.supportsComposition); - } - - /** - * @private - */ - DefaultCompositionProvider.prototype.cannotContainItself = function (parent, child) { - return !(parent.identifier.namespace === child.identifier.namespace - && parent.identifier.key === child.identifier.key); - }; - - /** - * @private - */ - DefaultCompositionProvider.prototype.supportsComposition = function (parent, child) { - return this.publicAPI.composition.supportsComposition(parent); - }; +/** + * @typedef {import('../../../openmct').OpenMCT} OpenMCT + */ +/** + * A CompositionProvider provides the underlying implementation of + * composition-related behavior for certain types of domain object. + * + * By default, a composition provider will not support composition + * modification. You can add support for mutation of composition by + * defining `add` and/or `remove` methods. + * + * If the composition of an object can change over time-- perhaps via + * server updates or mutation via the add/remove methods, then one must + * trigger events as necessary. + * @extends CompositionProvider + */ +export default class DefaultCompositionProvider extends CompositionProvider { /** * Check if this provider should be used to load composition for a * particular domain object. - * @param {module:openmct.DomainObject} domainObject the domain object + * @override + * @param {DomainObject} domainObject the domain object * to check - * @returns {boolean} true if this provider can provide - * composition for a given domain object - * @memberof module:openmct.CompositionProvider# - * @method appliesTo + * @returns {boolean} true if this provider can provide composition for a given domain object */ - DefaultCompositionProvider.prototype.appliesTo = function (domainObject) { + appliesTo(domainObject) { return Boolean(domainObject.composition); - }; - + } /** * Load any domain objects contained in the composition of this domain * object. - * @param {module:openmct.DomainObject} domainObject the domain object + * @override + * @param {DomainObject} domainObject the domain object * for which to load composition - * @returns {Promise.>} a promise for + * @returns {Promise} a promise for * the Identifiers in this composition - * @memberof module:openmct.CompositionProvider# - * @method load */ - DefaultCompositionProvider.prototype.load = function (domainObject) { + load(domainObject) { return Promise.all(domainObject.composition); - }; - + } /** * Attach listeners for changes to the composition of a given domain object. * Supports `add` and `remove` events. * - * @param {module:openmct.DomainObject} domainObject to listen to - * @param String event the event to bind to, either `add` or `remove`. - * @param Function callback callback to invoke when event is triggered. - * @param [context] context to use when invoking callback. + * @override + * @param {DomainObject} domainObject to listen to + * @param {string} event the event to bind to, either `add` or `remove`. + * @param {Function} callback callback to invoke when event is triggered. + * @param {any} [context] to use when invoking callback. */ - DefaultCompositionProvider.prototype.on = function ( - domainObject, + on(domainObject, event, callback, - context - ) { + context) { this.establishTopicListener(); + /** @type {string} */ const keyString = objectUtils.makeKeyString(domainObject.identifier); let objectListeners = this.listeningTo[keyString]; @@ -131,24 +108,24 @@ define([ callback: callback, context: context }); - }; - + } /** * Remove a listener that was previously added for a given domain object. * event name, callback, and context must be the same as when the listener * was originally attached. * - * @param {module:openmct.DomainObject} domainObject to remove listener for - * @param String event event to stop listening to: `add` or `remove`. - * @param Function callback callback to remove. - * @param [context] context of callback to remove. + * @override + * @param {DomainObject} domainObject to remove listener for + * @param {string} event event to stop listening to: `add` or `remove`. + * @param {Function} callback callback to remove. + * @param {any} context of callback to remove. */ - DefaultCompositionProvider.prototype.off = function ( - domainObject, + off(domainObject, event, callback, - context - ) { + context) { + + /** @type {string} */ const keyString = objectUtils.makeKeyString(domainObject.identifier); const objectListeners = this.listeningTo[keyString]; @@ -160,57 +137,64 @@ define([ if (!objectListeners.add.length && !objectListeners.remove.length && !objectListeners.reorder.length) { delete this.listeningTo[keyString]; } - }; - + } /** * Remove a domain object from another domain object's composition. * * This method is optional; if not present, adding to a domain object's * composition using this provider will be disallowed. * - * @param {module:openmct.DomainObject} domainObject the domain object + * @override + * @param {DomainObject} domainObject the domain object * which should have its composition modified - * @param {module:openmct.DomainObject} child the domain object to remove - * @memberof module:openmct.CompositionProvider# + * @param {Identifier} childId the domain object to remove * @method remove */ - DefaultCompositionProvider.prototype.remove = function (domainObject, childId) { + remove(domainObject, childId) { let composition = domainObject.composition.filter(function (child) { return !(childId.namespace === child.namespace - && childId.key === child.key); + && childId.key === child.key); }); this.publicAPI.objects.mutate(domainObject, 'composition', composition); - }; - + } /** * Add a domain object to another domain object's composition. * * This method is optional; if not present, adding to a domain object's * composition using this provider will be disallowed. * - * @param {module:openmct.DomainObject} domainObject the domain object + * @override + * @param {DomainObject} parent the domain object * which should have its composition modified - * @param {module:openmct.DomainObject} child the domain object to add - * @memberof module:openmct.CompositionProvider# + * @param {Identifier} childId the domain object to add * @method add */ - DefaultCompositionProvider.prototype.add = function (parent, childId) { + add(parent, childId) { if (!this.includes(parent, childId)) { parent.composition.push(childId); this.publicAPI.objects.mutate(parent, 'composition', parent.composition); } - }; + } /** - * @private + * @override + * @param {DomainObject} parent + * @param {Identifier} childId + * @returns {boolean} */ - DefaultCompositionProvider.prototype.includes = function (parent, childId) { - return parent.composition.some(composee => - this.publicAPI.objects.areIdsEqual(composee, childId)); - }; + includes(parent, childId) { + return parent.composition.some(composee => this.publicAPI.objects.areIdsEqual(composee, childId)); + } - DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) { + /** + * @override + * @param {DomainObject} domainObject + * @param {number} oldIndex + * @param {number} newIndex + * @returns + */ + reorder(domainObject, oldIndex, newIndex) { let newComposition = domainObject.composition.slice(); let removeId = oldIndex > newIndex ? oldIndex + 1 : oldIndex; let insertPosition = oldIndex < newIndex ? newIndex + 1 : newIndex; @@ -241,6 +225,7 @@ define([ this.publicAPI.objects.mutate(domainObject, 'composition', newComposition); + /** @type {string} */ let id = objectUtils.makeKeyString(domainObject.identifier); const listeners = this.listeningTo[id]; @@ -257,66 +242,5 @@ define([ listener.callback(reorderPlan); } } - }; - - /** - * Listens on general mutation topic, using injector to fetch to avoid - * circular dependencies. - * - * @private - */ - DefaultCompositionProvider.prototype.establishTopicListener = function () { - if (this.topicListener) { - return; - } - - this.publicAPI.objects.eventEmitter.on('mutation', this.onMutation); - this.topicListener = () => { - this.publicAPI.objects.eventEmitter.off('mutation', this.onMutation); - }; - }; - - /** - * Handles mutation events. If there are active listeners for the mutated - * object, detects changes to composition and triggers necessary events. - * - * @private - */ - DefaultCompositionProvider.prototype.onMutation = function (oldDomainObject) { - const id = objectUtils.makeKeyString(oldDomainObject.identifier); - const listeners = this.listeningTo[id]; - - if (!listeners) { - return; - } - - const oldComposition = listeners.composition.map(objectUtils.makeKeyString); - const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString); - - const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString); - const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString); - - function notify(value) { - return function (listener) { - if (listener.context) { - listener.callback.call(listener.context, value); - } else { - listener.callback(value); - } - }; - } - - listeners.composition = newComposition.map(objectUtils.parseKeyString); - - added.forEach(function (addedChild) { - listeners.add.forEach(notify(addedChild)); - }); - - removed.forEach(function (removedChild) { - listeners.remove.forEach(notify(removedChild)); - }); - - }; - - return DefaultCompositionProvider; -}); + } +} diff --git a/src/api/forms/FormsAPI.js b/src/api/forms/FormsAPI.js index c0bdc78c65..95fc6a3f7c 100644 --- a/src/api/forms/FormsAPI.js +++ b/src/api/forms/FormsAPI.js @@ -23,13 +23,11 @@ import FormController from './FormController'; import FormProperties from './components/FormProperties.vue'; -import EventEmitter from 'EventEmitter'; import Vue from 'vue'; +import _ from 'lodash'; -export default class FormsAPI extends EventEmitter { +export default class FormsAPI { constructor(openmct) { - super(); - this.openmct = openmct; this.formController = new FormController(openmct); } @@ -92,29 +90,75 @@ export default class FormsAPI extends EventEmitter { /** * Show form inside an Overlay dialog with given form structure + * @public + * @param {Array
} formStructure a form structure, array of section + * @param {Object} options + * @property {function} onChange a callback function when any changes detected + */ + showForm(formStructure, { + onChange + } = {}) { + let overlay; + + const self = this; + + const overlayEl = document.createElement('div'); + overlayEl.classList.add('u-contents'); + + overlay = self.openmct.overlays.overlay({ + element: overlayEl, + size: 'dialog' + }); + + let formSave; + let formCancel; + const promise = new Promise((resolve, reject) => { + formSave = resolve; + formCancel = reject; + }); + + this.showCustomForm(formStructure, { + element: overlayEl, + onChange + }) + .then((response) => { + overlay.dismiss(); + formSave(response); + }) + .catch((response) => { + overlay.dismiss(); + formCancel(response); + }); + + return promise; + } + + /** + * Show form as a child of the element provided with given form structure * * @public * @param {Array
} formStructure a form structure, array of section * @param {Object} options * @property {HTMLElement} element Parent Element to render a Form * @property {function} onChange a callback function when any changes detected - * @property {function} onSave a callback function when form is submitted - * @property {function} onDismiss a callback function when form is dismissed */ - showForm(formStructure, { + showCustomForm(formStructure, { element, onChange } = {}) { - const changes = {}; - let overlay; - let onDismiss; - let onSave; + if (element === undefined) { + throw Error('Required element parameter not provided'); + } const self = this; + const changes = {}; + let formSave; + let formCancel; + const promise = new Promise((resolve, reject) => { - onSave = onFormAction(resolve); - onDismiss = onFormAction(reject); + formSave = onFormAction(resolve); + formCancel = onFormAction(reject); }); const vm = new Vue({ @@ -126,26 +170,17 @@ export default class FormsAPI extends EventEmitter { return { formStructure, onChange: onFormPropertyChange, - onDismiss, - onSave + onCancel: formCancel, + onSave: formSave }; }, - template: '' + template: '' }).$mount(); const formElement = vm.$el; - if (element) { - element.append(formElement); - } else { - overlay = self.openmct.overlays.overlay({ - element: vm.$el, - size: 'dialog', - onDestroy: () => vm.$destroy() - }); - } + element.append(formElement); function onFormPropertyChange(data) { - self.emit('onFormPropertyChange', data); if (onChange) { onChange(data); } @@ -158,17 +193,14 @@ export default class FormsAPI extends EventEmitter { key = property.join('.'); } - changes[key] = data.value; + _.set(changes, key, data.value); } } function onFormAction(callback) { return () => { - if (element) { - formElement.remove(); - } else { - overlay.dismiss(); - } + formElement.remove(); + vm.$destroy(); if (callback) { callback(changes); diff --git a/src/api/forms/FormsAPISpec.js b/src/api/forms/FormsAPISpec.js index ac7f0fc9fb..362e398da7 100644 --- a/src/api/forms/FormsAPISpec.js +++ b/src/api/forms/FormsAPISpec.js @@ -133,7 +133,7 @@ describe('The Forms API', () => { }); it('when container element is provided', (done) => { - openmct.forms.showForm(formStructure, { element }).catch(() => { + openmct.forms.showCustomForm(formStructure, { element }).catch(() => { done(); }); const titleElement = element.querySelector('.c-overlay__dialog-title'); diff --git a/src/api/forms/components/FormProperties.vue b/src/api/forms/components/FormProperties.vue index 2ca84d0a73..9f631e108b 100644 --- a/src/api/forms/components/FormProperties.vue +++ b/src/api/forms/components/FormProperties.vue @@ -73,7 +73,7 @@ tabindex="0" class="c-button js-cancel-button" aria-label="Cancel" - @click="onDismiss" + @click="onCancel" > {{ cancelLabel }} @@ -164,8 +164,8 @@ export default { this.$emit('onChange', data); }, - onDismiss() { - this.$emit('onDismiss'); + onCancel() { + this.$emit('onCancel'); }, onSave() { this.$emit('onSave'); diff --git a/src/api/forms/components/controls/SelectField.vue b/src/api/forms/components/controls/SelectField.vue index aecf0c2868..b5833c120f 100644 --- a/src/api/forms/components/controls/SelectField.vue +++ b/src/api/forms/components/controls/SelectField.vue @@ -26,6 +26,7 @@ v-model="selected" required="model.required" name="mctControl" + :aria-label="model.ariaLabel || model.name" @change="onChange($event)" >