Compare commits
	
		
			56 Commits
		
	
	
		
			imagery-te
			...
			plots-insp
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 59c3c836c3 | ||
|   | 3a2f78cbc6 | ||
|   | 10b281de94 | ||
|   | 53bf50d3e6 | ||
|   | e6188e3d80 | ||
|   | ab4089f4d0 | ||
|   | dcb69503a5 | ||
|   | 5a5974ae73 | ||
|   | 57b2e2bee2 | ||
|   | 697f9f16ae | ||
|   | 8d6e6569cc | ||
|   | 00a0bdef37 | ||
|   | 23dd1b236b | ||
|   | 4e113772d7 | ||
|   | 8c756bf81e | ||
|   | cfef77edfc | ||
|   | 188cfb3087 | ||
|   | d01768f14f | ||
|   | ab95ace86d | ||
|   | e53aee0076 | ||
|   | 6ff5bb7012 | ||
|   | 83ab35b376 | ||
|   | aacbce8e3a | ||
|   | fb04e4998f | ||
|   | 1f1e754943 | ||
|   | 9a885d7dcc | ||
|   | 8b26e9db82 | ||
|   | 8c3cf43895 | ||
|   | 8f0a993b3d | ||
|   | 9889a636c0 | ||
|   | bdf15ad3b0 | ||
|   | 1e337844b6 | ||
|   | 5178cdd979 | ||
|   | 8d5796f8be | ||
|   | ece57c0e0c | ||
|   | b977505c0e | ||
|   | 7aa39c9617 | ||
|   | bd387fe1cf | ||
|   | d8777e5f5b | ||
|   | 0b625dc47e | ||
|   | 535e8aef13 | ||
|   | a4bbd0d3d7 | ||
|   | 7282516d30 | ||
|   | 7b244a6bc7 | ||
|   | 343ee67444 | ||
|   | b93efa63b2 | ||
|   | 8f764be600 | ||
|   | b1b98d5d43 | ||
|   | 5958f146a4 | ||
|   | 649d7ef92a | ||
|   | 2da5bea996 | ||
|   | 1ab08fc523 | ||
|   | c2cd2356e9 | ||
|   | 6fd91ac4bf | ||
|   | d9caf081d8 | ||
|   | 72a95da7b1 | 
| @@ -1,103 +1,36 @@ | ||||
| version: 2.1 | ||||
| executors: | ||||
|   linux: | ||||
|     docker: | ||||
|       - image: cimg/base:stable | ||||
| orbs: | ||||
|   node: circleci/node@4.5.1 | ||||
|   browser-tools: circleci/browser-tools@1.1.3 | ||||
| version: 2 | ||||
| jobs: | ||||
|   test: | ||||
|     parameters: | ||||
|       node-version: | ||||
|         type: string | ||||
|       browser: | ||||
|         type: string | ||||
|     executor: linux | ||||
|   build: | ||||
|     docker: | ||||
|         - image: circleci/node:13-browsers | ||||
|           environment: | ||||
|             CHROME_BIN: "/usr/bin/google-chrome" | ||||
|     steps: | ||||
|       - checkout | ||||
|       - restore_cache: | ||||
|           key: deps-{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }} | ||||
|       - node/install: | ||||
|           install-npm: false | ||||
|           node-version: << parameters.node-version >> | ||||
|       - run: npm install | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [ "FirefoxESR", <<parameters.browser>> ] | ||||
|           steps: | ||||
|             - browser-tools/install-firefox: | ||||
|                 version: "91.2.0esr" #https://archive.mozilla.org/pub/firefox/releases/           | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [ "FirefoxHeadless", <<parameters.browser>> ] | ||||
|           steps: | ||||
|             - browser-tools/install-firefox | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [ "ChromeHeadless", <<parameters.browser>> ] | ||||
|           steps: | ||||
|             - browser-tools/install-chrome: | ||||
|                 replace-existing: false | ||||
|       - save_cache: | ||||
|           key: deps-{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }} | ||||
|           paths: | ||||
|             - ~/.npm | ||||
|             - ~/.cache | ||||
|             - node_modules | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [ "", <<parameters.browser>> ] #Only run linting when browsers are not running to save time | ||||
|           steps: | ||||
|             - run: npm run lint | ||||
|       - when: | ||||
|           condition: << parameters.browser >> #Truthy evaluation to only run when browser is specified | ||||
|           steps: | ||||
|             - run: npm run test:coverage -- --browsers=<<parameters.browser>> | ||||
|             - store_test_results: | ||||
|                 path: dist/reports/tests/ | ||||
|             - store_artifacts: | ||||
|                 path: dist/reports/ | ||||
|         - checkout | ||||
|         - run: | ||||
|             name: Update npm | ||||
|             command: 'sudo npm install -g npm@latest' | ||||
|         - restore_cache: | ||||
|             key: dependency-cache-{{ checksum "package.json" }} | ||||
|         - run: | ||||
|             name: Installing dependencies (npm install) | ||||
|             command: npm install | ||||
|         - save_cache: | ||||
|             key: dependency-cache-{{ checksum "package.json" }} | ||||
|             paths: | ||||
|               - node_modules | ||||
|         - run: | ||||
|             name: npm run test:coverage | ||||
|             command: npm run test:coverage | ||||
|         - run: | ||||
|             name: npm run lint | ||||
|             command: npm run lint | ||||
|         - store_artifacts: | ||||
|             path: dist | ||||
|             prefix: dist | ||||
|  | ||||
| workflows: | ||||
|   matrix-tests: | ||||
|   version: 2 | ||||
|   test: | ||||
|     jobs: | ||||
|       - test: | ||||
|           post-steps: | ||||
|             - run: | ||||
|                 command: | ||||
|                   curl -Os https://uploader.codecov.io/latest/linux/codecov;chmod +x codecov;./codecov               | ||||
|           name: node10-chrome | ||||
|           node-version: lts/dubnium | ||||
|           browser: ChromeHeadless | ||||
|       - test: | ||||
|           name: node12-build-lint | ||||
|           node-version: lts/erbium | ||||
|           browser: "" #Skip unit tests | ||||
|       - test:  | ||||
|           name: node14-build-lint | ||||
|           node-version: lts/fermium | ||||
|           browser: "" #Skip unit tests | ||||
|  | ||||
|   nightly: | ||||
|     jobs: | ||||
|       - test: | ||||
|           name: node10-chrome-nightly | ||||
|           node-version: lts/dubnium | ||||
|           browser: ChromeHeadless | ||||
|       - test: | ||||
|           name: node12-firefoxESR-nightly | ||||
|           node-version: lts/erbium | ||||
|           browser: FirefoxESR | ||||
|       - test: | ||||
|           name: node14-firefox-nightly | ||||
|           node-version: lts/fermium | ||||
|           browser: FirefoxHeadless | ||||
|     triggers: | ||||
|       - schedule: | ||||
|           cron: "0 0 * * *" | ||||
|           filters: | ||||
|             branches: | ||||
|               only: | ||||
|                 - master       | ||||
|  | ||||
|  | ||||
|       - build | ||||
|   | ||||
							
								
								
									
										44
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							| @@ -1,44 +0,0 @@ | ||||
| --- | ||||
| name: Bug report | ||||
| about: File a Bug ! | ||||
| title: '' | ||||
| labels: type:bug | ||||
| assignees: '' | ||||
|  | ||||
| --- | ||||
|  | ||||
| <!--- Focus on user impact in the title. Use the Summary Field to --> | ||||
| <!--- describe the problem technically. --> | ||||
|  | ||||
| #### Summary | ||||
| <!--- A description of the issue encountered. When possible, a description --> | ||||
| <!--- of the impact of the issue. What use case does it impede?--> | ||||
|  | ||||
| #### Expected vs Current Behavior | ||||
| <!--- Tell us what should have happened --> | ||||
|  | ||||
| #### Impact Check List | ||||
| <!--- Please select from the following options --> | ||||
|  | ||||
| - [ ] Data loss or misrepresented data? | ||||
| - [ ] Regression? Did this used to work or has it always been broken? | ||||
| - [ ] Is there a workaround available? | ||||
| - [ ] Does this impact a critical component? | ||||
| - [ ] Is this just a visual bug? | ||||
|  | ||||
| #### Steps to Reproduce | ||||
| <!--- Provide a link to a live example, or an unambiguous set of steps to --> | ||||
| <!--- reproduce this bug. Include code to reproduce, if relevant --> | ||||
| 1. | ||||
| 2. | ||||
| 3. | ||||
| 4. | ||||
|  | ||||
| #### Environment | ||||
| * Open MCT Version: <!--- date of build, version, or SHA --> | ||||
| * Deployment Type: <!--- npm dev? VIPER Dev? openmct-yamcs? --> | ||||
| * OS: | ||||
| * Browser: | ||||
|  | ||||
| #### Additional Information | ||||
| <!--- Include any screenshots, gifs, or logs which will expedite triage --> | ||||
							
								
								
									
										5
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +0,0 @@ | ||||
| blank_issues_enabled: true | ||||
| contact_links: | ||||
|   - name: Discussions | ||||
|     url: https://github.com/nasa/openmct/discussions | ||||
|     about: Got a question? | ||||
							
								
								
									
										20
									
								
								.github/ISSUE_TEMPLATE/enhancement-request.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								.github/ISSUE_TEMPLATE/enhancement-request.md
									
									
									
									
										vendored
									
									
								
							| @@ -1,20 +0,0 @@ | ||||
| --- | ||||
| name: Enhancement request | ||||
| about: Suggest an enhancement or new improvement for this project | ||||
| title: '' | ||||
| labels: type:enhancement | ||||
| assignees: '' | ||||
|  | ||||
| --- | ||||
|  | ||||
| **Is your feature request related to a problem? Please describe.** | ||||
| A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||||
|  | ||||
| **Describe the solution you'd like** | ||||
| A clear and concise description of what you want to happen. | ||||
|  | ||||
| **Describe alternatives you've considered** | ||||
| A clear and concise description of any alternative solutions or features you've considered. | ||||
|  | ||||
| **Additional context** | ||||
| Add any other context or screenshots about the feature request here. | ||||
							
								
								
									
										23
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
								
							| @@ -1,23 +0,0 @@ | ||||
