Merge branch 'master' into open401

Resolve conflicts for #416

Conflicts:
	platform/commonUI/browse/bundle.json
	platform/commonUI/browse/src/BrowseController.js
This commit is contained in:
Victor Woeltjen 2016-02-22 14:27:21 -08:00
commit d3e274bfdd
387 changed files with 14238 additions and 55416 deletions

6
.gitignore vendored
View File

@ -4,8 +4,10 @@
*.tgz
*.DS_Store
# Compiled CSS, unless directly added
*.sass-cache
*COMPILE.css
*.css
# Intellij project configuration files
*.idea
@ -15,6 +17,7 @@
# Build output
target
dist
# Mac OS X Finder
.DS_Store
@ -22,8 +25,9 @@ target
# Closed source libraries
closed-lib
# Node dependencies
# Node, Bower dependencies
node_modules
bower_components
# Protractor logs
protractor/logs

3
.jscsrc Normal file
View File

@ -0,0 +1,3 @@
{
"preset": "crockford"
}

4
.jshintrc Normal file
View File

@ -0,0 +1,4 @@
{
"validthis": true,
"laxbreak": true
}

35
.npmignore Normal file
View File

@ -0,0 +1,35 @@
*.scssc
*.zip
*.gzip
*.tgz
*.DS_Store
*.sass-cache
*COMPILE.css
# Intellij project configuration files
*.idea
*.iml
# External dependencies
# Build output
target
# Mac OS X Finder
.DS_Store
# Closed source libraries
closed-lib
# Node, Bower dependencies
node_modules
bower_components
Procfile
# Protractor logs
protractor/logs
# npm-debug log
npm-debug.log

6
Gemfile Normal file
View File

@ -0,0 +1,6 @@
source "https://rubygems.org"
group :development do
gem "compass", ">= 1.0.3"
gem "sass", "~> 3.4.18"
end

32
Gemfile.lock Normal file
View File