| <!--- This is for filing enhancements or features. If you have a general --> | ||||
| <!--- question, please visit https://github.com/nasa/openmct/discussions --> | ||||
|  | ||||
| --- | ||||
| name: Feature Request | ||||
| about: Suggest an idea for this project | ||||
|  | ||||
| --- | ||||
|  | ||||
| <!-- | ||||
| Thank you for suggesting an idea to make Open MCT better. | ||||
|  | ||||
| Please fill in as much of the template below as you're able. | ||||
| --> | ||||
|  | ||||
| **Is your feature request related to a problem? Please describe.** | ||||
| <!-- Please describe the problem you are trying to solve. --> | ||||
|  | ||||
| **Describe the solution you'd like** | ||||
| <!--- Please describe the desired behavior. --> | ||||
|  | ||||
| **Describe alternatives you've considered** | ||||
| <!--- Please describe alternative solutions or features you have considered. --> | ||||
							
								
								
									
										13
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							| @@ -1,13 +0,0 @@ | ||||
| ### All Submissions: | ||||
|  | ||||
| * [ ] Have you followed the guidelines in our [Contributing document](https://github.com/nasa/openmct/blob/master/CONTRIBUTING.md)? | ||||
| * [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/nasa/openmct/pulls) for the same update/change? | ||||
| * [ ] Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots. | ||||
|  | ||||
| ### Author Checklist | ||||
|  | ||||
| * [ ] Changes address original issue? | ||||
| * [ ] Unit tests included and/or updated with changes? | ||||
| * [ ] Command line build passes? | ||||
| * [ ] Has this been smoke tested? | ||||
| * [ ] Testing instructions included in associated issue? | ||||
							
								
								
									
										23
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,23 +0,0 @@ | ||||
|  | ||||
| version: 2 | ||||
| updates: | ||||
|   - package-ecosystem: "npm" | ||||
|     directory: "/" | ||||
|     schedule: | ||||
|       interval: "daily"   | ||||
|     open-pull-requests-limit: 2 | ||||
|     labels: | ||||
|       - "type:maintenance" | ||||
|       - "dependencies" | ||||
|     allow: | ||||
|       - dependency-name: "eslint*" | ||||
|       - dependency-name: "karma*" | ||||
|       - dependency-name: "jasmine*" | ||||
|  | ||||
|   - package-ecosystem: "github-actions" | ||||
|     directory: "/" | ||||
|     schedule: | ||||
|       interval: "daily"     | ||||
|     labels: | ||||
|       - "type:maintenance" | ||||
|       - "dependencies" | ||||
							
								
								
									
										41
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,41 +0,0 @@ | ||||
|  | ||||
| name: "CodeQL" | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: [ master ] | ||||
|   pull_request: | ||||
|     branches: [ master ] | ||||
|     paths-ignore: | ||||
|       - '**/*Spec.js' | ||||
|       - '**/*.md' | ||||
|       - '**/*.txt' | ||||
|       - '**/*.yml' | ||||
|       - '**/*.yaml' | ||||
|   schedule: | ||||
|     - cron: '28 21 * * 3' | ||||
|  | ||||
| jobs: | ||||
|   analyze: | ||||
|     name: Analyze | ||||
|     runs-on: ubuntu-latest | ||||
|     permissions: | ||||
|       actions: read | ||||
|       contents: read | ||||
|       security-events: write | ||||
|  | ||||
|     steps: | ||||
|     - name: Checkout repository | ||||
|       uses: actions/checkout@v2 | ||||
|  | ||||
|     # Initializes the CodeQL tools for scanning. | ||||
|     - name: Initialize CodeQL | ||||
|       uses: github/codeql-action/init@v1 | ||||
|       with: | ||||
|         languages: javascript | ||||
|  | ||||
|     - name: Autobuild | ||||
|       uses: github/codeql-action/autobuild@v1 | ||||
|  | ||||
|     - name: Perform CodeQL Analysis | ||||
|       uses: github/codeql-action/analyze@v1 | ||||
							
								
								
									
										20
									
								
								.github/workflows/lighthouse.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/lighthouse.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,20 +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'  | ||||
| jobs: | ||||
|   lighthouse: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - uses: actions/checkout@v2 | ||||
|         with: | ||||
|           ref: ${{ github.event.inputs.version }} | ||||
|       - uses: actions/setup-node@v2 | ||||
|         with: | ||||
|           node-version: '14' | ||||
|       - run: npm install && npm install -g @lhci/cli #Don't want to include this in our deps | ||||
|       - run: lhci autorun | ||||
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -40,10 +40,4 @@ npm-debug.log | ||||
| # karma reports | ||||
| report.*.json | ||||
|  | ||||
| # Lighthouse reports | ||||
| .lighthouseci | ||||
|  | ||||
| package-lock.json | ||||
|  | ||||
| #codecov artifacts | ||||
| codecov | ||||
|   | ||||
							
								
								
									
										19
									
								
								API.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								API.md
									
									
									
									
									
								
							| @@ -423,14 +423,13 @@ attribute      | type   | flags    | notes | ||||
|  | ||||
| ###### 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. | ||||
| Each telemetry value description has an object defining hints.  Keys in this 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. | ||||
|  | ||||
| ##### The Time Conductor and Telemetry  | ||||
|  | ||||
| @@ -595,17 +594,9 @@ section. | ||||
|  | ||||
| #### Limit Evaluators **draft** | ||||
|  | ||||
| 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  | ||||
| what the limit values are for different limit levels. | ||||
|  | ||||
| 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`. | ||||
| Limit evaluators allow a telemetry integrator to define how limits should be  | ||||
| applied to telemetry from a given domain object.  For an example of a limit  | ||||
| evaluator, take a look at `examples/generator/SinewaveLimitProvider.js`. | ||||
|  | ||||
| ### Telemetry Consumer APIs **draft** | ||||
|  | ||||
| @@ -996,7 +987,7 @@ reveal additional information when the mouse cursor is hovered over it. | ||||
| 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 | ||||
| returing 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  | ||||
| URL Status Indicator. | ||||
|  | ||||
|   | ||||
| @@ -10,7 +10,7 @@ accept changes from external contributors. | ||||
|  | ||||
| The short version: | ||||
|  | ||||
| 1. Write your contribution or describe your idea in the form of an [GitHub issue](https://github.com/nasa/openmct/issues/new/choose) or [Starting a GitHub Discussion](https://github.com/nasa/openmct/discussions) | ||||
| 1. Write your contribution. | ||||
| 2. Make sure your contribution meets code, test, and commit message | ||||
|    standards as described below. | ||||
| 3. Submit a pull request from a topic branch back to `master`. Include a check | ||||
| @@ -18,7 +18,6 @@ The short version: | ||||
|    for review.) | ||||
| 4. Respond to any discussion. When the reviewer decides it's ready, they | ||||
|    will merge back `master` and fill out their own check list. | ||||
| 5. If you are a first-time contributor, please see [this discussion](https://github.com/nasa/openmct/discussions/3821) for further information.    | ||||
|  | ||||
| ## Contribution Process | ||||
|  | ||||
| @@ -116,7 +115,7 @@ the pull request containing the reviewer checklist (from below) and complete | ||||
| the merge back to the master branch. | ||||
|  | ||||
| Additionally: | ||||
| * Every pull request must link to the issue that it addresses. Eg. “Addresses #1234” or “Closes #1234”. This is the responsibility of the pull request’s __author__. If no issue exists, [create one](https://github.com/nasa/openmct/issues/new/choose). | ||||
| * Every pull request must link to the issue that it addresses. Eg. “Addresses #1234” or “Closes #1234”. This is the responsibility of the pull request’s __author__. If no issue exists, create one. | ||||
| * Every __author__ must include testing instructions. These instructions should identify the areas of code affected, and some minimal test steps. If addressing a bug, reproduction steps should be included, if they were not included in the original issue. If reproduction steps were included on the original issue, and are sufficient, refer to them. | ||||
| * A pull request that closes an issue should say so in the description. Including the text “Closes #1234” will cause the linked issue to be automatically closed when the pull request is merged. This is the responsibility of the pull request’s __author__. | ||||
| * When a pull request is merged, and the corresponding issue closed, the __reviewer__ must add the tag “unverified” to the original issue. This will indicate that although the issue is closed, it has not been tested yet. | ||||
| @@ -297,12 +296,23 @@ these standards. | ||||
|  | ||||
| Issues are tracked at https://github.com/nasa/openmct/issues. | ||||
|  | ||||
| Issues should include: | ||||
|  | ||||
| * A short description of the issue encountered. | ||||
| * A longer-form description of the issue encountered. When possible, steps to | ||||
|   reproduce the issue. | ||||
| * When possible, a description of the impact of the issue. What use case does | ||||
|   it impede? | ||||
| * An assessment of the severity of the issue. | ||||
|  | ||||
| Issue severity is categorized as follows (in ascending order): | ||||
|  | ||||
| * _Trivial_: Minimal impact on the usefulness and functionality of the software; a "nice-to-have." Visual impact without functional impact, | ||||
| * _Medium_: Some impairment of use, but simple workarounds exist | ||||
| * _Critical_: Significant loss of functionality or impairment of use. Display of telemetry data is not affected though. | ||||
| * _Blocker_: Major functionality is impaired or lost, threatening mission success. Display of telemetry data is impaired or blocked by the bug, which could lead to loss of situational awareness. | ||||
| * _Trivial_: Minimal impact on the usefulness and functionality of the | ||||
|   software; a "nice-to-have." | ||||
| * _(Unspecified)_: Major loss of functionality or impairment of use. | ||||
| * _Critical_: Large-scale loss of functionality or impairment of use, | ||||
|   such that remaining utility becomes marginal. | ||||
| * _Blocker_: Harmful or otherwise unacceptable behavior. Must fix. | ||||
|  | ||||
| ## Check Lists | ||||
|  | ||||
| @@ -312,20 +322,16 @@ checklist). | ||||
|  | ||||
| ### Author Checklist | ||||
|  | ||||
| [Within PR Template](.github/PULL_REQUEST_TEMPLATE.md) | ||||
| 1. Changes address original issue? | ||||
| 2. Unit tests included and/or updated with changes? | ||||
| 3. Command line build passes? | ||||
| 4. Changes have been smoke-tested? | ||||
| 5. Testing instructions included? | ||||
|  | ||||
| ### Reviewer Checklist | ||||
|  | ||||
| * [ ] Changes appear to address issue? | ||||
| * [ ] Changes appear not to be breaking changes? | ||||
| * [ ] Appropriate unit tests included? | ||||
| * [ ] Code style and in-line documentation are appropriate? | ||||
| * [ ] Commit messages meet standards? | ||||
| * [ ] Has associated issue been labelled `unverified`? (only applicable if this PR closes the issue) | ||||
| * [ ] Has associated issue been labelled `bug`? (only applicable if this PR is for a bug fix) | ||||
| * [ ] List of Acceptance Tests Performed. | ||||
|  | ||||
| Write out a small list of tests performed with just enough detail for another developer on the team  | ||||
| to execute.  | ||||
|  | ||||
| i.e. ```When Clicking on Add button, new `object` appears in dropdown.``` | ||||
| 1. Changes appear to address issue? | ||||
| 2. Appropriate unit tests included? | ||||
| 3. Code style and in-line documentation are appropriate? | ||||
| 4. Commit messages meet standards? | ||||
| 5. Has associated issue been labelled `unverified`? (only applicable if this PR closes the issue) | ||||
|   | ||||
| @@ -1,11 +1,9 @@ | ||||
| # Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) [](https://lgtm.com/projects/g/nasa/openmct/context:javascript) [](https://codecov.io/gh/nasa/openmct) | ||||
| # Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) | ||||
|  | ||||
| Open MCT (Open Mission Control Technologies) is a next-generation mission control framework for visualization of data on desktop and mobile devices. It is developed at NASA's Ames Research Center, and is being used by NASA for data analysis of spacecraft missions, as well as planning and operation of experimental rover systems. As a generalizable and open source framework, Open MCT could be used as the basis for building applications for planning, operation, and analysis of any systems producing telemetry data. | ||||
|  | ||||
| Please visit our [Official Site](https://nasa.github.io/openmct/) and [Getting Started Guide](https://nasa.github.io/openmct/getting-started/) | ||||
|  | ||||
| Once you've created something amazing with Open MCT, showcase your work in our GitHub Discussions [Show and Tell](https://github.com/nasa/openmct/discussions/categories/show-and-tell) section. We love seeing unique and wonderful implementations of Open MCT! | ||||
|  | ||||
| ## See Open MCT in Action | ||||
|  | ||||
| Try Open MCT now with our [live demo](https://openmct-demo.herokuapp.com/). | ||||
| @@ -46,7 +44,7 @@ The clearest examples for developing Open MCT plugins are in the | ||||
| our documentation. | ||||
|  | ||||
| We want Open MCT to be as easy to use, install, run, and develop for as | ||||
| possible, and your feedback will help us get there! Feedback can be provided via [GitHub issues](https://github.com/nasa/openmct/issues/new/choose), [Starting a GitHub Discussion](https://github.com/nasa/openmct/discussions), or by emailing us at [arc-dl-openmct@mail.nasa.gov](mailto:arc-dl-openmct@mail.nasa.gov). | ||||
| possible, and your feedback will help us get there! Feedback can be provided via [GitHub issues](https://github.com/nasa/openmct/issues), or by emailing us at [arc-dl-openmct@mail.nasa.gov](mailto:arc-dl-openmct@mail.nasa.gov). | ||||
|  | ||||
| ## Building Applications With Open MCT | ||||
|  | ||||
| @@ -85,8 +83,6 @@ naming convention is otherwise the same.) | ||||
| When `npm test` is run, test results will be written as HTML to | ||||
| `dist/reports/tests/`. Code coverage information is written to `dist/reports/coverage`. | ||||
|  | ||||
| Code Coverage Reports are available from [codecov.io](https://app.codecov.io/gh/nasa/openmct/) | ||||
|  | ||||
| # Glossary | ||||
|  | ||||
| Certain terms are used throughout Open MCT with consistent meanings | ||||
|   | ||||
							
								
								
									
										27
									
								
								codecov.yml
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								codecov.yml
									
									
									
									
									
								
							| @@ -1,27 +0,0 @@ | ||||
| codecov: | ||||
|   require_ci_to_pass: false #This setting will update the bot regardless of whether or not tests pass | ||||
|  | ||||
| coverage: | ||||
|   status: | ||||
|     project: | ||||
|       default: | ||||
|         informational: true | ||||
|     patch: | ||||
|       default: | ||||
|         informational: true | ||||
|   precision: 2 | ||||
|   round: down | ||||
|   range: "66...100" | ||||
|  | ||||
| parsers: | ||||
|   gcov: | ||||
|     branch_detection: | ||||
|       conditional: true | ||||
|       loop: true | ||||
|       method: false | ||||
|       macro: false | ||||
|  | ||||
| comment: | ||||
|   layout: "reach,diff,flags,files,footer" | ||||
|   behavior: default | ||||
|   require_changes: false | ||||
| @@ -423,7 +423,7 @@ which can help with this, however. | ||||
|   instead of separate approaches for static and substitutable | ||||
|   dependencies. | ||||
| * Removes need to understand Angular's DI mechanism. | ||||
| * Improves usability of documentation (`typeService` is an | ||||
| * Improves useability of documentation (`typeService` is an | ||||
|   instance of `CompositeService` and implements `TypeService` | ||||
|   so you can easily traverse links in the JSDoc.) | ||||
| * Can be used more easily from Web Workers, allowing services | ||||
|   | ||||
| @@ -25,7 +25,7 @@ | ||||
| ## Legacy Documentation | ||||
|  | ||||
| As we transition to a new API, the following documentation for the old API | ||||
| (which is supported during the transition) may be useful as well: | ||||
| (which is supported during the transtion) may be useful as well: | ||||
|  | ||||
|  * The [Architecture Overview](architecture/) describes the concepts used | ||||
|  throughout Open MCT, and gives a high level overview of the platform's design. | ||||
|   | ||||
| @@ -73,11 +73,11 @@ acceptance testing (e.g. by resolving any blockers found); any | ||||
| resources not needed for this effort should be used to begin work | ||||
| for the subsequent sprint. | ||||
|  | ||||
| | Week  | Mon                       | Tue    | Wed | Thu                          | Fri                                   | | ||||
| |:-----:|:-------------------------:|:------:|:---:|:----------------------------:|:-------------------------------------:| | ||||
| | __1__ | Sprint plan               | Tag-up |     |                              |                                       | | ||||
| | __2__ |                           | Tag-up |     |                              | Code freeze  and sprint branch        | | ||||
| | __3__ | Per-sprint testing        | Triage |     | _Per-sprint testing*_        | Ship and merge sprint branch to master| | ||||
| | Week  | Mon                       | Tue    | Wed | Thu                          | Fri         | | ||||
| |:-----:|:-------------------------:|:------:|:---:|:----------------------------:|:-----------:| | ||||
| | __1__ | Sprint plan               | Tag-up |     |                              |             | | ||||
| | __2__ |                           | Tag-up |     |                              | Code freeze | | ||||
| | __3__ | Per-sprint testing        | Triage |     | _Per-sprint testing*_        | Ship        | | ||||
|  | ||||
| * If necessary. | ||||
|  | ||||
| @@ -105,20 +105,14 @@ emphasis on testing. | ||||
|     that team may begin work for that sprint during the | ||||
|     third week, since testing and blocker resolution is unlikely | ||||
|     to require all available resources. | ||||
|   * Testing success criteria identified per issue (where necessary). This could be in the form of acceptance tests on the issue or detailing performance tests, for example. | ||||
| * __Tag-up.__ Check in and status update among development team. | ||||
|   May amend plan for sprint as-needed. | ||||
| * __Code freeze.__ Any new work from this sprint | ||||
|   (features, bug fixes, enhancements) must be integrated by the | ||||
|   end of the second week of the sprint. After code freeze, a sprint | ||||
|   branch will be created (and until the end of the sprint) the only  | ||||
|   changes that should be merged into the sprint branch should  | ||||
|   directly address issues needed to pass acceptance testing. | ||||
|   During this time, any other feature development will continue to | ||||
|   be merged into the master branch for the next sprint. | ||||
| * __Sprint branch merge to master.__ After acceptance testing, the sprint branch | ||||
|   will be merged back to the master branch. Any code conflicts that  | ||||
|   arise will be resolved by the team. | ||||
|   end of the second week of the sprint. After code freeze | ||||
|   (and until the end of the sprint) the only changes that should be | ||||
|   merged into the master branch should directly address issues | ||||
|   needed to pass acceptance testing. | ||||
| * [__Per-release Testing.__](testing/plan.md#per-release-testing) | ||||
|   Structured testing with predefined | ||||
|   success criteria. No release should ship without passing | ||||
| @@ -132,8 +126,8 @@ emphasis on testing. | ||||
|   * [__Testathon.__](testing/plan.md#user-testing) | ||||
|     Multi-user testing, involving as many users as | ||||
|     is feasible, plus development team. Open-ended; should verify | ||||
|     completed work from this sprint using the sprint branch, test  | ||||
|     exploratorily for regressions, et cetera. | ||||
|     completed work from this sprint, test exploratorily for | ||||
|     regressions, et cetera. | ||||
|   * [__Long-Duration Test.__](testing/plan.md#long-duration-testing) A | ||||
|     test to verify that the software remains | ||||
|     stable after running for longer durations. May include some | ||||
| @@ -149,7 +143,7 @@ emphasis on testing. | ||||
|   Subset of Pre-release Testing | ||||
|   which should be performed before shipping at the end of any | ||||
|   sprint. Time is allocated for a second round of | ||||
|   Pre-release Testing if the first round is not passed. Smoke tests collected from issues/PRs | ||||
|   Pre-release Testing if the first round is not passed. | ||||
| * __Triage.__ Team reviews issues from acceptance testing and uses | ||||
|   success criteria to determine whether or not they should block | ||||
|   release, then formulates a plan to address these issues before | ||||
|   | ||||
| @@ -19,7 +19,7 @@ Testing for Open MCT includes: | ||||
|  | ||||
| Manual, non-rigorous testing of the software and/or specific features | ||||
| of interest. Verifies that the software runs and that basic functionality | ||||
| is present. The outcome of Smoke Testing should be a simplified list of Acceptance Tests which could be executed by another team member with sufficient context. | ||||
| is present. | ||||
|  | ||||
| ### Unit Testing | ||||
|  | ||||
| @@ -49,7 +49,7 @@ User testing will focus on the following activities: | ||||
| * General "trying to break things." | ||||
|  | ||||
| During user testing, users will | ||||
| [report issues](https://github.com/nasa/openmct/issues/new/choose) | ||||
| [report issues](https://github.com/nasa/openmctweb/blob/master/CONTRIBUTING.md#issue-reporting) | ||||
| as they are encountered. | ||||
|  | ||||
| Desired outcomes of user testing are: | ||||
| @@ -71,7 +71,7 @@ usage. After twenty-four hours, the software is evaluated for: | ||||
|   at the start of the test? Is it as responsive? | ||||
|  | ||||
| Any defects or unexpected behavior identified during testing should be | ||||
| [reported as issues](https://github.com/nasa/openmct/issues/new/choose) | ||||
| [reported as issues](https://github.com/nasa/openmctweb/blob/master/CONTRIBUTING.md#issue-reporting) | ||||
| and reviewed for severity. | ||||
|  | ||||
| ## Test Performance | ||||
|   | ||||
| @@ -92,8 +92,8 @@ should update (or delegate the task of updating) Open MCT version | ||||
| numbers by the following process: | ||||
|  | ||||
| 1. Update version number in `package.json` | ||||
|   1. Checkout branch created for the last sprint that has been successfully tested. | ||||
|   2. Remove a `-SNAPSHOT` suffix from the version in `package.json`. | ||||
|   1. Create a new branch off the `master` branch. | ||||
|   2. Remove `-SNAPSHOT` suffix from the version in `package.json`. | ||||
|   3. Verify that resulting version number meets semantic versioning | ||||
|      requirements relative to previous stable version. Increment the  | ||||
|      version number if necessary. | ||||
| @@ -131,8 +131,7 @@ numbers by the following process: | ||||
|   3. In `package.json` change package to be public (private: false) | ||||
|   4. Test the package before publishing by doing `npm publish --dry-run`  | ||||
|      if necessary. | ||||
|   5. Publish the package to the npmjs registry (e.g. `npm publish --access public`)  | ||||
|      NOTE: Use the `--tag unstable` flag to the npm publishj if this is a prerelease. | ||||
|   5. Publish the package to the npmjs registry (e.g. `npm publish --access public`) | ||||
|   6. Confirm the package has been published (e.g. `https://www.npmjs.com/package/openmct`) | ||||
| 5. Update snapshot status in `package.json` | ||||
|   1. Create a new branch off the `master` branch. | ||||
|   | ||||
| @@ -28,15 +28,6 @@ define([ | ||||
|                         domain: 2 | ||||
|                     } | ||||
|                 }, | ||||
|                 { | ||||
|                     key: "cos", | ||||
|                     name: "Cosine", | ||||
|                     unit: "deg", | ||||
|                     formatString: '%0.2f', | ||||
|                     hints: { | ||||
|                         domain: 3 | ||||
|                     } | ||||
|                 }, | ||||
|                 // Need to enable "LocalTimeSystem" plugin to make use of this | ||||
|                 // { | ||||
|                 //     key: "local", | ||||
|   | ||||
| @@ -26,26 +26,14 @@ define([ | ||||
|  | ||||
| ) { | ||||
|  | ||||
|     var PURPLE = { | ||||
|             sin: 2.2, | ||||
|             cos: 2.2 | ||||
|         }, | ||||
|         RED = { | ||||
|     var RED = { | ||||
|             sin: 0.9, | ||||
|             cos: 0.9 | ||||
|         }, | ||||
|         ORANGE = { | ||||
|             sin: 0.7, | ||||
|             cos: 0.7 | ||||
|         }, | ||||
|         YELLOW = { | ||||
|             sin: 0.5, | ||||
|             cos: 0.5 | ||||
|         }, | ||||
|         CYAN = { | ||||
|             sin: 0.45, | ||||
|             cos: 0.45 | ||||
|         }, | ||||
|         LIMITS = { | ||||
|             rh: { | ||||
|                 cssClass: "is-limit--upr is-limit--red", | ||||
| @@ -105,70 +93,5 @@ define([ | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     SinewaveLimitProvider.prototype.getLimits = function (domainObject) { | ||||
|  | ||||
|         return { | ||||
|             limits: function () { | ||||
|                 return Promise.resolve({ | ||||
|                     WATCH: { | ||||
|                         low: { | ||||
|                             color: "cyan", | ||||
|                             sin: -CYAN.sin, | ||||
|                             cos: -CYAN.cos | ||||
|                         }, | ||||
|                         high: { | ||||
|                             color: "cyan", | ||||
|                             ...CYAN | ||||
|                         } | ||||
|                     }, | ||||
|                     WARNING: { | ||||
|                         low: { | ||||
|                             color: "yellow", | ||||
|                             sin: -YELLOW.sin, | ||||
|                             cos: -YELLOW.cos | ||||
|                         }, | ||||
|                         high: { | ||||
|                             color: "yellow", | ||||
|                             ...YELLOW | ||||
|                         } | ||||
|                     }, | ||||
|                     DISTRESS: { | ||||
|                         low: { | ||||
|                             color: "orange", | ||||
|                             sin: -ORANGE.sin, | ||||
|                             cos: -ORANGE.cos | ||||
|                         }, | ||||
|                         high: { | ||||
|                             color: "orange", | ||||
|                             ...ORANGE | ||||
|                         } | ||||
|                     }, | ||||
|                     CRITICAL: { | ||||
|                         low: { | ||||
|                             color: "red", | ||||
|                             sin: -RED.sin, | ||||
|                             cos: -RED.cos | ||||
|                         }, | ||||
|                         high: { | ||||
|                             color: "red", | ||||
|                             ...RED | ||||
|                         } | ||||
|                     }, | ||||
|                     SEVERE: { | ||||
|                         low: { | ||||
|                             color: "purple", | ||||
|                             sin: -PURPLE.sin, | ||||
|                             cos: -PURPLE.cos | ||||
|                         }, | ||||
|                         high: { | ||||
|                             color: "purple", | ||||
|                             ...PURPLE | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|             } | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     return SinewaveLimitProvider; | ||||
| }); | ||||
|   | ||||
| @@ -63,7 +63,7 @@ define([ | ||||
|  | ||||
|     StateGeneratorProvider.prototype.request = function (domainObject, options) { | ||||
|         var start = options.start; | ||||
|         var end = Math.min(Date.now(), options.end); // no future values | ||||
|         var end = options.end; | ||||
|         var duration = domainObject.telemetry.duration * 1000; | ||||
|         if (options.strategy === 'latest' || options.size === 1) { | ||||
|             start = end; | ||||
|   | ||||
| @@ -54,38 +54,23 @@ | ||||
|         var start = Date.now(); | ||||
|         var step = 1000 / data.dataRateInHz; | ||||
|         var nextStep = start - (start % step) + step; | ||||
|         let work; | ||||
|         if (data.spectra) { | ||||
|             work = function (now) { | ||||
|                 while (nextStep < now) { | ||||
|                     const messageCopy = Object.create(message); | ||||
|                     message.data.start = nextStep - (60 * 1000); | ||||
|                     message.data.end = nextStep; | ||||
|                     onRequest(messageCopy); | ||||
|                     nextStep += step; | ||||
|                 } | ||||
|  | ||||
|                 return nextStep; | ||||
|             }; | ||||
|         } else { | ||||
|             work = function (now) { | ||||
|                 while (nextStep < now) { | ||||
|                     self.postMessage({ | ||||
|                         id: message.id, | ||||
|                         data: { | ||||
|                             name: data.name, | ||||
|                             utc: nextStep, | ||||
|                             yesterday: nextStep - 60 * 60 * 24 * 1000, | ||||
|                             sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness), | ||||
|                             wavelength: wavelength(start, nextStep), | ||||
|                             cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness) | ||||
|                         } | ||||
|                     }); | ||||
|                     nextStep += step; | ||||
|                 } | ||||
|         function work(now) { | ||||
|             while (nextStep < now) { | ||||
|                 self.postMessage({ | ||||
|                     id: message.id, | ||||
|                     data: { | ||||
|                         name: data.name, | ||||
|                         utc: nextStep, | ||||
|                         yesterday: nextStep - 60 * 60 * 24 * 1000, | ||||
|                         sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness), | ||||
|                         cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness) | ||||
|                     } | ||||
|                 }); | ||||
|                 nextStep += step; | ||||
|             } | ||||
|  | ||||
|                 return nextStep; | ||||
|             }; | ||||
|             return nextStep; | ||||
|         } | ||||
|  | ||||
|         subscriptions[message.id] = work; | ||||
| @@ -126,21 +111,13 @@ | ||||
|                 utc: nextStep, | ||||
|                 yesterday: nextStep - 60 * 60 * 24 * 1000, | ||||
|                 sin: sin(nextStep, period, amplitude, offset, phase, randomness), | ||||
|                 wavelength: wavelength(start, nextStep), | ||||
|                 cos: cos(nextStep, period, amplitude, offset, phase, randomness) | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         self.postMessage({ | ||||
|             id: message.id, | ||||
|             data: request.spectra ? { | ||||
|                 wavelength: data.map((item) => { | ||||
|                     return item.wavelength; | ||||
|                 }), | ||||
|                 cos: data.map((item) => { | ||||
|                     return item.cos; | ||||
|                 }) | ||||
|             } : data | ||||
|             data: data | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| @@ -154,10 +131,6 @@ | ||||
|             * Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset; | ||||
|     } | ||||
|  | ||||
|     function wavelength(start, nextStep) { | ||||
|         return (nextStep - start) / 10; | ||||
|     } | ||||
|  | ||||
|     function sendError(error, message) { | ||||
|         self.postMessage({ | ||||
|             error: error.name + ': ' + error.message, | ||||
|   | ||||
| @@ -49,24 +49,12 @@ define([ | ||||
|         ]; | ||||
|         const IMAGE_DELAY = 20000; | ||||
|  | ||||
|         function getCompassValues(min, max) { | ||||
|             return min + Math.random() * (max - min); | ||||
|         } | ||||
|  | ||||
|         function pointForTimestamp(timestamp, name) { | ||||
|             const url = IMAGE_SAMPLES[Math.floor(timestamp / IMAGE_DELAY) % IMAGE_SAMPLES.length]; | ||||
|             const urlItems = url.split('/'); | ||||
|             const imageDownloadName = `example.imagery.${urlItems[urlItems.length - 1]}`; | ||||
|  | ||||
|             return { | ||||
|                 name, | ||||
|                 name: name, | ||||
|                 utc: Math.floor(timestamp / IMAGE_DELAY) * IMAGE_DELAY, | ||||
|                 local: Math.floor(timestamp / IMAGE_DELAY) * IMAGE_DELAY, | ||||
|                 url, | ||||
|                 sunOrientation: getCompassValues(0, 360), | ||||
|                 cameraPan: getCompassValues(0, 360), | ||||
|                 heading: getCompassValues(0, 360), | ||||
|                 imageDownloadName | ||||
|                 url: IMAGE_SAMPLES[Math.floor(timestamp / IMAGE_DELAY) % IMAGE_SAMPLES.length] | ||||
|             }; | ||||
|         } | ||||
|  | ||||
| @@ -151,14 +139,6 @@ define([ | ||||
|                                 hints: { | ||||
|                                     image: 1 | ||||
|                                 } | ||||
|                             }, | ||||
|                             { | ||||
|                                 name: 'Image Download Name', | ||||
|                                 key: 'imageDownloadName', | ||||
|                                 format: 'imageDownloadName', | ||||
|                                 hints: { | ||||
|                                     imageDownloadName: 1 | ||||
|                                 } | ||||
|                             } | ||||
|                         ] | ||||
|                     }; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import Vue from 'vue'; | ||||
| import Vue from 'Vue'; | ||||
| import HelloWorld from './HelloWorld.vue'; | ||||
|  | ||||
| function SimpleVuePlugin() { | ||||
|   | ||||
| @@ -152,7 +152,7 @@ | ||||
|         <h2>How to Use Glyphs</h2> | ||||
|         <div class="cols cols1-1"> | ||||
|             <div class="col"> | ||||
|                 <p>The easiest way to use a glyph is to include its CSS class in an element. The CSS adds a pseudo <code>:before</code> HTML element to whatever element it's attached to that makes proper use of the symbols font.</p> | ||||
|                 <p>The easiest way to use a glyph is to include its CSS class in an element. The CSS adds a psuedo <code>:before</code> HTML element to whatever element it's attached to that makes proper use of the symbols font.</p> | ||||
|                 <p>Alternately, you can use the <code>.ui-symbol</code> class in an object that contains encoded HTML entities. This method is only recommended if you cannot use the aforementioned CSS class approach.</p> | ||||
|             </div> | ||||
|             <mct-example><a class="s-button icon-gear" title="Settings"></a> | ||||
|   | ||||
| @@ -88,7 +88,7 @@ | ||||
|         openmct.install(openmct.plugins.ExampleImagery()); | ||||
|         openmct.install(openmct.plugins.PlanLayout()); | ||||
|         openmct.install(openmct.plugins.Timeline()); | ||||
|         openmct.install(openmct.plugins.Hyperlink()); | ||||
|         openmct.install(openmct.plugins.PlotVue()); | ||||
|         openmct.install(openmct.plugins.UTCTimeSystem()); | ||||
|         openmct.install(openmct.plugins.AutoflowView({ | ||||
|             type: "telemetry.panel" | ||||
| @@ -195,7 +195,6 @@ | ||||
|             ['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked'], | ||||
|             {indicator: true} | ||||
|         )); | ||||
|         openmct.install(openmct.plugins.Clock({ enableClockIndicator: true })); | ||||
|         openmct.start(); | ||||
|     </script> | ||||
| </html> | ||||
|   | ||||
| @@ -23,9 +23,9 @@ | ||||
| /*global module,process*/ | ||||
|  | ||||
| const devMode = process.env.NODE_ENV !== 'production'; | ||||
| const browsers = [process.env.NODE_ENV === 'debug' ? 'ChromeDebugging' : 'ChromeHeadless']; | ||||
| const browsers = [process.env.NODE_ENV === 'debug' ? 'ChromeDebugging' : 'FirefoxHeadless']; | ||||
| const coverageEnabled = process.env.COVERAGE === 'true'; | ||||
| const reporters = ['spec', 'junit']; | ||||
| const reporters = ['progress', 'html']; | ||||
|  | ||||
| if (coverageEnabled) { | ||||
|     reporters.push('coverage-istanbul'); | ||||
| @@ -59,8 +59,7 @@ module.exports = (config) => { | ||||
|         browsers: browsers, | ||||
|         client: { | ||||
|             jasmine: { | ||||
|                 random: false, | ||||
|                 timeoutInterval: 5000 | ||||
|                 random: false | ||||
|             } | ||||
|         }, | ||||
|         customLaunchers: { | ||||
| @@ -68,47 +67,29 @@ module.exports = (config) => { | ||||
|                 base: 'Chrome', | ||||
|                 flags: ['--remote-debugging-port=9222'], | ||||
|                 debug: true | ||||
|             }, | ||||
|             FirefoxESR: { | ||||
|                 base: 'FirefoxHeadless', | ||||
|                 name: 'FirefoxESR' | ||||
|             } | ||||
|         }, | ||||
|         colors: true, | ||||
|         logLevel: config.LOG_INFO, | ||||
|         autoWatch: true, | ||||
|         // HTML test reporting. | ||||
|         // htmlReporter: { | ||||
|         //    outputDir: "dist/reports/tests", | ||||
|         //    preserveDescribeNesting: true, | ||||
|         //    foldAll: false | ||||
|         // }, | ||||
|         junitReporter: { | ||||
|         htmlReporter: { | ||||
|             outputDir: "dist/reports/tests", | ||||
|             outputFile: "test-results.xml", | ||||
|             useBrowserName: false | ||||
|             preserveDescribeNesting: true, | ||||
|             foldAll: false | ||||
|         }, | ||||
|         coverageIstanbulReporter: { | ||||
|             fixWebpackSourcePaths: true, | ||||
|             dir: process.env.CIRCLE_ARTIFACTS | ||||
|                 ? process.env.CIRCLE_ARTIFACTS + '/coverage' | ||||
|                 : "dist/reports/coverage", | ||||
|             reports: ['lcovonly', 'text-summary'], | ||||
|             dir: process.env.CIRCLE_ARTIFACTS ? | ||||
|                 process.env.CIRCLE_ARTIFACTS + '/coverage' : | ||||
|                 "dist/reports/coverage", | ||||
|             reports: ['html', 'lcovonly', 'text-summary'], | ||||
|             thresholds: { | ||||
|                 global: { | ||||
|                     lines: 66 | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         specReporter: { | ||||
|             maxLogLines: 5, | ||||
|             suppressErrorSummary: true, | ||||
|             suppressFailed: false, | ||||
|             suppressPassed: false, | ||||
|             suppressSkipped: true, | ||||
|             showSpecTiming: true, | ||||
|             failFast: false | ||||
|         }, | ||||
|         preprocessors: { | ||||
|             'indexTest.js': ['webpack', 'sourcemap'] | ||||
|         }, | ||||
|   | ||||
| @@ -1,96 +0,0 @@ | ||||
| --- | ||||
| ci: | ||||
|   collect: | ||||
|     urls: | ||||
|     - http://localhost/ | ||||
|     numberOfRuns: 5 | ||||
|     settings: | ||||
|       onlyCategories: | ||||
|       - performance | ||||
|       - best-practices | ||||
|   upload: | ||||
|     target: temporary-public-storage | ||||
|   assert: | ||||
|     preset: lighthouse:recommended | ||||
|     assertions: | ||||
|       ### Applicable assertions | ||||
|       bootup-time: | ||||
|       - warn | ||||
|       - minScore: 0.88 #Original value was calculated at 0.88 | ||||
|       dom-size:  | ||||
|       - error | ||||
|       - maxNumericValue: 200 #Original value was calculated at 188 | ||||
|       first-contentful-paint: | ||||
|       - error | ||||
|       - minScore: 0.07 #Original value was calculated at 0.08 | ||||
|       mainthread-work-breakdown: | ||||
|       - warn | ||||
|       - minScore: 0.8 #Original value was calculated at 0.8 | ||||
|       unused-javascript: | ||||
|       - warn | ||||
|       - maxLength: 1 | ||||
|       - error | ||||
|       - maxNumericValue: 2000 #Original value was calculated at 1855 | ||||
|       unused-css-rules: warn | ||||
|       installable-manifest: warn | ||||
|       service-worker: warn | ||||
|       ### Disabled seo, accessibility, and pwa assertions, below | ||||
|       categories:seo: 'off' | ||||
|       categories:accessibility: 'off' | ||||
|       categories:pwa: 'off' | ||||
|       accesskeys: 'off' | ||||
|       apple-touch-icon: 'off' | ||||
|       aria-allowed-attr: 'off' | ||||
|       aria-command-name: 'off' | ||||
|       aria-hidden-body: 'off' | ||||
|       aria-hidden-focus: 'off' | ||||
|       aria-input-field-name: 'off' | ||||
|       aria-meter-name: 'off' | ||||
|       aria-progressbar-name: 'off' | ||||
|       aria-required-attr: 'off' | ||||
|       aria-required-children: 'off' | ||||
|       aria-required-parent: 'off' | ||||
|       aria-roles: 'off' | ||||
|       aria-toggle-field-name: 'off' | ||||
|       aria-tooltip-name: 'off' | ||||
|       aria-treeitem-name: 'off' | ||||
|       aria-valid-attr: 'off' | ||||
|       aria-valid-attr-value: 'off' | ||||
|       button-name: 'off' | ||||
|       bypass: 'off' | ||||
|       canonical: 'off' | ||||
|       color-contrast: 'off' | ||||
|       content-width: 'off' | ||||
|       crawlable-anchors: 'off' | ||||
|       csp-xss: 'off' | ||||
|       font-display: 'off' | ||||
|       font-size: 'off' | ||||
|       maskable-icon: 'off' | ||||
|       heading-order: 'off' | ||||
|       hreflang: 'off' | ||||
|       html-has-lang: 'off' | ||||
|       html-lang-valid: 'off' | ||||
|       http-status-code: 'off' | ||||
|       image-alt: 'off' | ||||
|       input-image-alt: 'off' | ||||
|       is-crawlable: 'off' | ||||
|       label: 'off' | ||||
|       link-name: 'off' | ||||
|       link-text: 'off' | ||||
|       list: 'off' | ||||
|       listitem: 'off' | ||||
|       meta-description: 'off' | ||||
|       meta-refresh: 'off' | ||||
|       meta-viewport: 'off' | ||||
|       object-alt: 'off' | ||||
|       plugins: 'off' | ||||
|       robots-txt: 'off' | ||||
|       splash-screen: 'off' | ||||
|       tabindex: 'off' | ||||
|       tap-targets: 'off' | ||||
|       td-headers-attr: 'off' | ||||
|       th-has-data-cells: 'off' | ||||
|       themed-omnibox: 'off' | ||||
|       valid-lang: 'off' | ||||
|       video-caption: 'off' | ||||
|       viewport: 'off' | ||||
							
								
								
									
										38
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,9 +1,9 @@ | ||||
| { | ||||
|   "name": "openmct", | ||||
|   "version": "1.8.1-SNAPSHOT", | ||||
|   "version": "1.7.1-SNAPSHOT", | ||||
|   "description": "The Open MCT core platform", | ||||
|   "dependencies": {}, | ||||
|   "devDependencies": { | ||||
|     "@braintree/sanitize-url": "^5.0.2", | ||||
|     "angular": ">=1.8.0", | ||||
|     "angular-route": "1.4.14", | ||||
|     "babel-eslint": "10.0.3", | ||||
| @@ -12,9 +12,16 @@ | ||||
|     "copy-webpack-plugin": "^4.5.2", | ||||
|     "cross-env": "^6.0.3", | ||||
|     "css-loader": "^1.0.0", | ||||
|     "d3-array": "1.2.x", | ||||
|     "d3-axis": "1.0.x", | ||||
|     "d3-collection": "1.0.x", | ||||
|     "d3-color": "1.0.x", | ||||
|     "d3-format": "1.2.x", | ||||
|     "d3-interpolate": "1.1.x", | ||||
|     "d3-scale": "1.0.x", | ||||
|     "d3-selection": "1.3.x", | ||||
|     "d3-time": "1.0.x", | ||||
|     "d3-time-format": "2.1.x", | ||||
|     "eslint": "7.0.0", | ||||
|     "eslint-plugin-vue": "^7.5.0", | ||||
|     "eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0", | ||||
| @@ -27,21 +34,20 @@ | ||||
|     "git-rev-sync": "^1.4.0", | ||||
|     "glob": ">= 3.0.0", | ||||
|     "html-loader": "^0.5.5", | ||||
|     "html2canvas": "^1.0.0-rc.7", | ||||
|     "html2canvas": "^1.0.0-alpha.12", | ||||
|     "imports-loader": "^0.8.0", | ||||
|     "istanbul-instrumenter-loader": "^3.0.1", | ||||
|     "jasmine-core": "^3.7.1", | ||||
|     "jasmine-core": "^3.1.0", | ||||
|     "jsdoc": "^3.3.2", | ||||
|     "karma": "6.3.4", | ||||
|     "karma": "5.1.1", | ||||
|     "karma-chrome-launcher": "3.1.0", | ||||
|     "karma-firefox-launcher": "1.3.0", | ||||
|     "karma-cli": "2.0.0", | ||||
|     "karma-coverage": "2.0.3", | ||||
|     "karma-coverage-istanbul-reporter": "3.0.3", | ||||
|     "karma-firefox-launcher": "2.1.1", | ||||
|     "karma-jasmine": "4.0.1", | ||||
|     "karma-junit-reporter": "2.0.1", | ||||
|     "karma-sourcemap-loader": "0.3.8", | ||||
|     "karma-spec-reporter": "0.0.32", | ||||
|     "karma-html-reporter": "0.2.7", | ||||
|     "karma-jasmine": "3.3.1", | ||||
|     "karma-sourcemap-loader": "0.3.7", | ||||
|     "karma-webpack": "4.0.2", | ||||
|     "location-bar": "^3.0.1", | ||||
|     "lodash": "^4.17.12", | ||||
| @@ -54,9 +60,7 @@ | ||||
|     "moment-timezone": "0.5.28", | ||||
|     "node-bourbon": "^4.2.3", | ||||
|     "node-sass": "^4.14.1", | ||||
|     "painterro": "^1.2.56", | ||||
|     "plotly.js-basic-dist": "^2.5.0", | ||||
|     "plotly.js-gl2d-dist": "^2.5.0", | ||||
|     "painterro": "^1.0.35", | ||||
|     "printj": "^1.2.1", | ||||
|     "raw-loader": "^0.5.1", | ||||
|     "request": "^2.69.0", | ||||
| @@ -65,7 +69,6 @@ | ||||
|     "uuid": "^3.3.3", | ||||
|     "v8-compile-cache": "^1.1.0", | ||||
|     "vue": "2.5.6", | ||||
|     "vue-eslint-parser": "7.11.0", | ||||
|     "vue-loader": "^15.2.6", | ||||
|     "vue-template-compiler": "2.5.6", | ||||
|     "webpack": "^4.16.2", | ||||
| @@ -75,8 +78,7 @@ | ||||
|     "zepto": "^1.2.0" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "clean": "rm -rf ./dist /node_modules; rm package-lock.json", | ||||
|     "clean-test-lint": "npm run clean; npm install ; npm run test; npm run lint", | ||||
|     "clean": "rm -rf ./dist", | ||||
|     "start": "node app.js", | ||||
|     "lint": "eslint platform example src --ext .js,.vue openmct.js", | ||||
|     "lint:fix": "eslint platform example src --ext .js,.vue openmct.js --fix", | ||||
| @@ -86,7 +88,6 @@ | ||||
|     "test": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --single-run", | ||||
|     "test:debug": "cross-env NODE_ENV=debug karma start --no-single-run", | ||||
|     "test:coverage": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" COVERAGE=true karma start --single-run", | ||||
|     "test:coverage:firefox": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --single-run --browsers=FirefoxHeadless", | ||||
|     "test:watch": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --no-single-run", | ||||
|     "verify": "concurrently 'npm:test' 'npm:lint'", | ||||
|     "jsdoc": "jsdoc -c jsdoc.json -R API.md -r -d dist/docs/api", | ||||
| @@ -98,9 +99,6 @@ | ||||
|     "type": "git", | ||||
|     "url": "https://github.com/nasa/openmct.git" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": ">=10.10.2 <16.0.0" | ||||
|   }, | ||||
|   "author": "", | ||||
|   "license": "Apache-2.0", | ||||
|   "private": true | ||||
|   | ||||
| @@ -24,6 +24,7 @@ define([ | ||||
|     "./src/navigation/NavigationService", | ||||
|     "./src/navigation/NavigateAction", | ||||
|     "./src/navigation/OrphanNavigationHandler", | ||||
|     "./src/windowing/NewTabAction", | ||||
|     "./res/templates/browse.html", | ||||
|     "./res/templates/browse-object.html", | ||||
|     "./res/templates/browse/object-header.html", | ||||
| @@ -36,6 +37,7 @@ define([ | ||||
|     NavigationService, | ||||
|     NavigateAction, | ||||
|     OrphanNavigationHandler, | ||||
|     NewTabAction, | ||||
|     browseTemplate, | ||||
|     browseObjectTemplate, | ||||
|     objectHeaderTemplate, | ||||
| @@ -126,6 +128,23 @@ define([ | ||||
|                         "depends": [ | ||||
|                             "navigationService" | ||||
|                         ] | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "window", | ||||
|                         "name": "Open In New Tab", | ||||
|                         "implementation": NewTabAction, | ||||
|                         "description": "Open in a new browser tab", | ||||
|                         "category": [ | ||||
|                             "view-control", | ||||
|                             "contextual" | ||||
|                         ], | ||||
|                         "depends": [ | ||||
|                             "urlService", | ||||
|                             "$window" | ||||
|                         ], | ||||
|                         "group": "windowing", | ||||
|                         "priority": 10, | ||||
|                         "cssClass": "icon-new-window" | ||||
|                     } | ||||
|                 ], | ||||
|                 "runs": [ | ||||
|   | ||||
| @@ -64,7 +64,7 @@ define( | ||||
|          * | ||||
|          * @param {DomainObject} domainObject the domain object to navigate to | ||||
|          * @param {Boolean} force if true, force navigation to occur. | ||||
|          * @returns {Boolean} true if navigation occurred, otherwise false. | ||||
|          * @returns {Boolean} true if navigation occured, otherwise false. | ||||
|          */ | ||||
|         NavigationService.prototype.setNavigation = function (domainObject, force) { | ||||
|             if (force) { | ||||
|   | ||||
| @@ -20,40 +20,39 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| import HyperlinkLayout from './HyperlinkLayout.vue'; | ||||
| import Vue from 'vue'; | ||||
| /** | ||||
|  * Module defining NewTabAction (Originally NewWindowAction). Created by vwoeltje on 11/18/14. | ||||
|  */ | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|         /** | ||||
|          * The new tab action allows a domain object to be opened | ||||
|          * into a new browser tab. | ||||
|          * @memberof platform/commonUI/browse | ||||
|          * @constructor | ||||
|          * @implements {Action} | ||||
|          */ | ||||
|         function NewTabAction(urlService, $window, context) { | ||||
|             context = context || {}; | ||||
| 
 | ||||
| export default function HyperlinkProvider(openmct) { | ||||
| 
 | ||||
|     return { | ||||
|         key: 'hyperlink.view', | ||||
|         name: 'Hyperlink', | ||||
|         cssClass: 'icon-chain-links', | ||||
|         canView(domainObject) { | ||||
|             return domainObject.type === 'hyperlink'; | ||||
|         }, | ||||
| 
 | ||||
|         view: function (domainObject) { | ||||
|             let component; | ||||
| 
 | ||||
|             return { | ||||
|                 show: function (element) { | ||||
|                     component = new Vue({ | ||||
|                         el: element, | ||||
|                         components: { | ||||
|                             HyperlinkLayout | ||||
|                         }, | ||||
|                         provide: { | ||||
|                             domainObject | ||||
|                         }, | ||||
|                         template: '<hyperlink-layout></hyperlink-layout>' | ||||
|                     }); | ||||
|                 }, | ||||
|                 destroy: function () { | ||||
|                     component.$destroy(); | ||||
|                     component = undefined; | ||||
|                 } | ||||
|             this.urlService = urlService; | ||||
|             this.open = function () { | ||||
|                 arguments[0] += "&hideTree=true&hideInspector=true"; | ||||
|                 $window.open.apply($window, arguments); | ||||
|             }; | ||||
| 
 | ||||
|             // Choose the object to be opened into a new tab
 | ||||
|             this.domainObject = context.selectedObject || context.domainObject; | ||||
|         } | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|         NewTabAction.prototype.perform = function () { | ||||
|             this.open( | ||||
|                 this.urlService.urlForNewTab("browse", this.domainObject), | ||||
|                 "_blank" | ||||
|             ); | ||||
|         }; | ||||
| 
 | ||||
|         return NewTabAction; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										75
									
								
								platform/commonUI/browse/test/windowing/NewTabActionSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								platform/commonUI/browse/test/windowing/NewTabActionSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/windowing/NewTabAction"], | ||||
|     function (NewTabAction) { | ||||
|  | ||||
|         describe("The new tab action", function () { | ||||
|             var actionSelected, | ||||
|                 actionCurrent, | ||||
|                 mockWindow, | ||||
|                 mockContextCurrent, | ||||
|                 mockContextSelected, | ||||
|                 mockUrlService; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockWindow = jasmine.createSpyObj("$window", ["open", "location"]); | ||||
|  | ||||
|                 // Context if the current object is selected | ||||
|                 // For example, when the top right new tab | ||||
|                 // button is clicked, the user is using the | ||||
|                 // current domainObject | ||||
|                 mockContextCurrent = jasmine.createSpyObj("context", ["domainObject"]); | ||||
|  | ||||
|                 // Context if the selected object is selected | ||||
|                 // For example, when an object in the left | ||||
|                 // tree is opened in a new tab using the | ||||
|                 // context menu | ||||
|                 mockContextSelected = jasmine.createSpyObj("context", ["selectedObject", | ||||
|                     "domainObject"]); | ||||
|  | ||||
|                 // Mocks the urlService used to make the new tab's url from a | ||||
|                 // domainObject and mode | ||||
|                 mockUrlService = jasmine.createSpyObj("urlService", ["urlForNewTab"]); | ||||
|  | ||||
|                 // Action done using the current context or mockContextCurrent | ||||
|                 actionCurrent = new NewTabAction(mockUrlService, mockWindow, | ||||
|                     mockContextCurrent); | ||||
|  | ||||
|                 // Action done using the selected context or mockContextSelected | ||||
|                 actionSelected = new NewTabAction(mockUrlService, mockWindow, | ||||
|                     mockContextSelected); | ||||
|  | ||||
|             }); | ||||
|  | ||||
|             it("new tab with current url is opened", function () { | ||||
|                 actionCurrent.perform(); | ||||
|             }); | ||||
|  | ||||
|             it("new tab with a selected url is opened", function () { | ||||
|                 actionSelected.perform(); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -34,6 +34,9 @@ define([ | ||||
|     "./src/policies/EditPersistableObjectsPolicy", | ||||
|     "./src/representers/EditRepresenter", | ||||
|     "./src/capabilities/EditorCapability", | ||||
|     "./src/capabilities/TransactionCapabilityDecorator", | ||||
|     "./src/services/TransactionManager", | ||||
|     "./src/services/TransactionService", | ||||
|     "./src/creation/CreateMenuController", | ||||
|     "./src/creation/LocatorController", | ||||
|     "./src/creation/CreationPolicy", | ||||
| @@ -60,6 +63,9 @@ define([ | ||||
|     EditPersistableObjectsPolicy, | ||||
|     EditRepresenter, | ||||
|     EditorCapability, | ||||
|     TransactionCapabilityDecorator, | ||||
|     TransactionManager, | ||||
|     TransactionService, | ||||
|     CreateMenuController, | ||||
|     LocatorController, | ||||
|     CreationPolicy, | ||||
| @@ -257,6 +263,26 @@ define([ | ||||
|                     } | ||||
|                 ], | ||||
|                 "components": [ | ||||
|                     { | ||||
|                         "type": "decorator", | ||||
|                         "provides": "capabilityService", | ||||
|                         "implementation": TransactionCapabilityDecorator, | ||||
|                         "depends": [ | ||||
|                             "$q", | ||||
|                             "transactionManager" | ||||
|                         ], | ||||
|                         "priority": "fallback" | ||||
|                     }, | ||||
|                     { | ||||
|                         "type": "provider", | ||||
|                         "provides": "transactionService", | ||||
|                         "implementation": TransactionService, | ||||
|                         "depends": [ | ||||
|                             "$q", | ||||
|                             "$log", | ||||
|                             "cacheService" | ||||
|                         ] | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "CreateActionProvider", | ||||
|                         "provides": "actionService", | ||||
| @@ -294,6 +320,7 @@ define([ | ||||
|                         "description": "Provides transactional editing capabilities", | ||||
|                         "implementation": EditorCapability, | ||||
|                         "depends": [ | ||||
|                             "transactionService", | ||||
|                             "openmct" | ||||
|                         ] | ||||
|                     } | ||||
| @@ -304,6 +331,15 @@ define([ | ||||
|                         "template": locatorTemplate | ||||
|                     } | ||||
|                 ], | ||||
|                 "services": [ | ||||
|                     { | ||||
|                         "key": "transactionManager", | ||||
|                         "implementation": TransactionManager, | ||||
|                         "depends": [ | ||||
|                             "transactionService" | ||||
|                         ] | ||||
|                     } | ||||
|                 ], | ||||
|                 "runs": [ | ||||
|                     { | ||||
|                         depends: [ | ||||
|   | ||||
| @@ -96,7 +96,8 @@ function ( | ||||
|     SaveAsAction.prototype.save = function () { | ||||
|         var self = this, | ||||
|             domainObject = this.domainObject, | ||||
|             dialog = new SaveInProgressDialog(this.dialogService); | ||||
|             dialog = new SaveInProgressDialog(this.dialogService), | ||||
|             toUndirty = []; | ||||
|  | ||||
|         function doWizardSave(parent) { | ||||
|             var wizard = self.createWizard(parent); | ||||
| @@ -131,14 +132,11 @@ function ( | ||||
|             return fetchObject(object.getModel().location); | ||||
|         } | ||||
|  | ||||
|         function saveObject(object) { | ||||
|             //persist the object, which adds it to the transaction and then call editor.save | ||||
|             return object.getCapability("persistence").persist() | ||||
|                 .then(() => { | ||||
|                     return self.openmct.editor.save().then(() => { | ||||
|                         return object; | ||||
|                     }); | ||||
|                 }); | ||||
|         function saveObject(parent) { | ||||
|             return self.openmct.editor.save().then(() => { | ||||
|                 // Force mutation for search indexing | ||||
|                 return parent; | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function addSavedObjectToParent(parent) { | ||||
| @@ -152,6 +150,17 @@ function ( | ||||
|                 }); | ||||
|         } | ||||
|  | ||||
|         function undirty(object) { | ||||
|             return object.getCapability('persistence').refresh(); | ||||
|         } | ||||
|  | ||||
|         function undirtyOriginals(object) { | ||||
|             return Promise.all(toUndirty.map(undirty)) | ||||
|                 .then(() => { | ||||
|                     return object; | ||||
|                 }); | ||||
|         } | ||||
|  | ||||
|         function indexForSearch(addedObject) { | ||||
|             addedObject.useCapability('mutation', (model) => { | ||||
|                 return model; | ||||
| @@ -178,9 +187,10 @@ function ( | ||||
|         return getParent(domainObject) | ||||
|             .then(doWizardSave) | ||||
|             .then(showBlockingDialog) | ||||
|             .then(saveObject) | ||||
|             .then(getParent) | ||||
|             .then(saveObject) | ||||
|             .then(addSavedObjectToParent) | ||||
|             .then(undirtyOriginals) | ||||
|             .then((addedObject) => { | ||||
|                 return fetchObject(addedObject.getId()); | ||||
|             }) | ||||
|   | ||||
| @@ -30,17 +30,34 @@ define( | ||||
|          * Once initiated, any persist operations will be queued pending a | ||||
|          * subsequent call to [.save()](@link #save) or [.finish()](@link | ||||
|          * #finish). | ||||
|          * @param transactionService | ||||
|          * @param domainObject | ||||
|          * @constructor | ||||
|          */ | ||||
|         function EditorCapability( | ||||
|             transactionService, | ||||
|             openmct, | ||||
|             domainObject | ||||
|         ) { | ||||
|             this.transactionService = transactionService; | ||||
|             this.openmct = openmct; | ||||
|             this.domainObject = domainObject; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Initiate an editing session. This will start a transaction during | ||||
|          * which any persist operations will be deferred until either save() | ||||
|          * or finish() are called. | ||||
|          */ | ||||
|         EditorCapability.prototype.edit = function () { | ||||
|             console.warn('DEPRECATED: cannot edit via edit capability, use openmct.editor instead.'); | ||||
|  | ||||
|             if (!this.openmct.editor.isEditing()) { | ||||
|                 this.openmct.editor.edit(); | ||||
|                 this.domainObject.getCapability('status').set('editing', true); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Determines whether this object, or any of its ancestors are | ||||
|          * currently being edited. | ||||
| @@ -59,6 +76,38 @@ define( | ||||
|             return this.openmct.editor.isEditing(); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Save any unsaved changes from this editing session. This will | ||||
|          * end the current transaction and continue with a new one. | ||||
|          * @returns {*} | ||||
|          */ | ||||
|         EditorCapability.prototype.save = function () { | ||||
|             console.warn('DEPRECATED: cannot save via edit capability, use openmct.editor instead.'); | ||||
|  | ||||
|             return Promise.resolve(); | ||||
|         }; | ||||
|  | ||||
|         EditorCapability.prototype.invoke = EditorCapability.prototype.edit; | ||||
|  | ||||
|         /** | ||||
|          * Finish the current editing session. This will discard any pending | ||||
|          * persist operations | ||||
|          * @returns {*} | ||||
|          */ | ||||
|         EditorCapability.prototype.finish = function () { | ||||
|             console.warn('DEPRECATED: cannot finish via edit capability, use openmct.editor instead.'); | ||||
|  | ||||
|             return Promise.resolve(); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * @returns {boolean} true if there have been any domain model | ||||
|          * modifications since the last persist, false otherwise. | ||||
|          */ | ||||
|         EditorCapability.prototype.dirty = function () { | ||||
|             return this.transactionService.size() > 0; | ||||
|         }; | ||||
|  | ||||
|         return EditorCapability; | ||||
|     } | ||||
| ); | ||||
|   | ||||
| @@ -0,0 +1,75 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ['./TransactionalPersistenceCapability'], | ||||
|     function (TransactionalPersistenceCapability) { | ||||
|  | ||||
|         /** | ||||
|          * Wraps the [PersistenceCapability]{@link PersistenceCapability} with | ||||
|          * transactional capabilities. | ||||
|          * @param $q | ||||
|          * @param transactionService | ||||
|          * @param capabilityService | ||||
|          * @see TransactionalPersistenceCapability | ||||
|          * @constructor | ||||
|          */ | ||||
|         function TransactionCapabilityDecorator( | ||||
|             $q, | ||||
|             transactionService, | ||||
|             capabilityService | ||||
|         ) { | ||||
|             this.capabilityService = capabilityService; | ||||
|             this.transactionService = transactionService; | ||||
|             this.$q = $q; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Decorate PersistenceCapability to queue persistence calls when a | ||||
|          * transaction is in progress. | ||||
|          */ | ||||
|         TransactionCapabilityDecorator.prototype.getCapabilities = function () { | ||||
|             var self = this, | ||||
|                 capabilities = this.capabilityService.getCapabilities | ||||
|                     .apply(this.capabilityService, arguments), | ||||
|                 persistenceCapability = capabilities.persistence; | ||||
|  | ||||
|             capabilities.persistence = function (domainObject) { | ||||
|                 var original = | ||||
|                     (typeof persistenceCapability === 'function') | ||||
|                         ? persistenceCapability(domainObject) | ||||
|                         : persistenceCapability; | ||||
|  | ||||
|                 return new TransactionalPersistenceCapability( | ||||
|                     self.$q, | ||||
|                     self.transactionService, | ||||
|                     original, | ||||
|                     domainObject | ||||
|                 ); | ||||
|             }; | ||||
|  | ||||
|             return capabilities; | ||||
|         }; | ||||
|  | ||||
|         return TransactionCapabilityDecorator; | ||||
|     } | ||||
| ); | ||||
| @@ -0,0 +1,91 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|  | ||||
|         /** | ||||
|          * Wraps persistence capability to enable transactions. Transactions | ||||
|          * will cause persist calls not to be invoked immediately, but | ||||
|          * rather queued until [EditorCapability.save()]{@link EditorCapability#save} | ||||
|          * or [EditorCapability.cancel()]{@link EditorCapability#cancel} are | ||||
|          * called. | ||||
|          * @memberof platform/commonUI/edit/capabilities | ||||
|          * @param $q | ||||
|          * @param transactionManager | ||||
|          * @param persistenceCapability | ||||
|          * @param domainObject | ||||
|          * @constructor | ||||
|          */ | ||||
|         function TransactionalPersistenceCapability( | ||||
|             $q, | ||||
|             transactionManager, | ||||
|             persistenceCapability, | ||||
|             domainObject | ||||
|         ) { | ||||
|             this.transactionManager = transactionManager; | ||||
|             this.persistenceCapability = persistenceCapability; | ||||
|             this.domainObject = domainObject; | ||||
|             this.$q = $q; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * The wrapped persist function. If a transaction is active, persist | ||||
|          * will be queued until the transaction is committed or cancelled. | ||||
|          * @returns {*} | ||||
|          */ | ||||
|         TransactionalPersistenceCapability.prototype.persist = function () { | ||||
|             var wrappedPersistence = this.persistenceCapability; | ||||
|  | ||||
|             if (this.transactionManager.isActive()) { | ||||
|                 this.transactionManager.addToTransaction( | ||||
|                     this.domainObject.getId(), | ||||
|                     wrappedPersistence.persist.bind(wrappedPersistence), | ||||
|                     wrappedPersistence.refresh.bind(wrappedPersistence) | ||||
|                 ); | ||||
|  | ||||
|                 //Need to return a promise from this function | ||||
|                 return this.$q.when(true); | ||||
|             } else { | ||||
|                 return this.persistenceCapability.persist(); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         TransactionalPersistenceCapability.prototype.refresh = function () { | ||||
|             this.transactionManager | ||||
|                 .clearTransactionsFor(this.domainObject.getId()); | ||||
|  | ||||
|             return this.persistenceCapability.refresh(); | ||||
|         }; | ||||
|  | ||||
|         TransactionalPersistenceCapability.prototype.getSpace = function () { | ||||
|             return this.persistenceCapability.getSpace(); | ||||
|         }; | ||||
|  | ||||
|         TransactionalPersistenceCapability.prototype.persisted = function () { | ||||
|             return this.persistenceCapability.persisted(); | ||||
|         }; | ||||
|  | ||||
|         return TransactionalPersistenceCapability; | ||||
|     } | ||||
| ); | ||||
| @@ -86,7 +86,7 @@ define( | ||||
|                         }) | ||||
|                         .join('/'); | ||||
|  | ||||
|                 openmct.router.navigate(url); | ||||
|                 window.location.href = url; | ||||
|  | ||||
|                 if (isFirstViewEditable(object.useCapability('adapter'), objectPath)) { | ||||
|                     openmct.editor.edit(); | ||||
|   | ||||
| @@ -19,35 +19,31 @@ | ||||
|  * this source code distribution or the Licensing information page available | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| import { BAR_GRAPH_KEY } from './BarGraphConstants'; | ||||
| 
 | ||||
| export default function BarGraphCompositionPolicy(openmct) { | ||||
|     function hasRange(metadata) { | ||||
|         const rangeValues = metadata.valuesForHints(['range']); | ||||
| 
 | ||||
|         return rangeValues.length > 0; | ||||
| define(['./Transaction'], function (Transaction) { | ||||
|     /** | ||||
|      * A nested transaction is a transaction which takes place in the context | ||||
|      * of a larger parent transaction. It becomes part of the parent | ||||
|      * transaction when (and only when) committed. | ||||
|      * @param parent | ||||
|      * @constructor | ||||
|      * @extends {platform/commonUI/edit/services.Transaction} | ||||
|      * @memberof platform/commonUI/edit/services | ||||
|      */ | ||||
|     function NestedTransaction(parent) { | ||||
|         this.parent = parent; | ||||
|         Transaction.call(this, parent.$log); | ||||
|     } | ||||
| 
 | ||||
|     function hasBarGraphTelemetry(domainObject) { | ||||
|         if (!openmct.telemetry.isTelemetryObject(domainObject)) { | ||||
|             return false; | ||||
|         } | ||||
|     NestedTransaction.prototype = Object.create(Transaction.prototype); | ||||
| 
 | ||||
|         let metadata = openmct.telemetry.getMetadata(domainObject); | ||||
|     NestedTransaction.prototype.commit = function () { | ||||
|         this.parent.add( | ||||
|             Transaction.prototype.commit.bind(this), | ||||
|             Transaction.prototype.cancel.bind(this) | ||||
|         ); | ||||
| 
 | ||||
|         return metadata.values().length > 0 && hasRange(metadata); | ||||
|     } | ||||
| 
 | ||||
|     return { | ||||
|         allow: function (parent, child) { | ||||
|             if ((parent.type === BAR_GRAPH_KEY) | ||||
|                 && (hasBarGraphTelemetry(child) === false) | ||||
|             ) { | ||||
|                 return false; | ||||
|             } | ||||
| 
 | ||||
|             return true; | ||||
|         } | ||||
|         return Promise.resolve(true); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|     return NestedTransaction; | ||||
| }); | ||||
							
								
								
									
										99
									
								
								platform/commonUI/edit/src/services/Transaction.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								platform/commonUI/edit/src/services/Transaction.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
| define([], function () { | ||||
|     /** | ||||
|      * A Transaction represents a set of changes that are intended to | ||||
|      * be kept or discarded as a unit. | ||||
|      * @param $log Angular's `$log` service, for logging messages | ||||
|      * @constructor | ||||
|      * @memberof platform/commonUI/edit/services | ||||
|      */ | ||||
|     function Transaction($log) { | ||||
|         this.$log = $log; | ||||
|         this.callbacks = []; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Add a change to the current transaction, as expressed by functions | ||||
|      * to either keep or discard the change. | ||||
|      * @param {Function} commit called when the transaction is committed | ||||
|      * @param {Function} cancel called when the transaction is cancelled | ||||
|      * @returns {Function) a function which may be called to remove this | ||||
|      *          pair of callbacks from the transaction | ||||
|      */ | ||||
|     Transaction.prototype.add = function (commit, cancel) { | ||||
|         var callback = { | ||||
|             commit: commit, | ||||
|             cancel: cancel | ||||
|         }; | ||||
|         this.callbacks.push(callback); | ||||
|  | ||||
|         return function () { | ||||
|             this.callbacks = this.callbacks.filter(function (c) { | ||||
|                 return c !== callback; | ||||
|             }); | ||||
|         }.bind(this); | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Get the number of changes in the current transaction. | ||||
|      * @returns {number} the size of the current transaction | ||||
|      */ | ||||
|     Transaction.prototype.size = function () { | ||||
|         return this.callbacks.length; | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Keep all changes associated with this transaction. | ||||
|      * @method {platform/commonUI/edit/services.Transaction#commit} | ||||
|      * @returns {Promise} a promise which will resolve when all callbacks | ||||
|      *          have been handled. | ||||
|      */ | ||||
|  | ||||
|     /** | ||||
|      * Discard all changes associated with this transaction. | ||||
|      * @method {platform/commonUI/edit/services.Transaction#cancel} | ||||
|      * @returns {Promise} a promise which will resolve when all callbacks | ||||
|      *          have been handled. | ||||
|      */ | ||||
|  | ||||
|     ['commit', 'cancel'].forEach(function (method) { | ||||
|         Transaction.prototype[method] = function () { | ||||
|             var promises = []; | ||||
|             var callback; | ||||
|  | ||||
|             while (this.callbacks.length > 0) { | ||||
|                 callback = this.callbacks.shift(); | ||||
|                 try { | ||||
|                     promises.push(callback[method]()); | ||||
|                 } catch (e) { | ||||
|                     this.$log | ||||
|                         .error("Error trying to " + method + " transaction."); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return Promise.all(promises); | ||||
|         }; | ||||
|     }); | ||||
|  | ||||
|     return Transaction; | ||||
| }); | ||||
							
								
								
									
										119
									
								
								platform/commonUI/edit/src/services/TransactionManager.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								platform/commonUI/edit/src/services/TransactionManager.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,119 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([], function () { | ||||
|     /** | ||||
|      * Manages transactions to support the TransactionalPersistenceCapability. | ||||
|      * This assumes that all commit/cancel callbacks for a given domain | ||||
|      * object are equivalent, and only need to be added once to any active | ||||
|      * transaction. Violating this assumption may cause unexpected behavior. | ||||
|      * @constructor | ||||
|      * @memberof platform/commonUI/edit | ||||
|      */ | ||||
|     function TransactionManager(transactionService) { | ||||
|         this.transactionService = transactionService; | ||||
|         this.clearTransactionFns = {}; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Check if a transaction is currently active. | ||||
|      * @returns {boolean} true if there is a transaction active | ||||
|      */ | ||||
|     TransactionManager.prototype.isActive = function () { | ||||
|         return this.transactionService.isActive(); | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Check if callbacks associated with this domain object have already | ||||
|      * been added to the active transaction. | ||||
|      * @private | ||||
|      * @param {string} id the identifier of the domain object to check | ||||
|      * @returns {boolean} true if callbacks have been added | ||||
|      */ | ||||
|     TransactionManager.prototype.isScheduled = function (id) { | ||||
|         return Boolean(this.clearTransactionFns[id]); | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Add callbacks associated with this domain object to the active | ||||
|      * transaction. Both callbacks are expected to return promises that | ||||
|      * resolve when their associated behavior is complete. | ||||
|      * | ||||
|      * If callbacks associated with this domain object have already been | ||||
|      * added to the active transaction, this call will be ignored. | ||||
|      * | ||||
|      * @param {string} id the identifier of the associated domain object | ||||
|      * @param {Function} onCommit behavior to invoke when committing transaction | ||||
|      * @param {Function} onCancel behavior to invoke when cancelling transaction | ||||
|      */ | ||||
|     TransactionManager.prototype.addToTransaction = function ( | ||||
|         id, | ||||
|         onCommit, | ||||
|         onCancel | ||||
|     ) { | ||||
|         var release = this.releaseClearFn.bind(this, id); | ||||
|  | ||||
|         function chain(promiseFn, nextFn) { | ||||
|             return function () { | ||||
|                 return promiseFn().then(nextFn); | ||||
|             }; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Clear any existing persistence calls for object with given ID. This ensures only the most recent persistence | ||||
|          * call is executed. This should prevent stale objects being persisted and overwriting fresh ones. | ||||
|          */ | ||||
|         if (this.isScheduled(id)) { | ||||
|             this.clearTransactionsFor(id); | ||||
|         } | ||||
|  | ||||
|         this.clearTransactionFns[id] = | ||||
|             this.transactionService.addToTransaction( | ||||
|                 chain(onCommit, release), | ||||
|                 chain(onCancel, release) | ||||
|             ); | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Remove any callbacks associated with this domain object from the | ||||
|      * active transaction. | ||||
|      * @param {string} id the identifier for the domain object | ||||
|      */ | ||||
|     TransactionManager.prototype.clearTransactionsFor = function (id) { | ||||
|         if (this.isScheduled(id)) { | ||||
|             this.clearTransactionFns[id](); | ||||
|             this.releaseClearFn(id); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Release the cached "remove from transaction" function that has been | ||||
|      * stored in association with this domain object. | ||||
|      * @param {string} id the identifier for the domain object | ||||
|      * @private | ||||
|      */ | ||||
|     TransactionManager.prototype.releaseClearFn = function (id) { | ||||
|         delete this.clearTransactionFns[id]; | ||||
|     }; | ||||
|  | ||||
|     return TransactionManager; | ||||
| }); | ||||
							
								
								
									
										138
									
								
								platform/commonUI/edit/src/services/TransactionService.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								platform/commonUI/edit/src/services/TransactionService.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,138 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
| define( | ||||
|     ['./Transaction', './NestedTransaction'], | ||||
|     function (Transaction, NestedTransaction) { | ||||
|         /** | ||||
|          * Implements an application-wide transaction state. Once a | ||||
|          * transaction is started, calls to | ||||
|          * [PersistenceCapability.persist()]{@link PersistenceCapability#persist} | ||||
|          * will be deferred until a subsequent call to | ||||
|          * [TransactionService.commit]{@link TransactionService#commit} is made. | ||||
|          * | ||||
|          * @memberof platform/commonUI/edit/services | ||||
|          * @param $q | ||||
|          * @constructor | ||||
|          */ | ||||
|         function TransactionService($q, $log, cacheService) { | ||||
|             this.$q = $q; | ||||
|             this.$log = $log; | ||||
|             this.cacheService = cacheService; | ||||
|             this.transactions = []; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Starts a transaction. While a transaction is active all calls to | ||||
|          * [PersistenceCapability.persist](@link PersistenceCapability#persist) | ||||
|          * will be queued until [commit]{@link #commit} or [cancel]{@link | ||||
|          * #cancel} are called | ||||
|          */ | ||||
|         TransactionService.prototype.startTransaction = function () { | ||||
|             var transaction = this.isActive() | ||||
|                 ? new NestedTransaction(this.transactions[0]) | ||||
|                 : new Transaction(this.$log); | ||||
|  | ||||
|             this.transactions.push(transaction); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * @returns {boolean} If true, indicates that a transaction is in progress | ||||
|          */ | ||||
|         TransactionService.prototype.isActive = function () { | ||||
|             return this.transactions.length > 0; | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Adds provided functions to a queue to be called on | ||||
|          * [.commit()]{@link #commit} or | ||||
|          * [.cancel()]{@link #commit} | ||||
|          * @param onCommit A function to call on commit | ||||
|          * @param onCancel A function to call on cancel | ||||
|          */ | ||||
|         TransactionService.prototype.addToTransaction = function (onCommit, onCancel) { | ||||
|             if (this.isActive()) { | ||||
|                 return this.activeTransaction().add(onCommit, onCancel); | ||||
|             } else { | ||||
|                 //Log error because this is a programming error if it occurs. | ||||
|                 this.$log.error("No transaction in progress"); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Get the transaction at the top of the stack. | ||||
|          * @private | ||||
|          */ | ||||
|         TransactionService.prototype.activeTransaction = function () { | ||||
|             return this.transactions[this.transactions.length - 1]; | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * All persist calls deferred since the beginning of the transaction | ||||
|          * will be committed.  If this is the last transaction, clears the | ||||
|          * cache. | ||||
|          * | ||||
|          * @returns {Promise} resolved when all persist operations have | ||||
|          * completed. Will reject if any commit operations fail | ||||
|          */ | ||||
|         TransactionService.prototype.commit = function () { | ||||
|             var transaction = this.transactions.pop(); | ||||
|             if (!transaction) { | ||||
|                 return Promise.reject(); | ||||
|             } | ||||
|  | ||||
|             if (!this.isActive()) { | ||||
|                 return transaction.commit() | ||||
|                     .then(function (r) { | ||||
|                         this.cacheService.flush(); | ||||
|  | ||||
|                         return r; | ||||
|                     }.bind(this)); | ||||
|             } | ||||
|  | ||||
|             return transaction.commit(); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Cancel the current transaction, replacing any dirty objects from | ||||
|          * persistence. Not a true rollback, as it cannot be used to undo any | ||||
|          * persist calls that were successful in the event one of a batch of | ||||
|          * persists failing. | ||||
|          * | ||||
|          * @returns {*} | ||||
|          */ | ||||
|         TransactionService.prototype.cancel = function () { | ||||
|             var transaction = this.transactions.pop(); | ||||
|  | ||||
|             return transaction ? transaction.cancel() : Promise.reject(); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Get the size (the number of commit/cancel callbacks) of | ||||
|          * the active transaction. | ||||
|          * @returns {number} size of the active transaction | ||||
|          */ | ||||
|         TransactionService.prototype.size = function () { | ||||
|             return this.isActive() ? this.activeTransaction().size() : 0; | ||||
|         }; | ||||
|  | ||||
|         return TransactionService; | ||||
|     }); | ||||
							
								
								
									
										192
									
								
								platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,192 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/capabilities/EditorCapability"], | ||||
|     function (EditorCapability) { | ||||
|  | ||||
|         xdescribe("The editor capability", function () { | ||||
|             var mockDomainObject, | ||||
|                 capabilities, | ||||
|                 mockParentObject, | ||||
|                 mockTransactionService, | ||||
|                 mockStatusCapability, | ||||
|                 mockParentStatus, | ||||
|                 mockContextCapability, | ||||
|                 capability; | ||||
|  | ||||
|             function fastPromise(val) { | ||||
|                 return { | ||||
|                     then: function (callback) { | ||||
|                         return callback(val); | ||||
|                     } | ||||
|                 }; | ||||
|             } | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockDomainObject = jasmine.createSpyObj( | ||||
|                     "domainObject", | ||||
|                     ["getId", "getModel", "hasCapability", "getCapability", "useCapability"] | ||||
|                 ); | ||||
|                 mockParentObject = jasmine.createSpyObj( | ||||
|                     "domainObject", | ||||
|                     ["getId", "getModel", "hasCapability", "getCapability", "useCapability"] | ||||
|                 ); | ||||
|                 mockTransactionService = jasmine.createSpyObj( | ||||
|                     "transactionService", | ||||
|                     [ | ||||
|                         "startTransaction", | ||||
|                         "size", | ||||
|                         "commit", | ||||
|                         "cancel" | ||||
|                     ] | ||||
|                 ); | ||||
|                 mockTransactionService.commit.and.returnValue(fastPromise()); | ||||
|                 mockTransactionService.cancel.and.returnValue(fastPromise()); | ||||
|                 mockTransactionService.isActive = jasmine.createSpy('isActive'); | ||||
|  | ||||
|                 mockStatusCapability = jasmine.createSpyObj( | ||||
|                     "statusCapability", | ||||
|                     ["get", "set"] | ||||
|                 ); | ||||
|                 mockParentStatus = jasmine.createSpyObj( | ||||
|                     "statusCapability", | ||||
|                     ["get", "set"] | ||||
|                 ); | ||||
|                 mockContextCapability = jasmine.createSpyObj( | ||||
|                     "contextCapability", | ||||
|                     ["getParent"] | ||||
|                 ); | ||||
|                 mockContextCapability.getParent.and.returnValue(mockParentObject); | ||||
|  | ||||
|                 capabilities = { | ||||
|                     context: mockContextCapability, | ||||
|                     status: mockStatusCapability | ||||
|                 }; | ||||
|  | ||||
|                 mockDomainObject.hasCapability.and.callFake(function (name) { | ||||
|                     return capabilities[name] !== undefined; | ||||
|                 }); | ||||
|  | ||||
|                 mockDomainObject.getCapability.and.callFake(function (name) { | ||||
|                     return capabilities[name]; | ||||
|                 }); | ||||
|  | ||||
|                 mockParentObject.getCapability.and.returnValue(mockParentStatus); | ||||
|                 mockParentObject.hasCapability.and.returnValue(false); | ||||
|  | ||||
|                 capability = new EditorCapability( | ||||
|                     mockTransactionService, | ||||
|                     mockDomainObject | ||||
|                 ); | ||||
|             }); | ||||
|  | ||||
|             it("starts a transaction when edit is invoked", function () { | ||||
|                 capability.edit(); | ||||
|                 expect(mockTransactionService.startTransaction).toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|             it("sets editing status on object", function () { | ||||
|                 capability.edit(); | ||||
|                 expect(mockStatusCapability.set).toHaveBeenCalledWith("editing", true); | ||||
|             }); | ||||
|  | ||||
|             it("uses editing status to determine editing context root", function () { | ||||
|                 capability.edit(); | ||||
|                 mockStatusCapability.get.and.returnValue(false); | ||||
|                 expect(capability.isEditContextRoot()).toBe(false); | ||||
|                 mockStatusCapability.get.and.returnValue(true); | ||||
|                 expect(capability.isEditContextRoot()).toBe(true); | ||||
|             }); | ||||
|  | ||||
|             it("inEditingContext returns true if parent object is being" | ||||
|                 + " edited", function () { | ||||
|                 mockStatusCapability.get.and.returnValue(false); | ||||
|                 mockParentStatus.get.and.returnValue(false); | ||||
|                 expect(capability.inEditContext()).toBe(false); | ||||
|                 mockParentStatus.get.and.returnValue(true); | ||||
|                 expect(capability.inEditContext()).toBe(true); | ||||
|             }); | ||||
|  | ||||
|             describe("save", function () { | ||||
|                 beforeEach(function () { | ||||
|                     capability.edit(); | ||||
|                     capability.save(); | ||||
|                 }); | ||||
|                 it("commits the transaction", function () { | ||||
|                     expect(mockTransactionService.commit).toHaveBeenCalled(); | ||||
|                 }); | ||||
|                 it("begins a new transaction", function () { | ||||
|                     expect(mockTransactionService.startTransaction).toHaveBeenCalled(); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             describe("finish", function () { | ||||
|                 beforeEach(function () { | ||||
|                     mockTransactionService.isActive.and.returnValue(true); | ||||
|                     capability.edit(); | ||||
|                     capability.finish(); | ||||
|                 }); | ||||
|                 it("cancels the transaction", function () { | ||||
|                     expect(mockTransactionService.cancel).toHaveBeenCalled(); | ||||
|                 }); | ||||
|                 it("resets the edit state", function () { | ||||
|                     expect(mockStatusCapability.set).toHaveBeenCalledWith('editing', false); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             describe("finish", function () { | ||||
|                 beforeEach(function () { | ||||
|                     mockTransactionService.isActive.and.returnValue(false); | ||||
|                     capability.edit(); | ||||
|                 }); | ||||
|  | ||||
|                 it("does not cancel transaction when transaction is not active", function () { | ||||
|                     capability.finish(); | ||||
|                     expect(mockTransactionService.cancel).not.toHaveBeenCalled(); | ||||
|                 }); | ||||
|  | ||||
|                 it("returns a promise", function () { | ||||
|                     expect(capability.finish() instanceof Promise).toBe(true); | ||||
|                 }); | ||||
|  | ||||
|             }); | ||||
|  | ||||
|             describe("dirty", function () { | ||||
|                 var model = {}; | ||||
|  | ||||
|                 beforeEach(function () { | ||||
|                     mockDomainObject.getModel.and.returnValue(model); | ||||
|                     capability.edit(); | ||||
|                     capability.finish(); | ||||
|                 }); | ||||
|                 it("returns true if the object has been modified since it" | ||||
|                     + " was last persisted", function () { | ||||
|                     mockTransactionService.size.and.returnValue(0); | ||||
|                     expect(capability.dirty()).toBe(false); | ||||
|                     mockTransactionService.size.and.returnValue(1); | ||||
|                     expect(capability.dirty()).toBe(true); | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -20,52 +20,35 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| export default class Transaction { | ||||
|     constructor(objectAPI) { | ||||
|         this.dirtyObjects = new Set(); | ||||
|         this.objectAPI = objectAPI; | ||||
|     } | ||||
| define( | ||||
|     [ | ||||
|         "../../src/capabilities/TransactionalPersistenceCapability", | ||||
|         "../../src/capabilities/TransactionCapabilityDecorator" | ||||
|     ], | ||||
|     function (TransactionalPersistenceCapability, TransactionCapabilityDecorator) { | ||||
| 
 | ||||
|     add(object) { | ||||
|         this.dirtyObjects.add(object); | ||||
|     } | ||||
|         describe("The transaction capability decorator", function () { | ||||
|             var mockQ, | ||||
|                 mockTransactionService, | ||||
|                 mockCapabilityService, | ||||
|                 provider; | ||||
| 
 | ||||
|     cancel() { | ||||
|         return this._clear(); | ||||
|     } | ||||
| 
 | ||||
|     commit() { | ||||
|         const promiseArray = []; | ||||
|         const save = this.objectAPI.save.bind(this.objectAPI); | ||||
|         this.dirtyObjects.forEach(object => { | ||||
|             promiseArray.push(this.createDirtyObjectPromise(object, save)); | ||||
|         }); | ||||
| 
 | ||||
|         return Promise.all(promiseArray); | ||||
|     } | ||||
| 
 | ||||
|     createDirtyObjectPromise(object, action) { | ||||
|         return new Promise((resolve, reject) => { | ||||
|             action(object) | ||||
|                 .then(resolve) | ||||
|                 .catch(reject) | ||||
|                 .finally(() => { | ||||
|                     this.dirtyObjects.delete(object); | ||||
|             beforeEach(function () { | ||||
|                 mockQ = {}; | ||||
|                 mockTransactionService = {}; | ||||
|                 mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]); | ||||
|                 mockCapabilityService.getCapabilities.and.returnValue({ | ||||
|                     persistence: function () {} | ||||
|                 }); | ||||
| 
 | ||||
|                 provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService); | ||||
| 
 | ||||
|             }); | ||||
|             it("decorates the persistence capability", function () { | ||||
|                 var capabilities = provider.getCapabilities(); | ||||
|                 expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true); | ||||
|             }); | ||||
| 
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     start() { | ||||
|         this.dirtyObjects = new Set(); | ||||
|     } | ||||
| 
 | ||||
|     _clear() { | ||||
|         const promiseArray = []; | ||||
|         const refresh = this.objectAPI.refresh.bind(this.objectAPI); | ||||
|         this.dirtyObjects.forEach(object => { | ||||
|             promiseArray.push(this.createDirtyObjectPromise(object, refresh)); | ||||
|         }); | ||||
| 
 | ||||
|         return Promise.all(promiseArray); | ||||
|     } | ||||
| } | ||||
| ); | ||||
| @@ -0,0 +1,111 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     [ | ||||
|         "../../src/capabilities/TransactionalPersistenceCapability" | ||||
|     ], | ||||
|     function (TransactionalPersistenceCapability) { | ||||
|  | ||||
|         function fastPromise(val) { | ||||
|             return { | ||||
|                 then: function (callback) { | ||||
|                     return callback(val); | ||||
|                 } | ||||
|             }; | ||||
|         } | ||||
|  | ||||
|         describe("The transactional persistence decorator", function () { | ||||
|             var mockQ, | ||||
|                 mockTransactionManager, | ||||
|                 mockPersistence, | ||||
|                 mockDomainObject, | ||||
|                 testId, | ||||
|                 capability; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 testId = "test-id"; | ||||
|  | ||||
|                 mockQ = jasmine.createSpyObj("$q", ["when"]); | ||||
|                 mockQ.when.and.callFake(function (val) { | ||||
|                     return fastPromise(val); | ||||
|                 }); | ||||
|                 mockTransactionManager = jasmine.createSpyObj( | ||||
|                     "transactionService", | ||||
|                     ["isActive", "addToTransaction", "clearTransactionsFor"] | ||||
|                 ); | ||||
|                 mockPersistence = jasmine.createSpyObj( | ||||
|                     "persistenceCapability", | ||||
|                     ["persist", "refresh", "getSpace"] | ||||
|                 ); | ||||
|                 mockPersistence.persist.and.returnValue(fastPromise()); | ||||
|                 mockPersistence.refresh.and.returnValue(fastPromise()); | ||||
|  | ||||
|                 mockDomainObject = jasmine.createSpyObj( | ||||
|                     "domainObject", | ||||
|                     ["getModel", "getId"] | ||||
|                 ); | ||||
|                 mockDomainObject.getModel.and.returnValue({persisted: 1}); | ||||
|                 mockDomainObject.getId.and.returnValue(testId); | ||||
|  | ||||
|                 capability = new TransactionalPersistenceCapability( | ||||
|                     mockQ, | ||||
|                     mockTransactionManager, | ||||
|                     mockPersistence, | ||||
|                     mockDomainObject | ||||
|                 ); | ||||
|             }); | ||||
|  | ||||
|             it("if no transaction is active, passes through to persistence" | ||||
|                 + " provider", function () { | ||||
|                 mockTransactionManager.isActive.and.returnValue(false); | ||||
|                 capability.persist(); | ||||
|                 expect(mockPersistence.persist).toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|             it("if transaction is active, persist and cancel calls are" | ||||
|                 + " queued", function () { | ||||
|                 mockTransactionManager.isActive.and.returnValue(true); | ||||
|                 capability.persist(); | ||||
|                 expect(mockTransactionManager.addToTransaction).toHaveBeenCalled(); | ||||
|                 mockTransactionManager.addToTransaction.calls.mostRecent().args[1](); | ||||
|                 expect(mockPersistence.persist).toHaveBeenCalled(); | ||||
|                 mockTransactionManager.addToTransaction.calls.mostRecent().args[2](); | ||||
|                 expect(mockPersistence.refresh).toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|             it("wraps getSpace", function () { | ||||
|                 mockPersistence.getSpace.and.returnValue('foo'); | ||||
|                 expect(capability.getSpace()).toEqual('foo'); | ||||
|             }); | ||||
|  | ||||
|             it("clears transactions and delegates refresh calls", function () { | ||||
|                 capability.refresh(); | ||||
|                 expect(mockTransactionManager.clearTransactionsFor) | ||||
|                     .toHaveBeenCalledWith(testId); | ||||
|                 expect(mockPersistence.refresh) | ||||
|                     .toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -0,0 +1,75 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define(["../../src/services/NestedTransaction"], function (NestedTransaction) { | ||||
|     var TRANSACTION_METHODS = ['add', 'commit', 'cancel', 'size']; | ||||
|  | ||||
|     describe("A NestedTransaction", function () { | ||||
|         var mockTransaction, | ||||
|             nestedTransaction; | ||||
|  | ||||
|         beforeEach(function () { | ||||
|             mockTransaction = | ||||
|                 jasmine.createSpyObj('transaction', TRANSACTION_METHODS); | ||||
|             nestedTransaction = new NestedTransaction(mockTransaction); | ||||
|         }); | ||||
|  | ||||
|         it("exposes a Transaction's interface", function () { | ||||
|             TRANSACTION_METHODS.forEach(function (method) { | ||||
|                 expect(nestedTransaction[method]) | ||||
|                     .toEqual(jasmine.any(Function)); | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         describe("when callbacks are added", function () { | ||||
|             var mockCommit, | ||||
|                 mockCancel; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockCommit = jasmine.createSpy('commit'); | ||||
|                 mockCancel = jasmine.createSpy('cancel'); | ||||
|                 nestedTransaction.add(mockCommit, mockCancel); | ||||
|             }); | ||||
|  | ||||
|             it("does not interact with its parent transaction", function () { | ||||
|                 TRANSACTION_METHODS.forEach(function (method) { | ||||
|                     expect(mockTransaction[method]) | ||||
|                         .not.toHaveBeenCalled(); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             describe("and the transaction is committed", function () { | ||||
|                 beforeEach(function () { | ||||
|                     nestedTransaction.commit(); | ||||
|                 }); | ||||
|  | ||||
|                 it("adds to its parent transaction", function () { | ||||
|                     expect(mockTransaction.add).toHaveBeenCalledWith( | ||||
|                         jasmine.any(Function), | ||||
|                         jasmine.any(Function) | ||||
|                     ); | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
|  | ||||
							
								
								
									
										141
									
								
								platform/commonUI/edit/test/services/TransactionManagerSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								platform/commonUI/edit/test/services/TransactionManagerSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,141 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/services/TransactionManager"], | ||||
|     function (TransactionManager) { | ||||
|         describe("TransactionManager", function () { | ||||
|             var mockTransactionService, | ||||
|                 testId, | ||||
|                 mockOnCommit, | ||||
|                 mockOnCancel, | ||||
|                 mockRemoves, | ||||
|                 mockPromise, | ||||
|                 manager; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockRemoves = []; | ||||
|                 mockTransactionService = jasmine.createSpyObj( | ||||
|                     "transactionService", | ||||
|                     ["addToTransaction", "isActive"] | ||||
|                 ); | ||||
|                 mockOnCommit = jasmine.createSpy('commit'); | ||||
|                 mockOnCancel = jasmine.createSpy('cancel'); | ||||
|                 testId = 'test-id'; | ||||
|                 mockPromise = jasmine.createSpyObj('promise', ['then']); | ||||
|  | ||||
|                 mockOnCommit.and.returnValue(mockPromise); | ||||
|                 mockOnCancel.and.returnValue(mockPromise); | ||||
|  | ||||
|                 mockTransactionService.addToTransaction.and.callFake(function () { | ||||
|                     var mockRemove = | ||||
|                         jasmine.createSpy('remove-' + mockRemoves.length); | ||||
|                     mockRemoves.push(mockRemove); | ||||
|  | ||||
|                     return mockRemove; | ||||
|                 }); | ||||
|  | ||||
|                 manager = new TransactionManager(mockTransactionService); | ||||
|             }); | ||||
|  | ||||
|             it("delegates isActive calls", function () { | ||||
|                 [false, true].forEach(function (state) { | ||||
|                     mockTransactionService.isActive.and.returnValue(state); | ||||
|                     expect(manager.isActive()).toBe(state); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             describe("when addToTransaction is called", function () { | ||||
|                 beforeEach(function () { | ||||
|                     manager.addToTransaction( | ||||
|                         testId, | ||||
|                         mockOnCommit, | ||||
|                         mockOnCancel | ||||
|                     ); | ||||
|                 }); | ||||
|  | ||||
|                 it("adds callbacks to the active transaction", function () { | ||||
|                     expect(mockTransactionService.addToTransaction) | ||||
|                         .toHaveBeenCalledWith( | ||||
|                             jasmine.any(Function), | ||||
|                             jasmine.any(Function) | ||||
|                         ); | ||||
|                 }); | ||||
|  | ||||
|                 it("invokes passed-in callbacks from its own callbacks", function () { | ||||
|                     expect(mockOnCommit).not.toHaveBeenCalled(); | ||||
|                     mockTransactionService.addToTransaction | ||||
|                         .calls.mostRecent().args[0](); | ||||
|                     expect(mockOnCommit).toHaveBeenCalled(); | ||||
|  | ||||
|                     expect(mockOnCancel).not.toHaveBeenCalled(); | ||||
|                     mockTransactionService.addToTransaction | ||||
|                         .calls.mostRecent().args[1](); | ||||
|                     expect(mockOnCancel).toHaveBeenCalled(); | ||||
|                 }); | ||||
|  | ||||
|                 describe("Adds callbacks to transaction", function () { | ||||
|                     beforeEach(function () { | ||||
|                         spyOn(manager, 'clearTransactionsFor'); | ||||
|                         manager.clearTransactionsFor.and.callThrough(); | ||||
|                     }); | ||||
|  | ||||
|                     it("and clears pending calls if same object", function () { | ||||
|                         manager.addToTransaction( | ||||
|                             testId, | ||||
|                             jasmine.createSpy(), | ||||
|                             jasmine.createSpy() | ||||
|                         ); | ||||
|                         expect(manager.clearTransactionsFor).toHaveBeenCalledWith(testId); | ||||
|                     }); | ||||
|  | ||||
|                     it("and does not clear pending calls if different object", function () { | ||||
|                         manager.addToTransaction( | ||||
|                             'other-id', | ||||
|                             jasmine.createSpy(), | ||||
|                             jasmine.createSpy() | ||||
|                         ); | ||||
|                         expect(manager.clearTransactionsFor).not.toHaveBeenCalled(); | ||||
|                     }); | ||||
|  | ||||
|                     afterEach(function () { | ||||
|                         expect(mockTransactionService.addToTransaction.calls.count()).toEqual(2); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 it("does not remove callbacks from the transaction", function () { | ||||
|                     expect(mockRemoves[0]).not.toHaveBeenCalled(); | ||||
|                 }); | ||||
|  | ||||
|                 describe("and clearTransactionsFor is subsequently called", function () { | ||||
|                     beforeEach(function () { | ||||
|                         manager.clearTransactionsFor(testId); | ||||
|                     }); | ||||
|  | ||||
|                     it("removes callbacks from the transaction", function () { | ||||
|                         expect(mockRemoves[0]).toHaveBeenCalled(); | ||||
|                     }); | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										139
									
								
								platform/commonUI/edit/test/services/TransactionServiceSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								platform/commonUI/edit/test/services/TransactionServiceSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,139 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/services/TransactionService"], | ||||
|     function (TransactionService) { | ||||
|  | ||||
|         describe("The Transaction Service", function () { | ||||
|             var mockQ, | ||||
|                 mockLog, | ||||
|                 mockCacheService, | ||||
|                 transactionService; | ||||
|  | ||||
|             function fastPromise(val) { | ||||
|                 return { | ||||
|                     then: function (callback) { | ||||
|                         return fastPromise(callback(val)); | ||||
|                     } | ||||
|                 }; | ||||
|             } | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockQ = jasmine.createSpyObj("$q", ["all"]); | ||||
|                 mockCacheService = jasmine.createSpyObj("cacheService", ["flush"]); | ||||
|                 mockQ.all.and.returnValue(fastPromise()); | ||||
|                 mockLog = jasmine.createSpyObj("$log", ["error"]); | ||||
|                 transactionService = new TransactionService(mockQ, mockLog, mockCacheService); | ||||
|             }); | ||||
|  | ||||
|             it("isActive returns true if a transaction is in progress", function () { | ||||
|                 expect(transactionService.isActive()).toBe(false); | ||||
|                 transactionService.startTransaction(); | ||||
|                 expect(transactionService.isActive()).toBe(true); | ||||
|             }); | ||||
|  | ||||
|             it("addToTransaction queues onCommit and onCancel functions", function () { | ||||
|                 var onCommit = jasmine.createSpy('onCommit'), | ||||
|                     onCancel = jasmine.createSpy('onCancel'); | ||||
|  | ||||
|                 transactionService.startTransaction(); | ||||
|                 transactionService.addToTransaction(onCommit, onCancel); | ||||
|                 expect(transactionService.size()).toBe(1); | ||||
|             }); | ||||
|  | ||||
|             it("size function returns size of commit and cancel queues", function () { | ||||
|                 var onCommit = jasmine.createSpy('onCommit'), | ||||
|                     onCancel = jasmine.createSpy('onCancel'); | ||||
|  | ||||
|                 transactionService.startTransaction(); | ||||
|                 transactionService.addToTransaction(onCommit, onCancel); | ||||
|                 transactionService.addToTransaction(onCommit, onCancel); | ||||
|                 transactionService.addToTransaction(onCommit, onCancel); | ||||
|                 expect(transactionService.size()).toBe(3); | ||||
|             }); | ||||
|  | ||||
|             describe("commit", function () { | ||||
|                 var onCommits; | ||||
|  | ||||
|                 beforeEach(function () { | ||||
|                     onCommits = [0, 1, 2].map(function (val) { | ||||
|                         return jasmine.createSpy("onCommit" + val); | ||||
|                     }); | ||||
|  | ||||
|                     transactionService.startTransaction(); | ||||
|                     onCommits.forEach(transactionService.addToTransaction.bind(transactionService)); | ||||
|                 }); | ||||
|  | ||||
|                 it("commit calls all queued commit functions", function () { | ||||
|                     expect(transactionService.size()).toBe(3); | ||||
|  | ||||
|                     return transactionService.commit().then(() => { | ||||
|                         onCommits.forEach(function (spy) { | ||||
|                             expect(spy).toHaveBeenCalled(); | ||||
|                         }); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 it("commit resets active state and clears queues", function () { | ||||
|                     return transactionService.commit().then(() => { | ||||
|                         expect(transactionService.isActive()).toBe(false); | ||||
|                         expect(transactionService.size()).toBe(0); | ||||
|                         expect(transactionService.size()).toBe(0); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|             }); | ||||
|  | ||||
|             describe("cancel", function () { | ||||
|                 var onCancels; | ||||
|  | ||||
|                 beforeEach(function () { | ||||
|                     onCancels = [0, 1, 2].map(function (val) { | ||||
|                         return jasmine.createSpy("onCancel" + val); | ||||
|                     }); | ||||
|  | ||||
|                     transactionService.startTransaction(); | ||||
|                     onCancels.forEach(function (onCancel) { | ||||
|                         transactionService.addToTransaction(undefined, onCancel); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 it("cancel calls all queued cancel functions", function () { | ||||
|                     expect(transactionService.size()).toBe(3); | ||||
|                     transactionService.cancel(); | ||||
|                     onCancels.forEach(function (spy) { | ||||
|                         expect(spy).toHaveBeenCalled(); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 it("cancel resets active state and clears queues", function () { | ||||
|                     transactionService.cancel(); | ||||
|                     expect(transactionService.isActive()).toBe(false); | ||||
|                     expect(transactionService.size()).toBe(0); | ||||
|                 }); | ||||
|  | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										109
									
								
								platform/commonUI/edit/test/services/TransactionSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								platform/commonUI/edit/test/services/TransactionSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/services/Transaction"], | ||||
|     function (Transaction) { | ||||
|  | ||||
|         describe("A Transaction", function () { | ||||
|             var mockLog, | ||||
|                 transaction; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockLog = jasmine.createSpyObj( | ||||
|                     '$log', | ||||
|                     ['warn', 'info', 'error', 'debug'] | ||||
|                 ); | ||||
|                 transaction = new Transaction(mockLog); | ||||
|             }); | ||||
|  | ||||
|             it("initially has a size of zero", function () { | ||||
|                 expect(transaction.size()).toEqual(0); | ||||
|             }); | ||||
|  | ||||
|             describe("when callbacks are added", function () { | ||||
|                 var mockCommit, | ||||
|                     mockCancel, | ||||
|                     remove; | ||||
|  | ||||
|                 beforeEach(function () { | ||||
|                     mockCommit = jasmine.createSpy('commit'); | ||||
|                     mockCancel = jasmine.createSpy('cancel'); | ||||
|                     remove = transaction.add(mockCommit, mockCancel); | ||||
|                 }); | ||||
|  | ||||
|                 it("reports a new size", function () { | ||||
|                     expect(transaction.size()).toEqual(1); | ||||
|                 }); | ||||
|  | ||||
|                 it("returns a function to remove those callbacks", function () { | ||||
|                     expect(remove).toEqual(jasmine.any(Function)); | ||||
|                     remove(); | ||||
|                     expect(transaction.size()).toEqual(0); | ||||
|                 }); | ||||
|  | ||||
|                 describe("and the transaction is committed", function () { | ||||
|                     beforeEach(function () { | ||||
|                         transaction.commit(); | ||||
|                     }); | ||||
|  | ||||
|                     it("triggers the commit callback", function () { | ||||
|                         expect(mockCommit).toHaveBeenCalled(); | ||||
|                     }); | ||||
|  | ||||
|                     it("does not trigger the cancel callback", function () { | ||||
|                         expect(mockCancel).not.toHaveBeenCalled(); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 describe("and the transaction is cancelled", function () { | ||||
|                     beforeEach(function () { | ||||
|                         transaction.cancel(); | ||||
|                     }); | ||||
|  | ||||
|                     it("triggers the cancel callback", function () { | ||||
|                         expect(mockCancel).toHaveBeenCalled(); | ||||
|                     }); | ||||
|  | ||||
|                     it("does not trigger the commit callback", function () { | ||||
|                         expect(mockCommit).not.toHaveBeenCalled(); | ||||
|                     }); | ||||
|                 }); | ||||
|  | ||||
|                 describe("and an exception is encountered during commit", function () { | ||||
|                     beforeEach(function () { | ||||
|                         mockCommit.and.callFake(function () { | ||||
|                             throw new Error("test error"); | ||||
|                         }); | ||||
|                         transaction.commit(); | ||||
|                     }); | ||||
|  | ||||
|                     it("logs an error", function () { | ||||
|                         expect(mockLog.error).toHaveBeenCalled(); | ||||
|                     }); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
|  | ||||
| @@ -25,14 +25,15 @@ define([ | ||||
| ], function ( | ||||
|     moment | ||||
| ) { | ||||
|     const DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSS"; | ||||
|     const DATE_FORMATS = [ | ||||
|         DATE_FORMAT, | ||||
|         DATE_FORMAT + "Z", | ||||
|         "YYYY-MM-DD HH:mm:ss", | ||||
|         "YYYY-MM-DD HH:mm", | ||||
|         "YYYY-MM-DD" | ||||
|     ]; | ||||
|  | ||||
|     var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSS", | ||||
|         DATE_FORMATS = [ | ||||
|             DATE_FORMAT, | ||||
|             DATE_FORMAT + "Z", | ||||
|             "YYYY-MM-DD HH:mm:ss", | ||||
|             "YYYY-MM-DD HH:mm", | ||||
|             "YYYY-MM-DD" | ||||
|         ]; | ||||
|  | ||||
|     /** | ||||
|      * @typedef Scale | ||||
| @@ -52,27 +53,15 @@ define([ | ||||
|         this.key = "utc"; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} formatString | ||||
|      * @returns the value of formatString if the value is a string type and exists in the DATE_FORMATS array; otherwise the DATE_FORMAT value. | ||||
|      */ | ||||
|     function validateFormatString(formatString) { | ||||
|         return typeof formatString === 'string' && DATE_FORMATS.includes(formatString) ? formatString : DATE_FORMAT; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {number} value The value to format. | ||||
|      * @param {string} formatString The string format to format. Default "YYYY-MM-DD HH:mm:ss.SSS" + "Z" | ||||
|      * @returns {string} the formatted date(s) according to the proper parameter of formatString or the default value of "YYYY-MM-DD HH:mm:ss.SSS" + "Z". | ||||
|      * If multiple values were requested, then an array of | ||||
|      * @returns {string} the formatted date(s). If multiple values were requested, then an array of | ||||
|      * formatted values will be returned. Where a value could not be formatted, `undefined` will be returned at its position | ||||
|      * in the array. | ||||
|      */ | ||||
|     UTCTimeFormat.prototype.format = function (value, formatString) { | ||||
|     UTCTimeFormat.prototype.format = function (value) { | ||||
|         if (value !== undefined) { | ||||
|             const format = validateFormatString(formatString); | ||||
|  | ||||
|             return moment.utc(value).format(format) + (formatString ? '' : 'Z'); | ||||
|             return moment.utc(value).format(DATE_FORMAT) + "Z"; | ||||
|         } else { | ||||
|             return value; | ||||
|         } | ||||
|   | ||||
| @@ -21,14 +21,28 @@ | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     "./src/AgentService" | ||||
|     "./src/MCTDevice", | ||||
|     "./src/AgentService", | ||||
|     "./src/DeviceClassifier" | ||||
| ], function ( | ||||
|     AgentService | ||||
|     MCTDevice, | ||||
|     AgentService, | ||||
|     DeviceClassifier | ||||
| ) { | ||||
|  | ||||
|     return { | ||||
|         name: "platform/commonUI/mobile", | ||||
|         definition: { | ||||
|             "extensions": { | ||||
|                 "directives": [ | ||||
|                     { | ||||
|                         "key": "mctDevice", | ||||
|                         "implementation": MCTDevice, | ||||
|                         "depends": [ | ||||
|                             "agentService" | ||||
|                         ] | ||||
|                     } | ||||
|                 ], | ||||
|                 "services": [ | ||||
|                     { | ||||
|                         "key": "agentService", | ||||
| @@ -37,6 +51,15 @@ define([ | ||||
|                             "$window" | ||||
|                         ] | ||||
|                     } | ||||
|                 ], | ||||
|                 "runs": [ | ||||
|                     { | ||||
|                         "implementation": DeviceClassifier, | ||||
|                         "depends": [ | ||||
|                             "agentService", | ||||
|                             "$document" | ||||
|                         ] | ||||
|                     } | ||||
|                 ] | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -20,12 +20,122 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define(["../../../../src/utils/agent/Agent.js"], function (Agent) { | ||||
|     function AngularAgentServiceWrapper(window) { | ||||
|         const AS = Agent.default; | ||||
| /** | ||||
|  * Provides features which support variant behavior on mobile devices. | ||||
|  * | ||||
|  * @namespace platform/commonUI/mobile | ||||
|  */ | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|  | ||||
|         return new AS(window); | ||||
|         /** | ||||
|          * The query service handles calls for browser and userAgent | ||||
|          * info using a comparison between the userAgent and key | ||||
|          * device names | ||||
|          * @constructor | ||||
|          * @param $window Angular-injected instance of the window | ||||
|          * @memberof platform/commonUI/mobile | ||||
|          */ | ||||
|         function AgentService($window) { | ||||
|             var userAgent = $window.navigator.userAgent, | ||||
|                 matches = userAgent.match(/iPad|iPhone|Android/i) || []; | ||||
|  | ||||
|             this.userAgent = userAgent; | ||||
|             this.mobileName = matches[0]; | ||||
|             this.$window = $window; | ||||
|             this.touchEnabled = ($window.ontouchstart !== undefined); | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Check if the user is on a mobile device. | ||||
|          * @returns {boolean} true on mobile | ||||
|          */ | ||||
|         AgentService.prototype.isMobile = function () { | ||||
|             return Boolean(this.mobileName); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user is on a phone-sized mobile device. | ||||
|          * @returns {boolean} true on a phone | ||||
|          */ | ||||
|         AgentService.prototype.isPhone = function () { | ||||
|             if (this.isMobile()) { | ||||
|                 if (this.isAndroidTablet()) { | ||||
|                     return false; | ||||
|                 } else if (this.mobileName === 'iPad') { | ||||
|                     return false; | ||||
|                 } else { | ||||
|                     return true; | ||||
|                 } | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user is on a tablet sized android device | ||||
|          * @returns {boolean} true on an android tablet | ||||
|          */ | ||||
|         AgentService.prototype.isAndroidTablet = function () { | ||||
|             if (this.mobileName === 'Android') { | ||||
|                 if (this.isPortrait() && window.innerWidth >= 768) { | ||||
|                     return true; | ||||
|                 } else if (this.isLandscape() && window.innerHeight >= 768) { | ||||
|                     return true; | ||||
|                 } | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user is on a tablet-sized mobile device. | ||||
|          * @returns {boolean} true on a tablet | ||||
|          */ | ||||
|         AgentService.prototype.isTablet = function () { | ||||
|             return (this.isMobile() && !this.isPhone() && this.mobileName !== 'Android') || (this.isMobile() && this.isAndroidTablet()); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user's device is in a portrait-style | ||||
|          * orientation (display width is narrower than display height.) | ||||
|          * @returns {boolean} true in portrait mode | ||||
|          */ | ||||
|         AgentService.prototype.isPortrait = function () { | ||||
|             return this.$window.innerWidth < this.$window.innerHeight; | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user's device is in a landscape-style | ||||
|          * orientation (display width is greater than display height.) | ||||
|          * @returns {boolean} true in landscape mode | ||||
|          */ | ||||
|         AgentService.prototype.isLandscape = function () { | ||||
|             return !this.isPortrait(); | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user's device supports a touch interface. | ||||
|          * @returns {boolean} true if touch is supported | ||||
|          */ | ||||
|         AgentService.prototype.isTouch = function () { | ||||
|             return this.touchEnabled; | ||||
|         }; | ||||
|  | ||||
|         /** | ||||
|          * Check if the user agent matches a certain named device, | ||||
|          * as indicated by checking for a case-insensitive substring | ||||
|          * match. | ||||
|          * @param {string} name the name to check for | ||||
|          * @returns {boolean} true if the user agent includes that name | ||||
|          */ | ||||
|         AgentService.prototype.isBrowser = function (name) { | ||||
|             name = name.toLowerCase(); | ||||
|  | ||||
|             return this.userAgent.toLowerCase().indexOf(name) !== -1; | ||||
|         }; | ||||
|  | ||||
|         return AgentService; | ||||
|     } | ||||
|  | ||||
|     return AngularAgentServiceWrapper; | ||||
| }); | ||||
| ); | ||||
|   | ||||
| @@ -1,96 +0,0 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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 AgentService from "./AgentService"; | ||||
|  | ||||
| const TEST_USER_AGENTS = { | ||||
|     DESKTOP: | ||||
|     "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36", | ||||
|     IPAD: | ||||
|     "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53", | ||||
|     IPHONE: | ||||
|     "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" | ||||
| }; | ||||
|  | ||||
| describe("The AgentService", function () { | ||||
|     let testWindow; | ||||
|     let agentService; | ||||
|  | ||||
|     beforeEach(function () { | ||||
|         testWindow = { | ||||
|             innerWidth: 640, | ||||
|             innerHeight: 480, | ||||
|             navigator: { | ||||
|                 userAgent: TEST_USER_AGENTS.DESKTOP | ||||
|             } | ||||
|         }; | ||||
|     }); | ||||
|  | ||||
|     it("recognizes desktop devices as non-mobile", function () { | ||||
|         testWindow.navigator.userAgent = TEST_USER_AGENTS.DESKTOP; | ||||
|         agentService = new AgentService(testWindow); | ||||
|         expect(agentService.isMobile()).toBeFalsy(); | ||||
|         expect(agentService.isPhone()).toBeFalsy(); | ||||
|         expect(agentService.isTablet()).toBeFalsy(); | ||||
|     }); | ||||
|  | ||||
|     it("detects iPhones", function () { | ||||
|         testWindow.navigator.userAgent = TEST_USER_AGENTS.IPHONE; | ||||
|         agentService = new AgentService(testWindow); | ||||
|         expect(agentService.isMobile()).toBeTruthy(); | ||||
|         expect(agentService.isPhone()).toBeTruthy(); | ||||
|         expect(agentService.isTablet()).toBeFalsy(); | ||||
|     }); | ||||
|  | ||||
|     it("detects iPads", function () { | ||||
|         testWindow.navigator.userAgent = TEST_USER_AGENTS.IPAD; | ||||
|         agentService = new AgentService(testWindow); | ||||
|         expect(agentService.isMobile()).toBeTruthy(); | ||||
|         expect(agentService.isPhone()).toBeFalsy(); | ||||
|         expect(agentService.isTablet()).toBeTruthy(); | ||||
|     }); | ||||
|  | ||||
|     it("detects display orientation", function () { | ||||
|         agentService = new AgentService(testWindow); | ||||
|         testWindow.innerWidth = 1024; | ||||
|         testWindow.innerHeight = 400; | ||||
|         expect(agentService.isPortrait()).toBeFalsy(); | ||||
|         expect(agentService.isLandscape()).toBeTruthy(); | ||||
|         testWindow.innerWidth = 400; | ||||
|         testWindow.innerHeight = 1024; | ||||
|         expect(agentService.isPortrait()).toBeTruthy(); | ||||
|         expect(agentService.isLandscape()).toBeFalsy(); | ||||
|     }); | ||||
|  | ||||
|     it("detects touch support", function () { | ||||
|         testWindow.ontouchstart = null; | ||||
|         expect(new AgentService(testWindow).isTouch()).toBe(true); | ||||
|         delete testWindow.ontouchstart; | ||||
|         expect(new AgentService(testWindow).isTouch()).toBe(false); | ||||
|     }); | ||||
|  | ||||
|     it("allows for checking browser type", function () { | ||||
|         testWindow.navigator.userAgent = "Chromezilla Safarifox"; | ||||
|         agentService = new AgentService(testWindow); | ||||
|         expect(agentService.isBrowser("Chrome")).toBe(true); | ||||
|         expect(agentService.isBrowser("Firefox")).toBe(false); | ||||
|     }); | ||||
| }); | ||||
							
								
								
									
										72
									
								
								platform/commonUI/mobile/src/DeviceClassifier.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								platform/commonUI/mobile/src/DeviceClassifier.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ['./DeviceMatchers'], | ||||
|     function (DeviceMatchers) { | ||||
|  | ||||
|         /** | ||||
|          * Runs at application startup and adds a subset of the following | ||||
|          * CSS classes to the body of the document, depending on device | ||||
|          * attributes: | ||||
|          * | ||||
|          * * `mobile`: Phones or tablets. | ||||
|          * * `phone`: Phones specifically. | ||||
|          * * `tablet`: Tablets specifically. | ||||
|          * * `desktop`: Non-mobile devices. | ||||
|          * * `portrait`: Devices in a portrait-style orientation. | ||||
|          * * `landscape`: Devices in a landscape-style orientation. | ||||
|          * * `touch`: Device supports touch events. | ||||
|          * | ||||
|          * @param {platform/commonUI/mobile.AgentService} agentService | ||||
|          *        the service used to examine the user agent | ||||
|          * @param $document Angular's jqLite-wrapped document element | ||||
|          * @constructor | ||||
|          */ | ||||
|         function MobileClassifier(agentService, $document) { | ||||
|             var body = $document.find('body'); | ||||
|  | ||||
|             Object.keys(DeviceMatchers).forEach(function (key, index, array) { | ||||
|                 if (DeviceMatchers[key](agentService)) { | ||||
|                     body.addClass(key); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             if (agentService.isMobile()) { | ||||
|                 var mediaQuery = window.matchMedia('(orientation: landscape)'); | ||||
|  | ||||
|                 mediaQuery.addListener(function (event) { | ||||
|                     if (event.matches) { | ||||
|                         body.removeClass('portrait'); | ||||
|                         body.addClass('landscape'); | ||||
|                     } else { | ||||
|                         body.removeClass('landscape'); | ||||
|                         body.addClass('portrait'); | ||||
|                     } | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return MobileClassifier; | ||||
|  | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										58
									
								
								platform/commonUI/mobile/src/DeviceMatchers.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								platform/commonUI/mobile/src/DeviceMatchers.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
| define(function () { | ||||
|  | ||||
|     /** | ||||
|      * An object containing key-value pairs, where keys are symbolic of | ||||
|      * device attributes, and values are functions that take the | ||||
|      * `agentService` as inputs and return boolean values indicating | ||||
|      * whether or not the current device has these attributes. | ||||
|      * | ||||
|      * For internal use by the mobile support bundle. | ||||
|      * | ||||
|      * @memberof platform/commonUI/mobile | ||||
|      * @private | ||||
|      */ | ||||
|     return { | ||||
|         mobile: function (agentService) { | ||||
|             return agentService.isMobile(); | ||||
|         }, | ||||
|         phone: function (agentService) { | ||||
|             return agentService.isPhone(); | ||||
|         }, | ||||
|         tablet: function (agentService) { | ||||
|             return agentService.isTablet(); | ||||
|         }, | ||||
|         desktop: function (agentService) { | ||||
|             return !agentService.isMobile(); | ||||
|         }, | ||||
|         portrait: function (agentService) { | ||||
|             return agentService.isPortrait(); | ||||
|         }, | ||||
|         landscape: function (agentService) { | ||||
|             return agentService.isLandscape(); | ||||
|         }, | ||||
|         touch: function (agentService) { | ||||
|             return agentService.isTouch(); | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
							
								
								
									
										88
									
								
								platform/commonUI/mobile/src/MCTDevice.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								platform/commonUI/mobile/src/MCTDevice.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ['./DeviceMatchers'], | ||||
|     function (DeviceMatchers) { | ||||
|  | ||||
|         /** | ||||
|          * The `mct-device` directive, when applied as an attribute, | ||||
|          * only includes the element when the device being used matches | ||||
|          * a set of characteristics required. | ||||
|          * | ||||
|          * Required characteristics are given as space-separated strings | ||||
|          * as the value to this attribute, e.g.: | ||||
|          * | ||||
|          *    <span mct-device="mobile portrait">Hello world!</span> | ||||
|          * | ||||
|          * ...will only show Hello world! when viewed on a mobile device | ||||
|          * in the portrait orientation. | ||||
|          * | ||||
|          * Valid device characteristics to detect are: | ||||
|          * | ||||
|          * * `mobile`: Phones or tablets. | ||||
|          * * `phone`: Phones specifically. | ||||
|          * * `tablet`: Tablets specifically. | ||||
|          * * `desktop`: Non-mobile devices. | ||||
|          * * `portrait`: Devices in a portrait-style orientation. | ||||
|          * * `landscape`: Devices in a landscape-style orientation. | ||||
|          * * `touch`: Device supports touch events. | ||||
|          * | ||||
|          * @param {AgentService} agentService used to detect device type | ||||
|          *        based on information about the user agent | ||||
|          */ | ||||
|         function MCTDevice(agentService) { | ||||
|  | ||||
|             function deviceMatches(tokens) { | ||||
|                 tokens = tokens || ""; | ||||
|  | ||||
|                 return tokens.split(" ").every(function (token) { | ||||
|                     var fn = DeviceMatchers[token]; | ||||
|  | ||||
|                     return fn && fn(agentService); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             function link(scope, element, attrs, ctrl, transclude) { | ||||
|                 if (deviceMatches(attrs.mctDevice)) { | ||||
|                     transclude(function (clone) { | ||||
|                         element.replaceWith(clone); | ||||
|                     }); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return { | ||||
|                 link: link, | ||||
|                 // We are transcluding the whole element (like ng-if) | ||||
|                 transclude: 'element', | ||||
|                 // 1 more than ng-if | ||||
|                 priority: 601, | ||||
|                 // Also terminal, since element will be transcluded | ||||
|                 terminal: true, | ||||
|                 // Only apply as an attribute | ||||
|                 restrict: "A" | ||||
|             }; | ||||
|         } | ||||
|  | ||||
|         return MCTDevice; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										99
									
								
								platform/commonUI/mobile/test/AgentServiceSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								platform/commonUI/mobile/test/AgentServiceSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../src/AgentService"], | ||||
|     function (AgentService) { | ||||
|  | ||||
|         var TEST_USER_AGENTS = { | ||||
|             DESKTOP: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36", | ||||
|             IPAD: "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53", | ||||
|             IPHONE: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" | ||||
|         }; | ||||
|  | ||||
|         describe("The AgentService", function () { | ||||
|             var testWindow, agentService; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 testWindow = { | ||||
|                     innerWidth: 640, | ||||
|                     innerHeight: 480, | ||||
|                     navigator: { | ||||
|                         userAgent: TEST_USER_AGENTS.DESKTOP | ||||
|                     } | ||||
|                 }; | ||||
|             }); | ||||
|  | ||||
|             it("recognizes desktop devices as non-mobile", function () { | ||||
|                 testWindow.navigator.userAgent = TEST_USER_AGENTS.DESKTOP; | ||||
|                 agentService = new AgentService(testWindow); | ||||
|                 expect(agentService.isMobile()).toBeFalsy(); | ||||
|                 expect(agentService.isPhone()).toBeFalsy(); | ||||
|                 expect(agentService.isTablet()).toBeFalsy(); | ||||
|             }); | ||||
|  | ||||
|             it("detects iPhones", function () { | ||||
|                 testWindow.navigator.userAgent = TEST_USER_AGENTS.IPHONE; | ||||
|                 agentService = new AgentService(testWindow); | ||||
|                 expect(agentService.isMobile()).toBeTruthy(); | ||||
|                 expect(agentService.isPhone()).toBeTruthy(); | ||||
|                 expect(agentService.isTablet()).toBeFalsy(); | ||||
|             }); | ||||
|  | ||||
|             it("detects iPads", function () { | ||||
|                 testWindow.navigator.userAgent = TEST_USER_AGENTS.IPAD; | ||||
|                 agentService = new AgentService(testWindow); | ||||
|                 expect(agentService.isMobile()).toBeTruthy(); | ||||
|                 expect(agentService.isPhone()).toBeFalsy(); | ||||
|                 expect(agentService.isTablet()).toBeTruthy(); | ||||
|             }); | ||||
|  | ||||
|             it("detects display orientation", function () { | ||||
|                 agentService = new AgentService(testWindow); | ||||
|                 testWindow.innerWidth = 1024; | ||||
|                 testWindow.innerHeight = 400; | ||||
|                 expect(agentService.isPortrait()).toBeFalsy(); | ||||
|                 expect(agentService.isLandscape()).toBeTruthy(); | ||||
|                 testWindow.innerWidth = 400; | ||||
|                 testWindow.innerHeight = 1024; | ||||
|                 expect(agentService.isPortrait()).toBeTruthy(); | ||||
|                 expect(agentService.isLandscape()).toBeFalsy(); | ||||
|             }); | ||||
|  | ||||
|             it("detects touch support", function () { | ||||
|                 testWindow.ontouchstart = null; | ||||
|                 expect(new AgentService(testWindow).isTouch()) | ||||
|                     .toBe(true); | ||||
|                 delete testWindow.ontouchstart; | ||||
|                 expect(new AgentService(testWindow).isTouch()) | ||||
|                     .toBe(false); | ||||
|             }); | ||||
|  | ||||
|             it("allows for checking browser type", function () { | ||||
|                 testWindow.navigator.userAgent = "Chromezilla Safarifox"; | ||||
|                 agentService = new AgentService(testWindow); | ||||
|                 expect(agentService.isBrowser("Chrome")).toBe(true); | ||||
|                 expect(agentService.isBrowser("Firefox")).toBe(false); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										109
									
								
								platform/commonUI/mobile/test/DeviceClassifierSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								platform/commonUI/mobile/test/DeviceClassifierSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../src/DeviceClassifier", "../src/DeviceMatchers"], | ||||
|     function (DeviceClassifier, DeviceMatchers) { | ||||
|  | ||||
|         var AGENT_SERVICE_METHODS = [ | ||||
|                 'isMobile', | ||||
|                 'isPhone', | ||||
|                 'isTablet', | ||||
|                 'isPortrait', | ||||
|                 'isLandscape', | ||||
|                 'isTouch' | ||||
|             ], | ||||
|             TEST_PERMUTATIONS = [ | ||||
|                 ['isMobile', 'isPhone', 'isTouch', 'isPortrait'], | ||||
|                 ['isMobile', 'isPhone', 'isTouch', 'isLandscape'], | ||||
|                 ['isMobile', 'isTablet', 'isTouch', 'isPortrait'], | ||||
|                 ['isMobile', 'isTablet', 'isTouch', 'isLandscape'], | ||||
|                 ['isTouch'], | ||||
|                 [] | ||||
|             ]; | ||||
|  | ||||
|         describe("DeviceClassifier", function () { | ||||
|             var mockAgentService, | ||||
|                 mockDocument, | ||||
|                 mockBody; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockAgentService = jasmine.createSpyObj( | ||||
|                     'agentService', | ||||
|                     AGENT_SERVICE_METHODS | ||||
|                 ); | ||||
|                 mockDocument = jasmine.createSpyObj( | ||||
|                     '$document', | ||||
|                     ['find'] | ||||
|                 ); | ||||
|                 mockBody = jasmine.createSpyObj( | ||||
|                     'body', | ||||
|                     ['addClass'] | ||||
|                 ); | ||||
|                 mockDocument.find.and.callFake(function (sel) { | ||||
|                     return sel === 'body' && mockBody; | ||||
|                 }); | ||||
|                 AGENT_SERVICE_METHODS.forEach(function (m) { | ||||
|                     mockAgentService[m].and.returnValue(false); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             TEST_PERMUTATIONS.forEach(function (trueMethods) { | ||||
|                 var summary = trueMethods.length === 0 | ||||
|                     ? "device has no detected characteristics" | ||||
|                     : "device " + (trueMethods.join(", ")); | ||||
|  | ||||
|                 describe("when " + summary, function () { | ||||
|                     var classifier; // eslint-disable-line | ||||
|  | ||||
|                     beforeEach(function () { | ||||
|                         trueMethods.forEach(function (m) { | ||||
|                             mockAgentService[m].and.returnValue(true); | ||||
|                         }); | ||||
|                         classifier = new DeviceClassifier( | ||||
|                             mockAgentService, | ||||
|                             mockDocument | ||||
|                         ); | ||||
|                     }); | ||||
|  | ||||
|                     it("adds classes for matching, detected characteristics", function () { | ||||
|                         Object.keys(DeviceMatchers).filter(function (m) { | ||||
|                             return DeviceMatchers[m](mockAgentService); | ||||
|                         }).forEach(function (key) { | ||||
|                             expect(mockBody.addClass) | ||||
|                                 .toHaveBeenCalledWith(key); | ||||
|                         }); | ||||
|                     }); | ||||
|  | ||||
|                     it("does not add classes for non-matching characteristics", function () { | ||||
|                         Object.keys(DeviceMatchers).filter(function (m) { | ||||
|                             return !DeviceMatchers[m](mockAgentService); | ||||
|                         }).forEach(function (key) { | ||||
|                             expect(mockBody.addClass) | ||||
|                                 .not.toHaveBeenCalledWith(key); | ||||
|                         }); | ||||
|                     }); | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										78
									
								
								platform/commonUI/mobile/test/DeviceMatchersSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								platform/commonUI/mobile/test/DeviceMatchersSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../src/DeviceMatchers"], | ||||
|     function (DeviceMatchers) { | ||||
|  | ||||
|         describe("DeviceMatchers", function () { | ||||
|             var mockAgentService; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockAgentService = jasmine.createSpyObj( | ||||
|                     'agentService', | ||||
|                     [ | ||||
|                         'isMobile', | ||||
|                         'isPhone', | ||||
|                         'isTablet', | ||||
|                         'isPortrait', | ||||
|                         'isLandscape', | ||||
|                         'isTouch' | ||||
|                     ] | ||||
|                 ); | ||||
|             }); | ||||
|  | ||||
|             it("detects when a device is a desktop device", function () { | ||||
|                 mockAgentService.isMobile.and.returnValue(false); | ||||
|                 expect(DeviceMatchers.desktop(mockAgentService)) | ||||
|                     .toBe(true); | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 expect(DeviceMatchers.desktop(mockAgentService)) | ||||
|                     .toBe(false); | ||||
|             }); | ||||
|  | ||||
|             function method(deviceType) { | ||||
|                 return "is" + deviceType[0].toUpperCase() + deviceType.slice(1); | ||||
|             } | ||||
|  | ||||
|             [ | ||||
|                 "mobile", | ||||
|                 "phone", | ||||
|                 "tablet", | ||||
|                 "landscape", | ||||
|                 "portrait", | ||||
|                 "landscape", | ||||
|                 "touch" | ||||
|             ].forEach(function (deviceType) { | ||||
|                 it("detects when a device is a " + deviceType + " device", function () { | ||||
|                     mockAgentService[method(deviceType)].and.returnValue(true); | ||||
|                     expect(DeviceMatchers[deviceType](mockAgentService)) | ||||
|                         .toBe(true); | ||||
|                     mockAgentService[method(deviceType)].and.returnValue(false); | ||||
|                     expect(DeviceMatchers[deviceType](mockAgentService)) | ||||
|                         .toBe(false); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										168
									
								
								platform/commonUI/mobile/test/MCTDeviceSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								platform/commonUI/mobile/test/MCTDeviceSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,168 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ['../src/MCTDevice'], | ||||
|     function (MCTDevice) { | ||||
|  | ||||
|         var JQLITE_METHODS = ['replaceWith']; | ||||
|  | ||||
|         describe("The mct-device directive", function () { | ||||
|             var mockAgentService, | ||||
|                 mockTransclude, | ||||
|                 mockElement, | ||||
|                 mockClone, | ||||
|                 testAttrs, | ||||
|                 directive; | ||||
|  | ||||
|             function link() { | ||||
|                 directive.link(null, mockElement, testAttrs, null, mockTransclude); | ||||
|             } | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockAgentService = jasmine.createSpyObj( | ||||
|                     "agentService", | ||||
|                     ["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"] | ||||
|                 ); | ||||
|                 mockTransclude = jasmine.createSpy("$transclude"); | ||||
|                 mockElement = jasmine.createSpyObj(name, JQLITE_METHODS); | ||||
|                 mockClone = jasmine.createSpyObj(name, JQLITE_METHODS); | ||||
|  | ||||
|                 mockTransclude.and.callFake(function (fn) { | ||||
|                     fn(mockClone); | ||||
|                 }); | ||||
|  | ||||
|                 // Look desktop-like by default | ||||
|                 mockAgentService.isLandscape.and.returnValue(true); | ||||
|  | ||||
|                 testAttrs = {}; | ||||
|  | ||||
|                 directive = new MCTDevice(mockAgentService); | ||||
|             }); | ||||
|  | ||||
|             function expectInclusion() { | ||||
|                 expect(mockElement.replaceWith) | ||||
|                     .toHaveBeenCalledWith(mockClone); | ||||
|             } | ||||
|  | ||||
|             function expectExclusion() { | ||||
|                 expect(mockElement.replaceWith).not.toHaveBeenCalled(); | ||||
|             } | ||||
|  | ||||
|             it("is applicable at the attribute level", function () { | ||||
|                 expect(directive.restrict).toEqual("A"); | ||||
|             }); | ||||
|  | ||||
|             it("transcludes at the element level", function () { | ||||
|                 expect(directive.transclude).toEqual('element'); | ||||
|             }); | ||||
|  | ||||
|             it("has a greater priority number than ng-if", function () { | ||||
|                 expect(directive.priority > 600).toBeTruthy(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for mobile devices", function () { | ||||
|                 testAttrs.mctDevice = "mobile"; | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for tablet devices", function () { | ||||
|                 testAttrs.mctDevice = "tablet"; | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isTablet.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for phone devices", function () { | ||||
|                 testAttrs.mctDevice = "phone"; | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isPhone.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for desktop devices", function () { | ||||
|                 testAttrs.mctDevice = "desktop"; | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isMobile.and.returnValue(false); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for portrait orientation", function () { | ||||
|                 testAttrs.mctDevice = "portrait"; | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isPortrait.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("restricts element inclusion for landscape orientation", function () { | ||||
|                 testAttrs.mctDevice = "landscape"; | ||||
|                 mockAgentService.isLandscape.and.returnValue(false); | ||||
|                 mockAgentService.isPortrait.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isLandscape.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|  | ||||
|             it("allows multiple device characteristics to be requested", function () { | ||||
|                 // Won't try to test every permutation here, just | ||||
|                 // make sure the multi-characteristic feature has support. | ||||
|                 testAttrs.mctDevice = "portrait mobile"; | ||||
|                 link(); | ||||
|                 // Neither portrait nor mobile, not called | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isPortrait.and.returnValue(true); | ||||
|                 link(); | ||||
|  | ||||
|                 // Was portrait, but not mobile, so no | ||||
|                 expectExclusion(); | ||||
|  | ||||
|                 mockAgentService.isMobile.and.returnValue(true); | ||||
|                 link(); | ||||
|                 expectInclusion(); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -45,6 +45,7 @@ define([ | ||||
|     "./src/capabilities/MutationCapability", | ||||
|     "./src/capabilities/DelegationCapability", | ||||
|     "./src/capabilities/InstantiationCapability", | ||||
|     "./src/runs/TransactingMutationListener", | ||||
|     "./src/services/Now", | ||||
|     "./src/services/Throttle", | ||||
|     "./src/services/Topic", | ||||
| @@ -74,6 +75,7 @@ define([ | ||||
|     MutationCapability, | ||||
|     DelegationCapability, | ||||
|     InstantiationCapability, | ||||
|     TransactingMutationListener, | ||||
|     Now, | ||||
|     Throttle, | ||||
|     Topic, | ||||
| @@ -361,6 +363,12 @@ define([ | ||||
|                         ] | ||||
|                     } | ||||
|                 ], | ||||
|                 "runs": [ | ||||
|                     { | ||||
|                         "implementation": TransactingMutationListener, | ||||
|                         "depends": ["topic", "transactionService", "cacheService"] | ||||
|                     } | ||||
|                 ], | ||||
|                 "constants": [ | ||||
|                     { | ||||
|                         "key": "PERSISTENCE_SPACE", | ||||
| @@ -371,7 +379,7 @@ define([ | ||||
|                     { | ||||
|                         "name": "Math.uuid.js", | ||||
|                         "version": "1.4.7", | ||||
|                         "description": "Unique identifier generation (code adapted.)", | ||||
|                         "description": "Unique identifer generation (code adapted.)", | ||||
|                         "author": "Robert Kieffer", | ||||
|                         "website": "https://github.com/broofa/node-uuid", | ||||
|                         "copyright": "Copyright (c) 2010-2012 Robert Kieffer", | ||||
|   | ||||
| @@ -141,17 +141,11 @@ define( | ||||
|                 if (mutationResult !== false) { | ||||
|                     // Copy values if result was a different object | ||||
|                     // (either our clone or some other new thing) | ||||
|                     let modelHasChanged = _.isEqual(model, result) === false; | ||||
|                     if (modelHasChanged) { | ||||
|                     if (model !== result) { | ||||
|                         copyValues(model, result); | ||||
|                     } | ||||
|  | ||||
|                     if (modelHasChanged | ||||
|                         || (useTimestamp !== undefined) | ||||
|                         || (model.modified === undefined)) { | ||||
|                         model.modified = useTimestamp ? timestamp : now(); | ||||
|                     } | ||||
|  | ||||
|                     model.modified = useTimestamp ? timestamp : now(); | ||||
|                     notifyListeners(model); | ||||
|                 } | ||||
|  | ||||
|   | ||||
							
								
								
									
										55
									
								
								platform/core/src/runs/TransactingMutationListener.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								platform/core/src/runs/TransactingMutationListener.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT Web, Copyright (c) 2014-2015, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT Web 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 Web 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([], function () { | ||||
|  | ||||
|     /** | ||||
|      * Listens for mutation on domain objects and triggers persistence when | ||||
|      * it occurs. | ||||
|      * @param {Topic} topic the `topic` service; used to listen for mutation | ||||
|      * @memberof platform/core | ||||
|      */ | ||||
|     function TransactingMutationListener( | ||||
|         topic, | ||||
|         transactionService, | ||||
|         cacheService | ||||
|     ) { | ||||
|  | ||||
|         function hasChanged(domainObject) { | ||||
|             var model = domainObject.getModel(); | ||||
|  | ||||
|             return model.persisted === undefined || model.modified > model.persisted; | ||||
|         } | ||||
|  | ||||
|         var mutationTopic = topic('mutation'); | ||||
|         mutationTopic.listen(function (domainObject) { | ||||
|             var persistence = domainObject.getCapability('persistence'); | ||||
|             cacheService.put(domainObject.getId(), domainObject.getModel()); | ||||
|  | ||||
|             if (hasChanged(domainObject)) { | ||||
|                 persistence.persist(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     return TransactingMutationListener; | ||||
| }); | ||||
							
								
								
									
										112
									
								
								platform/core/test/runs/TransactingMutationListenerSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								platform/core/test/runs/TransactingMutationListenerSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,112 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/runs/TransactingMutationListener"], | ||||
|     function (TransactingMutationListener) { | ||||
|  | ||||
|         describe("TransactingMutationListener", function () { | ||||
|             var mockTopic, | ||||
|                 mockMutationTopic, | ||||
|                 mockCacheService, | ||||
|                 mockTransactionService, | ||||
|                 mockDomainObject, | ||||
|                 mockModel, | ||||
|                 mockPersistence; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockTopic = jasmine.createSpy('topic'); | ||||
|                 mockMutationTopic = | ||||
|                     jasmine.createSpyObj('mutation', ['listen']); | ||||
|                 mockCacheService = | ||||
|                     jasmine.createSpyObj('cacheService', [ | ||||
|                         'put' | ||||
|                     ]); | ||||
|                 mockTransactionService = | ||||
|                     jasmine.createSpyObj('transactionService', [ | ||||
|                         'isActive', | ||||
|                         'startTransaction', | ||||
|                         'commit' | ||||
|                     ]); | ||||
|                 mockDomainObject = jasmine.createSpyObj( | ||||
|                     'domainObject', | ||||
|                     ['getId', 'getCapability', 'getModel'] | ||||
|                 ); | ||||
|                 mockPersistence = jasmine.createSpyObj( | ||||
|                     'persistence', | ||||
|                     ['persist', 'refresh', 'persisted'] | ||||
|                 ); | ||||
|  | ||||
|                 mockTopic.and.callFake(function (t) { | ||||
|                     expect(t).toBe('mutation'); | ||||
|  | ||||
|                     return mockMutationTopic; | ||||
|                 }); | ||||
|  | ||||
|                 mockDomainObject.getId.and.returnValue('mockId'); | ||||
|                 mockDomainObject.getCapability.and.callFake(function (c) { | ||||
|                     expect(c).toBe('persistence'); | ||||
|  | ||||
|                     return mockPersistence; | ||||
|                 }); | ||||
|                 mockModel = {}; | ||||
|                 mockDomainObject.getModel.and.returnValue(mockModel); | ||||
|  | ||||
|                 mockPersistence.persisted.and.returnValue(true); | ||||
|  | ||||
|                 return new TransactingMutationListener( | ||||
|                     mockTopic, | ||||
|                     mockTransactionService, | ||||
|                     mockCacheService | ||||
|                 ); | ||||
|             }); | ||||
|  | ||||
|             it("listens for mutation", function () { | ||||
|                 expect(mockMutationTopic.listen) | ||||
|                     .toHaveBeenCalledWith(jasmine.any(Function)); | ||||
|             }); | ||||
|  | ||||
|             it("calls persist if the model has changed", function () { | ||||
|                 mockModel.persisted = Date.now(); | ||||
|  | ||||
|                 //Mark the model dirty by setting the mutated date later than the last persisted date. | ||||
|                 mockModel.modified = mockModel.persisted + 1; | ||||
|  | ||||
|                 mockMutationTopic.listen.calls.mostRecent() | ||||
|                     .args[0](mockDomainObject); | ||||
|  | ||||
|                 expect(mockPersistence.persist).toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|             it("does not call persist if the model has not changed", function () { | ||||
|                 mockModel.persisted = Date.now(); | ||||
|  | ||||
|                 mockModel.modified = mockModel.persisted; | ||||
|  | ||||
|                 mockMutationTopic.listen.calls.mostRecent() | ||||
|                     .args[0](mockDomainObject); | ||||
|  | ||||
|                 expect(mockPersistence.persist).not.toHaveBeenCalled(); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -21,24 +21,36 @@ | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     "moment-timezone", | ||||
|     "./src/indicators/ClockIndicator", | ||||
|     "./src/indicators/FollowIndicator", | ||||
|     "./src/services/TickerService", | ||||
|     "./src/services/TimerService", | ||||
|     "./src/controllers/ClockController", | ||||
|     "./src/controllers/TimerController", | ||||
|     "./src/controllers/RefreshingController", | ||||
|     "./src/actions/FollowTimerAction", | ||||
|     "./src/actions/StartTimerAction", | ||||
|     "./src/actions/RestartTimerAction", | ||||
|     "./src/actions/StopTimerAction", | ||||
|     "./src/actions/PauseTimerAction", | ||||
|     "./res/templates/clock.html", | ||||
|     "./res/templates/timer.html" | ||||
| ], function ( | ||||
|     MomentTimezone, | ||||
|     ClockIndicator, | ||||
|     FollowIndicator, | ||||
|     TickerService, | ||||
|     TimerService, | ||||
|     ClockController, | ||||
|     TimerController, | ||||
|     RefreshingController, | ||||
|     FollowTimerAction, | ||||
|     StartTimerAction, | ||||
|     RestartTimerAction, | ||||
|     StopTimerAction, | ||||
|     PauseTimerAction, | ||||
|     clockTemplate, | ||||
|     timerTemplate | ||||
| ) { | ||||
|     return { | ||||
| @@ -65,6 +77,16 @@ define([ | ||||
|                         "value": "YYYY/MM/DD HH:mm:ss" | ||||
|                     } | ||||
|                 ], | ||||
|                 "indicators": [ | ||||
|                     { | ||||
|                         "implementation": ClockIndicator, | ||||
|                         "depends": [ | ||||
|                             "tickerService", | ||||
|                             "CLOCK_INDICATOR_FORMAT" | ||||
|                         ], | ||||
|                         "priority": "preferred" | ||||
|                     } | ||||
|                 ], | ||||
|                 "services": [ | ||||
|                     { | ||||
|                         "key": "tickerService", | ||||
| @@ -81,6 +103,14 @@ define([ | ||||
|                     } | ||||
|                 ], | ||||
|                 "controllers": [ | ||||
|                     { | ||||
|                         "key": "ClockController", | ||||
|                         "implementation": ClockController, | ||||
|                         "depends": [ | ||||
|                             "$scope", | ||||
|                             "tickerService" | ||||
|                         ] | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "TimerController", | ||||
|                         "implementation": TimerController, | ||||
| @@ -100,6 +130,12 @@ define([ | ||||
|                     } | ||||
|                 ], | ||||
|                 "views": [ | ||||
|                     { | ||||
|                         "key": "clock", | ||||
|                         "type": "clock", | ||||
|                         "editable": false, | ||||
|                         "template": clockTemplate | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "timer", | ||||
|                         "type": "timer", | ||||
| @@ -108,6 +144,15 @@ define([ | ||||
|                     } | ||||
|                 ], | ||||
|                 "actions": [ | ||||
|                     { | ||||
|                         "key": "timer.follow", | ||||
|                         "implementation": FollowTimerAction, | ||||
|                         "depends": ["timerService"], | ||||
|                         "category": "contextual", | ||||
|                         "name": "Follow Timer", | ||||
|                         "cssClass": "icon-clock", | ||||
|                         "priority": "optional" | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "timer.start", | ||||
|                         "implementation": StartTimerAction, | ||||
| @@ -149,11 +194,75 @@ define([ | ||||
|                         ], | ||||
|                         "category": "contextual", | ||||
|                         "name": "Stop", | ||||
|                         "cssClass": "icon-box-round-corners", | ||||
|                         "cssClass": "icon-box", | ||||
|                         "priority": "preferred" | ||||
|                     } | ||||
|                 ], | ||||
|                 "types": [ | ||||
|                     { | ||||
|                         "key": "clock", | ||||
|                         "name": "Clock", | ||||
|                         "cssClass": "icon-clock", | ||||
|                         "description": "A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts.", | ||||
|                         "priority": 101, | ||||
|                         "features": [ | ||||
|                             "creation" | ||||
|                         ], | ||||
|                         "properties": [ | ||||
|                             { | ||||
|                                 "key": "clockFormat", | ||||
|                                 "name": "Display Format", | ||||
|                                 "control": "composite", | ||||
|                                 "items": [ | ||||
|                                     { | ||||
|                                         "control": "select", | ||||
|                                         "options": [ | ||||
|                                             { | ||||
|                                                 "value": "YYYY/MM/DD hh:mm:ss", | ||||
|                                                 "name": "YYYY/MM/DD hh:mm:ss" | ||||
|                                             }, | ||||
|                                             { | ||||
|                                                 "value": "YYYY/DDD hh:mm:ss", | ||||
|                                                 "name": "YYYY/DDD hh:mm:ss" | ||||
|                                             }, | ||||
|                                             { | ||||
|                                                 "value": "hh:mm:ss", | ||||
|                                                 "name": "hh:mm:ss" | ||||
|                                             } | ||||
|                                         ], | ||||
|                                         "cssClass": "l-inline" | ||||
|                                     }, | ||||
|                                     { | ||||
|                                         "control": "select", | ||||
|                                         "options": [ | ||||
|                                             { | ||||
|                                                 "value": "clock12", | ||||
|                                                 "name": "12hr" | ||||
|                                             }, | ||||
|                                             { | ||||
|                                                 "value": "clock24", | ||||
|                                                 "name": "24hr" | ||||
|                                             } | ||||
|                                         ], | ||||
|                                         "cssClass": "l-inline" | ||||
|                                     } | ||||
|                                 ] | ||||
|                             }, | ||||
|                             { | ||||
|                                 "key": "timezone", | ||||
|                                 "name": "Timezone", | ||||
|                                 "control": "autocomplete", | ||||
|                                 "options": MomentTimezone.tz.names() | ||||
|                             } | ||||
|                         ], | ||||
|                         "model": { | ||||
|                             "clockFormat": [ | ||||
|                                 "YYYY/MM/DD hh:mm:ss", | ||||
|                                 "clock12" | ||||
|                             ], | ||||
|                             "timezone": "UTC" | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         "key": "timer", | ||||
|                         "name": "Timer", | ||||
| @@ -190,7 +299,10 @@ define([ | ||||
|                         } | ||||
|                     } | ||||
|                 ], | ||||
|                 "runs": [], | ||||
|                 "runs": [{ | ||||
|                     "implementation": FollowIndicator, | ||||
|                     "depends": ["openmct", "timerService"] | ||||
|                 }], | ||||
|                 "licenses": [ | ||||
|                     { | ||||
|                         "name": "moment-duration-format", | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <!-- | ||||
|  Open MCT, Copyright (c) 2014-2020, United States Government | ||||
|  Open MCT, Copyright (c) 2009-2016, United States Government | ||||
|  as represented by the Administrator of the National Aeronautics and Space | ||||
|  Administration. All rights reserved. | ||||
| 
 | ||||
| @@ -19,34 +19,14 @@ | ||||
|  this source code distribution or the Licensing information page available | ||||
|  at runtime from the About dialog for additional information. | ||||
| --> | ||||
| 
 | ||||
| <template> | ||||
| <li class="c-inspect-properties__row"> | ||||
|     <div class="c-inspect-properties__label"> | ||||
|         {{ label }} | ||||
|     </div> | ||||
|     <div class="c-inspect-properties__value"> | ||||
|         {{ value }} | ||||
|     </div> | ||||
| </li> | ||||
| </template> | ||||
| 
 | ||||
| <script> | ||||
| 
 | ||||
| export default { | ||||
|     props: { | ||||
|         label: { | ||||
|             type: String, | ||||
|             default() { | ||||
|                 return ''; | ||||
|             } | ||||
|         }, | ||||
|         value: { | ||||
|             type: String, | ||||
|             default() { | ||||
|                 return ''; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| </script> | ||||
| <div class="c-clock l-time-display u-style-receiver js-style-receiver" ng-controller="ClockController as clock"> | ||||
| 	<div class="c-clock__timezone"> | ||||
| 		{{clock.zone()}} | ||||
| 	</div> | ||||
| 	<div class="c-clock__value"> | ||||
| 		{{clock.text()}} | ||||
| 	</div> | ||||
| 	<div class="c-clock__ampm"> | ||||
| 		{{clock.ampm()}} | ||||
| 	</div> | ||||
| </div> | ||||
							
								
								
									
										56
									
								
								platform/features/clock/src/actions/FollowTimerAction.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								platform/features/clock/src/actions/FollowTimerAction.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|  | ||||
|         /** | ||||
|          * Designates a specific timer for following. Timelines, for example, | ||||
|          * use the actively followed timer to display a time-of-interest line | ||||
|          * and interpret time conductor bounds in the Timeline's relative | ||||
|          * time frame. | ||||
|          * | ||||
|          * @implements {Action} | ||||
|          * @memberof platform/features/clock | ||||
|          * @constructor | ||||
|          * @param {ActionContext} context the context for this action | ||||
|          */ | ||||
|         function FollowTimerAction(timerService, context) { | ||||
|             var domainObject = | ||||
|                 context.domainObject | ||||
|                 && context.domainObject.useCapability('adapter'); | ||||
|             this.perform = | ||||
|                 timerService.setTimer.bind(timerService, domainObject); | ||||
|         } | ||||
|  | ||||
|         FollowTimerAction.appliesTo = function (context) { | ||||
|             var model = | ||||
|                 (context.domainObject && context.domainObject.getModel()) | ||||
|                 || {}; | ||||
|  | ||||
|             return model.type === 'timer'; | ||||
|         }; | ||||
|  | ||||
|         return FollowTimerAction; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										110
									
								
								platform/features/clock/src/controllers/ClockController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								platform/features/clock/src/controllers/ClockController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     'moment', | ||||
|     'moment-timezone' | ||||
| ], | ||||
| function ( | ||||
|     moment, | ||||
|     momentTimezone | ||||
| ) { | ||||
|  | ||||
|     /** | ||||
|          * Controller for views of a Clock domain object. | ||||
|          * | ||||
|          * @constructor | ||||
|          * @memberof platform/features/clock | ||||
|          * @param {angular.Scope} $scope the Angular scope | ||||
|          * @param {platform/features/clock.TickerService} tickerService | ||||
|          *        a service used to align behavior with clock ticks | ||||
|          */ | ||||
|     function ClockController($scope, tickerService) { | ||||
|         var lastTimestamp, | ||||
|             unlisten, | ||||
|             timeFormat, | ||||
|             zoneName, | ||||
|             self = this; | ||||
|  | ||||
|         function update() { | ||||
|             var m = zoneName | ||||
|                 ? moment.utc(lastTimestamp).tz(zoneName) : moment.utc(lastTimestamp); | ||||
|             self.zoneAbbr = m.zoneAbbr(); | ||||
|             self.textValue = timeFormat && m.format(timeFormat); | ||||
|             self.ampmValue = m.format("A"); // Just the AM or PM part | ||||
|         } | ||||
|  | ||||
|         function tick(timestamp) { | ||||
|             lastTimestamp = timestamp; | ||||
|             update(); | ||||
|         } | ||||
|  | ||||
|         function updateModel(model) { | ||||
|             var baseFormat; | ||||
|             if (model !== undefined) { | ||||
|                 baseFormat = model.clockFormat[0]; | ||||
|  | ||||
|                 self.use24 = model.clockFormat[1] === 'clock24'; | ||||
|                 timeFormat = self.use24 | ||||
|                     ? baseFormat.replace('hh', "HH") : baseFormat; | ||||
|                 // If wrong timezone is provided, the UTC will be used | ||||
|                 zoneName = momentTimezone.tz.names().includes(model.timezone) | ||||
|                     ? model.timezone : "UTC"; | ||||
|                 update(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Pull in the model (clockFormat and timezone) from the domain object model | ||||
|         $scope.$watch('model', updateModel); | ||||
|  | ||||
|         // Listen for clock ticks ... and stop listening on destroy | ||||
|         unlisten = tickerService.listen(tick); | ||||
|         $scope.$on('$destroy', unlisten); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|          * Get the clock's time zone, as displayable text. | ||||
|          * @returns {string} | ||||
|          */ | ||||
|     ClockController.prototype.zone = function () { | ||||
|         return this.zoneAbbr; | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|          * Get the current time, as displayable text. | ||||
|          * @returns {string} | ||||
|          */ | ||||
|     ClockController.prototype.text = function () { | ||||
|         return this.textValue; | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|          * Get the text to display to qualify a time as AM or PM. | ||||
|          * @returns {string} | ||||
|          */ | ||||
|     ClockController.prototype.ampm = function () { | ||||
|         return this.use24 ? '' : this.ampmValue; | ||||
|     }; | ||||
|  | ||||
|     return ClockController; | ||||
| } | ||||
| ); | ||||
							
								
								
									
										65
									
								
								platform/features/clock/src/indicators/ClockIndicator.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								platform/features/clock/src/indicators/ClockIndicator.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ['moment'], | ||||
|     function (moment) { | ||||
|  | ||||
|         /** | ||||
|          * Indicator that displays the current UTC time in the status area. | ||||
|          * @implements {Indicator} | ||||
|          * @memberof platform/features/clock | ||||
|          * @param {platform/features/clock.TickerService} tickerService | ||||
|          *        a service used to align behavior with clock ticks | ||||
|          * @param {string} indicatorFormat format string for timestamps | ||||
|          *        shown in this indicator | ||||
|          */ | ||||
|         function ClockIndicator(tickerService, indicatorFormat) { | ||||
|             var self = this; | ||||
|  | ||||
|             this.text = ""; | ||||
|  | ||||
|             tickerService.listen(function (timestamp) { | ||||
|                 self.text = moment.utc(timestamp) | ||||
|                     .format(indicatorFormat) + " UTC"; | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         ClockIndicator.prototype.getGlyphClass = function () { | ||||
|             return ""; | ||||
|         }; | ||||
|  | ||||
|         ClockIndicator.prototype.getCssClass = function () { | ||||
|             return "t-indicator-clock icon-clock no-minify c-indicator--not-clickable"; | ||||
|         }; | ||||
|  | ||||
|         ClockIndicator.prototype.getText = function () { | ||||
|             return this.text; | ||||
|         }; | ||||
|  | ||||
|         ClockIndicator.prototype.getDescription = function () { | ||||
|             return ""; | ||||
|         }; | ||||
|  | ||||
|         return ClockIndicator; | ||||
|     } | ||||
| ); | ||||
| @@ -1,5 +1,5 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2021, United States Government | ||||
|  * Open MCT, Copyright (c) 2009-2018, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
| @@ -20,34 +20,32 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| /** | ||||
|  * Module defining url handling. | ||||
|  */ | ||||
| define([], function () { | ||||
| 
 | ||||
| export function paramsToArray(openmct) { | ||||
|     // parse urParams from an object to an array.
 | ||||
|     let urlParams = openmct.router.getParams(); | ||||
|     let newTabParams = []; | ||||
|     for (let key in urlParams) { | ||||
|         if ({}.hasOwnProperty.call(urlParams, key)) { | ||||
|             let param = `${key}=${urlParams[key]}`; | ||||
|             newTabParams.push(param); | ||||
|     /** | ||||
|      * Indicator that displays the active timer, as well as its | ||||
|      * current state. | ||||
|      * @memberof platform/features/clock | ||||
|      */ | ||||
|     return function installFollowIndicator(openmct, timerService) { | ||||
|         var indicator = openmct.indicators.simpleIndicator(); | ||||
|         var timer = timerService.getTimer(); | ||||
|         setIndicatorStatus(timer); | ||||
| 
 | ||||
|         function setIndicatorStatus(newTimer) { | ||||
|             if (newTimer !== undefined) { | ||||
|                 indicator.iconClass('icon-timer'); | ||||
|                 indicator.statusClass('s-status-on'); | ||||
|                 indicator.text('Following timer ' + newTimer.name); | ||||
|             } else { | ||||
|                 indicator.iconClass('icon-timer'); | ||||
|                 indicator.statusClass('s-status-disabled'); | ||||
|                 indicator.text('No timer being followed'); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return newTabParams; | ||||
| } | ||||
|         timerService.on('change', setIndicatorStatus); | ||||
| 
 | ||||
| export function identifierToString(openmct, objectPath) { | ||||
|     return '#/browse/' + openmct.objects.getRelativePath(objectPath); | ||||
| } | ||||
| 
 | ||||
| export default function objectPathToUrl(openmct, objectPath) { | ||||
|     let url = identifierToString(openmct, objectPath); | ||||
|     let urlParams = paramsToArray(openmct); | ||||
|     if (urlParams.length) { | ||||
|         url += '?' + urlParams.join('&'); | ||||
|     } | ||||
| 
 | ||||
|     return url; | ||||
| } | ||||
|         openmct.indicators.add(indicator); | ||||
|     }; | ||||
| }); | ||||
| @@ -0,0 +1,89 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     "../../src/actions/FollowTimerAction" | ||||
| ], function (FollowTimerAction) { | ||||
|     var TIMER_SERVICE_METHODS = | ||||
|         ['setTimer', 'getTimer', 'clearTimer', 'on', 'off']; | ||||
|  | ||||
|     describe("The Follow Timer action", function () { | ||||
|         var testContext; | ||||
|         var testModel; | ||||
|         var testAdaptedObject; | ||||
|  | ||||
|         beforeEach(function () { | ||||
|             testModel = {}; | ||||
|             testContext = { | ||||
|                 domainObject: jasmine.createSpyObj('domainObject', [ | ||||
|                     'getModel', | ||||
|                     'useCapability' | ||||
|                 ]) | ||||
|             }; | ||||
|             testAdaptedObject = { foo: 'bar' }; | ||||
|             testContext.domainObject.getModel.and.returnValue(testModel); | ||||
|             testContext.domainObject.useCapability.and.callFake(function (c) { | ||||
|                 return c === 'adapter' && testAdaptedObject; | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         it("is applicable to timers", function () { | ||||
|             testModel.type = "timer"; | ||||
|             expect(FollowTimerAction.appliesTo(testContext)).toBe(true); | ||||
|         }); | ||||
|  | ||||
|         it("is inapplicable to non-timers", function () { | ||||
|             testModel.type = "folder"; | ||||
|             expect(FollowTimerAction.appliesTo(testContext)).toBe(false); | ||||
|         }); | ||||
|  | ||||
|         describe("when instantiated", function () { | ||||
|             var mockTimerService; | ||||
|             var action; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockTimerService = jasmine.createSpyObj( | ||||
|                     'timerService', | ||||
|                     TIMER_SERVICE_METHODS | ||||
|                 ); | ||||
|                 action = new FollowTimerAction(mockTimerService, testContext); | ||||
|             }); | ||||
|  | ||||
|             it("does not interact with the timer service", function () { | ||||
|                 TIMER_SERVICE_METHODS.forEach(function (method) { | ||||
|                     expect(mockTimerService[method]).not.toHaveBeenCalled(); | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             describe("and performed", function () { | ||||
|                 beforeEach(function () { | ||||
|                     action.perform(); | ||||
|                 }); | ||||
|  | ||||
|                 it("sets the active timer", function () { | ||||
|                     expect(mockTimerService.setTimer) | ||||
|                         .toHaveBeenCalledWith(testAdaptedObject); | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
							
								
								
									
										107
									
								
								platform/features/clock/test/controllers/ClockControllerSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								platform/features/clock/test/controllers/ClockControllerSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2017, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/controllers/ClockController"], | ||||
|     function (ClockController) { | ||||
|  | ||||
|         // Wed, 03 Jun 2015 17:56:14 GMT | ||||
|         var TEST_TIMESTAMP = 1433354174000; | ||||
|  | ||||
|         describe("A clock view's controller", function () { | ||||
|             var mockScope, | ||||
|                 mockTicker, | ||||
|                 mockUnticker, | ||||
|                 controller; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockScope = jasmine.createSpyObj('$scope', ['$watch', '$on']); | ||||
|                 mockTicker = jasmine.createSpyObj('ticker', ['listen']); | ||||
|                 mockUnticker = jasmine.createSpy('unticker'); | ||||
|  | ||||
|                 mockTicker.listen.and.returnValue(mockUnticker); | ||||
|  | ||||
|                 controller = new ClockController(mockScope, mockTicker); | ||||
|             }); | ||||
|  | ||||
|             it("watches for model (clockFormat and timezone) from the domain object model", function () { | ||||
|                 expect(mockScope.$watch).toHaveBeenCalledWith( | ||||
|                     "model", | ||||
|                     jasmine.any(Function) | ||||
|                 ); | ||||
|             }); | ||||
|  | ||||
|             it("subscribes to clock ticks", function () { | ||||
|                 expect(mockTicker.listen) | ||||
|                     .toHaveBeenCalledWith(jasmine.any(Function)); | ||||
|             }); | ||||
|  | ||||
|             it("unsubscribes to ticks when destroyed", function () { | ||||
|                 // Make sure $destroy is being listened for... | ||||
|                 expect(mockScope.$on.calls.mostRecent().args[0]).toEqual('$destroy'); | ||||
|                 expect(mockUnticker).not.toHaveBeenCalled(); | ||||
|  | ||||
|                 // ...and makes sure that its listener unsubscribes from ticker | ||||
|                 mockScope.$on.calls.mostRecent().args[1](); | ||||
|                 expect(mockUnticker).toHaveBeenCalled(); | ||||
|             }); | ||||
|  | ||||
|             it("formats using the format string from the model", function () { | ||||
|                 mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); | ||||
|                 mockScope.$watch.calls.mostRecent().args[1]({ | ||||
|                     "clockFormat": [ | ||||
|                         "YYYY-DDD hh:mm:ss", | ||||
|                         "clock24" | ||||
|                     ], | ||||
|                     "timezone": "Canada/Eastern" | ||||
|                 }); | ||||
|  | ||||
|                 expect(controller.zone()).toEqual("EDT"); | ||||
|                 expect(controller.text()).toEqual("2015-154 13:56:14"); | ||||
|                 expect(controller.ampm()).toEqual(""); | ||||
|             }); | ||||
|  | ||||
|             it("formats 12-hour time", function () { | ||||
|                 mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); | ||||
|                 mockScope.$watch.calls.mostRecent().args[1]({ | ||||
|                     "clockFormat": [ | ||||
|                         "YYYY-DDD hh:mm:ss", | ||||
|                         "clock12" | ||||
|                     ], | ||||
|                     "timezone": "" | ||||
|                 }); | ||||
|  | ||||
|                 expect(controller.zone()).toEqual("UTC"); | ||||
|                 expect(controller.text()).toEqual("2015-154 05:56:14"); | ||||
|                 expect(controller.ampm()).toEqual("PM"); | ||||
|             }); | ||||
|  | ||||
|             it("does not throw exceptions when model is undefined", function () { | ||||
|                 mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); | ||||
|                 expect(function () { | ||||
|                     mockScope.$watch.calls.mostRecent().args[1](undefined); | ||||
|                 }).not.toThrow(); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -101,7 +101,7 @@ define( | ||||
|                     name: "Pause" | ||||
|                 }); | ||||
|                 mockStop.getMetadata.and.returnValue({ | ||||
|                     cssClass: "icon-box-round-corners", | ||||
|                     cssClass: "icon-box", | ||||
|                     name: "Stop" | ||||
|                 }); | ||||
|                 mockScope.domainObject = mockDomainObject; | ||||
|   | ||||
| @@ -0,0 +1,58 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../../src/indicators/ClockIndicator"], | ||||
|     function (ClockIndicator) { | ||||
|  | ||||
|         // Wed, 03 Jun 2015 17:56:14 GMT | ||||
|         var TEST_TIMESTAMP = 1433354174000, | ||||
|             TEST_FORMAT = "YYYY-DDD HH:mm:ss"; | ||||
|  | ||||
|         describe("The clock indicator", function () { | ||||
|             var mockTicker, | ||||
|                 mockUnticker, | ||||
|                 indicator; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 mockTicker = jasmine.createSpyObj('ticker', ['listen']); | ||||
|                 mockUnticker = jasmine.createSpy('unticker'); | ||||
|  | ||||
|                 mockTicker.listen.and.returnValue(mockUnticker); | ||||
|  | ||||
|                 indicator = new ClockIndicator(mockTicker, TEST_FORMAT); | ||||
|             }); | ||||
|  | ||||
|             it("displays the current time", function () { | ||||
|                 mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); | ||||
|                 expect(indicator.getText()).toEqual("2015-154 17:56:14 UTC"); | ||||
|             }); | ||||
|  | ||||
|             it("implements the Indicator interface", function () { | ||||
|                 expect(indicator.getCssClass()).toEqual(jasmine.any(String)); | ||||
|                 expect(indicator.getText()).toEqual(jasmine.any(String)); | ||||
|                 expect(indicator.getDescription()).toEqual(jasmine.any(String)); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
| @@ -0,0 +1,96 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2018, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     "../../src/indicators/FollowIndicator", | ||||
|     "../../src/services/TimerService", | ||||
|     "../../../../../src/MCT", | ||||
|     'zepto' | ||||
| ], function ( | ||||
|     FollowIndicator, | ||||
|     TimerService, | ||||
|     MCT, | ||||
|     $ | ||||
| ) { | ||||
|     xdescribe("The timer-following indicator", function () { | ||||
|         var timerService; | ||||
|         var openmct; | ||||
|  | ||||
|         beforeEach(function () { | ||||
|             openmct = new MCT(); | ||||
|             timerService = new TimerService(openmct); | ||||
|             spyOn(openmct.indicators, "add"); | ||||
|         }); | ||||
|  | ||||
|         it("adds an indicator when installed", function () { | ||||
|             FollowIndicator(openmct, timerService); | ||||
|             expect(openmct.indicators.add).toHaveBeenCalled(); | ||||
|         }); | ||||
|  | ||||
|         it("indicates that no timer is being followed", function () { | ||||
|             FollowIndicator(openmct, timerService); | ||||
|             var simpleIndicator = openmct.indicators.add.calls.mostRecent().args[0]; | ||||
|             var element = simpleIndicator.element; | ||||
|             var text = $('.indicator-text', element).text().trim(); | ||||
|             expect(text).toEqual('No timer being followed'); | ||||
|         }); | ||||
|  | ||||
|         describe("when a timer is set", function () { | ||||
|             var testObject; | ||||
|             var simpleIndicator; | ||||
|  | ||||
|             beforeEach(function () { | ||||
|                 testObject = { | ||||
|                     identifier: { | ||||
|                         namespace: 'namespace', | ||||
|                         key: 'key' | ||||
|                     }, | ||||
|                     name: "some timer!" | ||||
|                 }; | ||||
|                 timerService.setTimer(testObject); | ||||
|                 FollowIndicator(openmct, timerService); | ||||
|                 simpleIndicator = openmct.indicators.add.calls.mostRecent().args[0]; | ||||
|             }); | ||||
|  | ||||
|             it("displays the timer's name", function () { | ||||
|                 var element = simpleIndicator.element; | ||||
|                 var text = $('.indicator-text', element).text().trim(); | ||||
|                 expect(text).toEqual('Following timer ' + testObject.name); | ||||
|             }); | ||||
|  | ||||
|             it("displays the timer's name when it changes", function () { | ||||
|                 var secondTimer = { | ||||
|                     identifier: { | ||||
|                         namespace: 'namespace', | ||||
|                         key: 'key2' | ||||
|                     }, | ||||
|                     name: "Some other timer" | ||||
|                 }; | ||||
|                 var element = simpleIndicator.element; | ||||
|                 timerService.setTimer(secondTimer); | ||||
|                 var text = $('.indicator-text', element).text().trim(); | ||||
|                 expect(text).toEqual('Following timer ' + secondTimer.name); | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
							
								
								
									
										120
									
								
								platform/features/hyperlink/bundle.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								platform/features/hyperlink/bundle.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define([ | ||||
|     './src/HyperlinkController', | ||||
|     './res/templates/hyperlink.html' | ||||
| ], function ( | ||||
|     HyperlinkController, | ||||
|     hyperlinkTemplate | ||||
| ) { | ||||
|     return { | ||||
|         name: "platform/features/hyperlink", | ||||
|         definition: { | ||||
|             "name": "Hyperlink", | ||||
|             "description": "Insert a hyperlink to reference a link", | ||||
|             "extensions": { | ||||
|                 "types": [ | ||||
|                     { | ||||
|                         "key": "hyperlink", | ||||
|                         "name": "Hyperlink", | ||||
|                         "cssClass": "icon-chain-links", | ||||
|                         "description": "A hyperlink to redirect to a different link", | ||||
|                         "features": ["creation"], | ||||
|                         "properties": [ | ||||
|                             { | ||||
|                                 "key": "url", | ||||
|                                 "name": "URL", | ||||
|                                 "control": "textfield", | ||||
|                                 "required": true, | ||||
|                                 "cssClass": "l-input-lg" | ||||
|                             }, | ||||
|  | ||||
|                             { | ||||
|                                 "key": "displayText", | ||||
|                                 "name": "Text to Display", | ||||
|                                 "control": "textfield", | ||||
|                                 "required": true, | ||||
|                                 "cssClass": "l-input-lg" | ||||
|                             }, | ||||
|                             { | ||||
|                                 "key": "displayFormat", | ||||
|                                 "name": "Display Format", | ||||
|                                 "control": "select", | ||||
|                                 "options": [ | ||||
|                                     { | ||||
|                                         "name": "Link", | ||||
|                                         "value": "link" | ||||
|                                     }, | ||||
|                                     { | ||||
|                                         "value": "button", | ||||
|                                         "name": "Button" | ||||
|                                     } | ||||
|                                 ], | ||||
|                                 "cssClass": "l-inline" | ||||
|                             }, | ||||
|                             { | ||||
|                                 "key": "openNewTab", | ||||
|                                 "name": "Tab to Open Hyperlink", | ||||
|                                 "control": "select", | ||||
|                                 "options": [ | ||||
|                                     { | ||||
|                                         "name": "Open in this tab", | ||||
|                                         "value": "thisTab" | ||||
|                                     }, | ||||
|                                     { | ||||
|                                         "value": "newTab", | ||||
|                                         "name": "Open in a new tab" | ||||
|                                     } | ||||
|                                 ], | ||||
|                                 "cssClass": "l-inline" | ||||
|  | ||||
|                             } | ||||
|                         ], | ||||
|                         "model": { | ||||
|                             "displayFormat": "link", | ||||
|                             "openNewTab": "thisTab", | ||||
|                             "removeTitle": true | ||||
|                         } | ||||
|  | ||||
|                     } | ||||
|                 ], | ||||
|                 "views": [ | ||||
|                     { | ||||
|                         "key": "hyperlink", | ||||
|                         "type": "hyperlink", | ||||
|                         "name": "Hyperlink Display", | ||||
|                         "template": hyperlinkTemplate, | ||||
|                         "editable": false | ||||
|                     } | ||||
|                 ], | ||||
|                 "controllers": [ | ||||
|                     { | ||||
|                         "key": "HyperlinkController", | ||||
|                         "implementation": HyperlinkController, | ||||
|                         "depends": ["$scope"] | ||||
|                     } | ||||
|                 ] | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
							
								
								
									
										28
									
								
								platform/features/hyperlink/res/templates/hyperlink.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								platform/features/hyperlink/res/templates/hyperlink.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| <!-- | ||||
|  Open MCT, Copyright (c) 2014-2021, 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. | ||||
| --> | ||||
| <a class="c-hyperlink u-links" ng-controller="HyperlinkController as hyperlink" href="{{domainObject.getModel().url}}" | ||||
|    ng-attr-target="{{hyperlink.openNewTab() ? '_blank' : undefined}}" | ||||
|    ng-class="{ | ||||
|    'c-hyperlink--button u-fills-container' : hyperlink.isButton(), | ||||
|    'c-hyperlink--link' : !hyperlink.isButton() }"> | ||||
|     <span class="c-hyperlink__label">{{domainObject.getModel().displayText}}</span> | ||||
| </a> | ||||
							
								
								
									
										61
									
								
								platform/features/hyperlink/src/HyperlinkController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								platform/features/hyperlink/src/HyperlinkController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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 bundle adds the Hyperlink object type, which can be used to add hyperlinks as a domain Object type | ||||
|  and into display Layouts as either a button or link that can be chosen to open in either the same tab or | ||||
|  create a new tab to open the link in | ||||
|  * @namespace platform/features/hyperlink | ||||
|  */ | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|         function HyperlinkController($scope) { | ||||
|             this.$scope = $scope; | ||||
|         } | ||||
|  | ||||
|         /**Function to analyze the location in which to open the hyperlink | ||||
|         @returns true if the hyperlink is chosen to open in a different tab, false if the same tab | ||||
|         **/ | ||||
|         HyperlinkController.prototype.openNewTab = function () { | ||||
|             if (this.$scope.domainObject.getModel().openNewTab === "thisTab") { | ||||
|                 return false; | ||||
|             } else { | ||||
|                 return true; | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         /**Function to specify the format in which the hyperlink should be created | ||||
|         @returns true if the hyperlink is chosen to be created as a button, false if a link | ||||
|         **/ | ||||
|         HyperlinkController.prototype.isButton = function () { | ||||
|             if (this.$scope.domainObject.getModel().displayFormat === "link") { | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             return true; | ||||
|         }; | ||||
|  | ||||
|         return HyperlinkController; | ||||
|     } | ||||
|  | ||||
| ); | ||||
							
								
								
									
										89
									
								
								platform/features/hyperlink/test/HyperlinkControllerSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								platform/features/hyperlink/test/HyperlinkControllerSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2009-2016, 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| define( | ||||
|     ["../src/HyperlinkController"], | ||||
|     function (HyperlinkController) { | ||||
|  | ||||
|         describe("The controller for hyperlinks", function () { | ||||
|             var domainObject, | ||||
|                 controller, | ||||
|                 scope; | ||||
|             beforeEach(function () { | ||||
|                 scope = jasmine.createSpyObj( | ||||
|                     "$scope", | ||||
|                     ["domainObject"] | ||||
|                 ); | ||||
|                 domainObject = jasmine.createSpyObj( | ||||
|                     "domainObject", | ||||
|                     ["getModel"] | ||||
|                 ); | ||||
|                 scope.domainObject = domainObject; | ||||
|                 controller = new HyperlinkController(scope); | ||||
|             }); | ||||
|             it("knows when it should open a new tab", function () { | ||||
|                 scope.domainObject.getModel.and.returnValue({ | ||||
|                     "displayFormat": "link", | ||||
|                     "openNewTab": "newTab", | ||||
|                     "showTitle": false | ||||
|                 } | ||||
|                 ); | ||||
|                 controller = new HyperlinkController(scope); | ||||
|                 expect(controller.openNewTab()) | ||||
|                     .toBe(true); | ||||
|             }); | ||||
|             it("knows when it is a button", function () { | ||||
|                 scope.domainObject.getModel.and.returnValue({ | ||||
|                     "displayFormat": "button", | ||||
|                     "openNewTab": "thisTab", | ||||
|                     "showTitle": false | ||||
|                 } | ||||
|                 ); | ||||
|                 controller = new HyperlinkController(scope); | ||||
|                 expect(controller.isButton()) | ||||
|                     .toEqual(true); | ||||
|             }); | ||||
|             it("knows when it should open in the same tab", function () { | ||||
|                 scope.domainObject.getModel.and.returnValue({ | ||||
|                     "displayFormat": "link", | ||||
|                     "openNewTab": "thisTab", | ||||
|                     "showTitle": false | ||||
|                 } | ||||
|                 ); | ||||
|                 controller = new HyperlinkController(scope); | ||||
|                 expect(controller.openNewTab()) | ||||
|                     .toBe(false); | ||||
|             }); | ||||
|             it("knows when it is a link", function () { | ||||
|                 scope.domainObject.getModel.and.returnValue({ | ||||
|                     "displayFormat": "link", | ||||
|                     "openNewTab": "thisTab", | ||||
|                     "showTitle": false | ||||
|                 } | ||||
|                 ); | ||||
|                 controller = new HyperlinkController(scope); | ||||
|                 expect(controller.openNewTab()) | ||||
|                     .toBe(false); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										70
									
								
								platform/features/timeline/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								platform/features/timeline/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| This bundle provides the Timeline domain object type, as well | ||||
| as other associated domain object types and relevant views. | ||||
|  | ||||
| # Implementation notes | ||||
|  | ||||
| ## Model Properties | ||||
|  | ||||
| The properties below record properties relevant to using and | ||||
| understanding timelines based on their JSON representation. | ||||
| Additional common properties, such as `modified` | ||||
| or `persisted` timestamps, may also be present. | ||||
|  | ||||
| ### Timeline Model | ||||
|  | ||||
| A timeline's model looks like: | ||||
|  | ||||
| ``` | ||||
| { | ||||
|     "type": "timeline", | ||||
|     "start": { | ||||
|         "timestamp": <number> (milliseconds since epoch), | ||||
|         "epoch": <string> (currently, always "SET") | ||||
|     }, | ||||
|     "capacity": <number> (optional; battery capacity in watt-hours) | ||||
|     "composition": <string[]> (array of identifiers for contained objects) | ||||
| } | ||||
| ``` | ||||
|  | ||||
| The identifiers in a timeline's `composition` field should refer to | ||||
| other Timeline objects, or to Activity objects. | ||||
|  | ||||
| ### Activity Model | ||||
|  | ||||
| An activity's model looks like: | ||||
|  | ||||
| ``` | ||||
| { | ||||
|     "type": "activity", | ||||
|     "start": { | ||||
|         "timestamp": <number> (milliseconds since epoch), | ||||
|         "epoch": <string> (currently, always "SET") | ||||
|     }, | ||||
|     "duration": { | ||||
|         "timestamp": <number> (duration of this activity, in milliseconds) | ||||
|         "epoch": "SET" (this is ignored) | ||||
|     }, | ||||
|     "relationships": { | ||||
|         "modes": <string[]> (array of applicable Activity Mode ids) | ||||
|     }, | ||||
|     "link": <string> (optional; URL linking to associated external resource) | ||||
|     "composition": <string[]> (array of identifiers for contained objects) | ||||
| } | ||||
| ``` | ||||
|  | ||||
| The identifiers in a timeline's `composition` field should only refer to | ||||
| other Activity objects. | ||||
|  | ||||
| ### Activity Mode Model | ||||
|  | ||||
| An activity mode's model looks like: | ||||
|  | ||||
| ``` | ||||
| { | ||||
|     "type": "mode", | ||||
|     "resources": { | ||||
|         "comms": <number> (communications utilization, in Kbps) | ||||
|         "power": <number> (power utilization, in watts) | ||||
|     } | ||||
| } | ||||
| ``` | ||||
| @@ -20,40 +20,33 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| import Clock from './components/Clock.vue'; | ||||
| import Vue from 'vue'; | ||||
| 
 | ||||
| export default function ClockViewProvider(openmct) { | ||||
| define([ | ||||
|     "./res/templates/deprecated-timeline-message.html" | ||||
| ], function ( | ||||
|     deprecatedTimelineMessage | ||||
| ) { | ||||
|     return { | ||||
|         key: 'clock.view', | ||||
|         name: 'Clock', | ||||
|         cssClass: 'icon-clock', | ||||
|         canView(domainObject) { | ||||
|             return domainObject.type === 'clock'; | ||||
|         }, | ||||
| 
 | ||||
|         view: function (domainObject) { | ||||
|             let component; | ||||
| 
 | ||||
|             return { | ||||
|                 show: function (element) { | ||||
|                     component = new Vue({ | ||||
|                         el: element, | ||||
|                         components: { | ||||
|                             Clock | ||||
|                         }, | ||||
|                         provide: { | ||||
|                             openmct, | ||||
|                             domainObject | ||||
|                         }, | ||||
|                         template: '<clock />' | ||||
|                     }); | ||||
|                 }, | ||||
|                 destroy: function () { | ||||
|                     component.$destroy(); | ||||
|                     component = undefined; | ||||
|                 } | ||||
|             }; | ||||
|         name: 'platform/features/timeline', | ||||
|         definition: { | ||||
|             extensions: { | ||||
|                 types: [ | ||||
|                     { | ||||
|                         key: "timeline", | ||||
|                         name: "Timeline", | ||||
|                         description: "Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. (07/18/2018)", | ||||
|                         priority: 502 | ||||
|                     } | ||||
|                 ], | ||||
|                 views: [ | ||||
|                     { | ||||
|                         key: "timeline", | ||||
|                         name: "Timeline", | ||||
|                         type: "timeline", | ||||
|                         description: "Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. (07/18/2018)", | ||||
|                         template: deprecatedTimelineMessage | ||||
|                     } | ||||
|                 ] | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| } | ||||
| }); | ||||
| @@ -0,0 +1,10 @@ | ||||
| <div> | ||||
|     Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. | ||||
| </div> | ||||
| <div> | ||||
|     Please open an issue in the | ||||
|     <a href="https://github.com/nasa/openmct/issues" target="_blank"> | ||||
|         Open MCT Issue tracker | ||||
|     </a> | ||||
|     if you have any questions about the timeline plugin. | ||||
| </div> | ||||
| @@ -44,11 +44,9 @@ define( | ||||
|                         setText(result.name); | ||||
|                         scope.ngModel[scope.field] = result; | ||||
|                         control.$setValidity("file-input", true); | ||||
|                         scope.$digest(); | ||||
|                     }, function () { | ||||
|                         setText('Select File'); | ||||
|                         control.$setValidity("file-input", false); | ||||
|                         scope.$digest(); | ||||
|                     }); | ||||
|                 } | ||||
|  | ||||
|   | ||||
| @@ -30,8 +30,8 @@ define([ | ||||
|  | ||||
|     return function ImportExportPlugin() { | ||||
|         return function (openmct) { | ||||
|             ExportAsJSONAction.prototype.appliesTo = function (context) { | ||||
|                 return this.openmct.$injector.get('policyService') | ||||
|             ExportAsJSONAction.appliesTo = function (context) { | ||||
|                 return openmct.$injector.get('policyService') | ||||
|                     .allow("creation", context.domainObject.getCapability("type") | ||||
|                     ); | ||||
|             }; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ define( | ||||
|     ], | ||||
|     function (ExportAsJSONAction, domainObjectFactory, MCT, AdapterCapability) { | ||||
|  | ||||
|         describe("The export JSON action", function () { | ||||
|         xdescribe("The export JSON action", function () { | ||||
|  | ||||
|             var context, | ||||
|                 action, | ||||
| @@ -102,7 +102,7 @@ define( | ||||
|                 expect(action).toBeDefined(); | ||||
|             }); | ||||
|  | ||||
|             xit("doesn't export non-creatable objects in tree", function () { | ||||
|             it("doesn't export non-creatable objects in tree", function () { | ||||
|                 var nonCreatableType = { | ||||
|                     hasFeature: | ||||
|                         function (feature) { | ||||
| @@ -149,7 +149,7 @@ define( | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             xit("can export self-containing objects", function () { | ||||
|             it("can export self-containing objects", function () { | ||||
|                 var parent = domainObjectFactory({ | ||||
|                     name: 'parent', | ||||
|                     model: { | ||||
| @@ -191,7 +191,7 @@ define( | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             xit("exports links to external objects as new objects", function () { | ||||
|             it("exports links to external objects as new objects", function () { | ||||
|                 var parent = domainObjectFactory({ | ||||
|                     name: 'parent', | ||||
|                     model: { | ||||
|   | ||||
| @@ -27,7 +27,7 @@ define( | ||||
|     ], | ||||
|     function (ImportAsJSONAction, domainObjectFactory) { | ||||
|  | ||||
|         describe("The import JSON action", function () { | ||||
|         xdescribe("The import JSON action", function () { | ||||
|  | ||||
|             var context = {}; | ||||
|             var action, | ||||
| @@ -146,7 +146,7 @@ define( | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             xit("can import self-containing objects", function () { | ||||
|             it("can import self-containing objects", function () { | ||||
|                 var compDomainObject = domainObjectFactory({ | ||||
|                     name: 'compObject', | ||||
|                     model: { name: 'compObject'}, | ||||
| @@ -198,7 +198,7 @@ define( | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             xit("assigns new ids to each imported object", function () { | ||||
|             it("assigns new ids to each imported object", function () { | ||||
|                 dialogService.getUserInput.and.returnValue(Promise.resolve( | ||||
|                     { | ||||
|                         selectFile: { | ||||
|   | ||||
| @@ -47,7 +47,7 @@ define( | ||||
|          * @param $interval Angular's $interval service | ||||
|          * @param {string} space the name of the persistence space being served | ||||
|          * @param {string} root the root of the path to ElasticSearch | ||||
|          * @param {string} path the path to domain objects within ElasticSearch | ||||
|          * @param {stirng} path the path to domain objects within ElasticSearch | ||||
|          */ | ||||
|         function ElasticPersistenceProvider($http, $q, space, root, path) { | ||||
|             this.spaces = [space]; | ||||
|   | ||||
							
								
								
									
										16
									
								
								src/MCT.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/MCT.js
									
									
									
									
									
								
							| @@ -122,7 +122,6 @@ define([ | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         this.destroy = this.destroy.bind(this); | ||||
|         /** | ||||
|          * Tracks current selection state of the application. | ||||
|          * @private | ||||
| @@ -136,7 +135,7 @@ define([ | ||||
|          * @memberof module:openmct.MCT# | ||||
|          * @name conductor | ||||
|          */ | ||||
|         this.time = new api.TimeAPI(this); | ||||
|         this.time = new api.TimeAPI(); | ||||
|  | ||||
|         /** | ||||
|          * An interface for interacting with the composition of domain objects. | ||||
| @@ -253,9 +252,7 @@ define([ | ||||
|  | ||||
|         this.status = new api.StatusAPI(this); | ||||
|  | ||||
|         this.priority = api.PriorityAPI; | ||||
|  | ||||
|         this.router = new ApplicationRouter(this); | ||||
|         this.router = new ApplicationRouter(); | ||||
|  | ||||
|         this.branding = BrandingAPI.default; | ||||
|  | ||||
| @@ -265,8 +262,7 @@ define([ | ||||
|         // Plugins that are installed by default | ||||
|  | ||||
|         this.install(this.plugins.Plot()); | ||||
|         this.install(this.plugins.Chart()); | ||||
|         this.install(this.plugins.TelemetryTable.default()); | ||||
|         this.install(this.plugins.TelemetryTable()); | ||||
|         this.install(PreviewPlugin.default()); | ||||
|         this.install(LegacyIndicatorsPlugin()); | ||||
|         this.install(LicensesPlugin.default()); | ||||
| @@ -278,7 +274,6 @@ define([ | ||||
|         this.install(ImageryPlugin.default()); | ||||
|         this.install(this.plugins.FlexibleLayout()); | ||||
|         this.install(this.plugins.GoToOriginalAction()); | ||||
|         this.install(this.plugins.OpenInNewTabAction()); | ||||
|         this.install(this.plugins.ImportExport()); | ||||
|         this.install(this.plugins.WebPage()); | ||||
|         this.install(this.plugins.Condition()); | ||||
| @@ -287,10 +282,8 @@ define([ | ||||
|         this.install(this.plugins.NotificationIndicator()); | ||||
|         this.install(this.plugins.NewFolderAction()); | ||||
|         this.install(this.plugins.ViewDatumAction()); | ||||
|         this.install(this.plugins.ViewLargeAction()); | ||||
|         this.install(this.plugins.ObjectInterceptors()); | ||||
|         this.install(this.plugins.NonEditableFolder()); | ||||
|         this.install(this.plugins.DeviceClassifier()); | ||||
|     } | ||||
|  | ||||
|     MCT.prototype = Object.create(EventEmitter.prototype); | ||||
| @@ -440,8 +433,6 @@ define([ | ||||
|                     Browse(this); | ||||
|                 } | ||||
|  | ||||
|                 window.addEventListener('beforeunload', this.destroy); | ||||
|  | ||||
|                 this.router.start(); | ||||
|                 this.emit('start'); | ||||
|             }.bind(this)); | ||||
| @@ -465,7 +456,6 @@ define([ | ||||
|     }; | ||||
|  | ||||
|     MCT.prototype.destroy = function () { | ||||
|         window.removeEventListener('beforeunload', this.destroy); | ||||
|         this.emit('destroy'); | ||||
|         this.router.destroy(); | ||||
|     }; | ||||
|   | ||||
| @@ -28,6 +28,8 @@ export default function LegacyActionAdapter(openmct, legacyActions) { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         console.warn(`DEPRECATION WARNING: Action ${action.definition.key} in bundle ${action.bundle.path} is non-contextual and should be migrated.`); | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -29,6 +29,7 @@ define([ | ||||
|     './capabilities/APICapabilityDecorator', | ||||
|     './policies/AdaptedViewPolicy', | ||||
|     './runs/AlternateCompositionInitializer', | ||||
|     './runs/TypeDeprecationChecker', | ||||
|     './runs/LegacyTelemetryProvider', | ||||
|     './runs/RegisterLegacyTypes', | ||||
|     './services/LegacyObjectAPIInterceptor', | ||||
| @@ -45,6 +46,7 @@ define([ | ||||
|     APICapabilityDecorator, | ||||
|     AdaptedViewPolicy, | ||||
|     AlternateCompositionInitializer, | ||||
|     TypeDeprecationChecker, | ||||
|     LegacyTelemetryProvider, | ||||
|     RegisterLegacyTypes, | ||||
|     LegacyObjectAPIInterceptor, | ||||
| @@ -133,6 +135,10 @@ define([ | ||||
|                     } | ||||
|                 ], | ||||
|                 runs: [ | ||||
|                     { | ||||
|                         implementation: TypeDeprecationChecker, | ||||
|                         depends: ["types[]"] | ||||
|                     }, | ||||
|                     { | ||||
|                         implementation: AlternateCompositionInitializer, | ||||
|                         depends: ["openmct"] | ||||
|   | ||||
| @@ -161,23 +161,6 @@ define([ | ||||
|             evaluate: function (datum, property) { | ||||
|                 return limitEvaluator.evaluate(datum, property && property.key); | ||||
|             } | ||||
|  | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     LegacyTelemetryProvider.prototype.getLimits = function (domainObject) { | ||||
|         const oldObject = this.instantiate( | ||||
|             utils.toOldFormat(domainObject), | ||||
|             utils.makeKeyString(domainObject.identifier) | ||||
|         ); | ||||
|         const limitEvaluator = oldObject.getCapability("limit"); | ||||
|  | ||||
|         return { | ||||
|             limits: () => { | ||||
|                 return limitEvaluator.limits.then !== undefined | ||||
|                     ? limitEvaluator.limits() | ||||
|                     : Promise.resolve(limitEvaluator.limits()); | ||||
|             } | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,12 @@ define([ | ||||
|  | ||||
| ) { | ||||
|     function RegisterLegacyTypes(types, openmct) { | ||||
|         types.forEach(function (legacyDefinition) { | ||||
|             if (!openmct.types.get(legacyDefinition.key)) { | ||||
|                 console.warn(`DEPRECATION WARNING: Migrate type ${legacyDefinition.key} from ${legacyDefinition.bundle.path} to use the new Types API.  Legacy type support will be removed soon.`); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         openmct.types.importLegacyTypes(types); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,9 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT Web, Copyright (c) 2014-2021, United States Government | ||||
|  * Open openmct, Copyright (c) 2014-2021, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT Web is licensed under the Apache License, Version 2.0 (the | ||||
|  * Open openmct 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.
 | ||||
| @@ -14,19 +14,33 @@ | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  * | ||||
|  * Open MCT Web includes source code licensed under additional open source | ||||
|  * Open openmct 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 RemoteClock from "./RemoteClock"; | ||||
| /** | ||||
|  * Install a clock that uses a configurable telemetry endpoint. | ||||
|  */ | ||||
| define([ | ||||
| 
 | ||||
| export default function (identifier) { | ||||
|     return function (openmct) { | ||||
|         openmct.time.addClock(new RemoteClock(openmct, identifier)); | ||||
|     }; | ||||
| } | ||||
| ], function ( | ||||
| 
 | ||||
| ) { | ||||
| 
 | ||||
|     function checkForDeprecatedFunctionality(typeDef) { | ||||
|         if (Object.prototype.hasOwnProperty.call(typeDef, 'telemetry')) { | ||||
|             console.warn( | ||||
|                 'DEPRECATION WARNING: Telemetry data on type ' | ||||
|                 + 'registrations will be deprecated in a future version, ' | ||||
|                 + 'please convert to a custom telemetry metadata provider ' | ||||
|                 + 'for type: ' + typeDef.key | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     function TypeDeprecationChecker(types) { | ||||
|         types.forEach(checkForDeprecatedFunctionality); | ||||
|     } | ||||
| 
 | ||||
|     return TypeDeprecationChecker; | ||||
| 
 | ||||
| }); | ||||
| @@ -81,8 +81,14 @@ define([ | ||||
|                     return models; | ||||
|                 } | ||||
|  | ||||
|                 //Temporary fix for missing models - don't retry using this.apiFetch | ||||
|                 return models; | ||||
|                 return this.apiFetch(missingIds) | ||||
|                     .then(function (apiResults) { | ||||
|                         Object.keys(apiResults).forEach(function (k) { | ||||
|                             models[k] = apiResults[k]; | ||||
|                         }); | ||||
|  | ||||
|                         return models; | ||||
|                     }); | ||||
|             }.bind(this)); | ||||
|     }; | ||||
|  | ||||
|   | ||||
| @@ -15,6 +15,8 @@ define([ | ||||
|     }; | ||||
|  | ||||
|     function LegacyViewProvider(legacyView, openmct, convertToLegacyObject) { | ||||
|         console.warn(`DEPRECATION WARNING: Migrate ${legacyView.key} from ${legacyView.bundle.path} to use the new View APIs.  Legacy view support will be removed soon.`); | ||||
|  | ||||
|         return { | ||||
|             key: legacyView.key, | ||||
|             name: legacyView.name, | ||||
|   | ||||
| @@ -4,6 +4,7 @@ define([ | ||||
|  | ||||
| ) { | ||||
|     function TypeInspectorViewProvider(typeDefinition, openmct, convertToLegacyObject) { | ||||
|         console.warn(`DEPRECATION WARNING: Migrate ${typeDefinition.key} from ${typeDefinition.bundle.path} to use the new Inspector View APIs.  Legacy Inspector view support will be removed soon.`); | ||||
|         let representation = openmct.$injector.get('representations[]') | ||||
|             .filter((r) => r.key === typeDefinition.inspector)[0]; | ||||
|  | ||||
| @@ -23,6 +24,13 @@ define([ | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|                 //TODO: Remove this when plots Angular implementation is deprecated | ||||
|                 let parent = selection[0].length > 1 && selection[0][1].context.item; | ||||
|                 if (parent && parent.type === 'time-strip') { | ||||
|                     return (selectionContext.item.type === typeDefinition.key) | ||||
|                             && (typeDefinition.key !== 'telemetry.plot.overlay'); | ||||
|                 } | ||||
|  | ||||
|                 return selectionContext.item.type === typeDefinition.key; | ||||
|             }, | ||||
|             view: function (selection) { | ||||
|   | ||||
| @@ -34,6 +34,7 @@ export default class Editor extends EventEmitter { | ||||
|      * Initiate an editing session. This will start a transaction during | ||||
|      * which any persist operations will be deferred until either save() | ||||
|      * or finish() are called. | ||||
|      * @private | ||||
|      */ | ||||
|     edit() { | ||||
|         if (this.editing === true) { | ||||
| @@ -41,8 +42,8 @@ export default class Editor extends EventEmitter { | ||||
|         } | ||||
|  | ||||
|         this.editing = true; | ||||
|         this.getTransactionService().startTransaction(); | ||||
|         this.emit('isEditing', true); | ||||
|         this.openmct.objects.startTransaction(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -55,36 +56,41 @@ export default class Editor extends EventEmitter { | ||||
|     /** | ||||
|      * Save any unsaved changes from this editing session. This will | ||||
|      * end the current transaction. | ||||
|      * | ||||
|      * @private | ||||
|      */ | ||||
|     save() { | ||||
|         const transaction = this.openmct.objects.getActiveTransaction(); | ||||
|         return this.getTransactionService().commit().then((result) => { | ||||
|             this.editing = false; | ||||
|             this.emit('isEditing', false); | ||||
|  | ||||
|         return transaction.commit() | ||||
|             .then(() => { | ||||
|                 this.editing = false; | ||||
|                 this.emit('isEditing', false); | ||||
|             }).catch(error => { | ||||
|                 throw error; | ||||
|             }).finally(() => { | ||||
|                 this.openmct.objects.endTransaction(); | ||||
|             }); | ||||
|             return result; | ||||
|         }).catch((error) => { | ||||
|             throw error; | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * End the currently active transaction and discard unsaved changes. | ||||
|      * | ||||
|      * @private | ||||
|      */ | ||||
|     cancel() { | ||||
|         let cancelPromise = this.getTransactionService().cancel(); | ||||
|         this.editing = false; | ||||
|         this.emit('isEditing', false); | ||||
|  | ||||
|         return new Promise((resolve, reject) => { | ||||
|             const transaction = this.openmct.objects.getActiveTransaction(); | ||||
|             transaction.cancel() | ||||
|                 .then(resolve) | ||||
|                 .catch(reject) | ||||
|                 .finally(() => { | ||||
|                     this.openmct.objects.endTransaction(); | ||||
|                 }); | ||||
|         }); | ||||
|         return cancelPromise; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @private | ||||
|      */ | ||||
|     getTransactionService() { | ||||
|         if (!this.transactionService) { | ||||
|             this.transactionService = this.openmct.$injector.get('transactionService'); | ||||
|         } | ||||
|  | ||||
|         return this.transactionService; | ||||
|     } | ||||
| } | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user