@ -0,0 +1,32 @@
GEM
remote: https://rubygems.org/
specs:
chunky_png (1.3.5)
compass (1.0.3)
chunky_png (~> 1.2)
compass-core (~> 1.0.2)
compass-import-once (~> 1.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
sass (>= 3.3.13, < 3.5)
compass-core (1.0.3)
multi_json (~> 1.0)
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
ffi (1.9.10)
multi_json (1.11.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
sass (3.4.21)
PLATFORMS
ruby
DEPENDENCIES
compass (>= 1.0.3)
sass (~> 3.4.18)
BUNDLED WITH
1.10.6

View File

@ -135,7 +135,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: http://requirejs.org/
* Version: 2.1.9
* Version: 2.1.22
* Author: The Dojo Foundation
@ -153,13 +153,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
---
### requirejs-text
#### Info
* Link: https://github.com/requirejs/text
* Version: 2.0.14
* Author: The Dojo Foundation
* Description: Text loading plugin for RequireJS
#### License
Copyright (c) 2010-2014, The Dojo Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
---
### AngularJS
#### Info
* Link: http://angularjs.org/
* Version: 1.2.26
* Version: 1.4.4
* Author: Google
@ -167,7 +203,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#### License
Copyright (c) 2010-2014 Google, Inc. http://angularjs.org
Copyright (c) 2010-2015 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ -183,7 +219,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: http://angularjs.org/
* Version: 1.2.26
* Version: 1.4.4
* Author: Google
@ -191,7 +227,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#### License
Copyright (c) 2010-2014 Google, Inc. http://angularjs.org
Copyright (c) 2010-2015 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ -207,7 +243,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: https://github.com/jakearchibald/es6-promise
* Version: 2.0.0
* Version: 3.0.2
* Authors: Yehuda Katz, Tom Dale, Stefan Penner and contributors
@ -231,7 +267,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: https://github.com/sindresorhus/screenfull.js/
* Version: 1.2.0
* Version: 3.0.0
* Author: Sindre Sorhus
@ -255,15 +291,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: https://github.com/broofa/node-uuid
* Version: 1.4
* Version: 1.4.7
* Author: Robert Kieffer
* Description: Unique identifer generation (code adapted.)
* Description: Unique identifer generation.
#### License
Copyright (c) 2010 Robert Kieffer
Copyright (c) 2010-2012 Robert Kieffer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ -327,7 +363,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
* Link: http://momentjs.com
* Version: 2.7.0
* Version: 2.11.1
* Authors: Tim Wood, Iskren Chernev, Moment.js contributors

101
README.md
View File

@ -20,52 +20,26 @@ directory names) to include in a running instance of Open MCT Web. Adding or
removing paths from this list will add or remove bundles from the running
application.
### Bundle Contents
A bundle directory will contain:
* `bundle.json`, the declaration of the bundles contents.
* A source code directory, named `src` by convention. This contains all
JavaScript sources exposed by the bundle. These are declared as
AMD modules.
* A directory for other resources, named `res` by convention. This
contains all HTML templates, CSS files, images, and so forth to be
used within a given bundle.
* A library directory, named `lib` by convention. This contains all
external libraries used and/or exposed by the bundle.
* A test directory, named `test` by convention. This contains all unit
tests declared for the bundle, as well as a `suite.json` that acts
as a listing of these dependencies. See the section on unit testing
below.
Following these bundle conventions is required, at present, to ensure
that Open MCT Web (and its build and tests) execute correctly.
## Tests
The repository for Open MCT Web includes a test suite that can be run
directly from the web browser, `test.html`. This page will:
Tests are written for [Jasmine 1.3](http://jasmine.github.io/1.3/introduction.html)
and run by [Karma](http://karma-runner.github.io). To run:
* Load `bundles.json` to determine which bundles are in the application.
* Load `test/suite.json` to determine which source files are to be tested.
This should contain an array of strings, where each is the name of an
AMD module in the bundle's source directory. For each source file:
* Code coverage instrumentation will be added, via Blanket.
* The associated test file will be loaded, via RequireJS. These will
be located in the bundle's test folder; the test runner will presume
these follow a naming convention where each module to be tested has a
corresponding test module with the suffix `Spec` in that folder.
* Jasmine will then be invoked to run all tests defined in the loaded
test modules. Code coverage reporting will be displayed at the bottom
of the test page.
`npm test`
At present, the test runner presumes that bundle conventions are followed
as above; that is, sources are contained in `src`, and tests are contained
in `test`. Additionally, individual test files must use the `Spec` suffix
as described above.
The test suite is configured to load any scripts ending with `Spec.js` found
in the `src` hierarchy. Full configuration details are found in
`karma.conf.js`. By convention, unit test scripts should be located
alongside the units that they test; for example, `src/foo/Bar.js` would be
tested by `src/foo/BarSpec.js`. (For legacy reasons, some existing tests may
be located in separate `test` folders near the units they test, but the
naming convention is otherwise the same.)
### Test Reporting
When `npm test` is run, test results will be written as HTML to
`target/tests`. Code coverage information is written to `target/coverage`.
An example of this is expressed in `platform/framework`, which follows
bundle conventions.
### Functional Testing
@ -82,41 +56,36 @@ To run:
## Build
Open MCT Web includes a Maven command line build. Although Open MCT Web
can be run as-is using the repository contents (that is, by viewing
`index.html` in a web browser), and its tests can be run in-place
similarly (that is, by viewing `test.html` in a browser), the command
line build allows machine-driven verification and packaging.
Open MCT Web is built using [`npm`](http://npmjs.com/)
and [`gulp`](http://gulpjs.com/).
This build will:
To build:
* Check all sources (excluding those in directories named `lib`) with
JSLint for code style compliance. The build will fail if any sources
do not satisfy JSLint.
* Run unit tests. This is done by running `test.html` in a PhantomJS
browser-like environment. The build will fail if any tests fail.
* Package the application as a `war` (web archive) file. This is
convenient for deployment on Tomcat or similar. This archive will
include sources, resources, and libraries for bundles, as well
as the top-level files used to initiate running of the application
(`index.html` and `bundles.json`).
`npm run prepublish`
Run as `mvn clean install`.
This will compile and minify JavaScript sources, as well as copy over assets.
The contents of the `dist` folder will contain a runnable Open MCT Web
instance (e.g. by starting an HTTP server in that directory), including:
* A `main.js` file containing Open MCT Web source code.
* Various assets in the `example` and `platform` directories.
* An `index.html` that runs Open MCT Web in its default configuration.
Additional `gulp` tasks are defined in [the gulpfile](gulpfile.js).
### Building Documentation
Open MCT Web's documentation is generated by an
[npm](https://www.npmjs.com/)-based build:
[npm](https://www.npmjs.com/)-based build. It has additional dependencies that
may not be available on every platform and thus is not covered in the standard
npm install. Ensure your system has [libcairo](http://cairographics.org/)
installed and then run the following commands:
* `npm install` _(only needs to run once)_
* `npm install`
* `npm install canvas nomnoml`
* `npm run docs`
Documentation will be generated in `target/docs`. Note that diagram
generation is dependent on having [Cairo](http://cairographics.org/download/)
installed; see
[node-canvas](https://github.com/Automattic/node-canvas#installation)'s
documentation for help with installation.
Documentation will be generated in `target/docs`.
# Glossary

8
app.js
View File

@ -41,7 +41,13 @@
// Override bundles.json for HTTP requests
app.use('/' + BUNDLE_FILE, function (req, res) {
var bundles = JSON.parse(fs.readFileSync(BUNDLE_FILE, 'utf8'));
var bundles;
try {
bundles = JSON.parse(fs.readFileSync(BUNDLE_FILE, 'utf8'));
} catch (e) {
bundles = [];
}
// Handle command line inclusions/exclusions
bundles = bundles.concat(options.include);

20
bower.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "openmctweb",
"description": "The OpenMCTWeb core platform",
"main": "",
"license": "Apache-2.0",
"moduleType": [],
"homepage": "http://nasa.github.io/openmctweb/",
"private": true,
"dependencies": {
"angular": "1.4.4",
"angular-route": "1.4.4",
"moment": "^2.11.1",
"moment-duration-format": "^1.3.0",
"requirejs": "~2.1.22",
"text": "requirejs-text#^2.0.14",
"es6-promise": "^3.0.2",
"screenfull": "^3.0.0",
"node-uuid": "^1.4.7"
}
}

View File

@ -1,39 +0,0 @@
[
"platform/framework",
"platform/core",
"platform/representation",
"platform/commonUI/about",
"platform/commonUI/browse",
"platform/commonUI/edit",
"platform/commonUI/dialog",
"platform/commonUI/formats",
"platform/commonUI/general",
"platform/commonUI/inspect",
"platform/commonUI/mobile",
"platform/commonUI/themes/espresso",
"platform/commonUI/notification",
"platform/containment",
"platform/execution",
"platform/telemetry",
"platform/features/clock",
"platform/features/events",
"platform/features/imagery",
"platform/features/layout",
"platform/features/pages",
"platform/features/plot",
"platform/features/scrolling",
"platform/features/timeline",
"platform/forms",
"platform/identity",
"platform/persistence/aggregator",
"platform/persistence/local",
"platform/persistence/queue",
"platform/policy",
"platform/entanglement",
"platform/search",
"platform/status",
"example/imagery",
"example/eventGenerator",
"example/generator"
]

View File

@ -2,10 +2,11 @@ deployment:
production:
branch: master
commands:
- npm install canvas nomnoml
- ./build-docs.sh
- git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master
openmctweb-staging-un:
branch: search
branch: nem_prototype
heroku:
appname: openmctweb-staging-un
openmctweb-staging-deux:

View File

@ -106,7 +106,7 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
}
// Convert from Github-flavored Markdown to HTML
function gfmifier() {
function gfmifier(renderTOC) {
var transform = new stream.Transform({ objectMode: true }),
markdown = "";
transform._transform = function (chunk, encoding, done) {
@ -114,9 +114,11 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
done();
};
transform._flush = function (done) {
// Prepend table of contents
markdown =
[ TOC_HEAD, toc(markdown).content, "", markdown ].join("\n");
if (renderTOC){
// Prepend table of contents
markdown =
[ TOC_HEAD, toc(markdown).content, "", markdown ].join("\n");
}
this.push(header);
this.push(marked(markdown));
this.push(footer);
@ -168,13 +170,16 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
var destination = file.replace(options['in'], options.out)
.replace(/md$/, "html"),
destPath = path.dirname(destination),
prefix = path.basename(destination).replace(/\.html$/, "");
prefix = path.basename(destination).replace(/\.html$/, ""),
//Determine whether TOC should be rendered for this file based
//on regex provided as command line option
renderTOC = file.match(options['suppress-toc'] || "") === null;
mkdirp(destPath, function (err) {
fs.createReadStream(file, { encoding: 'utf8' })
.pipe(split())
.pipe(nomnomlifier(destPath, prefix))
.pipe(gfmifier())
.pipe(gfmifier(renderTOC))
.pipe(fs.createWriteStream(destination, {
encoding: 'utf8'
}));

3
docs/src/design/index.md Normal file
View File

@ -0,0 +1,3 @@
Design proposals:
* [API Redesign](proposals/APIRedesign.md)

View File

@ -0,0 +1,338 @@
# API Refactoring
This document summarizes a path toward implementing API changes
from the [API Redesign](../proposals/APIRedesign.md) for Open MCT Web
v1.0.0.
# Goals
These plans are intended to minimize:
* Waste; avoid allocating effort to temporary changes.
* Downtime; avoid making changes in large increments that blocks
delivery of new features for substantial periods of time.
* Risk; ensure that changes can be validated quickly, avoid putting
large effort into changes that have not been validated.
# Plan
```nomnoml
#comment: This diagram is in nomnoml syntax and should be rendered.
#comment: See https://github.com/nasa/openmctweb/issues/264#issuecomment-167166471
[<start> Start]->[<state> Imperative bundle registration]
[<state> Imperative bundle registration]->[<state> Build and packaging]
[<state> Imperative bundle registration]->[<state> Refactor API]
[<state> Build and packaging |
[<start> Start]->[<state> Incorporate a build step]
[<state> Incorporate a build step |
[<start> Start]->[<state> Choose package manager]
[<start> Start]->[<state> Choose build system]
[<state> Choose build system]<->[<state> Choose package manager]
[<state> Choose package manager]->[<state> Implement]
[<state> Choose build system]->[<state> Implement]
[<state> Implement]->[<end> End]
]->[<state> Separate repositories]
[<state> Separate repositories]->[<end> End]
]->[<state> Release candidacy]
[<start> Start]->[<state> Design registration API]
[<state> Design registration API |
[<start> Start]->[<state> Decide on role of Angular]
[<state> Decide on role of Angular]->[<state> Design API]
[<state> Design API]->[<choice> Passes review?]
[<choice> Passes review?] no ->[<state> Design API]
[<choice> Passes review?]-> yes [<end> End]
]->[<state> Refactor API]
[<state> Refactor API |
[<start> Start]->[<state> Imperative extension registration]
[<state> Imperative extension registration]->[<state> Refactor individual extensions]
[<state> Refactor individual extensions |
[<start> Start]->[<state> Prioritize]
[<state> Prioritize]->[<choice> Sufficient value added?]
[<choice> Sufficient value added?] no ->[<end> End]
[<choice> Sufficient value added?] yes ->[<state> Design]
[<state> Design]->[<choice> Passes review?]
[<choice> Passes review?] no ->[<state> Design]
[<choice> Passes review?]-> yes [<state> Implement]
[<state> Implement]->[<end> End]
]->[<state> Remove legacy bundle support]
[<state> Remove legacy bundle support]->[<end> End]
]->[<state> Release candidacy]
[<state> Release candidacy |
[<start> Start]->[<state> Verify |
[<start> Start]->[<choice> API well-documented?]
[<start> Start]->[<choice> API well-tested?]
[<choice> API well-documented?]-> no [<state> Write documentation]
[<choice> API well-documented?] yes ->[<end> End]
[<state> Write documentation]->[<choice> API well-documented?]
[<choice> API well-tested?]-> no [<state> Write test cases]
[<choice> API well-tested?]-> yes [<end> End]
[<state> Write test cases]->[<choice> API well-tested?]
]
[<start> Start]->[<state> Validate |
[<start> Start]->[<choice> Passes review?]
[<start> Start]->[<state> Use internally]
[<state> Use internally]->[<choice> Proves useful?]
[<choice> Passes review?]-> no [<state> Address feedback]
[<state> Address feedback]->[<choice> Passes review?]
[<choice> Passes review?] yes -> [<end> End]
[<choice> Proves useful?] yes -> [<end> End]
[<choice> Proves useful?] no -> [<state> Fix problems]
[<state> Fix problems]->[<state> Use internally]
]
[<state> Validate]->[<end> End]
[<state> Verify]->[<end> End]
]->[<state> Release]
[<state> Release]->[<end> End]
```
## Step 1. Imperative bundle registration
Register whole bundles imperatively, using their current format.
For example, in each bundle add a `bundle.js` file:
```js
define([
'mctRegistry',
'json!bundle.json'
], function (mctRegistry, bundle) {
mctRegistry.install(bundle, "path/to/bundle");
});
```
Where `mctRegistry.install` is placeholder API that wires into the
existing bundle registration mechanisms. The main point of entry
would need to be adapted to clearly depend on these bundles
(in the require sense of a dependency), and the framework layer
would need to implement and integrate with this transitional
API.
Benefits:
* Achieves an API Redesign goal with minimal immediate effort.
* Conversion to an imperative syntax may be trivially automated.
* Minimal change; reuse existing bundle definitions, primarily.
* Allows early validation of switch to imperative; unforeseen
consequences of the change may be detected at this point.
* Allows implementation effort to progress in parallel with decisions
about API changes, including fundamental ones such as the role of
Angular. May act in some sense as a prototype to inform those
decisions.
* Creates a location (framework layer) where subsequent changes to
the manner in which extensions are registered may be centralized.
When there is a one-to-one correspondence between the existing
form of an extension and its post-refactor form, adapters can be
written here to defer the task of making changes ubiquitously
throughout bundles, allowing for earlier validation and
verification of those changes, and avoiding ubiquitous changes
which might require us to go dark. (Mitigates
["greenfield paradox"](http://stepaheadsoftware.blogspot.com/2012/09/greenfield-or-refactor-legacy-code-base.html);
want to add value with new API but don't want to discard value
of tested/proven legacy codebase.)
Detriments:
* Requires transitional API to be implemented/supported; this is
waste. May mitigate this by time-bounding the effort put into
this step to ensure that waste is minimal.
Note that API changes at this point do not meaningfully reflect
the desired 1.0.0 API, so no API reviews are necessary.
## Step 2. Incorporate a build step
After the previous step is completed, there should be a
straightforward dependency graph among AMD modules, and an
imperative (albeit transitional) API allowing for other plugins
to register themselves. This should allow for a build step to
be included in a straightforward fashion.
Some goals for this build step:
* Compile (and, preferably, optimize/minify) Open MCT Web
sources into a single `.js` file.
* It is desirable to do the same for HTML sources, but
may wish to defer this until a subsequent refactoring
step if appropriate.
* Provide non-code assets in a format that can be reused by
derivative projects in a straightforward fashion.
Should also consider which dependency/packaging manager should
be used by dependent projects to obtain Open MCT Web. Approaches
include:
1. Plain `npm`. Dependents then declare their dependency with
`npm` and utilize built sources and assets in a documented
fashion. (Note that there are
[documented challenges](http://blog.npmjs.org/post/101775448305/npm-and-front-end-packaging)
in using `npm` in this fashion.)
2. Build with `npm`, but recommend dependents install using
`bower`, as this is intended for front-end development. This may
require checking in built products, however, which
we wish to avoid (this could be solved by maintaining
a separate repository for built products.)
In all cases, there is a related question of which build system
to use for asset generation/management and compilation/minification/etc.
1. [`webpack`](https://webpack.github.io/)
is well-suited in principle, as it is specifically
designed for modules with non-JS dependencies. However,
there may be limitations and/or undesired behavior here
(for instance, CSS dependencies get in-lined as style tags,
removing our ability to control ordering) so it may
2. `gulp` or `grunt`. Commonplace, but both still require
non-trivial coding and/or configuration in order to produce
appropriate build artifacts.
3. [Just `npm`](http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/).
Reduces the amount of tooling being used, but may introduce
some complexity (e.g. custom scripts) to the build process,
and may reduce portability.
## Step 3. Separate repositories
Refactor existing applications built on Open MCT Web such that they
are no longer forks, but instead separate projects with a dependency
on the built artifacts from Step 2.
Note that this is achievable already using `bower` (see `warp-bower`
branch at http://developer.nasa.gov/mct/warp for an example.)
However, changes involved in switching to an imperative API and
introducing a build process may change (and should simplify) the
approach used to utilize Open MCT Web as a dependency, so these
changes should be introduced first.
## Step 4. Design registration API
Design the registration API that will replace declarative extension
categories and extensions (including Angular built-ins and composite
services.)
This may occur in parallel with implementation steps.
It will be necessary
to have a decision about the role of Angular at this point; are extensions
registered via provider configuration (Angular), or directly in some
exposed registry?
Success criteria here should be based on peer review. Scope of peer
review should be based on perceived risk/uncertainty surrounding
proposed changes, to avoid waste; may wish to limit this review to
the internal team. (The extent to which external
feedback is available is limited, but there is an inherent timeliness
to external review; need to balance this.)
Benefits:
* Solves the "general case" early, allowing for early validation.
Note that in specific cases, it may be desirable to refactor some
current "extension category" in a manner that will not appear as
registries, _or_ to locate these in different
namespaces, _or_ to remove/replace certain categories entirely.
This work is deferred intentionally to allow for a solution of the
general case.
## Step 5. Imperative extension registration
Register individual extensions imperatively, implementing API changes
from the previous step. At this stage, _usage_ of the API may be confined
to a transitional adapter in the framework layer; bundles may continue
to utilize the transitional API for registering extensions in the
legacy format.
An important, ongoing sub-task here will be to discover and define dependencies
among bundles. Composite services and extension categories are presently
"implicit"; after the API redesign, these will become "explicit", insofar
as some specific component will be responsible for creating any registries.
As such, "bundles" which _use_ specific registries will need to have an
enforceable dependency (e.g. require) upon those "bundles" which
_declare_ those registries.
## Step 6. Refactor individual extensions
Refactor individual extension categories and/or services that have
been identified as needing changes. This includes, but is not
necessarily limited to:
* Views/Representations/Templates (refactored into "components.")
* Capabilities (refactored into "roles", potentially.)
* Telemetry (from `TelemetrySeries` to `TelemetryService`.)
Changes should be made one category at a time (either serially
or separately in parallel) and should involve a tight cycle of:
1. Prioritization/reprioritization; highest-value API improvements
should be done first.
2. Design.
3. Review. Refactoring individual extensions will require significant
effort (likely the most significant effort in the process) so changes
should be validated early to minimize risk/waste.
4. Implementation. These changes will not have a one-to-one relationship
with existing extensions, so changes cannot be centralized; usages
will need to be updated across all "bundles" instead of centralized
in a legacy adapter. If changes are of sufficient complexity, some
planning should be done to spread out the changes incrementally.
By necessity, these changes may break functionality in applications
built using Open MCT Web. On a case-by-case basis, should consider
providing temporary "legacy support" to allow downstream updates
to occur as a separate task; the relevant trade here is between
waste/effort required to maintain legacy support, versus the
downtime which may be introduced by making these changes simultaneously
across several repositories.
## Step 7. Remove legacy bundle support
Update bundles to remove any usages of legacy support for bundles
(including that used by dependent projects.) Then, remove legacy
support from Open MCT Web.
## Step 8. Release candidacy
Once API changes are complete, Open MCT Web should enter a release
candidacy cycle. Important things to look at here:
* Are changes really complete?
* Are they sufficiently documented?
* Are they sufficiently tested?
* Are changes really sufficient?
* Do reviewers think they are usable?
* Does the development team find them useful in practice? This
will require calendar time to ascertain; should allocate time
for this, particularly in alignment with the sprint/release
cycle.
* Has learning curve been measurably decreased? Comparing a to-do
list tutorial to [other examples(http://todomvc.com/) could
provide an empirical basis to this. How much code is required?
How much explanation is required? How many dependencies must
be installed before initial setup?
* Does the API offer sufficient power to implement the extensions we
anticipate?
* Any open API-related issues which should block a 1.0.0 release?
Any problems identified during release candidacy will require
subsequent design changes and planning.
## Step 9. Release
Once API changes have been verified and validated, proceed
with release, including:
* Tagging as version 1.0.0 (at an appropriate time in the
sprint/release cycle.)
* Close any open issues which have been resolved (or made obsolete)
by API changes.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,251 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
- [Reducing interface depth (the bundle.json version)](#reducing-interface-depth-the-bundlejson-version)
- [Imperitive component registries](#imperitive-component-registries)
- [Get rid of "extension category" concept.](#get-rid-of-extension-category-concept)
- [Reduce number and depth of extension points](#reduce-number-and-depth-of-extension-points)
- [Composite services should not be the default](#composite-services-should-not-be-the-default)
- [Get rid of views, representations, and templates.](#get-rid-of-views-representations-and-templates)
- [Reducing interface depth (The angular discussion)](#reducing-interface-depth-the-angular-discussion)
- [More angular: for all services](#more-angular-for-all-services)
- [Less angular: only for views](#less-angular-only-for-views)
- [Standard packaging and build system](#standard-packaging-and-build-system)
- [Use systemjs for module loading](#use-systemjs-for-module-loading)
- [Use gulp or grunt for standard tooling](#use-gulp-or-grunt-for-standard-tooling)
- [Package openmctweb as single versioned file.](#package-openmctweb-as-single-versioned-file)
- [Misc Improvements](#misc-improvements)
- [Refresh on navigation](#refresh-on-navigation)
- [Move persistence adapter to promise rejection.](#move-persistence-adapter-to-promise-rejection)
- [Remove bulk requests from providers](#remove-bulk-requests-from-providers)
- [Notes on current API proposals:](#notes-on-current-api-proposals)
- [[1] Footnote: The angular debacle](#1-footnote-the-angular-debacle)
- ["Do or do not, there is no try"](#do-or-do-not-there-is-no-try)
- [A lack of commitment](#a-lack-of-commitment)
- [Commitment is good!](#commitment-is-good)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
# Reducing interface depth (the bundle.json version)
## Imperitive component registries
Transition component registries to javascript, get rid of bundle.json and bundles.json. Prescribe a method for application configuration, but allow flexibility in how application configuration is defined.
Register components in an imperitive fashion, see angularApp.factory, angularApp.controller, etc. Alternatively, implement our own application object with new registries and it's own form of registering objects.
## Get rid of "extension category" concept.
The concept of an "extension category" is itself an extraneous concept-- an extra layer of interface depth, an extra thing to learn before you can say "hello world". Extension points should be clearly supported and documented with whatever interfaces make sense. Developers who wish to add something that is conceptually equivalent to an extension category can do so directly, in the manner that suites their needs, without us forcing a common method on them.
## Reduce number and depth of extension points
Clearly specify supported extension points (e.g. persistence, model providers, telemetry providers, routes, time systems), but don't claim that the system has a clear and perfect repeatable solution for unknown extension types. New extension categories can be implemented in whatever way makes sense, without prescribing "the one and only system for managing extensions".
The underlying problem here is we are predicting needs for extension points where none exist-- if we try and design the extension system before we know how it is used, we design the wrong thing and have to rewrite it later.
## Composite services should not be the default
Understanding composite services, and describing services as composite services can confuse developers. Aggregators are implemented once and forgotten, while decorators tend to be hacky, brittle solutions that are generally needed to avoid circular imports. While composite services are a useful construct, it reduces interface depth to implement them as registries + typed providers.
You can write a provider (provides "thing x" for "inputs y") with a simple interface. A provider has two or more methods:
* a method which takes "inputs y" and returns True if it knows how to provide "thing x", false otherwise.
* one or more methods which provide "thing x" for objects of "inputs y".
Actually checking whether a provider can respond to a request before asking it to do work allows for faster failure and clearer errors when no providers match the request.
## Get rid of views, representations, and templates.
Templates are an implementation detail that should be handled by module loaders. Views and representations become "components," and a new concept, "routes", is used to exposing specific views to end users.
`components` - building blocks for views, have clear inputs and outputs, and can be coupled to other components when it makes sense. (e.g. parent-child components such as menu and menu item), but should have ZERO knowledge of our data models or telemetry apis. They should define data models that enable them to do their job well while still being easy to test.
`routes` - a view type for a given domain object, e.g. a plot, table, display layout, etc. Can be described as "whatever shows in the main screen when you are viewing an object." Handle loading of data from a domain object and passing that data to the view components. Routes should support editing as it makes sense in their own context.
To facilitate testing:
* routes should be testable without having to test the actual view.
* components should be independently testable with zero knowledge of our data models or telemetry APIs.
Component code should be organized side by side, such as:
```
app
|- components
|- productDetail
| |- productDetail.js
| |- productDetail.css
| |- productDetail.html
| |- productDetailSpec.js
|- productList
|- checkout
|- wishlist
```
Components are not always reusable, and we shouldn't be overly concerned with making them so. If components are heavily reused, they should either be moved to a platform feature (e.g. notifications, indicators), or broken off as an external dependency (e.g. publish mct-plot as mct-plot.js).
# Reducing interface depth (The angular discussion)
Two options here: use more angular, use less angular. Wrapping angular methods does not reduce interface depth and must be avoided.
The primary issue with angular is duplications of concerns-- both angular and the openmctweb platform implement the same tools side by side and it can be hard to comprehend-- it increases interface depth. For other concerns, see footnotes[1].
Wrapping angular methods for non-view related code is confusing to developers because of the random constraints angular places on these items-- developers ultimately have to understand both angular DI and our framework. For example, it's not possible to name the topic service "topicService" because angular expects Services to be implemented by Providers, which is different than our expectation.
To reduce interface depth, we can replace our own provider and registry patterns with angular patterns, or we can only utilize angular view logic, and only use our own DI patterns.
## More angular: for all services
Increasing our commitment to angular would mean using more of the angular factorys, services, etc, and less of our home grown tools. We'd implement our services and extension points as angular providers, and make them configurable via app.config.
As an example, registering a specific type of model provider in angular would look like:
```javascript
mct.provider('model', modelProvider() { /* implementation */});
mct.config(['modelProvider', function (modelProvider) {
modelProvider.providers.push(RootModelProvider);
}]);
```
## Less angular: only for views
If we wish to use less angular, I would recommend discontinuing use of all angular components that are not view related-- services, factories, $http, etc, and implementing them in our own paradigm. Otherwise, we end up with layered interfaces-- one of the goals we would like to avoid.
# Standard packaging and build system
Standardize the packaging and build system, and completely separate the core platform from deployments. Prescribe a starting point for deployments, but allow flexibility.
## Use systemjs for module loading
Allow developers to use whatever module loading system they'd like to use, while still supporting all standard cases. We should also use this system for loading assets (css, scss, html templates), which makes it easier to implement a single file deployment using standard build tooling.
## Use gulp or grunt for standard tooling
Using gulp or grunt as a task runner would bring us in line with standard web developer workflows and help standardize rendering, deployment, and packaging. Additional tools can be added to the workflow at low cost, simplifying the set up of developer environments.
Gulp and grunt provide useful developer tooling such as live reload, automatic scss/less/etc compiliation, and ease of extensibility for standard production build processes. They're key in decoupling code.
## Package openmctweb as single versioned file.
Deployments should depend on a specific version of openmctweb, but otherwise be allowed to have their own deployment and development toolsets.
Customizations and deployments of openmctweb should not use the same build tooling as the core platform; instead they should be free to use their own build tools as they wish. (We would provide a template for an application, based on our experience with warp-for-rp and vista)
Installation and utilization of openmctweb should be as simple as downloading the js file, including it in your own html page, and then initializing an app and running it. If a developer would prefer, they could use bower or npm to handle installation.
Then, if we're using imperative methods for extending the application we can use the following for basic customization:
```html
<script src="//localhost/openmctweb.js"></script>
<script>
// can configure from object
var myApp = new OpenMCTWeb({
persitence: {
providers: [
{
type: 'elastic',
uri: 'http://someElasticHost/'
} // ...
]
}
});
// alternative configurations
myApp.persistence.addProvider(MyPersistenceAdapter);
myApp.model.addProvider(someProviderObject);
// Removing via method
myApp.persistence.removeProvider('some method for removing functionality');
// directly mutating providers
myApp.persistence.providers = [ThisProviderStandsAlone];
//
myApp.run();
</script>
```
This packaging reduces the complexity of managing multiple deployed versions, and also allows us to provide users with incredibly simple tutorials-- they can use whatever tooling they like. For instance, a hello world tutorial may take the option of "exposing a new object in the tree".
```javascript
var myApp = new OpenMCTWeb();
myApp.roots.addRoot({
id: 'myRoot',
name: 'Hello World!',
});
myApp.routes.setDefault('myRoot');
myApp.run();
```
# Misc Improvements
## Refresh on navigation
In cases where navigation events change the entire screen, we should be using routes and location changes to navigate between objects. We should be using href for all navigation events.
At the same time, navigating should refresh state of every visible object. A properly configured persistence store will handle caching with standard cache headers and 304 not modified responses, which will provide good performance of object reloads, while helping us ensure that objects are always in sync between clients.
View state (say, the expanded tree nodes) should not be tied to caching of data-- it should be something we intentionally persist and restore with each navigation. Data (such as object definitions) should be reloaded from server as necessary to restore state.
## Move persistence adapter to promise rejection.
Simple: reject on fail, resolve on success.
## Remove bulk requests from providers
Aggregators can request multiple things at once, but individual providers should only have to implement handling at the level of a single request. Each provider can implement it's own internal batching, but it should support making requests at a finer level of detail.
Excessive wrapping of code with $q.all causes additional digest cycles and decreased performance.
For example, instead of every telemetry provider responding to a given telemetry request, aggregators should route each request to the first provider that can fulfill that request.
# Notes on current API proposals:
* [RequireJS for Dependency Injection](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#requirejs-as-dependency-injector): requires other topics to be discussed first.
* [Arbitrary HTML Views](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#arbitrary-html-views): think there is a place for it, requires other topics to be discussed first.
* [Wrap Angular Services](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#wrap-angular-services): No, this is bad.
* [Bundle definitions in Javascript](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#bundle-declarations-in-javascript): Points to a solution, but ultimately requires more discussion.
* [pass around a dependency injector](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#pass-around-a-dependency-injector): No.
* [remove partial constructors](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#remove-partial-constructors): Yes, this should be superseded by another proposal though. The entire concept was a messy solution to dependency injection issues caused by declarative syntax.
* [Rename views to applications](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#rename-views-to-applications): Points to a problem that needs to be solved but I think the name is bad.
* [Provide classes for extensions](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#provide-classes-for-extensions): Yes, in specific places
* [Normalize naming conventions](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#normalize-naming-conventions): Yes.
* [Expose no third-party APIs](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#expose-no-third-party-apis): Completely disagree, points to a real problem with poor angular integration.
* [Register Extensions as Instances instead of Constructors](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#register-extensions-as-instances-instead-of-constructors): Superseded by the fact that we should not hope to implement a generic construct.
* [Remove capability delegation](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#remove-capability-delegation): Yes.
* [Nomenclature Change](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#nomenclature-change): Yes, hope to discuss the implications of this more clearly in other proposals.
* [Capabilities as mixins](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#capabilities-as-mixins): Yes.
* [Remove appliesTo methods](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#remove-applies-to-methods): No-- I think some level of this is necessary. I think a more holistic approach to policy is needed. it's a rather complicated system.
* [Revise telemetry API](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#revise-telemetry-api): If we can rough out and agree to the specifics, then Yes. Needs discussion.
* [Allow composite services to fail gracefully](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#allow-composite-services-to-fail-gracefully): No. As mentioned above, I think composite services themselves should be eliminated for a more purpose bound tool.
* [Plugins as angular modules](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#plugins-as-angular-modules): Should we decide to embrace Angular completely, I would support this. Otherwise, no.
* [Contextual Injection](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#contextual-injection): No, don't see a need.
* [Add New Abstractions for Actions](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#add-new-abstractions-for-actions): Worth a discussion.
* [Add gesture handlers](https://github.com/nasa/openmctweb/blob/api-redesign/docs/src/design/proposals/APIRedesign.md#add-gesture-handlers): Yes if we can agree on details. We need a platform implementation that is easy to use, but we should not reinvent the wheel.
# [1] Footnote: The angular debacle
## "Do or do not, there is no try"
A commonly voiced concern of embracing angular is the possibility of becoming dependent on a third party framework. This concern is itself detrimental-- if we're afraid of becoming dependent on a third party framework, then we will do a bad job of using the framework, and inevitably will want to stop using it.
If we're using a framework, we need to use it fully, or not use it at all.
## A lack of commitment
A number of the concerns we heard from developers and interns can be attributed to the tenuous relationship between the OpenMCTWeb platform and angular. We claimed to be angular, but we weren't really angular. Instead, we are caught between our incomplete framework paradigm and the angular paradigm. In many cases we reinvented the wheel or worked around functionality that angular provides, and ended up in a more confusing state.
## Commitment is good!
We could just be an application that is built with angular.
An application that is modular and extensible not because it reinvents tools for providing modularity and extensibility, but because it reuses existing tools for modularity and extensibility.
There are benefits to buying into the angular paradigm: shift documentation burden to external project, engage a larger talent pool available both as voluntary open source contributors and as experienced developers for hire, and gain access to an ecosystem of tools that we can use to increase the speed of development.
There are negatives too: Angular is a monolith, it has performance concerns, and an unclear future. If we can't live with it, we should look at alternatives.

View File

@ -0,0 +1,164 @@
# Imperative Plugins
This is a design proposal for handling
[bundle declarations in JavaScript](
APIRedesign.md#bundle-declarations-in-javascript).
## Developer Use Cases
Developers will want to use bundles/plugins to (in rough order
of occurrence):
1. Add new extension instances.
2. Use existing services
3. Add new service implementations.
4. Decorate service implementations.
5. Decorate extension instances.
6. Add new types of services.
7. Add new extension categories.
Notably, bullets 4 and 5 above are currently handled implicitly,
which has been cited as a source of confusion.
## Interfaces
Two base classes may be used to satisfy these use cases:
* The `CompositeServiceFactory` provides composite service instances.
Decorators may be added; the approach used for compositing may be
modified; and individual services may be registered to support compositing.
* The `ExtensionRegistry` allows for the simpler case where what is desired
is an array of all instances of some kind of thing within the system.
Note that additional developer use cases may be supported by using the
more general-purpose `Registry`
```nomnoml
[Factory.<T, V>
|
- factoryFn : function (V) : T
|
+ decorate(decoratorFn : function (T, V) : T, options? : RegistrationOptions)
]-:>[function (V) : T]
[RegistrationOptions |
+ priority : number or string
]
[Registry.<T, V>
|
- compositorFn : function (Array.<T>) : V
|
+ register(item : T, options? : RegistrationOptions)
+ composite(compositorFn : function (Array.<T>) : V, options? : RegistrationOptions)
]-:>[Factory.<V, Void>]
[Factory.<V, Void>]-:>[Factory.<T, V>]
[ExtensionRegistry.<T>]-:>[Registry.<T, Array.<T>>]
[Registry.<T, Array.<T>>]-:>[Registry.<T, V>]
[CompositeServiceFactory.<T>]-:>[Registry.<T, T>]
[Registry.<T, T>]-:>[Registry.<T, V>]
```
## Examples
### 1. Add new extension instances.
```js
// Instance-style registration
mct.types.register(new mct.Type({
key: "timeline",
name: "Timeline",
description: "A container for activities ordered in time."
});
// Factory-style registration
mct.actions.register(function (domainObject) {
return new RemoveAction(domainObject);
}, { priority: 200 });
```
### 2. Use existing services
```js
mct.actions.register(function (domainObject) {
var dialogService = mct.ui.dialogServiceFactory();
return new PropertiesAction(dialogService, domainObject);
});
```
### 3. Add new service implementations
```js
// Instance-style registration
mct.persistenceServiceFactory.register(new LocalPersistenceService());
// Factory-style registration
mct.persistenceServiceFactory.register(function () {
var $http = angular.injector(['ng']).get('$http');
return new LocalPersistenceService($http);
});
```
### 4. Decorate service implementations
```js
mct.modelServiceFactory.decorate(function (modelService) {
return new CachingModelDecorator(modelService);
}, { priority: 100 });
```
### 5. Decorate extension instances
```js
mct.capabilities.decorate(function (capabilities) {
return capabilities.map(decorateIfApplicable);
});
```
This use case is not well-supported by these API changes. The most
common case for decoration is capabilities, which are under reconsideration;
should consider handling decoration of capabilities in a different way.
### 6. Add new types of services
```js
myModule.myServiceFactory = new mct.CompositeServiceFactory();
// In cases where a custom composition strategy is desired
myModule.myServiceFactory.composite(function (services) {
return new MyServiceCompositor(services);
});
```
### 7. Add new extension categories.
```js
myModule.hamburgers = new mct.ExtensionRegistry();
```
## Evaluation
### Benefits
* Encourages separation of registration from declaration (individual
components are decoupled from the manner in which they are added
to the architecture.)
* Minimizes "magic." Dependencies are acquired, managed, and exposed
using plain-old-JavaScript without any dependency injector present
to obfuscate what is happening.
* Offers comparable expressive power to existing APIs; can still
extend the behavior of platform components in a variety of ways.
* Does not force or limit formalisms to use;
### Detriments
* Does not encourage separation of dependency acquisition from
declaration; that is, it would be quite natural using this API
to acquire references to services during the constructor call
to an extension or service. But, passing these in as constructor
arguments is preferred (to separate implementation from architecture.)
* Adds (negligible?) boilerplate relative to declarative syntax.
* Relies on factories, increasing number of interfaces to be concerned
with.

View File

@ -0,0 +1,138 @@
# Roles
Roles are presented as an alternative formulation to capabilities
(dynamic behavior associated with individual domain objects.)
Specific goals here:
* Dependencies of individual scripts should be clear.
* Domain objects should be able to selectively exhibit a wide
variety of behaviors.
## Developer Use Cases
1. Checking for the existence of behavior.
2. Using behavior.
3. Augmenting existing behaviors.
4. Overriding existing behaviors.
5. Adding new behaviors.
## Overview of Proposed Solution
Remove `getCapability` from domain objects; add roles as external
services which can be applied to domain objects.
## Interfaces
```nomnoml
[Factory.<T, V>
|
- factoryFn : function (V) : T
|
+ decorate(decoratorFn : function (T, V) : T, options? : RegistrationOptions)
]-:>[function (V) : T]
[RegistrationOptions |
+ priority : number or string
]<:-[RoleOptions |
+ validate : function (DomainObject) : boolean
]
[Role.<T> |
+ validate(domainObject : DomainObject) : boolean
+ decorate(decoratorFn : function (T, V) : T, options? : RoleOptions)
]-:>[Factory.<T, DomainObject>]
[Factory.<T, DomainObject>]-:>[Factory.<T, V>]
```
## Examples
### 1. Checking for the existence of behavior
```js
function PlotViewPolicy(telemetryRole) {
this.telemetryRole = telemetryRole;
}
PlotViewPolicy.prototype.allow = function (view, domainObject) {
return this.telemetryRole.validate(domainObject);
};
```
### 2. Using behavior
```js
PropertiesAction.prototype.perform = function () {
var mutation = this.mutationRole(this.domainObject);
return this.showDialog.then(function (newModel) {
return mutation.mutate(function () {
return newModel;
});
});
};
```
### 3. Augmenting existing behaviors
```js
// Non-Angular style
mct.roles.persistenceRole.decorate(function (persistence) {
return new DecoratedPersistence(persistence);
});
// Angular style
myModule.decorate('persistenceRole', ['$delegate', function ($delegate) {
return new DecoratedPersistence(persistence);
}]);
```
### 4. Overriding existing behaviors
```js
// Non-Angular style
mct.roles.persistenceRole.decorate(function (persistence, domainObject) {
return domainObject.getModel().type === 'someType' ?
new DifferentPersistence(domainObject) :
persistence;
}, {
validate: function (domainObject, next) {
return domainObject.getModel().type === 'someType' || next();
}
});
```
### 5. Adding new behaviors
```js
function FooRole() {
mct.Role.apply(this, [function (domainObject) {
return new Foo(domainObject);
}]);
}
FooRole.prototype = Object.create(mct.Role.prototype);
FooRole.prototype.validate = function (domainObject) {
return domainObject.getModel().type === 'some-type';
};
//
myModule.roles.fooRole = new FooRole();
```
## Evaluation
### Benefits
* Simplifies/standardizes augmentation or replacement of behavior associated
with specific domain objects.
* Minimizes number of abstractions; roles are just factories.
* Clarifies dependencies; roles used must be declared/acquired in the
same manner as services.
### Detriments
* Externalizes functionality which is conceptually associated with a
domain object.
* Relies on factories, increasing number of interfaces to be concerned
with.

View File

@ -407,7 +407,7 @@ In addition to the directories defined in the bundle definition, a bundle will
typically contain other directories not used at run-time. Additionally, some
useful development scripts (such as the command line build and the test suite)
expect this directory structure to be in use, and may ignore options chosen by
`b undle.json`. It is recommended that the directory structure described below be
`bundle.json`. It is recommended that the directory structure described below be
used for new bundles.
* `src`: Contains JavaScript sources for this bundle. May contain additional
@ -2245,68 +2245,58 @@ options. The sources can be deployed in the same directory structure used during
development. A few utilities are included to support development processes.
## Command-line Build
Open MCT Web includes a script for building via command line using Maven 3.0.4
https://maven.apache.org/ .
Invoking mvn clean install will:
* Check code style using JSLint. The build will fail if JSLint raises any warnings.
* Run the test suite (see below.) The build will fail if any tests fail.
* Populate version info (e.g. commit hash, build time.)
* Produce a web archive (`.war`) artifact in the `target` directory.
Open MCT Web is built using [`npm`](http://npmjs.com/)
and [`gulp`](http://gulpjs.com/).
The produced artifact contains a subset of the repository's own folder
hierarchy, omitting tests and example bundles.
To install build dependencies (only needs to be run once):
`npm install`
To build:
`npm run prepublish`
This will compile and minify JavaScript sources, as well as copy over assets.
The contents of the `dist` folder will contain a runnable Open MCT Web
instance (e.g. by starting an HTTP server in that directory), including:
* A `main.js` file containing Open MCT Web source code.
* Various assets in the `example` and `platform` directories.
* An `index.html` that runs Open MCT Web in its default configuration.
Additional `gulp` tasks are defined in [the gulpfile](gulpfile.js).
Note that an internet connection is required to run this build, in order to
download build dependencies.
## Test Suite
Open MCT Web uses Jasmine http://jasmine.github.io/ for automated testing.
The file `test.html` included at the top level of the source repository, can be
run from the browser to perform tests for all active bundles, as defined in
`bundle.json`.
Open MCT Web uses [Jasmine 1.3](http://jasmine.github.io/) and
[Karma](http://karma-runner.github.io) for automated testing.
To define tests for a bundle:
The test suite is configured to load any scripts ending with `Spec.js` found
in the `src` hierarchy. Full configuration details are found in
`karma.conf.js`. By convention, unit test scripts should be located
alongside the units that they test; for example, `src/foo/Bar.js` would be
tested by `src/foo/BarSpec.js`. (For legacy reasons, some existing tests may
be located in separate `test` folders near the units they test, but the
naming convention is otherwise the same.)
* Include a directory named `test` within that bundle.
* In the `test` directory, include a file named `suite.json`. This will identify
which scripts will be tested.
* The file `suite.json` must contain a JSON array of strings, where each string
is the name of a script to be tested. These names should include any directory
paths to the script after (but not including) the `src` folder, and should not
include the file's `.js` extension. (Note that while Open MCT Web's framework
allows a different name to be chosen for the src directory, the test runner
does not: This directory must be named `src` for the test runner to find it.)
* For each script to be tested, a corresponding test script should be located in
the bundle's `test` directory. This should include the suffix Spec at the end of
the filename (but before the `.js` extension.) This test script should be an AMD
module which uses the Jasmine API to declare its test behavior. It should
declare an AMD dependency on the script to be tested, using a relative path.
For example, if writing tests for a bundle at example/foo with two scripts:
* `example/foo/src/controllers/FooController.js`
* `example/foo/src/directives/FooDirective.js`
First, these scripts should be identified in `example/foo/test/suite.json` e.g.
with contents:`[ "controllers/FooController", "directives/FooDirective" ]`
Then, scripts which describe these tests should be written. For example, test
`example/foo/test/controllers/FooControllerSpec.js` could look like:
Tests are written as AMD modules which depend (at minimum) upon the
unit under test. For example, `src/foo/BarSpec.js` could look like:
/*global define,Promise,describe,it,expect,beforeEach*/
define(
["../../src/controllers/FooController"],
function (FooController) {
["./Bar"],
function (Bar) {
"use strict";
describe("The foo controller", function () {
describe("Bar", function () {
it("does something", function () {
var controller = new FooController();
expect(controller.foo()).toEqual("foo");
var bar = new Bar();
expect(controller.baz()).toEqual("foo");
});
});
}
@ -2435,4 +2425,4 @@ The following configuration constants are recognized by Open MCT Web bundles:
* `ELASTIC_ROOT`: URL or path to the ElasticSearch instance to be used for
domain object persistence. Should not include a trailing slash.
* `ELASTIC_PATH`: Path relative to the ElasticSearch instance where domain
object models should be persisted. Should take the form `<index>/<type>`.
object models should be persisted. Should take the form `<index>/<type>`.

View File

@ -1,38 +0,0 @@
<!--
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.
-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Open MCT Web Documentation</title>
</head>
<body class="user-environ" ng-view>
Sections:
<ul>
<li><a href="api/">API</a></li>
<li><a href="architecture/">Architecture Overview</a></li>
<li><a href="guide/">Developer Guide</a></li>
<li><a href="tutorials/">Tutorials</a></li>
<li><a href="process/">Development Process</a></li>
</ul>
</body>
</html>

35
docs/src/index.md Normal file
View File

@ -0,0 +1,35 @@
# Open MCT Web Documentation
## Overview
Documentation is provided to support the use and development of
Open MCT Web. It's recommended that before doing
any development with Open MCT Web you take some time to familiarize yourself
with the documentation below.
Open MCT Web provides functionality out of the box, but it's also a platform for
building rich mission operations applications based on modern web technology.
The platform is configured declaratively, and defines conventions for
building on the provided capabilities by creating modular 'bundles' that
extend the platform at a variety of extension points. The details of how to
extend the platform are provided in the following documentation.
## Sections
* The [Architecture Overview](architecture/) describes the concepts used
throughout Open MCT Web, and gives a high level overview of the platform's design.
* The [Developer's Guide](guide/) goes into more detail about how to use the
platform and the functionality that it provides.
* The [Tutorials](tutorials/) give examples of extending the platform to add
functionality,
and integrate with data sources.
* The [API](api/) document is generated from inline documentation
using [JSDoc](http://usejsdoc.org/), and describes the JavaScript objects and
functions that make up the software platform.
* Finally, the [Development Process](process/) document describes the
Open MCT Web software development cycle.

View File

@ -1697,8 +1697,7 @@ Next, we utilize this functionality from the template:
</div>
</div>
</div>
'''
```
__tutorials/bargraph/res/templates/bargraph.html__
Here, we utilize the functions we just provided from the controller to position

View File

@ -0,0 +1,74 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ExampleController",
"./src/ExampleDirective",
"./src/ExampleService",
'legacyRegistry'
], function (
ExampleController,
ExampleDirective,
ExampleService,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/builtins", {
"name": "Angular Built-ins Example",
"description": "Example showing how to declare extensions with built-in support from Angular.",
"sources": "src",
"extensions": {
"controllers": [
{
"key": "ExampleController",
"implementation": ExampleController,
"depends": [
"$scope",
"exampleService"
]
}
],
"directives": [
{
"key": "exampleDirective",
"implementation": ExampleDirective,
"depends": [
"examples[]"
]
}
],
"routes": [
{
"templateUrl": "templates/example.html"
}
],
"services": [
{
"key": "exampleService",
"implementation": ExampleService
}
]
}
});
});

View File

@ -1,32 +0,0 @@
{
"name": "Angular Built-ins Example",
"description": "Example showing how to declare extensions with built-in support from Angular.",
"sources": "src",
"extensions": {
"controllers": [
{
"key": "ExampleController",
"implementation": "ExampleController.js",
"depends": [ "$scope", "exampleService" ]
}
],
"directives": [
{
"key": "exampleDirective",
"implementation": "ExampleDirective.js",
"depends": [ "examples[]" ]
}
],
"routes": [
{
"templateUrl": "templates/example.html"
}
],
"services": [
{
"key": "exampleService",
"implementation": "ExampleService.js"
}
]
}
}

View File

@ -0,0 +1,82 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/SomeProvider",
"./src/SomeOtherProvider",
"./src/SomeDecorator",
"./src/SomeOtherDecorator",
"./src/SomeAggregator",
"./src/SomeOtherExample",
'legacyRegistry'
], function (
SomeProvider,
SomeOtherProvider,
SomeDecorator,
SomeOtherDecorator,
SomeAggregator,
SomeOtherExample,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/composite", {
"extensions": {
"components": [
{
"implementation": SomeProvider,
"provides": "someService",
"type": "provider"
},
{
"implementation": SomeOtherProvider,
"provides": "someService",
"type": "provider"
},
{
"implementation": SomeDecorator,
"provides": "someService",
"type": "decorator"
},
{
"implementation": SomeOtherDecorator,
"provides": "someService",
"type": "decorator"
},
{
"implementation": SomeAggregator,
"provides": "someService",
"type": "aggregator"
}
],
"examples": [
{
"implementation": SomeOtherExample,
"depends": [
"someService"
]
}
]
}
});
});

View File

@ -1,37 +0,0 @@
{
"extensions": {
"components": [
{
"implementation": "SomeProvider.js",
"provides": "someService",
"type": "provider"
},
{
"implementation": "SomeOtherProvider.js",
"provides": "someService",
"type": "provider"
},
{
"implementation": "SomeDecorator.js",
"provides": "someService",
"type": "decorator"
},
{
"implementation": "SomeOtherDecorator.js",
"provides": "someService",
"type": "decorator"
},
{
"implementation": "SomeAggregator.js",
"provides": "someService",
"type": "aggregator"
}
],
"examples": [
{
"implementation": "SomeOtherExample.js",
"depends": [ "someService" ]
}
]
}
}

View File

@ -0,0 +1,70 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/EventTelemetryProvider",
'legacyRegistry'
], function (
EventTelemetryProvider,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/eventGenerator", {
"name": "Event Message Generator",
"description": "Example of a component that produces event data.",
"extensions": {
"components": [
{
"implementation": EventTelemetryProvider,
"type": "provider",
"provides": "telemetryService",
"depends": [
"$q",
"$timeout"
]
}
],
"types": [
{
"key": "eventGenerator",
"name": "Event Message Generator",
"glyph": "f",
"description": "An event message generator",
"features": "creation",
"model": {
"telemetry": {}
},
"telemetry": {
"source": "eventGenerator",
"ranges": [
{
"format": "string"
}
]
}
}
]
}
});
});

View File

@ -1,32 +0,0 @@
{
"name": "Event Message Generator",
"description": "Example of a component that produces event data.",
"extensions": {
"components": [
{
"implementation": "EventTelemetryProvider.js",
"type": "provider",
"provides": "telemetryService",
"depends": [ "$q", "$timeout" ]
}
],
"types": [
{
"key": "eventGenerator",
"name": "Event Message Generator",
"glyph": "f",
"description": "An event message generator",
"features": "creation",
"model": {
"telemetry": {}
},
"telemetry": {
"source": "eventGenerator",
"ranges": [
{ "format": "string" }
]
}
}
]
}
}

View File

@ -0,0 +1,51 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/SomeExample",
'legacyRegistry'
], function (
SomeExample,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/extensions", {
"name": "Custom Extensions Examples",
"description": "Example showing how to declare custom extensions.",
"sources": "src",
"extensions": {
"examples": [
{
"text": "I came from example/extensions"
},
{
"implementation": SomeExample,
"depends": [
"exampleService"
]
}
]
}
});
});

View File

@ -1,16 +0,0 @@
{
"name": "Custom Extensions Examples",
"description": "Example showing how to declare custom extensions.",
"sources": "src",
"extensions": {
"examples": [
{
"text": "I came from example/extensions"
},
{
"implementation": "SomeExample.js",
"depends": [ "exampleService" ]
}
]
}
}

53
example/forms/bundle.js Normal file
View File

@ -0,0 +1,53 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ExampleFormController",
'legacyRegistry'
], function (
ExampleFormController,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/forms", {
"name": "Declarative Forms example",
"sources": "src",
"extensions": {
"controllers": [
{
"key": "ExampleFormController",
"implementation": ExampleFormController,
"depends": [
"$scope"
]
}
],
"routes": [
{
"templateUrl": "templates/exampleForm.html"
}
]
}
});
});

View File

@ -1,18 +0,0 @@
{
"name": "Declarative Forms example",
"sources": "src",
"extensions": {
"controllers": [
{
"key": "ExampleFormController",
"implementation": "ExampleFormController.js",
"depends": [ "$scope" ]
}
],
"routes": [
{
"templateUrl": "templates/exampleForm.html"
}
]
}
}

143
example/generator/bundle.js Normal file
View File

@ -0,0 +1,143 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/SinewaveTelemetryProvider",
"./src/SinewaveLimitCapability",
"./src/SinewaveDeltaFormat",
'legacyRegistry'
], function (
SinewaveTelemetryProvider,
SinewaveLimitCapability,
SinewaveDeltaFormat,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/generator", {
"name": "Sine Wave Generator",
"description": "Example of a component that produces dataa.",
"extensions": {
"components": [
{
"implementation": SinewaveTelemetryProvider,
"type": "provider",
"provides": "telemetryService",
"depends": [
"$q",
"$timeout"
]
}
],
"capabilities": [
{
"key": "limit",
"implementation": SinewaveLimitCapability
}
],
"formats": [
{
"key": "example.delta",
"implementation": SinewaveDeltaFormat
}
],
"constants": [
{
"key": "TIME_CONDUCTOR_DOMAINS",
"value": [
{
"key": "time",
"name": "Time"
},
{
"key": "yesterday",
"name": "Yesterday"
},
{
"key": "delta",
"name": "Delta",
"format": "example.delta"
}
],
"priority": -1
}
],
"types": [
{
"key": "generator",
"name": "Sine Wave Generator",
"glyph": "T",
"description": "A sine wave generator",
"features": "creation",
"model": {
"telemetry": {
"period": 10
}
},
"telemetry": {
"source": "generator",
"domains": [
{
"key": "time",
"name": "Time"
},
{
"key": "yesterday",
"name": "Yesterday"
},
{
"key": "delta",
"name": "Delta",
"format": "example.delta"
}
],
"ranges": [
{
"key": "sin",
"name": "Sine"
},
{
"key": "cos",
"name": "Cosine"
}
]
},
"properties": [
{
"name": "Period",
"control": "textfield",
"cssclass": "l-small l-numeric",
"key": "period",
"required": true,
"property": [
"telemetry",
"period"
],
"pattern": "^\\d*(\\.\\d*)?$"
}
]
}
]
}
});
});

View File

@ -1,90 +0,0 @@
{
"name": "Sine Wave Generator",
"description": "Example of a component that produces dataa.",
"extensions": {
"components": [
{
"implementation": "SinewaveTelemetryProvider.js",
"type": "provider",
"provides": "telemetryService",
"depends": [ "$q", "$timeout" ]
}
],
"capabilities": [
{
"key": "limit",
"implementation": "SinewaveLimitCapability.js"
}
],
"formats": [
{
"key": "example.delta",
"implementation": "SinewaveDeltaFormat.js"
}
],
"constants": [
{
"key": "TIME_CONDUCTOR_DOMAINS",
"value": [
{ "key": "time", "name": "Time" },
{ "key": "yesterday", "name": "Yesterday" },
{ "key": "delta", "name": "Delta", "format": "example.delta" }
],
"priority": -1
}
],
"types": [
{
"key": "generator",
"name": "Sine Wave Generator",
"glyph": "T",
"description": "A sine wave generator",
"features": "creation",
"model": {
"telemetry": {
"period": 10
}
},
"telemetry": {
"source": "generator",
"domains": [
{
"key": "time",
"name": "Time"
},
{
"key": "yesterday",
"name": "Yesterday"
},
{
"key": "delta",
"name": "Delta",
"format": "example.delta"
}
],
"ranges": [
{
"key": "sin",
"name": "Sine"
},
{
"key": "cos",
"name": "Cosine"
}
]
},
"properties": [
{
"name": "Period",
"control": "textfield",
"cssclass": "l-small l-numeric",
"key": "period",
"required": true,
"property": [ "telemetry", "period" ],
"pattern": "^\\d*(\\.\\d*)?$"
}
]
}
]
}
}

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ExampleIdentityService",
'legacyRegistry'
], function (
ExampleIdentityService,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/identity", {
"extensions": {
"components": [
{
"implementation": ExampleIdentityService,
"provides": "identityService",
"type": "provider",
"depends": [
"dialogService"
]
}
]
}
});
});

View File

@ -1,12 +0,0 @@
{
"extensions": {
"components": [
{
"implementation": "ExampleIdentityService.js",
"provides": "identityService",
"type": "provider",
"depends": [ "dialogService" ]
}
]
}
}

78
example/imagery/bundle.js Normal file
View File

@ -0,0 +1,78 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ImageTelemetryProvider",
'legacyRegistry'
], function (
ImageTelemetryProvider,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/imagery", {
"name": "Imagery",
"description": "Example of a component that produces image telemetry.",
"extensions": {
"components": [
{
"implementation": ImageTelemetryProvider,
"type": "provider",
"provides": "telemetryService",
"depends": [
"$q",
"$timeout"
]
}
],
"types": [
{
"key": "imagery",
"name": "Example Imagery",
"glyph": "T",
"features": "creation",
"model": {
"telemetry": {}
},
"telemetry": {
"source": "imagery",
"domains": [
{
"name": "Time",
"key": "time",
"format": "timestamp"
}
],
"ranges": [
{
"name": "Image",
"key": "url",
"format": "imageUrl"
}
]
}
}
]
}
});
});

View File

@ -1,42 +0,0 @@
{
"name": "Imagery",
"description": "Example of a component that produces image telemetry.",
"extensions": {
"components": [
{
"implementation": "ImageTelemetryProvider.js",
"type": "provider",
"provides": "telemetryService",
"depends": [ "$q", "$timeout" ]
}
],
"types": [
{
"key": "imagery",
"name": "Example Imagery",
"glyph": "T",
"features": "creation",
"model": {
"telemetry": {}
},
"telemetry": {
"source": "imagery",
"domains": [
{
"name": "Time",
"key": "time",
"format": "timestamp"
}
],
"ranges": [
{
"name": "Image",
"key": "url",
"format": "imageUrl"
}
]
}
}
]
}
}

45
example/mobile/bundle.js Normal file
View File

@ -0,0 +1,45 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
'legacyRegistry'
], function (
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/mobile", {
"name": "Mobile",
"description": "Allows elements with pertinence to mobile usage and development",
"extensions": {
"stylesheets": [
{
"stylesheetUrl": "css/mobile-example.css",
"priority": "mandatory"
}
]
}
});
});

View File

@ -1,12 +0,0 @@
{
"name": "Mobile",
"description": "Allows elements with pertinence to mobile usage and development",
"extensions": {
"stylesheets": [
{
"stylesheetUrl": "css/mobile-example.css",
"priority": "mandatory"
}
]
}
}

View File

@ -0,0 +1,86 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/DialogLaunchController",
"./src/NotificationLaunchController",
"./src/DialogLaunchIndicator",
"./src/NotificationLaunchIndicator",
'legacyRegistry'
], function (
DialogLaunchController,
NotificationLaunchController,
DialogLaunchIndicator,
NotificationLaunchIndicator,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/notifications", {
"extensions": {
"templates": [
{
"key": "dialogLaunchTemplate",
"templateUrl": "dialog-launch.html"
},
{
"key": "notificationLaunchTemplate",
"templateUrl": "notification-launch.html"
}
],
"controllers": [
{
"key": "DialogLaunchController",
"implementation": DialogLaunchController,
"depends": [
"$scope",
"$timeout",
"$log",
"dialogService",
"notificationService"
]
},
{
"key": "NotificationLaunchController",
"implementation": NotificationLaunchController,
"depends": [
"$scope",
"$timeout",
"$log",
"notificationService"
]
}
],
"indicators": [
{
"implementation": DialogLaunchIndicator,
"priority": "fallback"
},
{
"implementation": NotificationLaunchIndicator,
"priority": "fallback"
}
]
}
});
});

View File

@ -1,47 +0,0 @@
{
"extensions": {
"templates": [
{
"key": "dialogLaunchTemplate",
"templateUrl": "dialog-launch.html"
},
{
"key": "notificationLaunchTemplate",
"templateUrl": "notification-launch.html"
}
],
"controllers": [
{
"key": "DialogLaunchController",
"implementation": "DialogLaunchController.js",
"depends": [
"$scope",
"$timeout",
"$log",
"dialogService",
"notificationService"
]
},
{
"key": "NotificationLaunchController",
"implementation": "NotificationLaunchController.js",
"depends": [
"$scope",
"$timeout",
"$log",
"notificationService"
]
}
],
"indicators": [
{
"implementation": "DialogLaunchIndicator.js",
"priority": "fallback"
},
{
"implementation": "NotificationLaunchIndicator.js",
"priority": "fallback"
}
]
}
}

View File

@ -0,0 +1,54 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/BrowserPersistenceProvider",
'legacyRegistry'
], function (
BrowserPersistenceProvider,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/persistence", {
"extensions": {
"components": [
{
"provides": "persistenceService",
"type": "provider",
"implementation": BrowserPersistenceProvider,
"depends": [
"$q",
"PERSISTENCE_SPACE"
]
}
],
"constants": [
{
"key": "PERSISTENCE_SPACE",
"value": "mct"
}
]
}
});
});

View File

@ -1,18 +0,0 @@
{
"extensions": {
"components": [
{
"provides": "persistenceService",
"type": "provider",
"implementation": "BrowserPersistenceProvider.js",
"depends": [ "$q", "PERSISTENCE_SPACE" ]
}
],
"constants": [
{
"key": "PERSISTENCE_SPACE",
"value": "mct"
}
]
}
}

45
example/policy/bundle.js Normal file
View File

@ -0,0 +1,45 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ExamplePolicy",
'legacyRegistry'
], function (
ExamplePolicy,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/policy", {
"name": "Example Policy",
"description": "Provides an example of using policies to prohibit actions.",
"extensions": {
"policies": [
{
"implementation": ExamplePolicy,
"category": "action"
}
]
}
});
});

View File

@ -1,12 +0,0 @@
{
"name": "Example Policy",
"description": "Provides an example of using policies to prohibit actions.",
"extensions": {
"policies": [
{
"implementation": "ExamplePolicy.js",
"category": "action"
}
]
}
}

View 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.
*****************************************************************************/
/*global define*/
define([
"./src/WatchIndicator",
"./src/DigestIndicator",
'legacyRegistry'
], function (
WatchIndicator,
DigestIndicator,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/profiling", {
"extensions": {
"indicators": [
{
"implementation": WatchIndicator,
"depends": [
"$interval",
"$rootScope"
]
},
{
"implementation": DigestIndicator,
"depends": [
"$interval",
"$rootScope"
]
}
]
}
});
});

View File

@ -1,14 +0,0 @@
{
"extensions": {
"indicators": [
{
"implementation": "WatchIndicator.js",
"depends": ["$interval", "$rootScope"]
},
{
"implementation": "DigestIndicator.js",
"depends": ["$interval", "$rootScope"]
}
]
}
}

View File

@ -0,0 +1,58 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ScratchPersistenceProvider",
'legacyRegistry'
], function (
ScratchPersistenceProvider,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/scratchpad", {
"extensions": {
"roots": [
{
"id": "scratch:root",
"model": {
"type": "folder",
"composition": [],
"name": "Scratchpad"
},
"priority": "preferred"
}
],
"components": [
{
"provides": "persistenceService",
"type": "provider",
"implementation": ScratchPersistenceProvider,
"depends": [
"$q"
]
}
]
}
});
});

View File

@ -1,23 +0,0 @@
{
"extensions": {
"roots": [
{
"id": "scratch:root",
"model": {
"type": "folder",
"composition": [],
"name": "Scratchpad"
},
"priority": "preferred"
}
],
"components": [
{
"provides": "persistenceService",
"type": "provider",
"implementation": "ScratchPersistenceProvider.js",
"depends": [ "$q" ]
}
]
}
}

View File

@ -0,0 +1,63 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/ExampleTaxonomyModelProvider",
'legacyRegistry'
], function (
ExampleTaxonomyModelProvider,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/taxonomy", {
"name": "Example taxonomy",
"description": "Example illustrating the addition of a static top-level hierarchy",
"extensions": {
"roots": [
{
"id": "exampleTaxonomy",
"model": {
"type": "folder",
"name": "Stub Subsystems",
"composition": [
"examplePacket0",
"examplePacket1",
"examplePacket2"
]
}
}
],
"components": [
{
"provides": "modelService",
"type": "provider",
"implementation": ExampleTaxonomyModelProvider,
"depends": [
"$q"
]
}
]
}
});
});

View File

@ -1,29 +0,0 @@
{
"name": "Example taxonomy",
"description": "Example illustrating the addition of a static top-level hierarchy",
"extensions": {
"roots": [
{
"id": "exampleTaxonomy",
"model": {
"type": "folder",
"name": "Stub Subsystems",
"composition": [
"examplePacket0",
"examplePacket1",
"examplePacket2"
]
}
}
],
"components": [
{
"provides": "modelService",
"type": "provider",
"implementation": "ExampleTaxonomyModelProvider.js",
"depends": [ "$q" ]
}
]
}
}

52
example/worker/bundle.js Normal file
View File

@ -0,0 +1,52 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/FibonacciIndicator",
'legacyRegistry'
], function (
FibonacciIndicator,
legacyRegistry
) {
"use strict";
legacyRegistry.register("example/worker", {
"extensions": {
"indicators": [
{
"implementation": FibonacciIndicator,
"depends": [
"workerService",
"$rootScope"
]
}
],
"workers": [
{
"key": "example.fibonacci",
"scriptUrl": "FibonacciWorker.js"
}
]
}
});
});

View File

@ -1,16 +0,0 @@
{
"extensions": {
"indicators": [
{
"implementation": "FibonacciIndicator.js",
"depends": [ "workerService", "$rootScope" ]
}
],
"workers": [
{
"key": "example.fibonacci",
"scriptUrl": "FibonacciWorker.js"
}
]
}
}

170
gulpfile.js Normal file
View File

@ -0,0 +1,170 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global require,__dirname*/
var gulp = require('gulp'),
requirejsOptimize = require('gulp-requirejs-optimize'),
sourcemaps = require('gulp-sourcemaps'),
compass = require('gulp-compass'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
replace = require('gulp-replace-task'),
karma = require('karma'),
path = require('path'),
fs = require('fs'),
git = require('git-rev-sync'),
moment = require('moment'),
project = require('./package.json'),
paths = {
main: 'main.js',
dist: 'dist',
assets: 'dist/assets',
scss: 'platform/**/*.scss',
scripts: [ 'main.js', 'platform/**/*.js', 'src/**/*.js' ],
static: [
'index.html',
'platform/**/*',
'example/**/*',
'bower_components/**/*'
]
},
options = {
requirejsOptimize: {
name: paths.main.replace(/\.js$/, ''),
mainConfigFile: paths.main,
wrapShim: true
},
karma: {
configFile: path.resolve(__dirname, 'karma.conf.js'),
singleRun: true
},
compass: {
sass: __dirname,
css: paths.assets,
sourcemap: true
},
replace: {
variables: {
version: project.version,
timestamp: moment.utc(Date.now()).format(),
revision: fs.existsSync('.git') ? git.long() : 'Unknown',
branch: fs.existsSync('.git') ? git.branch() : 'Unknown'
}
}
},
stream = require('stream');
/**
* Returns a transform stream that allows us to customize the destination
* paths for individual sass files. Wraps compass.
*/
function customCompass() {
var compassWrapper = new stream.Transform({objectMode: true});
compassWrapper._transform = function (chunk, encoding, done) {
if (/\/_[^\/]*.scss$/.test(chunk.path)) {
return done();
}
var baseDir = 'platform/' + chunk.relative.replace(/sass\/.*$/, ''),
options = {
project: __dirname,
sass: baseDir + 'sass/',
css: baseDir + 'css/',
comments: true,
bundle_exec: true
},
compassObj;
compassObj = compass(options);
compassObj.on('data', function (file) {
this.push(file);
}.bind(this));
compassObj.on('end', function () {
done();
});
compassObj.end(chunk);
};
return compassWrapper;
}
gulp.task('scripts', function () {
return gulp.src(paths.main)
.pipe(sourcemaps.init())
.pipe(requirejsOptimize(options.requirejsOptimize))
.pipe(sourcemaps.write('.'))
.pipe(replace(options.replace))
.pipe(gulp.dest(paths.dist));
});
gulp.task('test', function (done) {
new karma.Server(options.karma, done).start();
});
gulp.task('compass');
gulp.task('stylesheets', function () {
return gulp.src(paths.scss)
.pipe(customCompass());
});
gulp.task('lint', function () {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('checkstyle', function () {
return gulp.src(paths.scripts)
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
});
gulp.task('fixstyle', function () {
return gulp.src(paths.scripts, { base: '.' })
.pipe(jscs({ fix: true }))
.pipe(gulp.dest('.'));
});
gulp.task('static', ['stylesheets'], function () {
return gulp.src(paths.static, { base: '.' })
.pipe(gulp.dest(paths.dist));
});
gulp.task('watch', function () {
gulp.watch(paths.scss, ['stylesheets']);
});
gulp.task('serve', function () {
console.log('Running development server with all defaults');
var app = require('./app.js');
});
gulp.task('develop', ['serve', 'watch']);
gulp.task('install', [ 'static', 'scripts' ]);
gulp.task('verify', [ 'lint', 'test' ]);
gulp.task('build', [ 'verify', 'install' ]);

View File

@ -26,8 +26,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<script type="text/javascript"
src="platform/framework/lib/require.js"
data-main="platform/framework/src/Main.js">
src="bower_components/requirejs/require.js">
</script>
<script type="text/javascript">
require(['main'], function (mct) {
mct.run();
});
</script>
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-96x96.png" sizes="96x96">

View File

@ -34,6 +34,8 @@ module.exports = function(config) {
// List of files / patterns to load in the browser.
// By default, files are also included in a script tag.
files: [
{pattern: 'bower_components/**/*.js', included: false},
{pattern: 'src/**/*.js', included: false},
{pattern: 'example/**/*.js', included: false},
{pattern: 'platform/**/*.js', included: false},
{pattern: 'warp/**/*.js', included: false},
@ -47,12 +49,15 @@ module.exports = function(config) {
// Preprocess matching files before serving them to the browser.
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},
preprocessors: {
'src/**/src/**/!(*Spec).js': [ 'coverage' ],
'platform/**/src/**/!(*Spec).js': [ 'coverage' ]
},
// Test results reporter to use
// Possible values: 'dots', 'progress'
// Available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
reporters: ['progress', 'coverage', 'html'],
// Web server port.
port: 9876,
@ -68,11 +73,23 @@ module.exports = function(config) {
// Specify browsers to run tests in.
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'Chrome'
'PhantomJS'
],
// Code coverage reporting.
coverageReporter: {
dir: "dist/coverage"
},
// HTML test reporting.
htmlReporter: {
outputDir: "target/tests",
preserveDescribeNesting: true,
foldAll: false
},
// Continuous Integration mode.
// If true, Karma captures browsers, runs the tests and exits.
singleRun: false
singleRun: true
});
};

99
main.js Normal file
View File

@ -0,0 +1,99 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define, window, requirejs*/
requirejs.config({
"paths": {
"legacyRegistry": "src/legacyRegistry",
"angular": "bower_components/angular/angular.min",
"angular-route": "bower_components/angular-route/angular-route.min",
"es6-promise": "bower_components/es6-promise/promise.min",
"moment": "bower_components/moment/moment",
"moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format",
"screenfull": "bower_components/screenfull/dist/screenfull.min",
"text": "bower_components/text/text",
"uuid": "bower_components/node-uuid/uuid"
},
"shim": {
"angular": {
"exports": "angular"
},
"angular-route": {
"deps": [ "angular" ]
},
"moment-duration-format": {
"deps": [ "moment" ]
}
}
});
define([
'./platform/framework/src/Main',
'legacyRegistry',
'./platform/framework/bundle',
'./platform/core/bundle',
'./platform/representation/bundle',
'./platform/commonUI/about/bundle',
'./platform/commonUI/browse/bundle',
'./platform/commonUI/edit/bundle',
'./platform/commonUI/dialog/bundle',
'./platform/commonUI/formats/bundle',
'./platform/commonUI/general/bundle',
'./platform/commonUI/inspect/bundle',
'./platform/commonUI/mobile/bundle',
'./platform/commonUI/themes/espresso/bundle',
'./platform/commonUI/notification/bundle',
'./platform/containment/bundle',
'./platform/execution/bundle',
'./platform/telemetry/bundle',
'./platform/features/clock/bundle',
'./platform/features/events/bundle',
'./platform/features/imagery/bundle',
'./platform/features/layout/bundle',
'./platform/features/pages/bundle',
'./platform/features/plot/bundle',
'./platform/features/scrolling/bundle',
'./platform/features/timeline/bundle',
'./platform/forms/bundle',
'./platform/identity/bundle',
'./platform/persistence/aggregator/bundle',
'./platform/persistence/local/bundle',
'./platform/persistence/queue/bundle',
'./platform/policy/bundle',
'./platform/entanglement/bundle',
'./platform/search/bundle',
'./platform/status/bundle',
'./example/imagery/bundle',
'./example/eventGenerator/bundle',
'./example/generator/bundle'
], function (Main, legacyRegistry) {
'use strict';
return {
legacyRegistry: legacyRegistry,
run: function () {
return new Main().run(legacyRegistry);
}
};
});

View File

@ -1,29 +1,41 @@
{
"name": "open-mct-web",
"version": "0.7.2",
"description": "The OpenMCTWeb core platform",
"name": "openmctweb",
"version": "0.9.2-SNAPSHOT",
"description": "The Open MCT Web core platform",
"dependencies": {
"express": "^4.13.1",
"minimist": "^1.1.1"
},
"devDependencies": {
"bower": "^1.7.7",
"git-rev-sync": "^1.4.0",
"glob": ">= 3.0.0",
"gulp": "^3.9.0",
"gulp-compass": "^2.1.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.0",
"gulp-replace-task": "^0.11.0",
"gulp-requirejs-optimize": "^0.3.1",
"gulp-sourcemaps": "^1.6.0",
"jasmine-core": "^2.3.0",
"jsdoc": "^3.3.2",
"jshint": "^2.7.0",
"karma": "^0.12.31",
"karma": "^0.13.3",
"karma-chrome-launcher": "^0.1.8",
"karma-cli": "0.0.4",
"karma-coverage": "^0.5.3",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"karma-phantomjs-launcher": "^0.2.3",
"karma-requirejs": "^0.2.2",
"requirejs": "^2.1.17",
"lodash": "^3.10.1",
"markdown-toc": "^0.11.7",
"marked": "^0.3.5",
"glob": ">= 3.0.0",
"split": "^1.0.0",
"mkdirp": "^0.5.1",
"nomnoml": "^0.0.3",
"canvas": "^1.2.7",
"markdown-toc": "^0.11.7"
"moment": "^2.11.1",
"phantomjs": "^1.9.19",
"requirejs": "^2.1.17",
"split": "^1.0.0"
},
"scripts": {
"start": "node app.js",
@ -31,13 +43,15 @@
"jshint": "jshint platform example || exit 0",
"watch": "karma start",
"jsdoc": "jsdoc -c jsdoc.json -r -d target/docs/api",
"otherdoc": "node docs/gendocs.js --in docs/src --out target/docs",
"docs": "npm run jsdoc ; npm run otherdoc"
"otherdoc": "node docs/gendocs.js --in docs/src --out target/docs --suppress-toc 'docs/src/index.md|docs/src/process/index.md'",
"docs": "npm run jsdoc ; npm run otherdoc",
"prepublish": "./node_modules/bower/bin/bower install && bundle install && ./node_modules/gulp/bin/gulp.js install"
},
"repository": {
"type": "git",
"url": "https://github.com/nasa/openmctweb.git"
},
"author": "",
"license": "Apache-2.0"
"license": "Apache-2.0",
"private": true
}

View File

@ -0,0 +1,168 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"text!./res/templates/about-dialog.html",
"./src/LogoController",
"./src/AboutController",
"./src/LicenseController",
'legacyRegistry'
], function (
aboutDialogTemplate,
LogoController,
AboutController,
LicenseController,
legacyRegistry
) {
"use strict";
legacyRegistry.register("platform/commonUI/about", {
"name": "About Open MCT Web",
"extensions": {
"templates": [
{
"key": "app-logo",
"priority": "optional",
"templateUrl": "templates/app-logo.html"
},
{
"key": "about-logo",
"priority": "preferred",
"templateUrl": "templates/about-logo.html"
},
{
"key": "about-dialog",
"template": aboutDialogTemplate
},
{
"key": "overlay-about",
"templateUrl": "templates/overlay-about.html"
},
{
"key": "license-apache",
"templateUrl": "templates/license-apache.html"
},
{
"key": "license-mit",
"templateUrl": "templates/license-mit.html"
}
],
"controllers": [
{
"key": "LogoController",
"depends": [
"overlayService"
],
"implementation": LogoController
},
{
"key": "AboutController",
"depends": [
"versions[]",
"$window"
],
"implementation": AboutController
},
{
"key": "LicenseController",
"depends": [
"licenses[]"
],
"implementation": LicenseController
}
],
"licenses": [
{
"name": "Json.NET",
"version": "6.0.8",
"author": "Newtonsoft",
"description": "JSON serialization/deserialization",
"website": "http://www.newtonsoft.com/json",
"copyright": "Copyright (c) 2007 James Newton-King",
"license": "license-mit",
"link": "https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md"
},
{
"name": "Nancy",
"version": "0.23.2",
"author": "Andreas Håkansson, Steven Robbins and contributors",
"description": "Embedded web server",
"website": "http://nancyfx.org/",
"copyright": "Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors",
"license": "license-mit",
"link": "http://www.opensource.org/licenses/mit-license.php"
},
{
"name": "Nancy.Hosting.Self",
"version": "0.23.2",
"author": "Andreas Håkansson, Steven Robbins and contributors",
"description": "Embedded web server",
"website": "http://nancyfx.org/",
"copyright": "Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors",
"license": "license-mit",
"link": "http://www.opensource.org/licenses/mit-license.php"
},
{
"name": "SuperSocket",
"version": "0.9.0.2",
"author": " Kerry Jiang",
"description": "Supports SuperWebSocket",
"website": "https://supersocket.codeplex.com/",
"copyright": "Copyright 2010-2014 Kerry Jiang (kerry-jiang@hotmail.com)",
"license": "license-apache",
"link": "https://supersocket.codeplex.com/license"
},
{
"name": "SuperWebSocket",
"version": "0.9.0.2",
"author": " Kerry Jiang",
"description": "WebSocket implementation for client-server communication",
"website": "https://superwebsocket.codeplex.com/",
"copyright": "Copyright 2010-2014 Kerry Jiang (kerry-jiang@hotmail.com)",
"license": "license-apache",
"link": "https://superwebsocket.codeplex.com/license"
},
{
"name": "log4net",
"version": "2.0.3",
"author": "Apache Software Foundation",
"description": "Logging",
"website": "http://logging.apache.org/log4net/",
"copyright": "Copyright © 2004-2015 Apache Software Foundation.",
"license": "license-apache",
"link": "http://logging.apache.org/log4net/license.html"
}
],
"routes": [
{
"when": "/licenses",
"templateUrl": "templates/licenses.html"
},
{
"when": "/licenses-md",
"templateUrl": "templates/licenses-export-md.html"
}
]
}
});
});

View File

@ -1,122 +0,0 @@
{
"name": "About Open MCT Web",
"extensions": {
"templates": [
{
"key": "app-logo",
"priority": "optional",
"templateUrl": "templates/app-logo.html"
},
{
"key": "about-logo",
"priority": "preferred",
"templateUrl": "templates/about-logo.html"
},
{
"key": "about-dialog",
"templateUrl": "templates/about-dialog.html"
},
{
"key": "overlay-about",
"templateUrl": "templates/overlay-about.html"
},
{
"key": "license-apache",
"templateUrl": "templates/license-apache.html"
},
{
"key": "license-mit",
"templateUrl": "templates/license-mit.html"
}
],
"controllers": [
{
"key": "LogoController",
"depends": [ "overlayService" ],
"implementation": "LogoController.js"
},
{
"key": "AboutController",
"depends": [ "versions[]", "$window" ],
"implementation": "AboutController.js"
},
{
"key": "LicenseController",
"depends": [ "licenses[]" ],
"implementation": "LicenseController.js"
}
],
"licenses": [
{
"name": "Json.NET",
"version": "6.0.8",
"author": "Newtonsoft",
"description": "JSON serialization/deserialization",
"website": "http://www.newtonsoft.com/json",
"copyright": "Copyright (c) 2007 James Newton-King",
"license": "license-mit",
"link": "https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md"
},
{
"name": "Nancy",
"version": "0.23.2",
"author": "Andreas Håkansson, Steven Robbins and contributors",
"description": "Embedded web server",
"website": "http://nancyfx.org/",
"copyright": "Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors",
"license": "license-mit",
"link": "http://www.opensource.org/licenses/mit-license.php"
},
{
"name": "Nancy.Hosting.Self",
"version": "0.23.2",
"author": "Andreas Håkansson, Steven Robbins and contributors",
"description": "Embedded web server",
"website": "http://nancyfx.org/",
"copyright": "Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors",
"license": "license-mit",
"link": "http://www.opensource.org/licenses/mit-license.php"
},
{
"name": "SuperSocket",
"version": "0.9.0.2",
"author": " Kerry Jiang",
"description": "Supports SuperWebSocket",
"website": "https://supersocket.codeplex.com/",
"copyright": "Copyright 2010-2014 Kerry Jiang (kerry-jiang@hotmail.com)",
"license": "license-apache",
"link": "https://supersocket.codeplex.com/license"
},
{
"name": "SuperWebSocket",
"version": "0.9.0.2",
"author": " Kerry Jiang",
"description": "WebSocket implementation for client-server communication",
"website": "https://superwebsocket.codeplex.com/",
"copyright": "Copyright 2010-2014 Kerry Jiang (kerry-jiang@hotmail.com)",
"license": "license-apache",
"link": "https://superwebsocket.codeplex.com/license"
},
{
"name": "log4net",
"version": "2.0.3",
"author": "Apache Software Foundation",
"description": "Logging",
"website": "http://logging.apache.org/log4net/",
"copyright": "Copyright © 2004-2015 Apache Software Foundation.",
"license": "license-apache",
"link": "http://logging.apache.org/log4net/license.html"
}
],
"routes": [
{
"when": "/licenses",
"templateUrl": "templates/licenses.html"
},
{
"when": "/licenses-md",
"templateUrl": "templates/licenses-export-md.html"
}
]
}
}

View File

@ -1,5 +0,0 @@
[
"AboutController",
"LicenseController",
"LogoController"
]

View File

@ -0,0 +1,332 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/BrowseController",
"./src/PaneController",
"./src/BrowseObjectController",
"./src/creation/CreateMenuController",
"./src/creation/LocatorController",
"./src/MenuArrowController",
"./src/navigation/NavigationService",
"./src/creation/CreationPolicy",
"./src/navigation/NavigateAction",
"./src/windowing/NewTabAction",
"./src/windowing/FullscreenAction",
"./src/creation/CreateActionProvider",
"./src/creation/AddActionProvider",
"./src/creation/CreationService",
"./src/windowing/WindowTitler",
'legacyRegistry'
], function (
BrowseController,
PaneController,
BrowseObjectController,
CreateMenuController,
LocatorController,
MenuArrowController,
NavigationService,
CreationPolicy,
NavigateAction,
NewTabAction,
FullscreenAction,
CreateActionProvider,
AddActionProvider,
CreationService,
WindowTitler,
legacyRegistry
) {
"use strict";
legacyRegistry.register("platform/commonUI/browse", {
"extensions": {
"routes": [
{
"when": "/browse/:ids*",
"templateUrl": "templates/browse.html",
"reloadOnSearch": false
},
{
"when": "",
"templateUrl": "templates/browse.html",
"reloadOnSearch": false
}
],
"constants": [
{
"key": "DEFAULT_PATH",
"value": "mine",
"priority": "fallback"
}
],
"controllers": [
{
"key": "BrowseController",
"implementation": BrowseController,
"depends": [
"$scope",
"$route",
"$location",
"$q",
"objectService",
"navigationService",
"urlService",
"DEFAULT_PATH"
]
},
{
"key": "PaneController",
"implementation": PaneController,
"priority": "preferred",
"depends": [
"$scope",
"agentService",
"$window"
]
},
{
"key": "BrowseObjectController",
"implementation": BrowseObjectController,
"depends": [
"$scope",
"$location",
"$route",
"$q",
"navigationService"
]
},
{
"key": "CreateMenuController",
"implementation": CreateMenuController,
"depends": [
"$scope"
]
},
{
"key": "LocatorController",
"implementation": LocatorController,
"depends": [
"$scope",
"$timeout",
"objectService"
]
},
{
"key": "MenuArrowController",
"implementation": MenuArrowController,
"depends": [
"$scope"
]
}
],
"controls": [
{
"key": "locator",
"templateUrl": "templates/create/locator.html"
}
],
"representations": [
{
"key": "browse-object",
"templateUrl": "templates/browse-object.html",
"gestures": [
"drop"
],
"uses": [
"view"
]
},
{
"key": "create-button",
"templateUrl": "templates/create/create-button.html"
},
{
"key": "create-menu",
"templateUrl": "templates/create/create-menu.html",
"uses": [
"action"
]
},
{
"key": "grid-item",
"templateUrl": "templates/items/grid-item.html",
"uses": [
"type",
"action",
"location"
],
"gestures": [
"info",
"menu"
]
},
{
"key": "object-header",
"templateUrl": "templates/browse/object-header.html",
"uses": [
"type"
]
},
{
"key": "menu-arrow",
"templateUrl": "templates/menu-arrow.html",
"uses": [
"action"
],
"gestures": [
"menu"
]
},
{
"key": "back-arrow",
"uses": [
"context"
],
"templateUrl": "templates/back-arrow.html"
}
],
"services": [
{
"key": "navigationService",
"implementation": NavigationService
}
],
"policies": [
{
"implementation": CreationPolicy,
"category": "creation"
}
],
"actions": [
{
"key": "navigate",
"implementation": NavigateAction,
"depends": [
"navigationService",
"$q"
]
},
{
"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",
"glyph": "y",
"priority": "preferred"
},
{
"key": "fullscreen",
"implementation": FullscreenAction,
"category": "view-control",
"group": "windowing",
"glyph": "z",
"priority": "default"
}
],
"views": [
{
"key": "items",
"name": "Items",
"glyph": "9",
"description": "Grid of available items",
"templateUrl": "templates/items/items.html",
"uses": [
"composition"
],
"gestures": [
"drop"
],
"type": "folder",
"editable": false
}
],
"components": [
{
"key": "CreateActionProvider",
"provides": "actionService",
"type": "provider",
"implementation": CreateActionProvider,
"depends": [
"$q",
"typeService",
"navigationService",
"policyService"
]
},
{
"key": "AddActionProvider",
"provides": "actionService",
"type": "provider",
"implementation": AddActionProvider,
"depends": [
"$q",
"typeService",
"dialogService",
"policyService"
]
},
{
"key": "CreationService",
"provides": "creationService",
"type": "provider",
"implementation": CreationService,
"depends": [
"$q",
"$log"
]
}
],
"runs": [
{
"implementation": WindowTitler,
"depends": [
"navigationService",
"$rootScope",
"$document"
]
}
],
"licenses": [
{
"name": "screenfull.js",
"version": "1.2.0",
"description": "Wrapper for cross-browser usage of fullscreen API",
"author": "Sindre Sorhus",
"website": "https://github.com/sindresorhus/screenfull.js/",
"copyright": "Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
"license": "license-mit",
"link": "https://github.com/sindresorhus/screenfull.js/blob/gh-pages/license"
}
]
}
});
});

View File

@ -1,193 +0,0 @@
{
"extensions": {
"routes": [
{
"when": "/browse/:ids*",
"templateUrl": "templates/browse.html",
"reloadOnSearch": false
},
{
"when": "",
"templateUrl": "templates/browse.html",
"reloadOnSearch": false
}
],
"constants": [
{
"key": "DEFAULT_PATH",
"value": "mine",
"priority": "fallback"
}
],
"controllers": [
{
"key": "BrowseController",
"implementation": "BrowseController.js",
"depends": [
"$scope",
"$route",
"$location",
"objectService",
"navigationService",
"urlService",
"DEFAULT_PATH"
]
},
{
"key": "PaneController",
"implementation": "PaneController.js",
"priority": "preferred",
"depends": [ "$scope", "agentService","$window" ]
},
{
"key": "BrowseObjectController",
"implementation": "BrowseObjectController.js",
"depends": [ "$scope", "$location", "$route" ]
},
{
"key": "CreateMenuController",
"implementation": "creation/CreateMenuController.js",
"depends": [ "$scope" ]
},
{
"key": "LocatorController",
"implementation": "creation/LocatorController.js",
"depends": [ "$scope", "$timeout" ]
},
{
"key": "MenuArrowController",
"implementation": "MenuArrowController.js",
"depends": [ "$scope" ]
}
],
"controls": [
{
"key": "locator",
"templateUrl": "templates/create/locator.html"
}
],
"representations": [
{
"key": "browse-object",
"templateUrl": "templates/browse-object.html",
"uses": [ "view" ]
},
{
"key": "create-button",
"templateUrl": "templates/create/create-button.html"
},
{
"key": "create-menu",
"templateUrl": "templates/create/create-menu.html",
"uses": [ "action" ]
},
{
"key": "grid-item",
"templateUrl": "templates/items/grid-item.html",
"uses": [ "type", "action", "location" ],
"gestures": [ "info", "menu" ]
},
{
"key": "object-header",
"templateUrl": "templates/browse/object-header.html",
"uses": [ "type" ]
},
{
"key": "menu-arrow",
"templateUrl": "templates/menu-arrow.html",
"uses": [ "action" ],
"gestures": [ "menu" ]
},
{
"key": "back-arrow",
"uses": [ "context" ],
"templateUrl": "templates/back-arrow.html"
}
],
"services": [
{
"key": "navigationService",
"implementation": "navigation/NavigationService.js"
}
],
"policies": [
{
"implementation": "creation/CreationPolicy.js",
"category": "creation"
}
],
"actions": [
{
"key": "navigate",
"implementation": "navigation/NavigateAction.js",
"depends": [ "navigationService", "$q" ]
},
{
"key": "window",
"name": "Open In New Tab",
"implementation": "windowing/NewTabAction.js",
"description": "Open in a new browser tab",
"category": ["view-control", "contextual"],
"depends": [ "urlService", "$window" ],
"group": "windowing",
"glyph": "y",
"priority": "preferred"
},
{
"key": "fullscreen",
"implementation": "windowing/FullscreenAction.js",
"category": "view-control",
"group": "windowing",
"glyph": "z",
"priority": "default"
}
],
"views": [
{
"key": "items",
"name": "Items",
"glyph": "9",
"description": "Grid of available items",
"templateUrl": "templates/items/items.html",
"uses": [ "composition" ],
"gestures": [ "drop" ],
"type": "folder",
"editable": false
}
],
"components": [
{
"key": "CreateActionProvider",
"provides": "actionService",
"type": "provider",
"implementation": "creation/CreateActionProvider.js",
"depends": [ "typeService", "dialogService", "creationService", "policyService" ]
},
{
"key": "CreationService",
"provides": "creationService",
"type": "provider",
"implementation": "creation/CreationService.js",
"depends": [ "$q", "$log" ]
}
],
"runs": [
{
"implementation": "windowing/WindowTitler.js",
"depends": [ "navigationService", "$rootScope", "$document" ]
}
],
"licenses": [
{
"name": "screenfull.js",
"version": "1.2.0",
"description": "Wrapper for cross-browser usage of fullscreen API",
"author": "Sindre Sorhus",
"website": "https://github.com/sindresorhus/screenfull.js/",
"copyright": "Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
"license": "license-mit",
"link": "https://github.com/sindresorhus/screenfull.js/blob/gh-pages/license"
}
]
}
}

View File

@ -1,6 +0,0 @@
/*!
* screenfull
* v1.2.0 - 2014-04-29
* (c) Sindre Sorhus; MIT License
*/
!function(){"use strict";var a="undefined"!=typeof module&&module.exports,b="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,c=function(){for(var a,b,c=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],d=0,e=c.length,f={};e>d;d++)if(a=c[d],a&&a[1]in document){for(d=0,b=a.length;b>d;d++)f[c[0][d]]=a[d];return f}return!1}(),d={request:function(a){var d=c.requestFullscreen;a=a||document.documentElement,/5\.1[\.\d]* Safari/.test(navigator.userAgent)?a[d]():a[d](b&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){document[c.exitFullscreen]()},toggle:function(a){this.isFullscreen?this.exit():this.request(a)},onchange:function(){},onerror:function(){},raw:c};return c?(Object.defineProperties(d,{isFullscreen:{get:function(){return!!document[c.fullscreenElement]}},element:{enumerable:!0,get:function(){return document[c.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!document[c.fullscreenEnabled]}}}),document.addEventListener(c.fullscreenchange,function(a){d.onchange.call(d,a)}),document.addEventListener(c.fullscreenerror,function(a){d.onerror.call(d,a)}),void(a?module.exports=d:window.screenfull=d)):void(a?module.exports=!1:window.screenfull=!1)}();

View File

@ -19,8 +19,8 @@
this source code distribution or the Licensing information page available
at runtime from the About dialog for additional information.
-->
<span ng-controller="BrowseObjectController">
<div class="object-browse-bar l-flex-row">
<div ng-controller="BrowseObjectController" class="abs l-flex-col">
<div class="holder flex-elem l-flex-row object-browse-bar ">
<div class="items-select left flex-elem l-flex-row grows">
<mct-representation key="'back-arrow'"
mct-object="domainObject"
@ -43,8 +43,26 @@
</mct-representation>
</div>
</div>
<mct-representation key="representation.selected.key"
mct-object="representation.selected.key && domainObject"
class="abs object-holder">
</mct-representation>
</span>
<div class="holder l-flex-col flex-elem grows l-object-wrapper">
<div class="holder l-flex-col flex-elem grows l-object-wrapper-inner">
<!-- Toolbar and Save/Cancel buttons -->
<div class="l-edit-controls flex-elem l-flex-row flex-align-end">
<mct-toolbar name="mctToolbar"
structure="toolbar.structure"
ng-model="toolbar.state"
class="flex-elem grows">
</mct-toolbar>
<mct-representation key="'edit-action-buttons'"
mct-object="domainObject"
class='flex-elem conclude-editing'>
</mct-representation>
</div>
<mct-representation key="representation.selected.key"
mct-object="representation.selected.key && domainObject"
class="abs flex-elem grows object-holder-main scroll"
toolbar="toolbar">
</mct-representation>
</div><!--/ l-object-wrapper-inner -->
</div>
</div>

View File

@ -20,7 +20,7 @@
at runtime from the About dialog for additional information.
-->
<div class="abs holder-all browse-mode" ng-controller="BrowseController">
<div class="abs holder-all" ng-controller="BrowseController">
<mct-include key="'topbar-browse'"></mct-include>
<div class="abs holder holder-main browse-area s-browse-area browse-wrapper"
ng-controller="PaneController as modelPaneTree"
@ -72,7 +72,7 @@
<div class="split-pane-component t-inspect pane right mobile-hide">
<mct-representation key="'object-inspector'"
mct-object="domainObject"
mct-object="navigatedObject"
ng-model="treeModel">
</mct-representation>
<a class="mini-tab-icon anchor-right mobile-hide toggle-pane toggle-inspect"

View File

@ -27,7 +27,9 @@
<mct-representation class="desktop-hide" key="'info-button'" mct-object="domainObject"></mct-representation>
</div>
<div class='item-main abs lg'>
<span class="t-item-icon" ng-class="{ 'l-icon-link':location.isLink() }">{{type.getGlyph()}}</span>
<span class="t-item-icon" ng-class="{ 'l-icon-link':location.isLink() }">
<span class="t-item-icon-glyph ng-binding">{{type.getGlyph()}}</span>
</span>
<div class='ui-symbol abs item-open'>}</div>
</div>
<div class='bottom-bar bar abs'>

View File

@ -19,18 +19,23 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
/*global define,Promise, confirm*/
/**
* This bundle implements Browse mode.
* @namespace platform/commonUI/browse
*/
define(
[],
function () {
[
'../../../representation/src/gestures/GestureConstants',
'../../edit/src/objects/EditableDomainObject'
],
function (GestureConstants, EditableDomainObject) {
"use strict";
var ROOT_ID = "ROOT";
var ROOT_ID = "ROOT",
DEFAULT_PATH = "mine",
CONFIRM_MSG = "Unsaved changes will be lost if you leave this page.";
/**
* The BrowseController is used to populate the initial scope in Browse
@ -46,6 +51,7 @@ define(
$scope,
$route,
$location,
$q,
objectService,
navigationService,
urlService,
@ -55,6 +61,13 @@ define(
($route.current.params.ids || defaultPath).split("/")
);
function isDirty(){
var editorCapability = $scope.navigatedObject &&
$scope.navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges;
}
function updateRoute(domainObject) {
var priorRoute = $route.current,
// Act as if params HADN'T changed to avoid page reload
@ -71,20 +84,36 @@ define(
// urlService.urlForLocation used to adjust current
// path to new, addressed, path based on
// domainObject
$location.path(urlService.urlForLocation("browse", domainObject));
$location.path(urlService.urlForLocation("browse",
domainObject.hasCapability('editor') ?
domainObject.getOriginalObject() : domainObject));
}
// Callback for updating the in-scope reference to the object
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
if (domainObject === $scope.navigatedObject){
//do nothing;
return;
}
if (isDirty() && !confirm(CONFIRM_MSG)) {
$scope.treeModel.selectedObject = $scope.navigatedObject;
navigationService.setNavigation($scope.navigatedObject);
} else {
if ($scope.navigatedObject && $scope.navigatedObject.hasCapability("editor")){
$scope.navigatedObject.getCapability("editor").cancel();
}
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
}
}
function navigateTo(domainObject) {
// Check if an object has been navigated-to already...
// If not, or if an ID path has been explicitly set in the URL,
// navigate to the URL-specified object.
@ -156,12 +185,18 @@ define(
selectedObject: navigationService.getNavigation()
};
$scope.beforeUnloadWarning = function() {
return isDirty() ?
"Unsaved changes will be lost if you leave this page." :
undefined;
};
// Listen for changes in navigation state.
navigationService.addListener(setNavigation);
// Also listen for changes which come from the tree
$scope.$watch("treeModel.selectedObject", setNavigation);
// Clean up when the scope is destroyed
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);

View File

@ -22,8 +22,11 @@
/*global define,Promise*/
define(
[],
function () {
[
'../../../representation/src/gestures/GestureConstants',
'../../edit/src/objects/EditableDomainObject'
],
function (GestureConstants, EditableDomainObject) {
"use strict";
/**
@ -32,8 +35,10 @@ define(
* @memberof platform/commonUI/browse
* @constructor
*/
function BrowseObjectController($scope, $location, $route) {
function BrowseObjectController($scope, $location, $route, $q, navigationService) {
var navigatedObject;
function setViewForDomainObject(domainObject) {
var locationViewKey = $location.search().view;
function selectViewIfMatching(view) {
@ -47,12 +52,15 @@ define(
((domainObject && domainObject.useCapability('view')) || [])
.forEach(selectViewIfMatching);
}
navigatedObject = domainObject;
}
function updateQueryParam(viewKey) {
var unlisten, priorRoute = $route.current;
var unlisten,
priorRoute = $route.current,
isEditMode = $scope.domainObject && $scope.domainObject.hasCapability('editor');
if (viewKey) {
if (viewKey && !isEditMode) {
$location.search('view', viewKey);
unlisten = $scope.$on('$locationChangeSuccess', function () {
// Checks path to make sure /browse/ is at front
@ -67,6 +75,15 @@ define(
$scope.$watch('domainObject', setViewForDomainObject);
$scope.$watch('representation.selected.key', updateQueryParam);
$scope.cancelEditing = function() {
navigationService.setNavigation($scope.domainObject.getDomainObject());
};
$scope.doAction = function (action){
return $scope[action] && $scope[action]();
};
}
return BrowseObjectController;

View File

@ -0,0 +1,139 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise*/
/**
* Module defining AddAction. Created by ahenry on 01/21/16.
*/
define(
[
'./CreateWizard'
],
function (CreateWizard) {
"use strict";
/**
* The Add Action is performed to create new instances of
* domain objects of a specific type that are subobjects of an
* object being edited. This is the action that is performed when a
* user uses the Add menu option.
*
* @memberof platform/commonUI/browse
* @implements {Action}
* @constructor
*
* @param {Type} type the type of domain object to create
* @param {DomainObject} parent the domain object that should
* act as a container for the newly-created object
* (note that the user will have an opportunity to
* override this)
* @param {ActionContext} context the context in which the
* action is being performed
* @param {DialogService} dialogService
*/
function AddAction(type, parent, context, $q, dialogService, policyService) {
this.metadata = {
key: 'add',
glyph: type.getGlyph(),
name: type.getName(),
type: type.getKey(),
description: type.getDescription(),
context: context
};
this.type = type;
this.parent = parent;
this.$q = $q;
this.dialogService = dialogService;
this.policyService = policyService;
}
/**
*
* Create a new object of the given type.
* This will prompt for user input first.
*
* @returns {Promise} that will be resolved with the object that the
* action was originally invoked on (ie. the 'parent')
*/
AddAction.prototype.perform = function () {
var newModel = this.type.getInitialModel(),
newObject,
parentObject = this.parent,
wizard;
newModel.type = this.type.getKey();
newObject = parentObject.getCapability('instantiation').instantiate(newModel);
newObject.useCapability('mutation', function(model){
model.location = parentObject.getId();
});
wizard = new CreateWizard(newObject, this.parent, this.policyService);
function populateObjectFromInput (formValue) {
return wizard.populateObjectFromInput(formValue, newObject);
}
function addToParent (populatedObject) {
parentObject.getCapability('composition').add(populatedObject);
return parentObject.getCapability('persistence').persist().then(function(){
return parentObject;
});
}
function save(object) {
/*
It's necessary to persist the new sub-object in order
that it can be retrieved for composition in the parent.
Future refactoring that allows temporary objects to be
retrieved from object services will make this unnecessary.
*/
return object.getCapability('editor').save(true);
}
return this.dialogService
.getUserInput(wizard.getFormStructure(false), wizard.getInitialFormValue())
.then(populateObjectFromInput)
.then(save)
.then(addToParent);
};
/**
* Metadata associated with a Add action.
* @typedef {ActionMetadata} AddActionMetadata
* @property {string} type the key for the type of domain object
* to be created
*/
/**
* Get metadata about this action.
* @returns {AddActionMetadata} metadata about this action
*/
AddAction.prototype.getMetadata = function () {
return this.metadata;
};
return AddAction;
}
);

View File

@ -0,0 +1,87 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise*/
/**
* Module defining AddActionProvider.js. Created by ahenry on 01/21/16.
*/
define(
["./AddAction"],
function (AddAction) {
"use strict";
/**
* The AddActionProvider is an ActionProvider which introduces
* an Add action for creating sub objects.
*
* @memberof platform/commonUI/browse
* @constructor
* @implements {ActionService}
*
* @param {TypeService} typeService the type service, used to discover
* available types
* @param {DialogService} dialogService the dialog service, used by
* specific Create actions to get user input to populate the
* model of the newly-created domain object.
* @param {CreationService} creationService the creation service (also
* introduced in this bundle), responsible for handling actual
* object creation.
*/
function AddActionProvider($q, typeService, dialogService, policyService) {
this.typeService = typeService;
this.dialogService = dialogService;
this.$q = $q;
this.policyService = policyService;
}
AddActionProvider.prototype.getActions = function (actionContext) {
var context = actionContext || {},
key = context.key,
destination = context.domainObject,
self = this;
// We only provide Add actions, and we need a
// domain object to serve as the container for the
// newly-created object (although the user may later
// make a different selection)
if (key !== 'add' || !destination) {
return [];
}
// Introduce one create action per type
return this.typeService.listTypes().filter(function (type) {
return self.policyService.allow("creation", type) && self.policyService.allow("composition", destination.getCapability('type'), type);
}).map(function (type) {
return new AddAction(
type,
destination,
context,
self.$q,
self.dialogService,
self.policyService
);
});
};
return AddActionProvider;
}
);

View File

@ -25,8 +25,11 @@
* Module defining CreateAction. Created by vwoeltje on 11/10/14.
*/
define(
['./CreateWizard'],
function (CreateWizard) {
[
'./CreateWizard',
'../../../edit/src/objects/EditableDomainObject'
],
function (CreateWizard, EditableDomainObject) {
"use strict";
/**
@ -45,13 +48,11 @@ define(
* override this)
* @param {ActionContext} context the context in which the
* action is being performed
* @param {DialogService} dialogService the dialog service
* to use when requesting user input
* @param {CreationService} creationService the creation service,
* which handles the actual instantiation and persistence
* of the newly-created domain object
* @param {NavigationService} navigationService the navigation service,
* which handles changes in navigation. It allows the object
* being browsed/edited to be set.
*/
function CreateAction(type, parent, context, dialogService, creationService, policyService) {
function CreateAction(type, parent, context, $q, navigationService) {
this.metadata = {
key: 'create',
glyph: type.getGlyph(),
@ -63,9 +64,21 @@ define(
this.type = type;
this.parent = parent;
this.policyService = policyService;
this.dialogService = dialogService;
this.creationService = creationService;
this.navigationService = navigationService;
this.$q = $q;
}
// Get a count of views which are not flagged as non-editable.
function countEditableViews(domainObject) {
var views = domainObject && domainObject.useCapability('view'),
count = 0;
// A view is editable unless explicitly flagged as not
(views || []).forEach(function (view) {
count += (view.editable !== false) ? 1 : 0;
});
return count;
}
/**
@ -73,45 +86,25 @@ define(
* This will prompt for user input first.
*/
CreateAction.prototype.perform = function () {
/*
Overview of steps in object creation:
var newModel = this.type.getInitialModel(),
parentObject = this.navigationService.getNavigation(),
newObject,
editableObject;
1. Show dialog
a. Prepare dialog contents
b. Invoke dialogService
2. Create new object in persistence service
a. Generate UUID
b. Store model
3. Mutate destination container
a. Get mutation capability
b. Add new id to composition
4. Persist destination container
a. ...use persistence capability.
*/
newModel.type = this.type.getKey();
newObject = parentObject.useCapability('instantiation', newModel);
editableObject = new EditableDomainObject(newObject, this.$q);
editableObject.setOriginalObject(parentObject);
editableObject.getCapability('status').set('editing', true);
editableObject.useCapability('mutation', function(model){
model.location = parentObject.getId();
});
// The wizard will handle creating the form model based
// on the type...
var wizard =
new CreateWizard(this.type, this.parent, this.policyService),
self = this;
// Create and persist the new object, based on user
// input.
function persistResult(formValue) {
var parent = wizard.getLocation(formValue),
newModel = wizard.createModel(formValue);
return self.creationService.createObject(newModel, parent);
if (countEditableViews(editableObject) > 0 && editableObject.hasCapability('composition')) {
this.navigationService.setNavigation(editableObject);
} else {
return editableObject.getCapability('action').perform('save');
}
function doNothing() {
// Create cancelled, do nothing
return false;
}
return this.dialogService.getUserInput(
wizard.getFormStructure(),
wizard.getInitialFormValue()
).then(persistResult, doNothing);
};

View File

@ -46,10 +46,10 @@ define(
* introduced in this bundle), responsible for handling actual
* object creation.
*/
function CreateActionProvider(typeService, dialogService, creationService, policyService) {
function CreateActionProvider($q, typeService, navigationService, policyService) {
this.typeService = typeService;
this.dialogService = dialogService;
this.creationService = creationService;
this.navigationService = navigationService;
this.$q = $q;
this.policyService = policyService;
}
@ -75,9 +75,8 @@ define(
type,
destination,
context,
self.dialogService,
self.creationService,
self.policyService
self.$q,
self.navigationService
);
});
};

View File

@ -26,18 +26,21 @@ define(
'use strict';
/**
* Construct a new CreateWizard.
* A class for capturing user input data from an object creation
* dialog, and populating a domain object with that data.
*
* @param {TypeImpl} type the type of domain object to be created
* @param {DomainObject} domainObject the newly created object to
* populate with user input
* @param {DomainObject} parent the domain object to serve as
* the initial parent for the created object, in the dialog
* @memberof platform/commonUI/browse
* @constructor
*/
function CreateWizard(type, parent, policyService) {
this.type = type;
this.model = type.getInitialModel();
this.properties = type.getProperties();
function CreateWizard(domainObject, parent, policyService) {
this.type = domainObject.getCapability('type');
this.model = domainObject.getModel();
this.domainObject = domainObject;
this.properties = this.type.getProperties();
this.parent = parent;
this.policyService = policyService;
}
@ -46,11 +49,14 @@ define(
* Get the form model for this wizard; this is a description
* that will be rendered to an HTML form. See the
* platform/forms bundle
*
* @param {boolean} includeLocation if true, a 'location' section
* will be included that will allow the user to select the location
* of the newly created object, otherwise the .location property of
* the model will be used.
* @return {FormModel} formModel the form model to
* show in the create dialog
*/
CreateWizard.prototype.getFormStructure = function () {
CreateWizard.prototype.getFormStructure = function (includeLocation) {
var sections = [],
type = this.type,
policyService = this.policyService;
@ -84,12 +90,16 @@ define(
});
// Ensure there is always a "save in" section
sections.push({ name: 'Location', rows: [{
name: "Save In",
control: "locator",
validate: validateLocation,
key: "createParent"
}]});
if (includeLocation) {
sections.push({
name: 'Location', rows: [{
name: "Save In",
control: "locator",
validate: validateLocation,
key: "createParent"
}]
});
}
return {
sections: sections,
@ -97,6 +107,23 @@ define(
};
};
/**
* Given some form input values and a domain object, populate the
* domain object used to create this wizard from the given form values.
* @param formValue
* @returns {DomainObject}
*/
CreateWizard.prototype.populateObjectFromInput = function(formValue) {
var parent = this.getLocation(formValue),
formModel = this.createModel(formValue);
formModel.location = parent.getId();
this.domainObject.useCapability("mutation", function(){
return formModel;
});
return this.domainObject;
};
/**
* Get the initial value for the form being described.
* This will include the values for all properties described
@ -120,6 +147,7 @@ define(
/**
* Based on a populated form, get the domain object which
* should be used as a parent for the newly-created object.
* @private
* @return {DomainObject}
*/
CreateWizard.prototype.getLocation = function (formValue) {
@ -129,6 +157,7 @@ define(
/**
* Create the domain object model for a newly-created object,
* based on user input read from a formModel.
* @private
* @return {object} the domain object model
*/
CreateWizard.prototype.createModel = function (formValue) {

View File

@ -33,7 +33,7 @@ define(
* @memberof platform/commonUI/browse
* @constructor
*/
function LocatorController($scope, $timeout) {
function LocatorController($scope, $timeout, objectService) {
// Populate values needed by the locator control. These are:
// * rootObject: The top-level object, since we want to show
// the full tree
@ -52,6 +52,18 @@ define(
$scope.rootObject =
(context && context.getRoot()) || $scope.rootObject;
}, 0);
} else if (!contextRoot){
//If no context root is available, default to the root
// object
$scope.rootObject = undefined;
// Update the displayed tree on a timeout to avoid
// an infinite digest exception.
objectService.getObjects(['ROOT'])
.then(function(objects){
$timeout(function () {
$scope.rootObject = objects.ROOT;
}, 0);
});
}
$scope.treeModel.selectedObject = domainObject;

View File

@ -25,7 +25,7 @@
* Module defining FullscreenAction. Created by vwoeltje on 11/18/14.
*/
define(
["../../lib/screenfull.min"],
["screenfull"],
function () {
"use strict";

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/
/**
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
@ -29,7 +29,8 @@ define(
function (BrowseController) {
"use strict";
describe("The browse controller", function () {
//TODO: Disabled for NEM Beta
xdescribe("The browse controller", function () {
var mockScope,
mockRoute,
mockLocation,

View File

@ -0,0 +1,137 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/
/**
* MCTRepresentationSpec. Created by ahenry on 01/21/14.
*/
define(
["../../src/creation/AddActionProvider"],
function (AddActionProvider) {
"use strict";
describe("The add action provider", function () {
var mockTypeService,
mockDialogService,
mockPolicyService,
mockCreationPolicy,
mockCompositionPolicy,
mockPolicyMap = {},
mockTypes,
mockDomainObject,
mockQ,
provider;
function createMockType(name) {
var mockType = jasmine.createSpyObj(
"type" + name,
[
"getKey",
"getGlyph",
"getName",
"getDescription",
"getProperties",
"getInitialModel",
"hasFeature"
]
);
mockType.hasFeature.andReturn(true);
mockType.getName.andReturn(name);
return mockType;
}
beforeEach(function () {
mockTypeService = jasmine.createSpyObj(
"typeService",
[ "listTypes" ]
);
mockDialogService = jasmine.createSpyObj(
"dialogService",
[ "getUserInput" ]
);
mockPolicyService = jasmine.createSpyObj(
"policyService",
[ "allow" ]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability" ]
);
//Mocking getCapability because AddActionProvider uses the
// type capability of the destination object.
mockDomainObject.getCapability.andReturn({});
mockTypes = [ "A", "B", "C" ].map(createMockType);
mockTypes.forEach(function(type){
mockPolicyMap[type.getName()] = true;
});
mockCreationPolicy = function(type){
return mockPolicyMap[type.getName()];
};
mockCompositionPolicy = function(){
return true;
};
mockPolicyService.allow.andReturn(true);
mockTypeService.listTypes.andReturn(mockTypes);
provider = new AddActionProvider(
mockQ,
mockTypeService,
mockDialogService,
mockPolicyService
);
});
it("checks for creatability", function () {
provider.getActions({
key: "add",
domainObject: mockDomainObject
});
// Make sure it was creation which was used to check
expect(mockPolicyService.allow)
.toHaveBeenCalledWith("creation", mockTypes[0]);
});
it("checks for composability of type", function () {
provider.getActions({
key: "add",
domainObject: mockDomainObject
});
expect(mockPolicyService.allow).toHaveBeenCalledWith(
"composition",
jasmine.any(Object),
jasmine.any(Object)
);
expect(mockDomainObject.getCapability).toHaveBeenCalledWith('type');
});
});
}
);

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/
/**
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
@ -32,11 +32,12 @@ define(
describe("The create action provider", function () {
var mockTypeService,
mockDialogService,
mockCreationService,
mockNavigationService,
mockPolicyService,
mockCreationPolicy,
mockPolicyMap = {},
mockTypes,
mockQ,
provider;
function createMockType(name) {
@ -66,9 +67,9 @@ define(
"dialogService",
[ "getUserInput" ]
);
mockCreationService = jasmine.createSpyObj(
"creationService",
[ "createObject" ]
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation" ]
);
mockPolicyService = jasmine.createSpyObj(
"policyService",
@ -92,9 +93,9 @@ define(
mockTypeService.listTypes.andReturn(mockTypes);
provider = new CreateActionProvider(
mockQ,
mockTypeService,
mockDialogService,
mockCreationService,
mockNavigationService,
mockPolicyService
);
});

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/
/**
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
@ -103,7 +103,8 @@ define(
expect(metadata.glyph).toEqual("T");
});
it("invokes the creation service when performed", function () {
//TODO: Disabled for NEM Beta
xit("invokes the creation service when performed", function () {
action.perform();
expect(mockCreationService.createObject).toHaveBeenCalledWith(
{ type: "test" },
@ -111,7 +112,8 @@ define(
);
});
it("does not create an object if the user cancels", function () {
//TODO: Disabled for NEM Beta
xit("does not create an object if the user cancels", function () {
mockDialogService.getUserInput.andReturn({
then: function (callback, fail) {
fail();

View File

@ -35,6 +35,7 @@ define(
mockProperties,
mockPolicyService,
testModel,
mockDomainObject,
wizard;
function createMockProperty(name) {
@ -81,8 +82,18 @@ define(
mockType.getInitialModel.andReturn(testModel);
mockType.getProperties.andReturn(mockProperties);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
['getCapability', 'useCapability', 'getModel']
);
//Mocking the getCapability('type') call
mockDomainObject.getCapability.andReturn(mockType);
mockDomainObject.useCapability.andReturn();
mockDomainObject.getModel.andReturn(testModel);
wizard = new CreateWizard(
mockType,
mockDomainObject,
mockParent,
mockPolicyService
);
@ -130,6 +141,18 @@ define(
});
});
it("populates the model on the associated object", function () {
var formValue = {
"A": "ValueA",
"B": "ValueB",
"C": "ValueC"
},
compareModel = wizard.createModel(formValue);
wizard.populateObjectFromInput(formValue);
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel);
});
it("validates selection types using policy", function () {
var mockDomainObject = jasmine.createSpyObj(
'domainObject',
@ -139,7 +162,8 @@ define(
'otherType',
['getKey']
),
structure = wizard.getFormStructure(),
//Create a form structure with location
structure = wizard.getFormStructure(true),
sections = structure.sections,
rows = structure.sections[sections.length - 1].rows,
locationRow = rows[rows.length - 1];
@ -156,6 +180,12 @@ define(
);
});
it("creates a form model without a location if not requested", function () {
expect(wizard.getFormStructure(false).sections.some(function(section){
return section.name === 'Location';
})).toEqual(false);
});
});
}

View File

@ -35,6 +35,8 @@ define(
mockDomainObject,
mockRootObject,
mockContext,
mockObjectService,
getObjectsPromise,
controller;
beforeEach(function () {
@ -55,73 +57,106 @@ define(
"context",
[ "getRoot" ]
);
mockObjectService = jasmine.createSpyObj(
"objectService",
["getObjects"]
);
getObjectsPromise = jasmine.createSpyObj(
"promise",
["then"]
);
mockDomainObject.getCapability.andReturn(mockContext);
mockContext.getRoot.andReturn(mockRootObject);
mockObjectService.getObjects.andReturn(getObjectsPromise);
mockScope.ngModel = {};
mockScope.field = "someField";
controller = new LocatorController(mockScope, mockTimeout);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});
describe("when context is available", function () {
it("adds a treeModel to scope", function () {
expect(mockScope.treeModel).toBeDefined();
});
beforeEach(function () {
mockContext.getRoot.andReturn(mockRootObject);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});
it("watches for changes to treeModel", function () {
// This is what the embedded tree representation
// will be modifying.
expect(mockScope.$watch).toHaveBeenCalledWith(
"treeModel.selectedObject",
jasmine.any(Function)
);
});
it("adds a treeModel to scope", function () {
expect(mockScope.treeModel).toBeDefined();
});
it("changes its own model on embedded model updates", function () {
// Need to pass on selection changes as updates to
// the control's value
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModel.someField).toEqual(mockDomainObject);
expect(mockScope.rootObject).toEqual(mockRootObject);
it("watches for changes to treeModel", function () {
// This is what the embedded tree representation
// will be modifying.
expect(mockScope.$watch).toHaveBeenCalledWith(
"treeModel.selectedObject",
jasmine.any(Function)
);
});
// Verify that the capability we expect to have been used
// was used.
expect(mockDomainObject.getCapability)
.toHaveBeenCalledWith("context");
});
it("changes its own model on embedded model updates", function () {
// Need to pass on selection changes as updates to
// the control's value
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModel.someField).toEqual(mockDomainObject);
expect(mockScope.rootObject).toEqual(mockRootObject);
it("rejects changes which fail validation", function () {
mockScope.structure = { validate: jasmine.createSpy('validate') };
mockScope.structure.validate.andReturn(false);
// Verify that the capability we expect to have been used
// was used.
expect(mockDomainObject.getCapability)
.toHaveBeenCalledWith("context");
});
// Pass selection change
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
it("rejects changes which fail validation", function () {
mockScope.structure = { validate: jasmine.createSpy('validate') };
mockScope.structure.validate.andReturn(false);
expect(mockScope.structure.validate).toHaveBeenCalled();
// Change should have been rejected
expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject);
});
// Pass selection change
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
it("treats a lack of a selection as invalid", function () {
mockScope.ngModelController = jasmine.createSpyObj(
'ngModelController',
[ '$setValidity' ]
);
expect(mockScope.structure.validate).toHaveBeenCalled();
// Change should have been rejected
expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject);
});
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), true);
it("treats a lack of a selection as invalid", function () {
mockScope.ngModelController = jasmine.createSpyObj(
'ngModelController',
[ '$setValidity' ]
);
mockScope.$watch.mostRecentCall.args[1](undefined);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), false);
});
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), true);
mockScope.$watch.mostRecentCall.args[1](undefined);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), false);
});
});
describe("when no context is available", function () {
var defaultRoot = "DEFAULT_ROOT";
beforeEach(function () {
mockContext.getRoot.andReturn(undefined);
getObjectsPromise.then.andCallFake(function(callback){
callback({'ROOT':defaultRoot});
});
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});
it("provides a default context where none is available", function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.rootObject).toBe(defaultRoot);
});
});
});
}
);

View File

@ -1,18 +0,0 @@
[
"BrowseController",
"BrowseObjectController",
"PaneController",
"MenuArrowController",
"creation/CreateAction",
"creation/CreateActionProvider",
"creation/CreateMenuController",
"creation/CreateWizard",
"creation/CreationService",
"creation/CreationPolicy",
"creation/LocatorController",
"navigation/NavigateAction",
"navigation/NavigationService",
"windowing/FullscreenAction",
"windowing/NewTabAction",
"windowing/WindowTitler"
]

View File

@ -0,0 +1,91 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/DialogService",
"./src/OverlayService",
'legacyRegistry'
], function (
DialogService,
OverlayService,
legacyRegistry
) {
"use strict";
legacyRegistry.register("platform/commonUI/dialog", {
"extensions": {
"services": [
{
"key": "dialogService",
"implementation": DialogService,
"depends": [
"overlayService",
"$q",
"$log"
]
},
{
"key": "overlayService",
"implementation": OverlayService,
"depends": [
"$document",
"$compile",
"$rootScope"
]
}
],
"templates": [
{
"key": "overlay-dialog",
"templateUrl": "templates/overlay-dialog.html"
},
{
"key": "overlay-options",
"templateUrl": "templates/overlay-options.html"
},
{
"key": "form-dialog",
"templateUrl": "templates/dialog.html"
},
{
"key": "overlay-blocking-message",
"templateUrl": "templates/overlay-blocking-message.html"
},
{
"key": "message",
"templateUrl": "templates/message.html"
},
{
"key": "overlay-message-list",
"templateUrl": "templates/overlay-message-list.html"
}
],
"containers": [
{
"key": "overlay",
"templateUrl": "templates/overlay.html"
}
]
}
});
});

View File

@ -1,48 +0,0 @@
{
"extensions": {
"services": [
{
"key": "dialogService",
"implementation": "DialogService.js",
"depends": [ "overlayService", "$q", "$log" ]
},
{
"key": "overlayService",
"implementation": "OverlayService.js",
"depends": [ "$document", "$compile", "$rootScope" ]
}
],
"templates": [
{
"key": "overlay-dialog",
"templateUrl": "templates/overlay-dialog.html"
},
{
"key": "overlay-options",
"templateUrl": "templates/overlay-options.html"
},
{
"key": "form-dialog",
"templateUrl": "templates/dialog.html"
},
{
"key": "overlay-blocking-message",
"templateUrl": "templates/overlay-blocking-message.html"
},
{
"key": "message",
"templateUrl": "templates/message.html"
},
{
"key": "overlay-message-list",
"templateUrl": "templates/overlay-message-list.html"
}
],
"containers": [
{
"key": "overlay",
"templateUrl": "templates/overlay.html"
}
]
}
}

View File

@ -1,4 +0,0 @@
[
"DialogService",
"OverlayService"
]

View File

@ -0,0 +1,235 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
"./src/controllers/EditController",
"./src/controllers/EditActionController",
"./src/controllers/EditPanesController",
"./src/controllers/ElementsController",
"./src/directives/MCTBeforeUnload",
"./src/actions/LinkAction",
"./src/actions/EditAction",
"./src/actions/PropertiesAction",
"./src/actions/RemoveAction",
"./src/actions/SaveAction",
"./src/actions/CancelAction",
"./src/policies/EditActionPolicy",
"./src/representers/EditRepresenter",
"./src/representers/EditToolbarRepresenter",
'legacyRegistry'
], function (
EditController,
EditActionController,
EditPanesController,
ElementsController,
MCTBeforeUnload,
LinkAction,
EditAction,
PropertiesAction,
RemoveAction,
SaveAction,
CancelAction,
EditActionPolicy,
EditRepresenter,
EditToolbarRepresenter,
legacyRegistry
) {
"use strict";
legacyRegistry.register("platform/commonUI/edit", {
"extensions": {
"routes": [
{
"when": "/edit",
"templateUrl": "templates/edit.html"
}
],
"controllers": [
{
"key": "EditController",
"implementation": EditController,
"depends": [
"$scope",
"$q",
"navigationService"
]
},
{
"key": "EditActionController",
"implementation": EditActionController,
"depends": [
"$scope"
]
},
{
"key": "EditPanesController",
"implementation": EditPanesController,
"depends": [
"$scope"
]
},
{
"key": "ElementsController",
"implementation": ElementsController,
"depends": [
"$scope"
]
}
],
"directives": [
{
"key": "mctBeforeUnload",
"implementation": MCTBeforeUnload,
"depends": [
"$window"
]
}
],
"actions": [
{
"key": "compose",
"implementation": LinkAction
},
{
"key": "edit",
"implementation": EditAction,
"depends": [
"$location",
"navigationService",
"$log",
"$q"
],
"description": "Edit this object.",
"category": "view-control",
"glyph": "p"
},
{
"key": "properties",
"category": [
"contextual",
"view-control"
],
"implementation": PropertiesAction,
"glyph": "p",
"name": "Edit Properties...",
"description": "Edit properties of this object.",
"depends": [
"dialogService"
]
},
{
"key": "remove",
"category": "contextual",
"implementation": RemoveAction,
"glyph": "Z",
"name": "Remove",
"description": "Remove this object from its containing object.",
"depends": [
"$q",
"navigationService"
]
},
{
"key": "save",
"category": "conclude-editing",
"implementation": SaveAction,
"name": "Save",
"description": "Save changes made to these objects.",
"depends": [
"$injector",
"policyService",
"dialogService",
"creationService",
"copyService"
],
"priority": "mandatory"
},
{
"key": "cancel",
"category": "conclude-editing",
"implementation": CancelAction,
"name": "Cancel",
"description": "Discard changes made to these objects.",
"depends": [
"$injector",
"navigationService"
]
}
],
"policies": [
{
"category": "action",
"implementation": EditActionPolicy
}
],
"templates": [
{
"key": "edit-library",
"templateUrl": "templates/library.html"
}
],
"representations": [
{
"key": "edit-object",
"templateUrl": "templates/edit-object.html",
"uses": [
"view"
]
},
{
"key": "edit-action-buttons",
"templateUrl": "templates/edit-action-buttons.html",
"uses": [
"action"
]
},
{
"key": "edit-elements",
"templateUrl": "templates/elements.html",
"uses": [
"composition"
],
"gestures": [
"drop"
]
},
{
"key": "topbar-edit",
"templateUrl": "templates/topbar-edit.html"
}
],
"representers": [
{
"implementation": EditRepresenter,
"depends": [
"$q",
"$log"
]
},
{
"implementation": EditToolbarRepresenter
}
]
}
});
});

View File

@ -1,130 +0,0 @@
{
"extensions": {
"routes": [
{
"when": "/edit",
"templateUrl": "templates/edit.html"
}
],
"controllers": [
{
"key": "EditController",
"implementation": "controllers/EditController.js",
"depends": [ "$scope", "$q", "navigationService" ]
},
{
"key": "EditActionController",
"implementation": "controllers/EditActionController.js",
"depends": [ "$scope" ]
},
{
"key": "EditPanesController",
"implementation": "controllers/EditPanesController.js",
"depends": [ "$scope" ]
}
],
"directives": [
{
"key": "mctBeforeUnload",
"implementation": "directives/MCTBeforeUnload.js",
"depends": [ "$window" ]
}
],
"actions": [
{
"key": "compose",
"implementation": "actions/LinkAction.js"
},
{
"key": "edit",
"implementation": "actions/EditAction.js",
"depends": [ "$location", "navigationService", "$log" ],
"description": "Edit this object.",
"category": "view-control",
"glyph": "p"
},
{
"key": "properties",
"category": ["contextual", "view-control"],
"implementation": "actions/PropertiesAction.js",
"glyph": "p",
"name": "Edit Properties...",
"description": "Edit properties of this object.",
"depends": [ "dialogService" ]
},
{
"key": "remove",
"category": "contextual",
"implementation": "actions/RemoveAction.js",
"glyph": "Z",
"name": "Remove",
"description": "Remove this object from its containing object.",
"depends": [ "$q", "navigationService" ]
},
{
"key": "save",
"category": "conclude-editing",
"implementation": "actions/SaveAction.js",
"name": "Save",
"description": "Save changes made to these objects.",
"depends": [ "$location", "urlService" ],
"priority": "mandatory"
},
{
"key": "cancel",
"category": "conclude-editing",
"implementation": "actions/CancelAction.js",
"name": "Cancel",
"description": "Discard changes made to these objects.",
"depends": [ "$location", "urlService" ]
}
],
"policies": [
{
"category": "action",
"implementation": "policies/EditActionPolicy.js"
},
{
"category": "view",
"implementation": "policies/EditableViewPolicy.js"
}
],
"templates": [
{
"key": "edit-library",
"templateUrl": "templates/library.html"
}
],
"representations": [
{
"key": "edit-object",
"templateUrl": "templates/edit-object.html",
"uses": [ "view" ]
},
{
"key": "edit-action-buttons",
"templateUrl": "templates/edit-action-buttons.html",
"uses": [ "action" ]
},
{
"key": "edit-elements",
"templateUrl": "templates/elements.html",
"uses": [ "composition" ],
"gestures": [ "drop" ]
},
{
"key": "topbar-edit",
"templateUrl": "templates/topbar-edit.html"
}
],
"representers": [
{
"implementation": "representers/EditRepresenter.js",
"depends": [ "$q", "$log" ]
},
{
"implementation": "representers/EditToolbarRepresenter.js"
}
]
}
}

View File

@ -21,10 +21,11 @@
-->
<span ng-controller="EditActionController">
<span ng-repeat="currentAction in editActions">
<a class='s-btn'
<a class='s-btn t-{{currentAction.getMetadata().key}}'
title='{{currentAction.getMetadata().name}}'
ng-click="currentAction.perform()"
ng-class="{ major: $index === 0, subtle: $index !== 0 }">
{{currentAction.getMetadata().name}}
ng-class="{ major: $index === 0 }">
<span class="title-label">{{currentAction.getMetadata().name}}</span>
</a>
</span>
</span>

View File

@ -19,14 +19,19 @@
this source code distribution or the Licensing information page available
at runtime from the About dialog for additional information.
-->
<div class="current-elements abs" style="height: 100%;">
<!--p class="hint">Drop objects here to add them...</p-->
<ul class="tree">
<li ng-repeat="containedObject in composition">
<span class="tree-item">
<mct-representation key="'label'" mct-object="containedObject">
</mct-representation>
</span>
</li>
</ul>
<div ng-controller="ElementsController">
<mct-include key="'input-filter'"
class="flex-elem holder"
ng-model="filterBy">
</mct-include>
<div class="current-elements abs" style="height: 100%;">
<ul class="tree">
<li ng-repeat="containedObject in composition | filter:searchText">
<span class="tree-item">
<mct-representation key="'label'" mct-object="containedObject">
</mct-representation>
</span>
</li>
</ul>
</div>
</div>

View File

@ -33,10 +33,10 @@ define(
* @memberof platform/commonUI/edit
* @implements {Action}
*/
function CancelAction($location, urlService, context) {
function CancelAction($injector, navigationService, context) {
this.domainObject = context.domainObject;
this.$location = $location;
this.urlService = urlService;
this.navigationService = navigationService;
this.objectService = $injector.get('objectService');
}
/**
@ -47,8 +47,7 @@ define(
*/
CancelAction.prototype.perform = function () {
var domainObject = this.domainObject,
$location = this.$location,
urlService = this.urlService;
self = this;
// Look up the object's "editor.completion" capability;
// this is introduced by EditableDomainObject which is
@ -64,13 +63,10 @@ define(
return editor.cancel();
}
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browise UI.)
//Discard current 'editable' object, and retrieve original
// un-edited object.
function returnToBrowse() {
$location.path($location.path(urlService.urlForLocation(
"browse",
domainObject
)));
return self.navigationService.setNavigation(self.domainObject.getOriginalObject());
}
return doCancel(getEditorCapability())

View File

@ -25,8 +25,8 @@
* Module defining EditAction. Created by vwoeltje on 11/14/14.
*/
define(
[],
function () {
['../objects/EditableDomainObject'],
function (EditableDomainObject) {
"use strict";
// A no-op action to return in the event that the action cannot
@ -46,7 +46,7 @@ define(
* @constructor
* @implements {Action}
*/
function EditAction($location, navigationService, $log, context) {
function EditAction($location, navigationService, $log, $q, context) {
var domainObject = (context || {}).domainObject;
// We cannot enter Edit mode if we have no domain object to
@ -65,14 +65,20 @@ define(
this.domainObject = domainObject;
this.$location = $location;
this.navigationService = navigationService;
this.$q = $q;
}
/**
* Enter edit mode.
*/
EditAction.prototype.perform = function () {
this.navigationService.setNavigation(this.domainObject);
this.$location.path("/edit");
var editableObject;
if (!this.domainObject.hasCapability("editor")) {
editableObject = new EditableDomainObject(this.domainObject, this.$q);
editableObject.getCapability('status').set('editing', true);
this.navigationService.setNavigation(editableObject);
}
//this.$location.path("/edit");
};
/**
@ -83,10 +89,11 @@ define(
*/
EditAction.appliesTo = function (context) {
var domainObject = (context || {}).domainObject,
type = domainObject && domainObject.getCapability('type');
type = domainObject && domainObject.getCapability('type'),
isEditMode = domainObject && domainObject.getDomainObject ? true : false;
// Only allow creatable types to be edited
return type && type.hasFeature('creation');
return type && type.hasFeature('creation') && !isEditMode;
};
return EditAction;

View File

@ -20,10 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
/*jslint es5: true */
define(
function () {
['../../../browse/src/creation/CreateWizard'],
function (CreateWizard) {
'use strict';
/**
@ -34,12 +36,32 @@ define(
* @implements {Action}
* @memberof platform/commonUI/edit
*/
function SaveAction($location, urlService, context) {
function SaveAction(
$injector,
policyService,
dialogService,
creationService,
copyService,
context
) {
this.domainObject = (context || {}).domainObject;
this.$location = $location;
this.urlService = urlService;
this.injectObjectService = function(){
this.objectService = $injector.get("objectService");
};
this.policyService = policyService;
this.dialogService = dialogService;
this.creationService = creationService;
this.copyService = copyService;
}
SaveAction.prototype.getObjectService = function(){
// Lazily acquire object service (avoids cyclical dependency)
if (!this.objectService) {
this.injectObjectService();
}
return this.objectService;
};
/**
* Save changes and conclude editing.
*
@ -49,26 +71,85 @@ define(
*/
SaveAction.prototype.perform = function () {
var domainObject = this.domainObject,
$location = this.$location,
urlService = this.urlService;
copyService = this.copyService,
self = this;
function resolveWith(object){
return function () {
return object;
};
}
function doWizardSave(parent) {
var context = domainObject.getCapability("context"),
wizard = new CreateWizard(
domainObject,
parent,
self.policyService
);
return self.dialogService
.getUserInput(
wizard.getFormStructure(true),
wizard.getInitialFormValue()
)
.then(wizard.populateObjectFromInput.bind(wizard));
}
function fetchObject(objectId){
return self.getObjectService().getObjects([objectId]).then(function(objects){
return objects[objectId];
});
}
function getParent(object){
return fetchObject(object.getModel().location);
}
function allowClone(objectToClone) {
return (objectToClone.getId() === domainObject.getId()) ||
objectToClone.getCapability('location').isOriginal();
}
function cloneIntoParent(parent) {
return copyService.perform(domainObject, parent, allowClone);
}
function cancelEditingAfterClone(clonedObject) {
return domainObject.getCapability("editor").cancel()
.then(resolveWith(clonedObject));
}
// Invoke any save behavior introduced by the editor capability;
// this is introduced by EditableDomainObject which is
// used to insulate underlying objects from changes made
// during editing.
function doSave() {
return domainObject.getCapability("editor").save();
//This is a new 'virtual object' that has not been persisted
// yet.
if (domainObject.getModel().persisted === undefined){
return getParent(domainObject)
.then(doWizardSave)
.then(getParent)
.then(cloneIntoParent)
.then(cancelEditingAfterClone)
.catch(resolveWith(false));
} else {
return domainObject.getCapability("editor").save()
.then(resolveWith(domainObject.getOriginalObject()));
}
}
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browise UI.)
function returnToBrowse() {
return $location.path(urlService.urlForLocation(
"browse",
domainObject
));
// UI, which will have been pushed atop the Browse UI.)
function returnToBrowse(object) {
if (object) {
object.getCapability("action").perform("navigate");
}
return object;
}
//return doSave().then(returnToBrowse);
return doSave().then(returnToBrowse);
};

View File

@ -0,0 +1,60 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define(
function () {
'use strict';
var DISALLOWED_ACTIONS = ["move", "copy", "link", "window", "follow"];
/**
* Editable Action Capability. Overrides the action capability
* normally exhibited by a domain object and filters out certain
* actions not applicable when an object is in edit mode.
*
* Meant specifically for use by EditableDomainObject and the
* associated cache; the constructor signature is particular
* to a pattern used there and may contain unused arguments.
* @constructor
* @memberof platform/commonUI/edit
* @implements {PersistenceCapability}
*/
function EditableActionCapability(
actionCapability,
editableObject,
domainObject,
cache
) {
var action = Object.create(actionCapability);
action.getActions = function(domainObject) {
return actionCapability.getActions(domainObject).filter(function(action){
return DISALLOWED_ACTIONS.indexOf(action.getMetadata().key) === -1;
});
};
return action;
}
return EditableActionCapability;
}
);

View File

@ -0,0 +1,60 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define(
['./EditableLookupCapability'],
function (EditableLookupCapability) {
'use strict';
/**
* Wrapper for the "instantiation" capability;
* ensures that any domain objects instantiated in Edit mode
* are also wrapped as EditableDomainObjects.
*
* Meant specifically for use by EditableDomainObject and the
* associated cache; the constructor signature is particular
* to a pattern used there and may contain unused arguments.
* @constructor
* @memberof platform/commonUI/edit
* @implements {CompositionCapability}
*/
return function EditableInstantiationCapability(
contextCapability,
editableObject,
domainObject,
cache
) {
// This is a "lookup" style capability (it looks up other
// domain objects), but we do not want to return the same
// specific value every time (composition may change)
return new EditableLookupCapability(
contextCapability,
editableObject,
domainObject,
cache,
false // Not idempotent
);
};
}
);

View File

@ -45,7 +45,8 @@ define(
cache,
idempotent
) {
var capability = Object.create(contextCapability);
var capability = Object.create(contextCapability),
method;
// Check for domain object interface. If something has these
// three methods, we assume it's a domain object.
@ -114,7 +115,9 @@ define(
}
// Wrap all methods; return only editable domain objects.
Object.keys(contextCapability).forEach(wrapMethod);
for (method in contextCapability) {
wrapMethod(method);
}
return capability;
};

View File

@ -80,7 +80,9 @@ define(
EditorCapability.prototype.save = function (nonrecursive) {
var domainObject = this.domainObject,
editableObject = this.editableObject,
cache = this.cache;
self = this,
cache = this.cache,
returnPromise;
// Update the underlying, "real" domain object's model
// with changes made to the copy used for editing.
@ -95,9 +97,21 @@ define(
return domainObject.getCapability('persistence').persist();
}
return nonrecursive ?
resolvePromise(doMutate()).then(doPersist) :
resolvePromise(cache.saveAll());
editableObject.getCapability("status").set("editing", false);
if (nonrecursive) {
returnPromise = resolvePromise(doMutate())
.then(doPersist)
.then(function(){
self.cancel();
});
} else {
returnPromise = resolvePromise(cache.saveAll());
}
//Return the original (non-editable) object
return returnPromise.then(function() {
return domainObject.getOriginalObject ? domainObject.getOriginalObject() : domainObject;
});
};
/**
@ -109,6 +123,9 @@ define(
* @memberof platform/commonUI/edit.EditorCapability#
*/
EditorCapability.prototype.cancel = function () {
this.editableObject.getCapability("status").set("editing", false);
//TODO: Reset the cache as well here.
this.cache.markClean();
return resolvePromise(undefined);
};

View File

@ -0,0 +1,47 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise*/
define(
[],
function () {
"use strict";
/**
* The ElementsController prepares the elements view for display
*
* @constructor
*/
function ElementsController($scope) {
function filterBy(text){
if (typeof text === 'undefined') {
return $scope.searchText;
} else {
$scope.searchText = text;
}
}
$scope.filterBy = filterBy;
}
return ElementsController;
}
);

Some files were not shown because too many files have changed in this diff Show More