Compare commits
95 Commits
renamed-ty
...
time-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be476aff43 | ||
|
|
d62a3ca494 | ||
|
|
d77ea6c024 | ||
|
|
fae7cd69da | ||
|
|
80432710e0 | ||
|
|
7dd5da8993 | ||
|
|
95ac304afb | ||
|
|
80dc5a13b8 | ||
|
|
b5abe6527b | ||
|
|
616aab4a2d | ||
|
|
12e693941c | ||
|
|
59c61e72b8 | ||
|
|
3ce954c68c | ||
|
|
df0d4dff6f | ||
|
|
a867cd6be0 | ||
|
|
b48dd4b63b | ||
|
|
35c457b7fb | ||
|
|
6870055033 | ||
|
|
5f968b50f8 | ||
|
|
251438eefd | ||
|
|
c07a372c6e | ||
|
|
f666a7ca09 | ||
|
|
c27b37918a | ||
|
|
67eab82bd1 | ||
|
|
8d86ca05da | ||
|
|
4d6a0d4931 | ||
|
|
4ae35576a5 | ||
|
|
af622599a5 | ||
|
|
12d1302138 | ||
|
|
09419398e9 | ||
|
|
b69e03368a | ||
|
|
4e457f1cf0 | ||
|
|
4196da9f52 | ||
|
|
a59177447b | ||
|
|
529abcc4b0 | ||
|
|
1cb5dd021f | ||
|
|
399b745084 | ||
|
|
f09a76e23b | ||
|
|
16b6a70e22 | ||
|
|
1a7260cc14 | ||
|
|
8a75381a3d | ||
|
|
c394fe9287 | ||
|
|
06f4a955b5 | ||
|
|
a2bf92db97 | ||
|
|
da40f4c96e | ||
|
|
6fa5a31217 | ||
|
|
5bc7a701dc | ||
|
|
5cd0516048 | ||
|
|
48a603ece8 | ||
|
|
abfa56464a | ||
|
|
c1d6e21c3c | ||
|
|
3bd556a406 | ||
|
|
347fb6d882 | ||
|
|
b3cf7a5d93 | ||
|
|
c7cffdeb3b | ||
|
|
d45ae7908d | ||
|
|
b10fb4533e | ||
|
|
c74fdb816f | ||
|
|
40985a56c8 | ||
|
|
5c01f0be24 | ||
|
|
f7ff5af60b | ||
|
|
2088fc52f3 | ||
|
|
db33ab143e | ||
|
|
8c77d4006a | ||
|
|
2fa567b98b | ||
|
|
e61f04663a | ||
|
|
4b905fa7d2 | ||
|
|
5e6e7f018a | ||
|
|
53f56b430a | ||
|
|
50c934820c | ||
|
|
2a10a2cae2 | ||
|
|
65325b90fd | ||
|
|
cfecc36ae6 | ||
|
|
d9f8622459 | ||
|
|
8e13819e1e | ||
|
|
aaedf5d576 | ||
|
|
af9ffaf02d | ||
|
|
970acbd56e | ||
|
|
fa962b42bc | ||
|
|
34dc457aff | ||
|
|
a3311e4c57 | ||
|
|
ef8efbd53d | ||
|
|
6cd99efbb9 | ||
|
|
ae2b73a4f5 | ||
|
|
0c3ff82cfe | ||
|
|
50f303bbdc | ||
|
|
2a4944d6ee | ||
|
|
3544caf4be | ||
|
|
976333d7f7 | ||
|
|
6d5530ba9c | ||
|
|
77d0134e2e | ||
|
|
3d3baddd23 | ||
|
|
784114e256 | ||
|
|
d1e7e7894e | ||
|
|
65bf38d5e6 |
558
API.md
558
API.md
@@ -1,76 +1,150 @@
|
||||
# Open MCT API
|
||||
# Building Applications With Open MCT
|
||||
|
||||
The Open MCT framework public api can be utilized by building the application
|
||||
(`gulp install`) and then copying the file from `dist/main.js` to your
|
||||
directory of choice.
|
||||
## Scope and purpose of this document
|
||||
|
||||
Open MCT supports AMD, CommonJS, and loading via a script tag; it's easy to use
|
||||
in your project. The [`openmct`]{@link module:openmct} module is exported
|
||||
via AMD and CommonJS, and is also exposed as `openmct` in the global scope
|
||||
if loaded via a script tag.
|
||||
This document is intended to serve as a reference for developing an application
|
||||
based on Open MCT. It will provide details of the API functions necessary to extend the
|
||||
Open MCT platform meet common use cases such as integrating with a telemetry source.
|
||||
|
||||
## Overview
|
||||
The best place to start is with the [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial).
|
||||
These will walk you through the process of getting up and running with Open MCT,
|
||||
as well as addressing some common developer use cases.
|
||||
|
||||
Open MCT's goal is to allow you to browse, create, edit, and visualize all of
|
||||
the domain knowledge you need on a daily basis.
|
||||
## Building From Source
|
||||
|
||||
To do this, the main building block provided by Open MCT is the _domain object_.
|
||||
The temperature sensor on the starboard solar panel,
|
||||
an overlay plot comparing the results of all temperature sensor,
|
||||
the command dictionary for a spacecraft,
|
||||
the individual commands in that dictionary, your "my documents" folder:
|
||||
The latest version of Open MCT is available from [our GitHub repository](https://github.com/nasa/openmct).
|
||||
If you have `git`, and `node` installed, you can build Open MCT with the commands
|
||||
```
|
||||
git clone https://github.com/nasa/openmct.git
|
||||
cd openmct
|
||||
npm install
|
||||
```
|
||||
|
||||
These commands will fetch the Open MCT source from our GitHub repository, and build
|
||||
a minified version that can be included in your application. The output of the
|
||||
build process is placed in a `dist` folder under the openmct source directory,
|
||||
which can be copied out to another location as needed. The contents of this
|
||||
folder will include a minified javascript file named `openmct.js` as well as
|
||||
assets such as html, css, and images necessary for the UI.
|
||||
|
||||
## Starting an Open MCT application
|
||||
|
||||
To start a minimally functional Open MCT application, it is necessary to include
|
||||
the Open MCT distributable, enable some basic plugins, and bootstrap the application.
|
||||
The tutorials walk through the process of getting Open MCT up and running from scratch,
|
||||
but provided below is a minimal HTML template that includes Open MCT, installs
|
||||
some basic plugins, and bootstraps the application. It assumes that Open MCT is
|
||||
installed under an `openmct` subdirectory, as described in [Building From Source](#building-from-source).
|
||||
|
||||
This approach includes openmct using a simple script tag, resulting in a global
|
||||
variable named `openmct`. This `openmct` object is used subsequently to make API
|
||||
calls.
|
||||
|
||||
Open MCT is packaged as a UMD (Universal Module Definition) module, so common
|
||||
script loaders are also supported.
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Open MCT</title>
|
||||
<script src="openmct.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
openmct.setAssetPath('openmct/dist');
|
||||
openmct.install(openmct.plugins.LocalStorage());
|
||||
openmct.install(openmct.plugins.MyItems());
|
||||
openmct.install(openmct.plugins.UTCTimeSystem());
|
||||
openmct.install(openmct.plugins.Espresso());
|
||||
openmct.start();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
The Open MCT library included above requires certain assets such as html templates,
|
||||
images, and css. If you installed Open MCT from GitHub as described in the section
|
||||
on [Building from Source](#building-from-source) then these assets will have been
|
||||
downloaded along with the Open MCT javascript library. You can specify the
|
||||
location of these assets by calling `openmct.setAssetPath()`. Typically this will
|
||||
be the same location as the `openmct.js` library is included from.
|
||||
|
||||
There are some plugins bundled with the application that provide UI, persistence,
|
||||
and other default configuration which are necessary to be able to do anything with
|
||||
the application initially. Any of these plugins can, in principle, be replaced with a custom
|
||||
plugin. The included plugins are documented in the [Included Plugins](#included-plugins)
|
||||
section.
|
||||
|
||||
## Plugins
|
||||
|
||||
### Defining and Installing a New Plugin
|
||||
|
||||
```javascript
|
||||
openmct.install(function install(openmctAPI) {
|
||||
// Do things here
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
New plugins are installed in Open MCT by calling `openmct.install`, and providing
|
||||
a plugin installation function. This function will be invoked on application
|
||||
startup with one parameter - the openmct API object. A common approach used in
|
||||
the Open MCT codebase is to define a plugin as a function that returns this
|
||||
installation function. This allows configuration to be specified when the plugin is included.
|
||||
|
||||
eg.
|
||||
```javascript
|
||||
openmct.install(openmct.plugins.Elasticsearch("http://localhost:8002/openmct"));
|
||||
```
|
||||
This approach can be seen in all of the [plugins provided with Open MCT](https://github.com/nasa/openmct/blob/master/src/plugins/plugins.js).
|
||||
|
||||
## Domain Objects and Identifiers
|
||||
|
||||
_Domain Objects_ are the basic entities that represent domain knowledge in Open MCT.
|
||||
The temperature sensor on a solar panel, an overlay plot comparing
|
||||
the results of all temperature sensors, the command dictionary for a spacecraft,
|
||||
the individual commands in that dictionary, the "My Items" folder:
|
||||
All of these things are domain objects.
|
||||
|
||||
Domain objects have Types, so a specific instrument temperature sensor is a
|
||||
"Telemetry Point," and turning on a drill for a certain duration of time is
|
||||
an "Activity". Types allow you to form an ontology of knowledge and provide
|
||||
an abstraction for grouping, visualizing, and interpreting data.
|
||||
A _Domain Object_ is simply a javascript object with some standard attributes.
|
||||
An example of a _Domain Object_ is the "My Items" object which is a folder in
|
||||
which a user can persist any objects that they create. The My Items object
|
||||
looks like this:
|
||||
|
||||
And then we have Views. Views allow you to visualize domain objects. Views can
|
||||
apply to specific domain objects; they may also apply to certain types of
|
||||
domain objects, or they may apply to everything. Views are simply a method
|
||||
of visualizing domain objects.
|
||||
|
||||
Regions allow you to specify what views are displayed for specific types of
|
||||
domain objects in response to different user actions. For instance, you may
|
||||
want to display a different view while editing, or you may want to update the
|
||||
toolbar display when objects are selected. Regions allow you to map views to
|
||||
specific user actions.
|
||||
|
||||
Domain objects can be mutated and persisted, developers can create custom
|
||||
actions and apply them to domain objects, and many more things can be done.
|
||||
For more information, read on!
|
||||
|
||||
## Running Open MCT
|
||||
|
||||
Once the [`openmct`](@link module:openmct) module has been loaded, you can
|
||||
simply invoke [`start`]{@link module:openmct.MCT#start} to run Open MCT:
|
||||
|
||||
|
||||
```
|
||||
openmct.start();
|
||||
```javascript
|
||||
{
|
||||
identifier: {
|
||||
namespace: ""
|
||||
key: "mine"
|
||||
}
|
||||
name:"My Items",
|
||||
type:"folder",
|
||||
location:"ROOT",
|
||||
composition: []
|
||||
}
|
||||
```
|
||||
|
||||
Generally, however, you will want to configure Open MCT by adding plugins
|
||||
before starting it. It is important to install plugins and configure Open MCT
|
||||
_before_ calling [`start`]{@link module:openmct.MCT#start}; Open MCT is not
|
||||
designed to be reconfigured once started.
|
||||
### Object Attributes
|
||||
|
||||
## Configuring Open MCT
|
||||
The main attributes to note are the `identifier`, and `type` attributes.
|
||||
* `identifier`: A composite key that provides a universally unique identifier for
|
||||
this object. The `namespace` and `key` are used to identify the object. The `key`
|
||||
must be unique within the namespace.
|
||||
* `type`: All objects in Open MCT have a type. Types allow you to form an
|
||||
ontology of knowledge and provide an abstraction for grouping, visualizing, and
|
||||
interpreting data. Details on how to define a new object type are provided below.
|
||||
|
||||
The [`openmct`]{@link module:openmct} module (more specifically, the
|
||||
[`MCT`]{@link module:openmct.MCT} class, of which `openmct` is an instance)
|
||||
exposes a variety of methods to allow the application to be configured,
|
||||
extended, and customized before running.
|
||||
Open MCT uses a number of builtin types. Typically you are going to want to
|
||||
define your own if extending Open MCT.
|
||||
|
||||
Short examples follow; see the linked documentation for further details.
|
||||
### Domain Object Types
|
||||
|
||||
### Adding Domain Object Types
|
||||
Custom types may be registered via the `addType` function on the opencmt Type
|
||||
registry.
|
||||
|
||||
Custom types may be registered via
|
||||
[`openmct.types`]{@link module:openmct.MCT#types}:
|
||||
|
||||
```
|
||||
eg.
|
||||
```javascript
|
||||
openmct.types.addType('my-type', {
|
||||
label: "My Type",
|
||||
description: "This is a type that I added!",
|
||||
@@ -78,66 +152,98 @@ openmct.types.addType('my-type', {
|
||||
});
|
||||
```
|
||||
|
||||
### Adding Views
|
||||
The `addType` function accepts two arguments:
|
||||
* A `string` key identifying the type. This key is used when specifying a type
|
||||
for an object.
|
||||
* An object type specification. An object type definition supports the following
|
||||
attributes
|
||||
* `label`: a `string` naming this object type
|
||||
* `description`: a `string` specifying a longer-form description of this type
|
||||
* `initialize`: a `function` which initializes the model for new domain objects
|
||||
of this type. This can be used for setting default values on an object when
|
||||
it is instantiated.
|
||||
* `creatable`: A `boolean` indicating whether users should be allowed to create
|
||||
this type (default: `false`). This will determine whether the type appears
|
||||
in the `Create` menu.
|
||||
* `cssClass`: A `string` specifying a CSS class to apply to each representation
|
||||
of this object. This is used for specifying an icon to appear next to each
|
||||
object of this type.
|
||||
|
||||
Custom views may be registered based on the region in the application
|
||||
where they should appear:
|
||||
The [Open MCT Tutorials](https://github.com/openmct/openmct-tutorial) provide a
|
||||
step-by-step examples of writing code for Open MCT that includes a [section on
|
||||
defining a new object type](https://github.com/nasa/openmct-tutorial#step-3---providing-objects).
|
||||
|
||||
* [`openmct.mainViews`]{@link module:openmct.MCT#mainViews} is a registry
|
||||
of views of domain objects which should appear in the main viewing area.
|
||||
* [`openmct.inspectors`]{@link module:openmct.MCT#inspectors} is a registry
|
||||
of views of domain objects and/or active selections, which should appear in
|
||||
the Inspector.
|
||||
* [`openmct.toolbars`]{@link module:openmct.MCT#toolbars} is a registry
|
||||
of views of domain objects and/or active selections, which should appear in
|
||||
the toolbar area while editing.
|
||||
* [`openmct.indicators`]{@link module:openmct.MCT#inspectors} is a registry
|
||||
of views which should appear in the status area of the application.
|
||||
## Root Objects
|
||||
|
||||
Example:
|
||||
In many cases, you'd like a certain object (or a certain hierarchy of objects)
|
||||
to be accessible from the top level of the application (the tree on the left-hand
|
||||
side of Open MCT.) For example, it is typical to expose a telemetry dictionary
|
||||
as a hierarchy of telemetry-providing domain objects in this fashion.
|
||||
|
||||
```
|
||||
openmct.mainViews.addProvider({
|
||||
canView: function (domainObject) {
|
||||
return domainObject.type === 'my-type';
|
||||
},
|
||||
view: function (domainObject) {
|
||||
return new MyView(domainObject);
|
||||
}
|
||||
});
|
||||
To do so, use the `addRoot` method of the object API.
|
||||
|
||||
eg.
|
||||
```javascript
|
||||
openmct.objects.addRoot({
|
||||
namespace: "my-namespace",
|
||||
key: "my-key"
|
||||
});
|
||||
```
|
||||
|
||||
### Adding a Root-level Object
|
||||
|
||||
In many cases, you'd like a certain object (or a certain hierarchy of
|
||||
objects) to be accessible from the top level of the application (the
|
||||
tree on the left-hand side of Open MCT.) It is typical to expose a telemetry
|
||||
dictionary as a hierarchy of telemetry-providing domain objects in this
|
||||
fashion.
|
||||
|
||||
To do so, use the [`addRoot`]{@link module:openmct.ObjectAPI#addRoot} method
|
||||
of the [object API]{@link module:openmct.ObjectAPI}:
|
||||
|
||||
```
|
||||
openmct.objects.addRoot({ key: "my-key", namespace: "my-namespace" });
|
||||
```
|
||||
The `addRoot` function takes a single [object identifier](#domain-objects-and-identifiers)
|
||||
as an argument.
|
||||
|
||||
Root objects are loaded just like any other objects, i.e. via an object
|
||||
provider.
|
||||
|
||||
### Adding Composition Providers
|
||||
## Object Providers
|
||||
|
||||
The "composition" of a domain object is the list of objects it contains,
|
||||
as shown (for example) in the tree for browsing. Open MCT provides a
|
||||
An Object Provider is used to build _Domain Objects_, typically retrieved from
|
||||
some source such as a persistence store or telemetry dictionary. In order to
|
||||
integrate telemetry from a new source an object provider will need to be created
|
||||
that can build objects representing telemetry points exposed by the telemetry
|
||||
source. The API call to define a new object provider is fairly straightforward.
|
||||
Here's a very simple example:
|
||||
|
||||
```javascript
|
||||
openmct.objects.addProvider('example.namespace', {
|
||||
get: function (identifier) {
|
||||
return Promise.resolve({
|
||||
identifier: identifier,
|
||||
name: 'Example Object',
|
||||
type: 'example-object-type'
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
The `addProvider` function takes two arguments:
|
||||
|
||||
* `namespace`: A `string` representing the namespace that this object provider
|
||||
will provide objects for.
|
||||
* `provider`: An `object` with a single function, `get`. This function accepts an
|
||||
[Identifier](#domain-objects-and-identifiers) for the object to be provided.
|
||||
It is expected that the `get` function will return a
|
||||
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
||||
that resolves with the object being requested.
|
||||
|
||||
In future, object providers will support other methods to enable other operations
|
||||
with persistence stores, such as creating, updating, and deleting objects.
|
||||
|
||||
## Composition Providers
|
||||
|
||||
The _composition_ of a domain object is the list of objects it contains, as shown
|
||||
(for example) in the tree for browsing. Open MCT provides a
|
||||
[default solution](#default-composition-provider) for composition, but there
|
||||
may be cases where you want to provide the composition of a certain object
|
||||
(or type of object) dynamically.
|
||||
|
||||
For instance, you may want to populate a hierarchy under a custom root-level
|
||||
object based on the contents of a telemetry dictionary.
|
||||
To do this, you can add a new CompositionProvider:
|
||||
### Adding Composition Providers
|
||||
|
||||
```
|
||||
You may want to populate a hierarchy under a custom root-level object based on
|
||||
the contents of a telemetry dictionary. To do this, you can add a new
|
||||
Composition Provider:
|
||||
|
||||
```javascript
|
||||
openmct.composition.addProvider({
|
||||
appliesTo: function (domainObject) {
|
||||
return domainObject.type === 'my-type';
|
||||
@@ -147,20 +253,27 @@ openmct.composition.addProvider({
|
||||
}
|
||||
});
|
||||
```
|
||||
The `addProvider` function accepts a Composition Provider object as its sole
|
||||
argument. A Composition Provider is a javascript object exposing two functions:
|
||||
* `appliesTo`: A `function` that accepts a `domainObject` argument, and returns
|
||||
a `boolean` value indicating whether this composition provider applies to the
|
||||
given object.
|
||||
* `load`: A `function` that accepts a `domainObject` as an argument, and returns
|
||||
a `Promise` that resolves with an array of [Identifier](#domain-objects-and-identifiers).
|
||||
These identifiers will be used to fetch Domain Objects from an [Object Provider](#object-provider)
|
||||
|
||||
#### Default Composition Provider
|
||||
### Default Composition Provider
|
||||
|
||||
The default composition provider applies to any domain object with
|
||||
a `composition` property. The value of `composition` should be an
|
||||
array of identifiers, e.g.:
|
||||
The default composition provider applies to any domain object with a `composition`
|
||||
property. The value of `composition` should be an array of identifiers, e.g.:
|
||||
|
||||
```js
|
||||
```javascript
|
||||
var domainObject = {
|
||||
name: "My Object",
|
||||
type: 'folder',
|
||||
composition: [
|
||||
{
|
||||
key: '412229c3-922c-444b-8624-736d85516247',
|
||||
id: '412229c3-922c-444b-8624-736d85516247',
|
||||
namespace: 'foo'
|
||||
},
|
||||
{
|
||||
@@ -171,169 +284,146 @@ var domainObject = {
|
||||
};
|
||||
```
|
||||
|
||||
### Adding Telemetry Providers
|
||||
## Telemetry Providers
|
||||
|
||||
When connecting to a new telemetry source, you will want to register a new
|
||||
[telemetry provider]{@link module:openmct.TelemetryAPI~TelemetryProvider}
|
||||
with the [telemetry API]{@link module:openmct.TelemetryAPI#addProvider}:
|
||||
When connecting to a new telemetry source, you will need to register a new
|
||||
_Telemetry Provider_. A _Telemetry Provider_ retrieves telemetry data from some telemetry
|
||||
source, and exposes them in a way that can be used by Open MCT. A telemetry
|
||||
provider typically can support a one off __request__ for a batch of telemetry data,
|
||||
or it can provide the ability to __subscribe__ to receive new telemetry data when
|
||||
it becomes available, or both.
|
||||
|
||||
```
|
||||
```javascript
|
||||
openmct.telemetry.addProvider({
|
||||
canProvideTelemetry: function (domainObject) {
|
||||
return domainObject.type === 'my-type';
|
||||
supportsRequest: function (domainObject) {
|
||||
//...
|
||||
},
|
||||
properties: function (domainObject) {
|
||||
return [
|
||||
{ key: 'value', name: "Temperature", units: "degC" },
|
||||
{ key: 'time', name: "UTC" }
|
||||
];
|
||||
supportsSubscribe: function (domainObject) {
|
||||
//...
|
||||
},
|
||||
request: function (domainObject, options) {
|
||||
var telemetryId = domainObject.myTelemetryId;
|
||||
return myAdapter.request(telemetryId, options.start, options.end);
|
||||
request: function (domainObject, options) {
|
||||
//...
|
||||
},
|
||||
subscribe: function (domainObject, callback) {
|
||||
var telemetryId = domainObject.myTelemetryId;
|
||||
myAdapter.subscribe(telemetryId, callback);
|
||||
return myAdapter.unsubscribe.bind(myAdapter, telemetryId, callback);
|
||||
subscribe: function (domainObject, callback, options) {
|
||||
//...
|
||||
}
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
A telemetry provider is an object with the following functions defined:
|
||||
|
||||
* `supportsRequest`: An __optional__ `function` that accepts a
|
||||
[Domain Object](#domain-objects-and-identifiers) and returns a `boolean` value
|
||||
indicating whether or not this provider supports telemetry requests for the
|
||||
given object. If this returns `true` then a `request` function must be defined.
|
||||
* `supportsSubscribe`: An __optional__ `function` that accepts a
|
||||
[Domain Object](#domain-objects-and-identifiers) and returns a `boolean` value
|
||||
indicating whether or not this provider supports telemetry subscriptions. If this
|
||||
returns `true` then a `subscribe` function must also be defined. As with `request`,
|
||||
the return value will typically be conditional, and based on attributes of
|
||||
`domainObject` such as its identifier.
|
||||
* `request`: A `function` that returns a `Promise` that will resolve with an `Array`
|
||||
of telemetry in a single query. This function accepts as arguments a
|
||||
[Domain Object](#domain-objects-and-identifiers) and an object containing some
|
||||
[request options](#telemetry-requests).
|
||||
* `subscribe`: A `function` that accepts a [Domain Object](#domain-objects-and-identifiers),
|
||||
a callback `function`, and a [telemetry request](#telemetry-requests). The
|
||||
callback is invoked whenever telemetry is available, and
|
||||
|
||||
|
||||
The implementations for `request` and `subscribe` can vary depending on the
|
||||
nature of the endpoint which will provide telemetry. In the example above,
|
||||
it is assumed that `myAdapter` contains the specific implementations
|
||||
(HTTP requests, WebSocket connections, etc.) associated with some telemetry
|
||||
it is assumed that `myAdapter` contains the implementation details
|
||||
(such as HTTP requests, WebSocket connections, etc.) associated with some telemetry
|
||||
source.
|
||||
|
||||
## Using Open MCT
|
||||
For a step-by-step guide to building a telemetry adapter, please see the
|
||||
[Open MCT Tutorials](https://github.com/larkin/openmct-tutorial).
|
||||
|
||||
When implementing new features, it is useful and sometimes necessary to
|
||||
utilize functionality exposed by Open MCT.
|
||||
|
||||
### Retrieving Composition
|
||||
|
||||
To limit which objects are loaded at any given time, the composition of
|
||||
a domain object must be requested asynchronously:
|
||||
|
||||
```
|
||||
openmct.composition(myObject).load().then(function (childObjects) {
|
||||
childObjects.forEach(doSomething);
|
||||
});
|
||||
### Telemetry Requests
|
||||
Telemetry requests support time bounded queries. A call to a _Telemetry Provider_'s
|
||||
`request` function will include an `options` argument. These are simply javascript
|
||||
objects with attributes for the request parameters. An example of a telemetry
|
||||
request object with a start and end time is included below:
|
||||
```javascript
|
||||
{
|
||||
start: 1487981997240,
|
||||
end: 1487982897240
|
||||
}
|
||||
```
|
||||
|
||||
### Support Common Gestures
|
||||
### Telemetry Data
|
||||
|
||||
Custom views may also want to support common gestures using the
|
||||
[gesture API]{@link module:openmct.GestureAPI}. For instance, to make
|
||||
a view (or part of a view) selectable:
|
||||
Telemetry data is provided to Open MCT by _[Telemetry Providers](#telemetry-providers)_
|
||||
in the form of javascript objects. A collection of telemetry values (for example,
|
||||
retrieved in response to a `request`) is represented by an `Array` of javascript
|
||||
objects. These telemetry javascript objects are simply key value pairs.
|
||||
|
||||
```
|
||||
openmct.gestures.selectable(myHtmlElement, myDomainObject);
|
||||
Typically a telemetry datum will have some timestamp associated with it. This
|
||||
time stamp should have a key that corresponds to some time system supported by
|
||||
Open MCT. If the `UTCTimeSystem` plugin is installed, then the key `utc` can be used.
|
||||
|
||||
An example of a telemetry provider request function that returns a collection of
|
||||
mock telemtry data is below:
|
||||
|
||||
```javascript
|
||||
openmct.telemetry.addProvider({
|
||||
supportsRequest: function (domainObject) {
|
||||
return true
|
||||
},
|
||||
request: function (domainObject, options) {
|
||||
return Promise.resolve([
|
||||
{
|
||||
'utc': Date.now() - 2000,
|
||||
'value': 1,
|
||||
},
|
||||
{
|
||||
'utc': Date.now() - 1000,
|
||||
'value': 2,
|
||||
},
|
||||
{
|
||||
'utc': Date.now(),
|
||||
'value': 3,
|
||||
}
|
||||
]);
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Working with Domain Objects
|
||||
|
||||
The [object API]{@link module:openmct.ObjectAPI} provides useful methods
|
||||
for working with domain objects.
|
||||
|
||||
To make changes to a domain object, use the
|
||||
[`mutate`]{@link module:openmct.ObjectAPI#mutate} method:
|
||||
|
||||
```
|
||||
openmct.objects.mutate(myDomainObject, "name", "New name!");
|
||||
```
|
||||
|
||||
Making modifications in this fashion allows other usages of the domain
|
||||
object to remain up to date using the
|
||||
[`observe`]{@link module:openmct.ObjectAPI#observe} method:
|
||||
|
||||
```
|
||||
openmct.objects.observe(myDomainObject, "name", function (newName) {
|
||||
myLabel.textContent = newName;
|
||||
});
|
||||
```
|
||||
|
||||
### Using Telemetry
|
||||
|
||||
Very often in Open MCT, you wish to work with telemetry data (for instance,
|
||||
to display it in a custom visualization.)
|
||||
|
||||
|
||||
### Synchronizing with the Time Conductor
|
||||
|
||||
Views which wish to remain synchronized with the state of Open MCT's
|
||||
time conductor should utilize
|
||||
[`openmct.conductor`]{@link module:openmct.TimeConductor}:
|
||||
|
||||
```
|
||||
openmct.conductor.on('bounds', function (newBounds) {
|
||||
requestTelemetry(newBounds.start, newBounds.end).then(displayTelemetry);
|
||||
});
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
While you can register new features with Open MCT directly, it is generally
|
||||
more useful to package these as a plugin. A plugin is a function that takes
|
||||
[`openmct`]{@link module:openmct} as an argument, and performs configuration
|
||||
upon `openmct` when invoked.
|
||||
|
||||
### Installing Plugins
|
||||
|
||||
To install plugins, use the [`install`]{@link module:openmct.MCT#install}
|
||||
method:
|
||||
|
||||
```
|
||||
openmct.install(myPlugin);
|
||||
```
|
||||
|
||||
The plugin will be invoked to configure Open MCT before it is started.
|
||||
|
||||
### Included Plugins
|
||||
## Included Plugins
|
||||
|
||||
Open MCT is packaged along with a few general-purpose plugins:
|
||||
|
||||
* `openmct.plugins.CouchDB` is an adapter for using CouchDB for persistence
|
||||
of user-created objects. This is a constructor that takes the URL for the
|
||||
CouchDB database as a parameter, e.g.
|
||||
`openmct.install(new openmct.plugins.CouchDB('http://localhost:5984/openmct'))`
|
||||
```javascript
|
||||
openmct.install(openmct.plugins.CouchDB('http://localhost:5984/openmct'))
|
||||
```
|
||||
* `openmct.plugins.Elasticsearch` is an adapter for using Elasticsearch for
|
||||
persistence of user-created objects. This is a
|
||||
constructor that takes the URL for the Elasticsearch instance as a
|
||||
parameter, e.g.
|
||||
`openmct.install(new openmct.plugins.CouchDB('http://localhost:9200'))`.
|
||||
Domain objects will be indexed at `/mct/domain_object`.
|
||||
* `openmct.plugins.espresso` and `openmct.plugins.snow` are two different
|
||||
parameter. eg.
|
||||
```javascript
|
||||
openmct.install(openmct.plugins.CouchDB('http://localhost:9200'))
|
||||
```
|
||||
* `openmct.plugins.Espresso` and `openmct.plugins.Snow` are two different
|
||||
themes (dark and light) available for Open MCT. Note that at least one
|
||||
of these themes must be installed for Open MCT to appear correctly.
|
||||
* `openmct.plugins.localStorage` provides persistence of user-created
|
||||
* `openmct.plugins.LocalStorage` provides persistence of user-created
|
||||
objects in browser-local storage. This is particularly useful in
|
||||
development environments.
|
||||
* `openmct.plugins.myItems` adds a top-level folder named "My Items"
|
||||
* `openmct.plugins.MyItems` adds a top-level folder named "My Items"
|
||||
when the application is first started, providing a place for a
|
||||
user to store created items.
|
||||
* `openmct.plugins.utcTimeSystem` provides support for using the time
|
||||
conductor with UTC time.
|
||||
* `openmct.plugins.UTCTimeSystem` provides a default time system for Open MCT.
|
||||
|
||||
Generally, you will want to either install these plugins, or install
|
||||
different plugins that provide persistence and an initial folder
|
||||
hierarchy. Installation is as described [above](#installing-plugins):
|
||||
hierarchy.
|
||||
|
||||
eg.
|
||||
```javascript
|
||||
openmct.install(openmct.plugins.LocalStorage());
|
||||
openmct.install(openmct.plugins.MyItems());
|
||||
```
|
||||
openmct.install(openmct.plugins.localStorage);
|
||||
openmct.install(openmct.plugins.myItems);
|
||||
```
|
||||
|
||||
### Writing Plugins
|
||||
|
||||
Plugins configure Open MCT, and should utilize the
|
||||
[`openmct`]{@link module:openmct} module to do so, as summarized above in
|
||||
"Configuring Open MCT" and "Using Open MCT" above.
|
||||
|
||||
### Distributing Plugins
|
||||
|
||||
Hosting or downloading plugins is outside of the scope of this documentation.
|
||||
We recommend distributing plugins as UMD modules which export a single
|
||||
function.
|
||||
|
||||
|
||||
@@ -2261,10 +2261,7 @@ The platform understands the following policy categories (specifiable as the
|
||||
|
||||
* `action`: Determines whether or not a given action is allowable. The candidate
|
||||
argument here is an Action; the context is its action context object.
|
||||
* `composition`: Determines whether or not domain objects of a given type are
|
||||
allowed to contain domain objects of another type. The candidate argument here
|
||||
is the container's `Type`; the context argument is the `Type` of the object to be
|
||||
contained.
|
||||
* `composition`: Determines whether or not a given domain object(first argument, `parent`) can contain a candidate child object (second argument, `child`).
|
||||
* `view`: Determines whether or not a view is applicable for a domain object.
|
||||
The candidate argument is the view's extension definition; the context argument
|
||||
is the `DomainObject` to be viewed.
|
||||
|
||||
@@ -320,7 +320,7 @@ define([
|
||||
+ {
|
||||
+ "key": "example.todo",
|
||||
+ "name": "To-Do List",
|
||||
+ "cssclass": "icon-check",
|
||||
+ "cssClass": "icon-check",
|
||||
+ "description": "A list of things that need to be done.",
|
||||
+ "features": ["creation"]
|
||||
+ }
|
||||
@@ -340,7 +340,7 @@ Going through the properties we've defined:
|
||||
domain objects of this type.
|
||||
* The `name` of "To-Do List" is the human-readable name for this type, and will
|
||||
be shown to users.
|
||||
* The `cssclass` maps to an icon that will be shown for each To-Do List. The icons
|
||||
* The `cssClass` maps to an icon that will be shown for each To-Do List. The icons
|
||||
are defined in our [custom open MCT icon set](https://github.com/nasa/openmct/blob/master/platform/commonUI/general/res/sass/_glyphs.scss).
|
||||
A complete list of available icons will be provided in the future.
|
||||
* The `description` is also human-readable, and will be used whenever a longer
|
||||
@@ -416,7 +416,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"]
|
||||
}
|
||||
@@ -425,7 +425,7 @@ define([
|
||||
+ {
|
||||
+ "key": "example.todo",
|
||||
+ "type": "example.todo",
|
||||
+ "cssclass": "icon-check",
|
||||
+ "cssClass": "icon-check",
|
||||
+ "name": "List",
|
||||
+ "templateUrl": "templates/todo.html",
|
||||
+ "editable": true
|
||||
@@ -447,7 +447,7 @@ the domain object type, but could have chosen any unique name.
|
||||
domain objects of that type. This means that we'll see this view for To-do Lists
|
||||
that we create, but not for other domain objects (such as Folders.)
|
||||
|
||||
* The `cssclass` and `name` properties describe the icon and human-readable name
|
||||
* The `cssClass` and `name` properties describe the icon and human-readable name
|
||||
for this view to display in the UI where needed (if multiple views are available
|
||||
for To-do Lists, the user will be able to choose one.)
|
||||
|
||||
@@ -473,7 +473,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"],
|
||||
+ "model": {
|
||||
@@ -488,7 +488,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"type": "example.todo",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"name": "List",
|
||||
"templateUrl": "templates/todo.html",
|
||||
"editable": true
|
||||
@@ -647,7 +647,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"],
|
||||
"model": {
|
||||
@@ -662,7 +662,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"type": "example.todo",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"name": "List",
|
||||
"templateUrl": "templates/todo.html",
|
||||
"editable": true
|
||||
@@ -741,7 +741,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"],
|
||||
"model": {
|
||||
@@ -756,7 +756,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"type": "example.todo",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"name": "List",
|
||||
"templateUrl": "templates/todo.html",
|
||||
"editable": true,
|
||||
@@ -766,7 +766,7 @@ define([
|
||||
+ "items": [
|
||||
+ {
|
||||
+ "text": "Add Task",
|
||||
+ "cssclass": "icon-plus",
|
||||
+ "cssClass": "icon-plus",
|
||||
+ "method": "addTask",
|
||||
+ "control": "button"
|
||||
+ }
|
||||
@@ -775,7 +775,7 @@ define([
|
||||
+ {
|
||||
+ "items": [
|
||||
+ {
|
||||
+ "cssclass": "icon-trash",
|
||||
+ "cssClass": "icon-trash",
|
||||
+ "method": "removeTask",
|
||||
+ "control": "button"
|
||||
+ }
|
||||
@@ -971,7 +971,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"],
|
||||
"model": {
|
||||
@@ -986,7 +986,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"type": "example.todo",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"name": "List",
|
||||
"templateUrl": "templates/todo.html",
|
||||
"editable": true,
|
||||
@@ -996,7 +996,7 @@ define([
|
||||
"items": [
|
||||
{
|
||||
"text": "Add Task",
|
||||
"cssclass": "icon-plus",
|
||||
"cssClass": "icon-plus",
|
||||
"method": "addTask",
|
||||
"control": "button"
|
||||
}
|
||||
@@ -1005,7 +1005,7 @@ define([
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"cssclass": "icon-trash",
|
||||
"cssClass": "icon-trash",
|
||||
"method": "removeTask",
|
||||
"control": "button"
|
||||
}
|
||||
@@ -1236,7 +1236,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"name": "To-Do List",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"description": "A list of things that need to be done.",
|
||||
"features": ["creation"],
|
||||
"model": {
|
||||
@@ -1248,7 +1248,7 @@ define([
|
||||
{
|
||||
"key": "example.todo",
|
||||
"type": "example.todo",
|
||||
"cssclass": "icon-check",
|
||||
"cssClass": "icon-check",
|
||||
"name": "List",
|
||||
"templateUrl": "templates/todo.html",
|
||||
"editable": true,
|
||||
@@ -1258,7 +1258,7 @@ define([
|
||||
"items": [
|
||||
{
|
||||
"text": "Add Task",
|
||||
"cssclass": "icon-plus",
|
||||
"cssClass": "icon-plus",
|
||||
"method": "addTask",
|
||||
"control": "button"
|
||||
}
|
||||
@@ -1267,7 +1267,7 @@ define([
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"cssclass": "icon-trash",
|
||||
"cssClass": "icon-trash",
|
||||
"method": "removeTask",
|
||||
"control": "button"
|
||||
}
|
||||
@@ -1374,7 +1374,7 @@ define([
|
||||
{
|
||||
"name": "Bar Graph",
|
||||
"key": "example.bargraph",
|
||||
"cssclass": "icon-autoflow-tabular",
|
||||
"cssClass": "icon-autoflow-tabular",
|
||||
"templateUrl": "templates/bargraph.html",
|
||||
"needs": [ "telemetry" ],
|
||||
"delegation": true
|
||||
@@ -1677,7 +1677,7 @@ define([
|
||||
{
|
||||
"name": "Bar Graph",
|
||||
"key": "example.bargraph",
|
||||
"cssclass": "icon-autoflow-tabular",
|
||||
"cssClass": "icon-autoflow-tabular",
|
||||
"templateUrl": "templates/bargraph.html",
|
||||
"needs": [ "telemetry" ],
|
||||
"delegation": true
|
||||
@@ -1843,7 +1843,7 @@ define([
|
||||
{
|
||||
"name": "Bar Graph",
|
||||
"key": "example.bargraph",
|
||||
"cssclass": "icon-autoflow-tabular",
|
||||
"cssClass": "icon-autoflow-tabular",
|
||||
"templateUrl": "templates/bargraph.html",
|
||||
"needs": [ "telemetry" ],
|
||||
"delegation": true,
|
||||
@@ -2320,7 +2320,7 @@ define([
|
||||
{
|
||||
"name": "Spacecraft",
|
||||
"key": "example.spacecraft",
|
||||
"cssclass": "icon-object"
|
||||
"cssClass": "icon-object"
|
||||
}
|
||||
],
|
||||
"roots": [
|
||||
@@ -2706,18 +2706,18 @@ define([
|
||||
{
|
||||
"name": "Spacecraft",
|
||||
"key": "example.spacecraft",
|
||||
"cssclass": "icon-object"
|
||||
"cssClass": "icon-object"
|
||||
},
|
||||
+ {
|
||||
+ "name": "Subsystem",
|
||||
+ "key": "example.subsystem",
|
||||
+ "cssclass": "icon-object",
|
||||
+ "cssClass": "icon-object",
|
||||
+ "model": { "composition": [] }
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "Measurement",
|
||||
+ "key": "example.measurement",
|
||||
+ "cssclass": "icon-telemetry",
|
||||
+ "cssClass": "icon-telemetry",
|
||||
+ "model": { "telemetry": {} },
|
||||
+ "telemetry": {
|
||||
+ "source": "example.source",
|
||||
@@ -3031,18 +3031,18 @@ define([
|
||||
{
|
||||
"name": "Spacecraft",
|
||||
"key": "example.spacecraft",
|
||||
"cssclass": "icon-object"
|
||||
"cssClass": "icon-object"
|
||||
},
|
||||
{
|
||||
"name": "Subsystem",
|
||||
"key": "example.subsystem",
|
||||
"cssclass": "icon-object",
|
||||
"cssClass": "icon-object",
|
||||
"model": { "composition": [] }
|
||||
},
|
||||
{
|
||||
"name": "Measurement",
|
||||
"key": "example.measurement",
|
||||
"cssclass": "icon-telemetry",
|
||||
"cssClass": "icon-telemetry",
|
||||
"model": { "telemetry": {} },
|
||||
"telemetry": {
|
||||
"source": "example.source",
|
||||
|
||||
@@ -49,7 +49,7 @@ define([
|
||||
{
|
||||
"key": "eventGenerator",
|
||||
"name": "Event Message Generator",
|
||||
"cssclass": "icon-folder-new",
|
||||
"cssClass": "icon-folder-new",
|
||||
"description": "For development use. Creates sample event message data that mimics a live data stream.",
|
||||
"priority": 10,
|
||||
"features": "creation",
|
||||
|
||||
@@ -36,7 +36,7 @@ define([
|
||||
"name": "Export Telemetry as CSV",
|
||||
"implementation": ExportTelemetryAsCSVAction,
|
||||
"category": "contextual",
|
||||
"cssclass": "icon-download",
|
||||
"cssClass": "icon-download",
|
||||
"depends": [ "exportService" ]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -41,6 +41,10 @@ define([
|
||||
return domainObject.type === 'generator';
|
||||
};
|
||||
|
||||
GeneratorProvider.prototype.supportsRequest =
|
||||
GeneratorProvider.prototype.supportsSubscribe =
|
||||
GeneratorProvider.prototype.canProvideTelemetry;
|
||||
|
||||
GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) {
|
||||
var props = [
|
||||
'amplitude',
|
||||
@@ -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*/
|
||||
/*global define*/
|
||||
|
||||
define({
|
||||
START_TIME: Date.now() - 24 * 60 * 60 * 1000 // Now minus a day.
|
||||
@@ -19,12 +19,11 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,Promise*/
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./SinewaveConstants', 'moment'],
|
||||
function (SinewaveConstants, moment) {
|
||||
"use strict";
|
||||
|
||||
var START_TIME = SinewaveConstants.START_TIME,
|
||||
FORMAT_REGEX = /^-?\d+:\d+:\d+$/,
|
||||
@@ -1,183 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*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": "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
"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",
|
||||
"cssclass": "icon-telemetry",
|
||||
"description": "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
"priority": 10,
|
||||
"features": "creation",
|
||||
"model": {
|
||||
"telemetry": {
|
||||
"period": 10,
|
||||
"amplitude": 1,
|
||||
"offset": 0,
|
||||
"dataRateInHz": 1
|
||||
}
|
||||
},
|
||||
"telemetry": {
|
||||
"source": "generator",
|
||||
"domains": [
|
||||
{
|
||||
"key": "utc",
|
||||
"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-input-sm l-numeric",
|
||||
"key": "period",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"period"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Amplitude",
|
||||
"control": "textfield",
|
||||
"cssclass": "l-input-sm l-numeric",
|
||||
"key": "amplitude",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"amplitude"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Offset",
|
||||
"control": "textfield",
|
||||
"cssclass": "l-input-sm l-numeric",
|
||||
"key": "offset",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"offset"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Data Rate (hz)",
|
||||
"control": "textfield",
|
||||
"cssclass": "l-input-sm l-numeric",
|
||||
"key": "dataRateInHz",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"dataRateInHz"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var FIFTEEN_MINUTES = 15 * 60 * 1000;
|
||||
|
||||
var handlers = {
|
||||
subscribe: onSubscribe,
|
||||
@@ -51,6 +52,7 @@
|
||||
function onSubscribe(message) {
|
||||
var data = message.data;
|
||||
|
||||
// Keep
|
||||
var start = Date.now();
|
||||
var step = 1000 / data.dataRateInHz;
|
||||
var nextStep = start - (start % step) + step;
|
||||
@@ -82,8 +84,11 @@
|
||||
|
||||
function onRequest(message) {
|
||||
var data = message.data;
|
||||
if (!data.start || !data.end) {
|
||||
throw new Error('missing start and end!');
|
||||
if (data.end == undefined) {
|
||||
data.end = Date.now();
|
||||
}
|
||||
if (data.start == undefined){
|
||||
data.start = data.end - FIFTEEN_MINUTES;
|
||||
}
|
||||
|
||||
var now = Date.now();
|
||||
171
example/generator/plugin.js
Normal file
171
example/generator/plugin.js
Normal file
@@ -0,0 +1,171 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
"./GeneratorProvider",
|
||||
"./SinewaveLimitCapability",
|
||||
"./SinewaveDeltaFormat"
|
||||
], function (
|
||||
GeneratorProvider,
|
||||
SinewaveLimitCapability,
|
||||
SinewaveDeltaFormat
|
||||
) {
|
||||
|
||||
var legacyExtensions = {
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"priority": -1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return function(openmct){
|
||||
//Register legacy extensions for things not yet supported by the new API
|
||||
Object.keys(legacyExtensions).forEach(function (type){
|
||||
var extensionsOfType = legacyExtensions[type];
|
||||
extensionsOfType.forEach(function (extension) {
|
||||
openmct.legacyExtension(type, extension)
|
||||
})
|
||||
});
|
||||
openmct.types.addType("generator", {
|
||||
label: "Sine Wave Generator",
|
||||
description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
cssClass: "icon-telemetry",
|
||||
creatable: true,
|
||||
form: [
|
||||
{
|
||||
name: "Period",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "period",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"period"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Amplitude",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "amplitude",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"amplitude"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Offset",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "offset",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"offset"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Data Rate (hz)",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "dataRateInHz",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"dataRateInHz"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
}
|
||||
],
|
||||
initialize: function (object) {
|
||||
object.telemetry = {
|
||||
period: 10,
|
||||
amplitude: 1,
|
||||
offset: 0,
|
||||
dataRateInHz: 1,
|
||||
domains: [
|
||||
{
|
||||
key: "utc",
|
||||
name: "Time",
|
||||
format: "utc"
|
||||
},
|
||||
{
|
||||
key: "yesterday",
|
||||
name: "Yesterday",
|
||||
format: "utc"
|
||||
},
|
||||
{
|
||||
key: "delta",
|
||||
name: "Delta",
|
||||
format: "example.delta"
|
||||
}
|
||||
],
|
||||
ranges: [
|
||||
{
|
||||
key: "sin",
|
||||
name: "Sine"
|
||||
},
|
||||
{
|
||||
key: "cos",
|
||||
name: "Cosine"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
openmct.telemetry.addProvider(new GeneratorProvider());
|
||||
};
|
||||
|
||||
});
|
||||
@@ -49,7 +49,7 @@ define([
|
||||
{
|
||||
"key": "imagery",
|
||||
"name": "Example Imagery",
|
||||
"cssclass": "icon-image",
|
||||
"cssClass": "icon-image",
|
||||
"features": "creation",
|
||||
"description": "For development use. Creates example imagery data that mimics a live imagery stream.",
|
||||
"priority": 10,
|
||||
|
||||
@@ -31,10 +31,25 @@ define(
|
||||
|
||||
var firstObservedTime = Date.now(),
|
||||
images = [
|
||||
"http://www.nasa.gov/393811main_Palomar_ao_bouchez_10s_after_impact_4x3_946-710.png",
|
||||
"http://www.nasa.gov/393821main_Palomar_ao_bouchez_15s_after_impact_4x3_946-710.png",
|
||||
"http://www.nasa.gov/images/content/393801main_CfhtVeillet2_4x3_516-387.jpg",
|
||||
"http://www.nasa.gov/images/content/392790main_1024_768_GeminiNorth_NightBeforeImpact_946-710.jpg"
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18731.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18732.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18733.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18734.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18735.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18736.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18737.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18738.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18739.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18740.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18741.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18742.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18743.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18744.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18745.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18746.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18747.jpg",
|
||||
"https://www.hq.nasa.gov/alsj/a16/AS16-117-18748.jpg"
|
||||
|
||||
].map(function (url, index) {
|
||||
return {
|
||||
timestamp: firstObservedTime + 1000 * index,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(['../../../platform/features/conductor/core/src/timeSystems/LocalClock'], function (LocalClock) {
|
||||
define(['../../../src/plugins/utcTimeSystem/LocalClock'], function (LocalClock) {
|
||||
/**
|
||||
* @implements TickSource
|
||||
* @constructor
|
||||
@@ -28,14 +28,12 @@ define(['../../../platform/features/conductor/core/src/timeSystems/LocalClock'],
|
||||
function LADTickSource ($timeout, period) {
|
||||
LocalClock.call(this, $timeout, period);
|
||||
|
||||
this.metadata = {
|
||||
key: 'test-lad',
|
||||
mode: 'lad',
|
||||
cssclass: 'icon-clock',
|
||||
label: 'Latest Available Data',
|
||||
name: 'Latest available data',
|
||||
description: 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
|
||||
};
|
||||
this.key = 'test-lad';
|
||||
this.mode = 'lad';
|
||||
this.cssClass = 'icon-clock';
|
||||
this.label = 'Latest Available Data';
|
||||
this.name = 'Latest available data';
|
||||
this.description = 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.';
|
||||
}
|
||||
LADTickSource.prototype = Object.create(LocalClock.prototype);
|
||||
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
'../../../platform/features/conductor/core/src/timeSystems/TimeSystem',
|
||||
'../../../platform/features/conductor/core/src/timeSystems/LocalClock',
|
||||
'../../../src/plugins/utcTimeSystem/LocalClock',
|
||||
'./LADTickSource'
|
||||
], function (TimeSystem, LocalClock, LADTickSource) {
|
||||
], function (LocalClock, LADTickSource) {
|
||||
var THIRTY_MINUTES = 30 * 60 * 1000,
|
||||
DEFAULT_PERIOD = 1000;
|
||||
|
||||
@@ -34,25 +33,20 @@ define([
|
||||
* @constructor
|
||||
*/
|
||||
function LocalTimeSystem ($timeout) {
|
||||
TimeSystem.call(this);
|
||||
|
||||
/**
|
||||
* Some metadata, which will be used to identify the time system in
|
||||
* the UI
|
||||
* @type {{key: string, name: string, glyph: string}}
|
||||
*/
|
||||
this.metadata = {
|
||||
'key': 'local',
|
||||
'name': 'Local',
|
||||
'glyph': '\u0043'
|
||||
};
|
||||
this.key = 'local';
|
||||
this.name = 'Local';
|
||||
this.cssClass = '\u0043';
|
||||
|
||||
this.fmts = ['local-format'];
|
||||
this.sources = [new LocalClock($timeout, DEFAULT_PERIOD), new LADTickSource($timeout, DEFAULT_PERIOD)];
|
||||
}
|
||||
|
||||
LocalTimeSystem.prototype = Object.create(TimeSystem.prototype);
|
||||
|
||||
LocalTimeSystem.prototype.formats = function () {
|
||||
return this.fmts;
|
||||
};
|
||||
@@ -65,6 +59,10 @@ define([
|
||||
return this.sources;
|
||||
};
|
||||
|
||||
LocalTimeSystem.prototype.isUTCBased = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
LocalTimeSystem.prototype.defaults = function (key) {
|
||||
var now = Math.ceil(Date.now() / 1000) * 1000;
|
||||
return {
|
||||
|
||||
@@ -41,18 +41,18 @@ define([
|
||||
{
|
||||
"name":"Mars Science Laboratory",
|
||||
"key": "msl.curiosity",
|
||||
"cssclass": "icon-object"
|
||||
"cssClass": "icon-object"
|
||||
},
|
||||
{
|
||||
"name": "Instrument",
|
||||
"key": "msl.instrument",
|
||||
"cssclass": "icon-object",
|
||||
"cssClass": "icon-object",
|
||||
"model": {"composition": []}
|
||||
},
|
||||
{
|
||||
"name": "Measurement",
|
||||
"key": "msl.measurement",
|
||||
"cssclass": "icon-telemetry",
|
||||
"cssClass": "icon-telemetry",
|
||||
"model": {"telemetry": {}},
|
||||
"telemetry": {
|
||||
"source": "rems.source",
|
||||
@@ -92,7 +92,7 @@ define([
|
||||
{
|
||||
"key":"rems.adapter",
|
||||
"implementation": RemsTelemetryServerAdapter,
|
||||
"depends": ["$q", "$http", "$log", "REMS_WS_URL"]
|
||||
"depends": ["$http", "$log", "REMS_WS_URL"]
|
||||
}
|
||||
],
|
||||
"components": [
|
||||
|
||||
@@ -42,14 +42,12 @@ define(
|
||||
* @param REMS_WS_URL The location of the REMS telemetry data.
|
||||
* @constructor
|
||||
*/
|
||||
function RemsTelemetryServerAdapter($q, $http, $log, REMS_WS_URL) {
|
||||
function RemsTelemetryServerAdapter($http, $log, REMS_WS_URL) {
|
||||
this.localDataURI = module.uri.substring(0, module.uri.lastIndexOf('/') + 1) + LOCAL_DATA;
|
||||
this.deferreds = {};
|
||||
this.REMS_WS_URL = REMS_WS_URL;
|
||||
this.$q = $q;
|
||||
this.$http = $http;
|
||||
this.$log = $log;
|
||||
this.cache = undefined;
|
||||
this.promise = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,15 +63,10 @@ define(
|
||||
*/
|
||||
RemsTelemetryServerAdapter.prototype.requestHistory = function(request) {
|
||||
var self = this,
|
||||
id = request.key,
|
||||
deferred = this.$q.defer();
|
||||
id = request.key;
|
||||
|
||||
function processResponse(response){
|
||||
var data = [];
|
||||
/*
|
||||
* Currently all data is returned for entire history of the mission. Cache response to avoid unnecessary re-queries.
|
||||
*/
|
||||
self.cache = response;
|
||||
/*
|
||||
* History data is organised by Sol. Iterate over sols...
|
||||
*/
|
||||
@@ -110,17 +103,15 @@ define(
|
||||
}
|
||||
|
||||
function packageAndResolve(results){
|
||||
deferred.resolve({id: id, values: results});
|
||||
return {id: id, values: results};
|
||||
}
|
||||
|
||||
|
||||
this.$q.when(this.cache || this.$http.get(this.REMS_WS_URL))
|
||||
return (this.promise = this.promise || this.$http.get(this.REMS_WS_URL))
|
||||
.catch(fallbackToLocal)
|
||||
.then(processResponse)
|
||||
.then(filterResults)
|
||||
.then(packageAndResolve);
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -132,7 +123,6 @@ define(
|
||||
* @returns {Promise | Array<RemsTelemetryValue>} that resolves with an Array of {@link RemsTelemetryValue} objects for the request data key.
|
||||
*/
|
||||
RemsTelemetryServerAdapter.prototype.history = function(request) {
|
||||
var id = request.key;
|
||||
return this.requestHistory(request);
|
||||
};
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ define([
|
||||
{
|
||||
"key": "plot",
|
||||
"name": "Example Telemetry Plot",
|
||||
"cssclass": "icon-telemetry-panel",
|
||||
"cssClass": "icon-telemetry-panel",
|
||||
"description": "For development use. A plot for displaying telemetry.",
|
||||
"priority": 10,
|
||||
"delegates": [
|
||||
@@ -129,7 +129,7 @@ define([
|
||||
{
|
||||
"name": "Period",
|
||||
"control": "textfield",
|
||||
"cssclass": "l-input-sm l-numeric",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "period",
|
||||
"required": true,
|
||||
"property": [
|
||||
|
||||
@@ -63,7 +63,7 @@ define(
|
||||
* Get the CSS class that defines the icon
|
||||
* to display in this indicator. This will appear
|
||||
* as a dataflow icon.
|
||||
* @returns {string} the cssclass of the dataflow icon
|
||||
* @returns {string} the cssClass of the dataflow icon
|
||||
*/
|
||||
getCssClass: function () {
|
||||
return "icon-connectivity";
|
||||
|
||||
@@ -69,6 +69,11 @@ var gulp = require('gulp'),
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
options.requirejsOptimize.optimize = 'none';
|
||||
}
|
||||
|
||||
|
||||
gulp.task('scripts', function () {
|
||||
var requirejsOptimize = require('gulp-requirejs-optimize');
|
||||
var replace = require('gulp-replace-task');
|
||||
|
||||
11
index.html
11
index.html
@@ -31,14 +31,15 @@
|
||||
require(['openmct'], function (openmct) {
|
||||
[
|
||||
'example/imagery',
|
||||
'example/eventGenerator',
|
||||
'example/generator'
|
||||
'example/eventGenerator'
|
||||
].forEach(
|
||||
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
||||
);
|
||||
openmct.install(openmct.plugins.myItems);
|
||||
openmct.install(openmct.plugins.localStorage);
|
||||
openmct.install(openmct.plugins.espresso);
|
||||
openmct.install(openmct.plugins.MyItems());
|
||||
openmct.install(openmct.plugins.LocalStorage());
|
||||
openmct.install(openmct.plugins.Espresso());
|
||||
openmct.install(openmct.plugins.Generator());
|
||||
openmct.install(openmct.plugins.UTCTimeSystem());
|
||||
openmct.start();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -53,7 +53,7 @@ module.exports = function(config) {
|
||||
// Preprocess matching files before serving them to the browser.
|
||||
// https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'src/**/src/**/!(*Spec).js': [ 'coverage' ],
|
||||
'src/**/!(*Spec).js': [ 'coverage' ],
|
||||
'platform/**/src/**/!(*Spec).js': [ 'coverage' ]
|
||||
},
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ define([
|
||||
"$window"
|
||||
],
|
||||
"group": "windowing",
|
||||
"cssclass": "icon-new-window",
|
||||
"cssClass": "icon-new-window",
|
||||
"priority": "preferred"
|
||||
},
|
||||
{
|
||||
@@ -241,7 +241,7 @@ define([
|
||||
{
|
||||
"key": "items",
|
||||
"name": "Items",
|
||||
"cssclass": "icon-thumbs-strip",
|
||||
"cssClass": "icon-thumbs-strip",
|
||||
"description": "Grid of available items",
|
||||
"template": itemsTemplate,
|
||||
"uses": [
|
||||
|
||||
@@ -43,24 +43,24 @@ define([], function () {
|
||||
return context.getParent();
|
||||
}
|
||||
|
||||
function isOrphan(domainObject) {
|
||||
var parent = getParent(domainObject),
|
||||
composition = parent.getModel().composition,
|
||||
id = domainObject.getId();
|
||||
return !composition || (composition.indexOf(id) === -1);
|
||||
}
|
||||
|
||||
function navigateToParent(domainObject) {
|
||||
function preventOrphanNavigation(domainObject) {
|
||||
var parent = getParent(domainObject);
|
||||
return parent.getCapability('action').perform('navigate');
|
||||
parent.useCapability('composition')
|
||||
.then(function (composees) {
|
||||
var isOrphan = composees.every(function (c) {
|
||||
return c.getId() !== domainObject.getId();
|
||||
});
|
||||
if (isOrphan) {
|
||||
parent.getCapability('action').perform('navigate');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkNavigation() {
|
||||
var navigatedObject = navigationService.getNavigation();
|
||||
if (navigatedObject.hasCapability('context') &&
|
||||
isOrphan(navigatedObject)) {
|
||||
if (navigatedObject.hasCapability('context')) {
|
||||
if (!navigatedObject.getCapability('editor').isEditContextRoot()) {
|
||||
navigateToParent(navigatedObject);
|
||||
preventOrphanNavigation(navigatedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ define(
|
||||
};
|
||||
|
||||
FullscreenAction.prototype.getMetadata = function () {
|
||||
// We override getMetadata, because the icon cssclass and
|
||||
// We override getMetadata, because the icon cssClass and
|
||||
// description need to be determined at run-time
|
||||
// based on whether or not we are currently
|
||||
// full screen.
|
||||
var metadata = Object.create(FullscreenAction);
|
||||
metadata.cssclass = screenfull.isFullscreen ? "icon-fullscreen-expand" : "icon-fullscreen-collapse";
|
||||
metadata.cssClass = screenfull.isFullscreen ? "icon-fullscreen-expand" : "icon-fullscreen-collapse";
|
||||
metadata.description = screenfull.isFullscreen ?
|
||||
EXIT_FULLSCREEN : ENTER_FULLSCREEN;
|
||||
metadata.group = "windowing";
|
||||
|
||||
@@ -33,7 +33,7 @@ define([
|
||||
mockContext,
|
||||
mockActionCapability,
|
||||
mockEditor,
|
||||
testParentModel,
|
||||
testParentComposition,
|
||||
testId,
|
||||
mockThrottledFns;
|
||||
|
||||
@@ -41,7 +41,6 @@ define([
|
||||
testId = 'some-identifier';
|
||||
|
||||
mockThrottledFns = [];
|
||||
testParentModel = {};
|
||||
|
||||
mockTopic = jasmine.createSpy('topic');
|
||||
mockThrottle = jasmine.createSpy('throttle');
|
||||
@@ -55,14 +54,12 @@ define([
|
||||
mockDomainObject = jasmine.createSpyObj('domainObject', [
|
||||
'getId',
|
||||
'getCapability',
|
||||
'getModel',
|
||||
'hasCapability'
|
||||
]);
|
||||
mockParentObject = jasmine.createSpyObj('domainObject', [
|
||||
'getId',
|
||||
'getCapability',
|
||||
'getModel',
|
||||
'hasCapability'
|
||||
'useCapability'
|
||||
]);
|
||||
mockContext = jasmine.createSpyObj('context', ['getParent']);
|
||||
mockActionCapability = jasmine.createSpyObj('action', ['perform']);
|
||||
@@ -75,9 +72,7 @@ define([
|
||||
mockThrottledFns.push(mockThrottledFn);
|
||||
return mockThrottledFn;
|
||||
});
|
||||
mockTopic.andCallFake(function (k) {
|
||||
return k === 'mutation' && mockMutationTopic;
|
||||
});
|
||||
mockTopic.andReturn(mockMutationTopic);
|
||||
mockDomainObject.getId.andReturn(testId);
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
@@ -88,12 +83,13 @@ define([
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
return !!mockDomainObject.getCapability(c);
|
||||
});
|
||||
mockParentObject.getModel.andReturn(testParentModel);
|
||||
mockParentObject.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability
|
||||
}[c];
|
||||
});
|
||||
testParentComposition = [];
|
||||
mockParentObject.useCapability.andReturn(Promise.resolve(testParentComposition));
|
||||
mockContext.getParent.andReturn(mockParentObject);
|
||||
mockNavigationService.getNavigation.andReturn(mockDomainObject);
|
||||
mockEditor.isEditContextRoot.andReturn(false);
|
||||
@@ -126,7 +122,9 @@ define([
|
||||
var prefix = isOrphan ? "" : "non-";
|
||||
describe("for " + prefix + "orphan objects", function () {
|
||||
beforeEach(function () {
|
||||
testParentModel.composition = isOrphan ? [] : [testId];
|
||||
if (!isOrphan) {
|
||||
testParentComposition.push(mockDomainObject);
|
||||
}
|
||||
});
|
||||
|
||||
[false, true].forEach(function (isEditRoot) {
|
||||
@@ -136,13 +134,31 @@ define([
|
||||
function itNavigatesAsExpected() {
|
||||
if (isOrphan && !isEditRoot) {
|
||||
it("navigates to the parent", function () {
|
||||
expect(mockActionCapability.perform)
|
||||
.toHaveBeenCalledWith('navigate');
|
||||
var done = false;
|
||||
waitsFor(function () {
|
||||
return done;
|
||||
});
|
||||
setTimeout(function () {
|
||||
done = true;
|
||||
}, 5);
|
||||
runs(function () {
|
||||
expect(mockActionCapability.perform)
|
||||
.toHaveBeenCalledWith('navigate');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
it("does nothing", function () {
|
||||
expect(mockActionCapability.perform)
|
||||
.not.toHaveBeenCalled();
|
||||
var done = false;
|
||||
waitsFor(function () {
|
||||
return done;
|
||||
});
|
||||
setTimeout(function () {
|
||||
done = true;
|
||||
}, 5);
|
||||
runs(function () {
|
||||
expect(mockActionCapability.perform)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -157,7 +173,6 @@ define([
|
||||
mockNavigationService.addListener.mostRecentCall
|
||||
.args[0](mockDomainObject);
|
||||
});
|
||||
|
||||
itNavigatesAsExpected();
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ define(
|
||||
});
|
||||
|
||||
it("provides displayable metadata", function () {
|
||||
expect(action.getMetadata().cssclass).toBeDefined();
|
||||
expect(action.getMetadata().cssClass).toBeDefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ define([
|
||||
"./src/actions/SaveAsAction",
|
||||
"./src/actions/CancelAction",
|
||||
"./src/policies/EditActionPolicy",
|
||||
"./src/policies/EditPersistableObjectsPolicy",
|
||||
"./src/policies/EditableLinkPolicy",
|
||||
"./src/policies/EditableMovePolicy",
|
||||
"./src/policies/EditContextualActionPolicy",
|
||||
@@ -72,6 +73,7 @@ define([
|
||||
SaveAsAction,
|
||||
CancelAction,
|
||||
EditActionPolicy,
|
||||
EditPersistableObjectsPolicy,
|
||||
EditableLinkPolicy,
|
||||
EditableMovePolicy,
|
||||
EditContextualActionPolicy,
|
||||
@@ -163,7 +165,7 @@ define([
|
||||
],
|
||||
"description": "Edit",
|
||||
"category": "view-control",
|
||||
"cssclass": "major icon-pencil"
|
||||
"cssClass": "major icon-pencil"
|
||||
},
|
||||
{
|
||||
"key": "properties",
|
||||
@@ -172,7 +174,7 @@ define([
|
||||
"view-control"
|
||||
],
|
||||
"implementation": PropertiesAction,
|
||||
"cssclass": "major icon-pencil",
|
||||
"cssClass": "major icon-pencil",
|
||||
"name": "Edit Properties...",
|
||||
"description": "Edit properties of this object.",
|
||||
"depends": [
|
||||
@@ -183,7 +185,7 @@ define([
|
||||
"key": "remove",
|
||||
"category": "contextual",
|
||||
"implementation": RemoveAction,
|
||||
"cssclass": "icon-trash",
|
||||
"cssClass": "icon-trash",
|
||||
"name": "Remove",
|
||||
"description": "Remove this object from its containing object.",
|
||||
"depends": [
|
||||
@@ -195,7 +197,7 @@ define([
|
||||
"category": "save",
|
||||
"implementation": SaveAndStopEditingAction,
|
||||
"name": "Save and Finish Editing",
|
||||
"cssclass": "icon-save labeled",
|
||||
"cssClass": "icon-save labeled",
|
||||
"description": "Save changes made to these objects.",
|
||||
"depends": [
|
||||
"dialogService",
|
||||
@@ -207,7 +209,7 @@ define([
|
||||
"category": "save",
|
||||
"implementation": SaveAction,
|
||||
"name": "Save and Continue Editing",
|
||||
"cssclass": "icon-save labeled",
|
||||
"cssClass": "icon-save labeled",
|
||||
"description": "Save changes made to these objects.",
|
||||
"depends": [
|
||||
"dialogService",
|
||||
@@ -219,7 +221,7 @@ define([
|
||||
"category": "save",
|
||||
"implementation": SaveAsAction,
|
||||
"name": "Save As...",
|
||||
"cssclass": "icon-save labeled",
|
||||
"cssClass": "icon-save labeled",
|
||||
"description": "Save changes made to these objects.",
|
||||
"depends": [
|
||||
"$injector",
|
||||
@@ -237,7 +239,7 @@ define([
|
||||
// Because we use the name as label for edit buttons and mct-control buttons need
|
||||
// the label to be set to undefined in order to not apply the labeled CSS rule.
|
||||
"name": undefined,
|
||||
"cssclass": "icon-x no-label",
|
||||
"cssClass": "icon-x no-label",
|
||||
"description": "Discard changes made to these objects.",
|
||||
"depends": []
|
||||
}
|
||||
@@ -247,6 +249,11 @@ define([
|
||||
"category": "action",
|
||||
"implementation": EditActionPolicy
|
||||
},
|
||||
{
|
||||
"category": "action",
|
||||
"implementation": EditPersistableObjectsPolicy,
|
||||
"depends": ["openmct"]
|
||||
},
|
||||
{
|
||||
"category": "action",
|
||||
"implementation": EditContextualActionPolicy,
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
<li ng-repeat="createAction in createActions" ng-click="createAction.perform()">
|
||||
<a ng-mouseover="representation.activeMetadata = createAction.getMetadata()"
|
||||
ng-mouseleave="representation.activeMetadata = undefined"
|
||||
class="menu-item-a {{ createAction.getMetadata().cssclass }}">
|
||||
class="menu-item-a {{ createAction.getMetadata().cssClass }}">
|
||||
{{createAction.getMetadata().name}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="pane right menu-item-description">
|
||||
<div class="desc-area icon {{ representation.activeMetadata.cssclass }}"></div>
|
||||
<div class="desc-area icon {{ representation.activeMetadata.cssClass }}"></div>
|
||||
<div class="desc-area title">
|
||||
{{representation.activeMetadata.name}}
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
structure="{
|
||||
text: saveActions[0].getMetadata().name,
|
||||
click: actionPerformer(saveActions[0]),
|
||||
cssclass: 'major ' + saveActions[0].getMetadata().cssclass
|
||||
cssClass: 'major ' + saveActions[0].getMetadata().cssClass
|
||||
}">
|
||||
</mct-control>
|
||||
</span>
|
||||
@@ -36,7 +36,7 @@
|
||||
structure="{
|
||||
options: saveActionsAsMenuOptions,
|
||||
click: saveActionMenuClickHandler,
|
||||
cssclass: 'btn-bar right icon-save no-label major'
|
||||
cssClass: 'btn-bar right icon-save no-label major'
|
||||
}">
|
||||
</mct-control>
|
||||
</span>
|
||||
@@ -46,7 +46,7 @@
|
||||
structure="{
|
||||
text: currentAction.getMetadata().name,
|
||||
click: actionPerformer(currentAction),
|
||||
cssclass: currentAction.getMetadata().cssclass
|
||||
cssClass: currentAction.getMetadata().cssClass
|
||||
}">
|
||||
</mct-control>
|
||||
</span>
|
||||
|
||||
@@ -48,9 +48,10 @@ define(
|
||||
* Decorate PersistenceCapability to queue persistence calls when a
|
||||
* transaction is in progress.
|
||||
*/
|
||||
TransactionCapabilityDecorator.prototype.getCapabilities = function (model) {
|
||||
TransactionCapabilityDecorator.prototype.getCapabilities = function () {
|
||||
var self = this,
|
||||
capabilities = this.capabilityService.getCapabilities(model),
|
||||
capabilities = this.capabilityService.getCapabilities
|
||||
.apply(this.capabilityService, arguments),
|
||||
persistenceCapability = capabilities.persistence;
|
||||
|
||||
capabilities.persistence = function (domainObject) {
|
||||
|
||||
@@ -41,7 +41,7 @@ define(
|
||||
return {
|
||||
key: action,
|
||||
name: action.getMetadata().name,
|
||||
cssclass: action.getMetadata().cssclass
|
||||
cssClass: action.getMetadata().cssClass
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ define(
|
||||
function AddAction(type, parent, context, $q, dialogService, policyService) {
|
||||
this.metadata = {
|
||||
key: 'add',
|
||||
cssclass: type.getCssClass(),
|
||||
cssClass: type.getCssClass(),
|
||||
name: type.getName(),
|
||||
type: type.getKey(),
|
||||
description: type.getDescription(),
|
||||
|
||||
@@ -54,8 +54,7 @@ define(
|
||||
AddActionProvider.prototype.getActions = function (actionContext) {
|
||||
var context = actionContext || {},
|
||||
key = context.key,
|
||||
destination = context.domainObject,
|
||||
self = this;
|
||||
destination = context.domainObject;
|
||||
|
||||
// We only provide Add actions, and we need a
|
||||
// domain object to serve as the container for the
|
||||
@@ -66,18 +65,16 @@ define(
|
||||
}
|
||||
|
||||
// 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 ['timeline', 'activity'].map(function (type) {
|
||||
return new AddAction(
|
||||
type,
|
||||
this.typeService.getType(type),
|
||||
destination,
|
||||
context,
|
||||
self.$q,
|
||||
self.dialogService,
|
||||
self.policyService
|
||||
this.$q,
|
||||
this.dialogService,
|
||||
this.policyService
|
||||
);
|
||||
});
|
||||
}, this);
|
||||
};
|
||||
|
||||
return AddActionProvider;
|
||||
|
||||
@@ -47,7 +47,7 @@ define(
|
||||
function CreateAction(type, parent, context) {
|
||||
this.metadata = {
|
||||
key: 'create',
|
||||
cssclass: type.getCssClass(),
|
||||
cssClass: type.getCssClass(),
|
||||
name: type.getName(),
|
||||
type: type.getKey(),
|
||||
description: type.getDescription(),
|
||||
|
||||
@@ -56,16 +56,14 @@ define(
|
||||
*/
|
||||
CreateWizard.prototype.getFormStructure = function (includeLocation) {
|
||||
var sections = [],
|
||||
type = this.type,
|
||||
domainObject = this.domainObject,
|
||||
policyService = this.policyService;
|
||||
|
||||
function validateLocation(locatingObject) {
|
||||
var locatingType = locatingObject &&
|
||||
locatingObject.getCapability('type');
|
||||
return locatingType && policyService.allow(
|
||||
function validateLocation(parent) {
|
||||
return parent && policyService.allow(
|
||||
"composition",
|
||||
locatingType,
|
||||
type
|
||||
parent,
|
||||
domainObject
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ define(
|
||||
if (includeLocation) {
|
||||
sections.push({
|
||||
name: 'Location',
|
||||
cssclass: "grows",
|
||||
cssClass: "grows",
|
||||
rows: [{
|
||||
name: "Save In",
|
||||
control: "locator",
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
['../../../../../src/api/objects/object-utils'],
|
||||
function (objectUtils) {
|
||||
|
||||
/**
|
||||
* Policy that prevents editing of any object from a provider that does not
|
||||
* support persistence (ie. the 'save' operation). Editing is prevented
|
||||
* as a subsequent save would fail, causing the loss of a user's changes.
|
||||
* @param openmct
|
||||
* @constructor
|
||||
*/
|
||||
function EditPersistableObjectsPolicy(openmct) {
|
||||
this.openmct = openmct;
|
||||
}
|
||||
|
||||
EditPersistableObjectsPolicy.prototype.allow = function (action, context) {
|
||||
var identifier;
|
||||
var provider;
|
||||
var domainObject = context.domainObject;
|
||||
var key = action.getMetadata().key;
|
||||
var category = (context || {}).category;
|
||||
|
||||
// Use category to selectively block edit from the view. Edit action
|
||||
// is also invoked during the create process which should be allowed,
|
||||
// because it may be saved elsewhere
|
||||
if ((key === 'edit' && category === 'view-control') || key === 'properties') {
|
||||
identifier = objectUtils.parseKeyString(domainObject.getId());
|
||||
provider = this.openmct.objects.getProvider(identifier);
|
||||
return provider.save !== undefined;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return EditPersistableObjectsPolicy;
|
||||
}
|
||||
);
|
||||
@@ -28,7 +28,7 @@ define(
|
||||
describe("The Edit Action controller", function () {
|
||||
var mockSaveActionMetadata = {
|
||||
name: "mocked-save-action",
|
||||
cssclass: "mocked-save-action-css"
|
||||
cssClass: "mocked-save-action-css"
|
||||
};
|
||||
|
||||
function fakeGetActions(actionContext) {
|
||||
@@ -86,7 +86,7 @@ define(
|
||||
expect(menuOptions[1].key).toEqual(mockScope.saveActions[1]);
|
||||
menuOptions.forEach(function (option) {
|
||||
expect(option.name).toEqual(mockSaveActionMetadata.name);
|
||||
expect(option.cssclass).toEqual(mockSaveActionMetadata.cssclass);
|
||||
expect(option.cssClass).toEqual(mockSaveActionMetadata.cssClass);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@ define(
|
||||
var mockTypeService,
|
||||
mockDialogService,
|
||||
mockPolicyService,
|
||||
mockCreationPolicy,
|
||||
mockCompositionPolicy,
|
||||
mockPolicyMap = {},
|
||||
mockTypeMap,
|
||||
mockTypes,
|
||||
mockDomainObject,
|
||||
mockQ,
|
||||
@@ -55,49 +53,33 @@ define(
|
||||
);
|
||||
mockType.hasFeature.andReturn(true);
|
||||
mockType.getName.andReturn(name);
|
||||
mockType.getKey.andReturn(name);
|
||||
return mockType;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockTypeService = jasmine.createSpyObj(
|
||||
"typeService",
|
||||
["listTypes"]
|
||||
);
|
||||
mockDialogService = jasmine.createSpyObj(
|
||||
"dialogService",
|
||||
["getUserInput"]
|
||||
);
|
||||
mockPolicyService = jasmine.createSpyObj(
|
||||
"policyService",
|
||||
["allow"]
|
||||
["getType"]
|
||||
);
|
||||
mockDialogService = {};
|
||||
mockPolicyService = {};
|
||||
mockDomainObject = {};
|
||||
|
||||
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 = [
|
||||
"timeline",
|
||||
"activity",
|
||||
"other"
|
||||
].map(createMockType);
|
||||
mockTypeMap = {};
|
||||
|
||||
mockTypes.forEach(function (type) {
|
||||
mockPolicyMap[type.getName()] = true;
|
||||
mockTypeMap[type.getKey()] = type;
|
||||
});
|
||||
|
||||
mockCreationPolicy = function (type) {
|
||||
return mockPolicyMap[type.getName()];
|
||||
};
|
||||
|
||||
mockCompositionPolicy = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
mockPolicyService.allow.andReturn(true);
|
||||
|
||||
mockTypeService.listTypes.andReturn(mockTypes);
|
||||
mockTypeService.getType.andCallFake(function (key) {
|
||||
return mockTypeMap[key];
|
||||
});
|
||||
|
||||
provider = new AddActionProvider(
|
||||
mockQ,
|
||||
@@ -107,29 +89,16 @@ define(
|
||||
);
|
||||
});
|
||||
|
||||
it("checks for creatability", function () {
|
||||
provider.getActions({
|
||||
it("provides actions for timeline and activity", function () {
|
||||
var actions = provider.getActions({
|
||||
key: "add",
|
||||
domainObject: mockDomainObject
|
||||
});
|
||||
expect(actions.length).toBe(2);
|
||||
expect(actions[0].metadata.type).toBe('timeline');
|
||||
expect(actions[1].metadata.type).toBe('activity');
|
||||
|
||||
// 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');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ define(
|
||||
|
||||
expect(metadata.name).toEqual("Test");
|
||||
expect(metadata.description).toEqual("a test type");
|
||||
expect(metadata.cssclass).toEqual("icon-telemetry");
|
||||
expect(metadata.cssClass).toEqual("icon-telemetry");
|
||||
});
|
||||
|
||||
describe("the perform function", function () {
|
||||
|
||||
@@ -161,6 +161,7 @@ define(
|
||||
'otherType',
|
||||
['getKey']
|
||||
),
|
||||
|
||||
//Create a form structure with location
|
||||
structure = wizard.getFormStructure(true),
|
||||
sections = structure.sections,
|
||||
@@ -174,8 +175,8 @@ define(
|
||||
// can actually contain objects of this type
|
||||
expect(mockPolicyService.allow).toHaveBeenCalledWith(
|
||||
'composition',
|
||||
mockOtherType,
|
||||
mockType
|
||||
mockDomainObj,
|
||||
mockDomainObject
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../../src/policies/EditPersistableObjectsPolicy"],
|
||||
function (EditPersistableObjectsPolicy) {
|
||||
|
||||
describe("The Edit persistable objects policy", function () {
|
||||
var mockDomainObject,
|
||||
mockEditAction,
|
||||
mockPropertiesAction,
|
||||
mockOtherAction,
|
||||
mockAPI,
|
||||
mockObjectAPI,
|
||||
testContext,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
'domainObject',
|
||||
[
|
||||
'getId'
|
||||
]
|
||||
);
|
||||
|
||||
mockObjectAPI = jasmine.createSpyObj('objectAPI', [
|
||||
'getProvider'
|
||||
]);
|
||||
|
||||
mockAPI = {
|
||||
objects: mockObjectAPI
|
||||
};
|
||||
|
||||
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
|
||||
mockPropertiesAction = jasmine.createSpyObj('properties', ['getMetadata']);
|
||||
mockOtherAction = jasmine.createSpyObj('other', ['getMetadata']);
|
||||
|
||||
mockEditAction.getMetadata.andReturn({ key: 'edit' });
|
||||
mockPropertiesAction.getMetadata.andReturn({ key: 'properties' });
|
||||
mockOtherAction.getMetadata.andReturn({key: 'other'});
|
||||
|
||||
mockDomainObject.getId.andReturn('test:testId');
|
||||
|
||||
testContext = {
|
||||
domainObject: mockDomainObject,
|
||||
category: 'view-control'
|
||||
};
|
||||
|
||||
policy = new EditPersistableObjectsPolicy(mockAPI);
|
||||
});
|
||||
|
||||
it("Applies to edit action", function () {
|
||||
mockObjectAPI.getProvider.andReturn({});
|
||||
expect(mockObjectAPI.getProvider).not.toHaveBeenCalled();
|
||||
|
||||
policy.allow(mockEditAction, testContext);
|
||||
expect(mockObjectAPI.getProvider).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("Applies to properties action", function () {
|
||||
mockObjectAPI.getProvider.andReturn({});
|
||||
expect(mockObjectAPI.getProvider).not.toHaveBeenCalled();
|
||||
|
||||
policy.allow(mockPropertiesAction, testContext);
|
||||
expect(mockObjectAPI.getProvider).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not apply to other actions", function () {
|
||||
mockObjectAPI.getProvider.andReturn({});
|
||||
expect(mockObjectAPI.getProvider).not.toHaveBeenCalled();
|
||||
|
||||
policy.allow(mockOtherAction, testContext);
|
||||
expect(mockObjectAPI.getProvider).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("Tests object provider for editability", function () {
|
||||
mockObjectAPI.getProvider.andReturn({});
|
||||
expect(policy.allow(mockEditAction, testContext)).toBe(false);
|
||||
expect(mockObjectAPI.getProvider).toHaveBeenCalled();
|
||||
mockObjectAPI.getProvider.andReturn({save: function () {}});
|
||||
expect(policy.allow(mockEditAction, testContext)).toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -76,17 +76,18 @@
|
||||
&:not(.first) {
|
||||
border-top: 1px solid $colorFormLines;
|
||||
}
|
||||
.form-row {
|
||||
@include align-items(center);
|
||||
border: none;
|
||||
padding: $interiorMarginSm 0;
|
||||
.label {
|
||||
min-width: 80px;
|
||||
}
|
||||
input[type='text'],
|
||||
input[type='search'] {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.form-row {
|
||||
@include align-items(center);
|
||||
border: none !important;
|
||||
margin-bottom: 0 !important;
|
||||
padding: $interiorMarginSm 0;
|
||||
.label {
|
||||
min-width: 80px;
|
||||
}
|
||||
input[type='text'],
|
||||
input[type='search'] {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
$output-bourbon-deprecation-warnings: false;
|
||||
@import "bourbon";
|
||||
@import "logo-and-bg";
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<a class="s-button key-{{parameters.action.getMetadata().key}} {{parameters.action.getMetadata().cssclass}}"
|
||||
<a class="s-button key-{{parameters.action.getMetadata().key}} {{parameters.action.getMetadata().cssClass}}"
|
||||
ng-class="{ labeled: parameters.labeled }"
|
||||
title="{{parameters.action.getMetadata().description}}"
|
||||
ng-click="parameters.action.perform()">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<span ng-controller="ViewSwitcherController">
|
||||
<div class="view-switcher menu-element s-menu-button {{ngModel.selected.cssclass}}"
|
||||
<div class="view-switcher menu-element s-menu-button {{ngModel.selected.cssClass}}"
|
||||
ng-if="view.length > 1"
|
||||
ng-controller="ClickAwayController as toggle">
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<ul>
|
||||
<li ng-repeat="option in view"
|
||||
ng-click="ngModel.selected = option; toggle.setState(false)"
|
||||
class="{{option.cssclass}}">
|
||||
class="{{option.cssClass}}">
|
||||
{{option.name}}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<li ng-repeat="menuAction in menuActions"
|
||||
ng-click="menuAction.perform()"
|
||||
title="{{menuAction.getMetadata().description}}"
|
||||
class="{{menuAction.getMetadata().cssclass}}">
|
||||
class="{{menuAction.getMetadata().cssClass}}">
|
||||
{{menuAction.getMetadata().name}}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
$output-bourbon-deprecation-warnings: false;
|
||||
@import "bourbon";
|
||||
|
||||
@import "../../../../general/res/sass/_mixins";
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
$output-bourbon-deprecation-warnings: false;
|
||||
@import "bourbon";
|
||||
|
||||
@import "../../../../general/res/sass/_mixins";
|
||||
|
||||
@@ -25,12 +25,14 @@ define([
|
||||
"./src/CompositionMutabilityPolicy",
|
||||
"./src/CompositionModelPolicy",
|
||||
"./src/ComposeActionPolicy",
|
||||
"./src/PersistableCompositionPolicy",
|
||||
'legacyRegistry'
|
||||
], function (
|
||||
CompositionPolicy,
|
||||
CompositionMutabilityPolicy,
|
||||
CompositionModelPolicy,
|
||||
ComposeActionPolicy,
|
||||
PersistableCompositionPolicy,
|
||||
legacyRegistry
|
||||
) {
|
||||
|
||||
@@ -40,9 +42,6 @@ define([
|
||||
{
|
||||
"category": "composition",
|
||||
"implementation": CompositionPolicy,
|
||||
"depends": [
|
||||
"$injector"
|
||||
],
|
||||
"message": "Objects of this type cannot contain objects of that type."
|
||||
},
|
||||
{
|
||||
@@ -62,6 +61,12 @@ define([
|
||||
"$injector"
|
||||
],
|
||||
"message": "Objects of this type cannot contain objects of that type."
|
||||
},
|
||||
{
|
||||
"category": "composition",
|
||||
"implementation": PersistableCompositionPolicy,
|
||||
"depends": ["openmct"],
|
||||
"message": "Change cannot be made to composition of non-persistable object"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
|
||||
/**
|
||||
* Build a table indicating which types are expected to expose
|
||||
* which capabilities. This supports composition policy (rules
|
||||
* for which objects can contain which other objects) which
|
||||
* sometimes is determined based on the presence of capabilities.
|
||||
* @constructor
|
||||
* @memberof platform/containment
|
||||
*/
|
||||
function CapabilityTable(typeService, capabilityService) {
|
||||
var self = this;
|
||||
|
||||
// Build an initial model for a type
|
||||
function buildModel(type) {
|
||||
var model = Object.create(type.getInitialModel() || {});
|
||||
model.type = type.getKey();
|
||||
return model;
|
||||
}
|
||||
|
||||
// Get capabilities expected for this type
|
||||
function getCapabilities(type) {
|
||||
return capabilityService.getCapabilities(buildModel(type));
|
||||
}
|
||||
|
||||
// Populate the lookup table for this type's capabilities
|
||||
function addToTable(type) {
|
||||
var typeKey = type.getKey();
|
||||
Object.keys(getCapabilities(type)).forEach(function (key) {
|
||||
self.table[key] = self.table[key] || {};
|
||||
self.table[key][typeKey] = true;
|
||||
});
|
||||
}
|
||||
|
||||
// Build the table
|
||||
this.table = {};
|
||||
(typeService.listTypes() || []).forEach(addToTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a type is expected to expose a specific capability.
|
||||
* @param {string} typeKey the type identifier
|
||||
* @param {string} capabilityKey the capability identifier
|
||||
* @returns {boolean} true if expected to be exposed
|
||||
*/
|
||||
CapabilityTable.prototype.hasCapability = function (typeKey, capabilityKey) {
|
||||
return (this.table[capabilityKey] || {})[typeKey];
|
||||
};
|
||||
|
||||
return CapabilityTable;
|
||||
}
|
||||
);
|
||||
@@ -43,11 +43,6 @@ define(
|
||||
}
|
||||
|
||||
ComposeActionPolicy.prototype.allowComposition = function (containerObject, selectedObject) {
|
||||
// Get the object types involved in the compose action
|
||||
var containerType = containerObject &&
|
||||
containerObject.getCapability('type'),
|
||||
selectedType = selectedObject &&
|
||||
selectedObject.getCapability('type');
|
||||
|
||||
// Get a reference to the policy service if needed...
|
||||
this.policyService = this.policyService || this.getPolicyService();
|
||||
@@ -56,8 +51,8 @@ define(
|
||||
return containerObject.getId() !== selectedObject.getId() &&
|
||||
this.policyService.allow(
|
||||
'composition',
|
||||
containerType,
|
||||
selectedType
|
||||
containerObject,
|
||||
selectedObject
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ define(
|
||||
}
|
||||
|
||||
CompositionModelPolicy.prototype.allow = function (candidate) {
|
||||
var candidateType = candidate.getCapability('type');
|
||||
return Array.isArray(
|
||||
(candidate.getInitialModel() || {}).composition
|
||||
(candidateType.getInitialModel() || {}).composition
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ define(
|
||||
// Equate creatability with mutability; that is, users
|
||||
// can only modify objects of types they can create, and
|
||||
// vice versa.
|
||||
return candidate.hasFeature('creation');
|
||||
return candidate.getCapability('type').hasFeature('creation');
|
||||
};
|
||||
|
||||
return CompositionMutabilityPolicy;
|
||||
|
||||
@@ -26,30 +26,42 @@
|
||||
* @namespace platform/containment
|
||||
*/
|
||||
define(
|
||||
['./ContainmentTable'],
|
||||
function (ContainmentTable) {
|
||||
[],
|
||||
function () {
|
||||
|
||||
/**
|
||||
* Defines composition policy as driven by type metadata.
|
||||
* Determines whether a given object can contain a candidate child object.
|
||||
* @constructor
|
||||
* @memberof platform/containment
|
||||
* @implements {Policy.<Type, Type>}
|
||||
* @implements {Policy.<DomainObjectImpl, DomainObjectImpl>}
|
||||
*/
|
||||
function CompositionPolicy($injector) {
|
||||
// We're really just wrapping the containment table and rephrasing
|
||||
// it as a policy decision.
|
||||
var table;
|
||||
|
||||
this.getTable = function () {
|
||||
return (table = table || new ContainmentTable(
|
||||
$injector.get('typeService'),
|
||||
$injector.get('capabilityService')
|
||||
));
|
||||
};
|
||||
function CompositionPolicy() {
|
||||
}
|
||||
|
||||
CompositionPolicy.prototype.allow = function (candidate, context) {
|
||||
return this.getTable().canContain(candidate, context);
|
||||
CompositionPolicy.prototype.allow = function (parent, child) {
|
||||
var parentDef = parent.getCapability('type').getDefinition();
|
||||
|
||||
// A parent without containment rules can contain anything.
|
||||
if (!parentDef.contains) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If any containment rule matches context type, the candidate
|
||||
// can contain this type.
|
||||
return parentDef.contains.some(function (c) {
|
||||
// Simple containment rules are supported typeKeys.
|
||||
if (typeof c === 'string') {
|
||||
return c === child.getCapability('type').getKey();
|
||||
}
|
||||
// More complicated rules require context to have all specified
|
||||
// capabilities.
|
||||
if (!Array.isArray(c.has)) {
|
||||
c.has = [c.has];
|
||||
}
|
||||
return c.has.every(function (capability) {
|
||||
return child.hasCapability(capability);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return CompositionPolicy;
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
['./CapabilityTable'],
|
||||
function (CapabilityTable) {
|
||||
|
||||
// Symbolic value for the type table for cases when any type
|
||||
// is allowed to be contained.
|
||||
var ANY = true;
|
||||
|
||||
/**
|
||||
* Supports composition policy by maintaining a table of
|
||||
* domain object types, to determine if they can contain
|
||||
* other domain object types. This is determined at application
|
||||
* start time (plug-in support means this cannot be determined
|
||||
* prior to that, but we don't want to redo these calculations
|
||||
* every time policy is checked.)
|
||||
* @constructor
|
||||
* @memberof platform/containment
|
||||
*/
|
||||
function ContainmentTable(typeService, capabilityService) {
|
||||
var self = this,
|
||||
types = typeService.listTypes(),
|
||||
capabilityTable = new CapabilityTable(typeService, capabilityService);
|
||||
|
||||
// Add types which have all these capabilities to the set
|
||||
// of allowed types
|
||||
function addToSetByCapability(set, has) {
|
||||
has = Array.isArray(has) ? has : [has];
|
||||
types.forEach(function (type) {
|
||||
var typeKey = type.getKey();
|
||||
set[typeKey] = has.map(function (capabilityKey) {
|
||||
return capabilityTable.hasCapability(typeKey, capabilityKey);
|
||||
}).reduce(function (a, b) {
|
||||
return a && b;
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
// Add this type (or type description) to the set of allowed types
|
||||
function addToSet(set, type) {
|
||||
// Is this a simple case of an explicit type identifier?
|
||||
if (typeof type === 'string') {
|
||||
// If so, add it to the set of allowed types
|
||||
set[type] = true;
|
||||
} else {
|
||||
// Otherwise, populate that set based on capabilities
|
||||
addToSetByCapability(set, (type || {}).has || []);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the lookup table for this type
|
||||
function addToTable(type) {
|
||||
var key = type.getKey(),
|
||||
definition = type.getDefinition() || {},
|
||||
contains = definition.contains;
|
||||
|
||||
// Check for defined containment restrictions
|
||||
if (contains === undefined) {
|
||||
// If not, accept anything
|
||||
self.table[key] = ANY;
|
||||
} else {
|
||||
// Start with an empty set...
|
||||
self.table[key] = {};
|
||||
// ...cast accepted types to array if necessary...
|
||||
contains = Array.isArray(contains) ? contains : [contains];
|
||||
// ...and add all containment rules to that set
|
||||
contains.forEach(function (c) {
|
||||
addToSet(self.table[key], c);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Build the table
|
||||
this.table = {};
|
||||
types.forEach(addToTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if domain objects of one type can contain domain
|
||||
* objects of another type.
|
||||
* @param {Type} containerType type of the containing domain object
|
||||
* @param {Type} containedType type of the domain object
|
||||
* to be contained
|
||||
* @returns {boolean} true if allowable
|
||||
*/
|
||||
ContainmentTable.prototype.canContain = function (containerType, containedType) {
|
||||
var set = this.table[containerType.getKey()] || {};
|
||||
// Recognize either the symbolic value for "can contain
|
||||
// anything", or lookup the specific type from the set.
|
||||
return (set === ANY) || set[containedType.getKey()];
|
||||
};
|
||||
|
||||
return ContainmentTable;
|
||||
}
|
||||
);
|
||||
60
platform/containment/src/PersistableCompositionPolicy.js
Normal file
60
platform/containment/src/PersistableCompositionPolicy.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* This bundle implements "containment" rules, which determine which objects
|
||||
* can be contained within which other objects.
|
||||
* @namespace platform/containment
|
||||
*/
|
||||
define(
|
||||
['../../../src/api/objects/object-utils'],
|
||||
function (objectUtils) {
|
||||
|
||||
function PersistableCompositionPolicy(openmct) {
|
||||
this.openmct = openmct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only allow changes to composition if the changes can be saved. This in
|
||||
* effect prevents selection of objects from the locator that do not
|
||||
* support persistence.
|
||||
* @param parent
|
||||
* @param child
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PersistableCompositionPolicy.prototype.allow = function (parent) {
|
||||
// If object is in edit mode, allow composition because it is
|
||||
// part of object creation, and the object may be saved to another
|
||||
// namespace that does support persistence. The EditPersistableObjectsPolicy
|
||||
// prevents editing of objects that cannot be persisted, so we can assume that this
|
||||
// is a new object.
|
||||
if (!(parent.hasCapability('editor') && parent.getCapability('editor').isEditContextRoot())) {
|
||||
var identifier = objectUtils.parseKeyString(parent.getId());
|
||||
var provider = this.openmct.objects.getProvider(identifier);
|
||||
return provider.save !== undefined;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
return PersistableCompositionPolicy;
|
||||
}
|
||||
);
|
||||
@@ -1,85 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../src/CapabilityTable"],
|
||||
function (CapabilityTable) {
|
||||
describe("Composition policy's capability table", function () {
|
||||
var mockTypeService,
|
||||
mockCapabilityService,
|
||||
mockTypes,
|
||||
table;
|
||||
|
||||
beforeEach(function () {
|
||||
mockTypeService = jasmine.createSpyObj(
|
||||
'typeService',
|
||||
['listTypes']
|
||||
);
|
||||
mockCapabilityService = jasmine.createSpyObj(
|
||||
'capabilityService',
|
||||
['getCapabilities']
|
||||
);
|
||||
// Both types can only contain b, let's say
|
||||
mockTypes = ['a', 'b'].map(function (type) {
|
||||
var mockType = jasmine.createSpyObj(
|
||||
'type-' + type,
|
||||
['getKey', 'getDefinition', 'getInitialModel']
|
||||
);
|
||||
mockType.getKey.andReturn(type);
|
||||
// Return a model to drive apparent capabilities
|
||||
mockType.getInitialModel.andReturn({ id: type });
|
||||
return mockType;
|
||||
});
|
||||
|
||||
mockTypeService.listTypes.andReturn(mockTypes);
|
||||
mockCapabilityService.getCapabilities.andCallFake(function (model) {
|
||||
var capabilities = {};
|
||||
capabilities[model.id + '-capability'] = true;
|
||||
return capabilities;
|
||||
});
|
||||
|
||||
table = new CapabilityTable(
|
||||
mockTypeService,
|
||||
mockCapabilityService
|
||||
);
|
||||
});
|
||||
|
||||
it("provides for lookup of capabilities by type", function () {
|
||||
// Based on initial model, should report the presence
|
||||
// of particular capabilities - suffixed above with -capability
|
||||
expect(table.hasCapability('a', 'a-capability'))
|
||||
.toBeTruthy();
|
||||
expect(table.hasCapability('a', 'b-capability'))
|
||||
.toBeFalsy();
|
||||
expect(table.hasCapability('a', 'c-capability'))
|
||||
.toBeFalsy();
|
||||
expect(table.hasCapability('b', 'a-capability'))
|
||||
.toBeFalsy();
|
||||
expect(table.hasCapability('b', 'b-capability'))
|
||||
.toBeTruthy();
|
||||
expect(table.hasCapability('b', 'c-capability'))
|
||||
.toBeFalsy();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -78,8 +78,8 @@ define(
|
||||
|
||||
expect(mockPolicyService.allow).toHaveBeenCalledWith(
|
||||
'composition',
|
||||
mockTypes[0],
|
||||
mockTypes[1]
|
||||
mockDomainObjects[0],
|
||||
mockDomainObjects[1]
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,19 +4,25 @@ define(
|
||||
function (CompositionModelPolicy) {
|
||||
|
||||
describe("The composition model policy", function () {
|
||||
var mockType,
|
||||
var mockObject,
|
||||
mockType,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
mockType = jasmine.createSpyObj('type', ['getInitialModel']);
|
||||
mockObject = {
|
||||
getCapability: function () {
|
||||
return mockType;
|
||||
}
|
||||
};
|
||||
policy = new CompositionModelPolicy();
|
||||
});
|
||||
|
||||
it("only allows composition for types which will have a composition property", function () {
|
||||
mockType.getInitialModel.andReturn({});
|
||||
expect(policy.allow(mockType)).toBeFalsy();
|
||||
expect(policy.allow(mockObject)).toBeFalsy();
|
||||
mockType.getInitialModel.andReturn({ composition: [] });
|
||||
expect(policy.allow(mockType)).toBeTruthy();
|
||||
expect(policy.allow(mockObject)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -25,18 +25,24 @@ define(
|
||||
function (CompositionMutabilityPolicy) {
|
||||
|
||||
describe("The composition mutability policy", function () {
|
||||
var mockType,
|
||||
var mockObject,
|
||||
mockType,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
mockType = jasmine.createSpyObj('type', ['hasFeature']);
|
||||
mockObject = {
|
||||
getCapability: function () {
|
||||
return mockType;
|
||||
}
|
||||
};
|
||||
policy = new CompositionMutabilityPolicy();
|
||||
});
|
||||
|
||||
it("only allows composition for types which can be created/modified", function () {
|
||||
expect(policy.allow(mockType)).toBeFalsy();
|
||||
expect(policy.allow(mockObject)).toBeFalsy();
|
||||
mockType.hasFeature.andReturn(true);
|
||||
expect(policy.allow(mockType)).toBeTruthy();
|
||||
expect(policy.allow(mockObject)).toBeTruthy();
|
||||
expect(mockType.hasFeature).toHaveBeenCalledWith('creation');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,60 +24,108 @@ define(
|
||||
["../src/CompositionPolicy"],
|
||||
function (CompositionPolicy) {
|
||||
describe("Composition policy", function () {
|
||||
var mockInjector,
|
||||
mockTypeService,
|
||||
mockCapabilityService,
|
||||
mockTypes,
|
||||
var mockParentObject,
|
||||
typeA,
|
||||
typeB,
|
||||
typeC,
|
||||
mockChildObject,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
mockInjector = jasmine.createSpyObj('$injector', ['get']);
|
||||
mockTypeService = jasmine.createSpyObj(
|
||||
'typeService',
|
||||
['listTypes']
|
||||
mockParentObject = jasmine.createSpyObj('domainObject', [
|
||||
'getCapability'
|
||||
]);
|
||||
|
||||
typeA = jasmine.createSpyObj(
|
||||
'type A-- the particular kind',
|
||||
['getKey', 'getDefinition']
|
||||
);
|
||||
mockCapabilityService = jasmine.createSpyObj(
|
||||
'capabilityService',
|
||||
['getCapabilities']
|
||||
);
|
||||
// Both types can only contain b, let's say
|
||||
mockTypes = ['a', 'b'].map(function (type) {
|
||||
var mockType = jasmine.createSpyObj(
|
||||
'type-' + type,
|
||||
['getKey', 'getDefinition', 'getInitialModel']
|
||||
);
|
||||
mockType.getKey.andReturn(type);
|
||||
mockType.getDefinition.andReturn({
|
||||
contains: ['b']
|
||||
});
|
||||
mockType.getInitialModel.andReturn({});
|
||||
return mockType;
|
||||
typeA.getKey.andReturn('a');
|
||||
typeA.getDefinition.andReturn({
|
||||
contains: ['a']
|
||||
});
|
||||
|
||||
mockInjector.get.andCallFake(function (name) {
|
||||
return {
|
||||
typeService: mockTypeService,
|
||||
capabilityService: mockCapabilityService
|
||||
}[name];
|
||||
|
||||
typeB = jasmine.createSpyObj(
|
||||
'type B-- anything goes',
|
||||
['getKey', 'getDefinition']
|
||||
);
|
||||
typeB.getKey.andReturn('b');
|
||||
typeB.getDefinition.andReturn({
|
||||
contains: ['a', 'b']
|
||||
});
|
||||
|
||||
mockTypeService.listTypes.andReturn(mockTypes);
|
||||
mockCapabilityService.getCapabilities.andReturn({});
|
||||
typeC = jasmine.createSpyObj(
|
||||
'type C-- distinguishing and interested in telemetry',
|
||||
['getKey', 'getDefinition']
|
||||
);
|
||||
typeC.getKey.andReturn('c');
|
||||
typeC.getDefinition.andReturn({
|
||||
contains: [{has: 'telemetry'}]
|
||||
});
|
||||
|
||||
policy = new CompositionPolicy(mockInjector);
|
||||
mockChildObject = jasmine.createSpyObj(
|
||||
'childObject',
|
||||
['getCapability', 'hasCapability']
|
||||
);
|
||||
|
||||
policy = new CompositionPolicy();
|
||||
});
|
||||
|
||||
// Test basic composition policy here; test more closely at
|
||||
// the unit level in ContainmentTable for 'has' support, et al
|
||||
it("enforces containment rules defined by types", function () {
|
||||
expect(policy.allow(mockTypes[0], mockTypes[1]))
|
||||
.toBeTruthy();
|
||||
expect(policy.allow(mockTypes[1], mockTypes[1]))
|
||||
.toBeTruthy();
|
||||
expect(policy.allow(mockTypes[1], mockTypes[0]))
|
||||
.toBeFalsy();
|
||||
expect(policy.allow(mockTypes[0], mockTypes[0]))
|
||||
.toBeFalsy();
|
||||
describe('enforces simple containment rules', function () {
|
||||
|
||||
it('allows when type matches', function () {
|
||||
mockParentObject.getCapability.andReturn(typeA);
|
||||
|
||||
mockChildObject.getCapability.andReturn(typeA);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeTruthy();
|
||||
|
||||
mockParentObject.getCapability.andReturn(typeB);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeTruthy();
|
||||
|
||||
mockChildObject.getCapability.andReturn(typeB);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
it('disallows when type doesn\'t match', function () {
|
||||
|
||||
mockParentObject.getCapability.andReturn(typeA);
|
||||
mockChildObject.getCapability.andReturn(typeB);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeFalsy();
|
||||
|
||||
mockChildObject.getCapability.andReturn(typeC);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeFalsy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('enforces capability-based containment rules', function () {
|
||||
it('allows when object has capability', function () {
|
||||
mockParentObject.getCapability.andReturn(typeC);
|
||||
|
||||
mockChildObject.hasCapability.andReturn(true);
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeTruthy();
|
||||
expect(mockChildObject.hasCapability)
|
||||
.toHaveBeenCalledWith('telemetry');
|
||||
});
|
||||
|
||||
it('skips when object doesn\'t have capability', function () {
|
||||
mockChildObject.hasCapability.andReturn(false);
|
||||
|
||||
mockParentObject.getCapability.andReturn(typeC);
|
||||
|
||||
expect(policy.allow(mockParentObject, mockChildObject))
|
||||
.toBeFalsy();
|
||||
expect(mockChildObject.hasCapability)
|
||||
.toHaveBeenCalledWith('telemetry');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../src/ContainmentTable"],
|
||||
function (ContainmentTable) {
|
||||
describe("Composition policy's containment table", function () {
|
||||
var mockTypeService,
|
||||
mockCapabilityService,
|
||||
mockTypes,
|
||||
table;
|
||||
|
||||
beforeEach(function () {
|
||||
mockTypeService = jasmine.createSpyObj(
|
||||
'typeService',
|
||||
['listTypes']
|
||||
);
|
||||
mockCapabilityService = jasmine.createSpyObj(
|
||||
'capabilityService',
|
||||
['getCapabilities']
|
||||
);
|
||||
// Both types can only contain b, let's say
|
||||
mockTypes = ['a', 'b', 'c'].map(function (type, index) {
|
||||
var mockType = jasmine.createSpyObj(
|
||||
'type-' + type,
|
||||
['getKey', 'getDefinition', 'getInitialModel']
|
||||
);
|
||||
mockType.getKey.andReturn(type);
|
||||
mockType.getDefinition.andReturn({
|
||||
// First two contain objects with capability 'b';
|
||||
// third one defines no containership rules
|
||||
contains: (index < 2) ? [{ has: 'b' }] : undefined
|
||||
});
|
||||
// Return a model to drive apparent capabilities
|
||||
mockType.getInitialModel.andReturn({ id: type });
|
||||
return mockType;
|
||||
});
|
||||
|
||||
mockTypeService.listTypes.andReturn(mockTypes);
|
||||
mockCapabilityService.getCapabilities.andCallFake(function (model) {
|
||||
var capabilities = {};
|
||||
capabilities[model.id] = true;
|
||||
return capabilities;
|
||||
});
|
||||
|
||||
table = new ContainmentTable(
|
||||
mockTypeService,
|
||||
mockCapabilityService
|
||||
);
|
||||
});
|
||||
|
||||
// The plain type case is tested in CompositionPolicySpec,
|
||||
// so just test for special syntax ('has', or no contains rules) here
|
||||
it("enforces 'has' containment rules related to capabilities", function () {
|
||||
expect(table.canContain(mockTypes[0], mockTypes[1]))
|
||||
.toBeTruthy();
|
||||
expect(table.canContain(mockTypes[1], mockTypes[1]))
|
||||
.toBeTruthy();
|
||||
expect(table.canContain(mockTypes[1], mockTypes[0]))
|
||||
.toBeFalsy();
|
||||
expect(table.canContain(mockTypes[0], mockTypes[0]))
|
||||
.toBeFalsy();
|
||||
});
|
||||
|
||||
it("allows anything when no containership rules are defined", function () {
|
||||
expect(table.canContain(mockTypes[2], mockTypes[0]))
|
||||
.toBeTruthy();
|
||||
expect(table.canContain(mockTypes[2], mockTypes[1]))
|
||||
.toBeTruthy();
|
||||
expect(table.canContain(mockTypes[2], mockTypes[2]))
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,85 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../src/PersistableCompositionPolicy"],
|
||||
function (PersistableCompositionPolicy) {
|
||||
describe("Persistable Composition policy", function () {
|
||||
var objectAPI;
|
||||
var mockOpenMCT;
|
||||
var persistableCompositionPolicy;
|
||||
var mockParent;
|
||||
var mockChild;
|
||||
var mockEditorCapability;
|
||||
|
||||
beforeEach(function () {
|
||||
objectAPI = jasmine.createSpyObj('objectsAPI', [
|
||||
'getProvider'
|
||||
]);
|
||||
|
||||
mockOpenMCT = {
|
||||
objects: objectAPI
|
||||
};
|
||||
mockParent = jasmine.createSpyObj('domainObject', [
|
||||
'hasCapability',
|
||||
'getCapability',
|
||||
'getId'
|
||||
]);
|
||||
mockParent.hasCapability.andReturn(true);
|
||||
mockParent.getId.andReturn('someNamespace:someId');
|
||||
mockChild = {};
|
||||
mockEditorCapability = jasmine.createSpyObj('domainObject', [
|
||||
'isEditContextRoot'
|
||||
]);
|
||||
mockParent.getCapability.andReturn(mockEditorCapability);
|
||||
|
||||
objectAPI.getProvider.andReturn({
|
||||
save: function () {}
|
||||
});
|
||||
persistableCompositionPolicy = new PersistableCompositionPolicy(mockOpenMCT);
|
||||
});
|
||||
|
||||
//Parent
|
||||
// - getCapability ('editor')
|
||||
// - isEditContextRoot
|
||||
// - openMct.objects.getProvider
|
||||
|
||||
it("Does not allow composition for objects that are not persistable", function () {
|
||||
mockEditorCapability.isEditContextRoot.andReturn(false);
|
||||
expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true);
|
||||
objectAPI.getProvider.andReturn({});
|
||||
expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(false);
|
||||
});
|
||||
|
||||
it("Always allows composition of objects in edit mode to support object creation", function () {
|
||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||
expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true);
|
||||
expect(objectAPI.getProvider).not.toHaveBeenCalled();
|
||||
|
||||
mockEditorCapability.isEditContextRoot.andReturn(false);
|
||||
expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true);
|
||||
expect(objectAPI.getProvider).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -49,7 +49,6 @@ define([
|
||||
"./src/services/Now",
|
||||
"./src/services/Throttle",
|
||||
"./src/services/Topic",
|
||||
"./src/services/Contextualize",
|
||||
"./src/services/Instantiate",
|
||||
'legacyRegistry'
|
||||
], function (
|
||||
@@ -81,7 +80,6 @@ define([
|
||||
Now,
|
||||
Throttle,
|
||||
Topic,
|
||||
Contextualize,
|
||||
Instantiate,
|
||||
legacyRegistry
|
||||
) {
|
||||
@@ -241,7 +239,7 @@ define([
|
||||
"property": "name",
|
||||
"pattern": "\\S+",
|
||||
"required": true,
|
||||
"cssclass": "l-input-lg"
|
||||
"cssClass": "l-input-lg"
|
||||
},
|
||||
{
|
||||
"name": "Notes",
|
||||
@@ -249,19 +247,19 @@ define([
|
||||
"property": "notes",
|
||||
"control": "textarea",
|
||||
"required": false,
|
||||
"cssclass": "l-textarea-sm"
|
||||
"cssClass": "l-textarea-sm"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "root",
|
||||
"name": "Root",
|
||||
"cssclass": "icon-folder"
|
||||
"cssClass": "icon-folder"
|
||||
},
|
||||
{
|
||||
"key": "folder",
|
||||
"name": "Folder",
|
||||
"cssclass": "icon-folder",
|
||||
"cssClass": "icon-folder",
|
||||
"features": "creation",
|
||||
"description": "Create folders to organize other objects or links to objects.",
|
||||
"priority": 1000,
|
||||
@@ -272,11 +270,11 @@ define([
|
||||
{
|
||||
"key": "unknown",
|
||||
"name": "Unknown Type",
|
||||
"cssclass": "icon-object-unknown"
|
||||
"cssClass": "icon-object-unknown"
|
||||
},
|
||||
{
|
||||
"name": "Unknown Type",
|
||||
"cssclass": "icon-object-unknown"
|
||||
"cssClass": "icon-object-unknown"
|
||||
}
|
||||
],
|
||||
"capabilities": [
|
||||
@@ -284,8 +282,7 @@ define([
|
||||
"key": "composition",
|
||||
"implementation": CompositionCapability,
|
||||
"depends": [
|
||||
"$injector",
|
||||
"contextualize"
|
||||
"$injector"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -380,13 +377,6 @@ define([
|
||||
"$log"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "contextualize",
|
||||
"implementation": Contextualize,
|
||||
"depends": [
|
||||
"$log"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "instantiate",
|
||||
"implementation": Instantiate,
|
||||
|
||||
@@ -58,7 +58,7 @@ define(
|
||||
* @property {string} key machine-readable identifier for this action
|
||||
* @property {string} name human-readable name for this action
|
||||
* @property {string} description human-readable description
|
||||
* @property {string} cssclass CSS class for icon
|
||||
* @property {string} cssClass CSS class for icon
|
||||
* @property {ActionContext} context the context in which the action
|
||||
* will be performed.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
* Module defining CompositionCapability. Created by vwoeltje on 11/7/14.
|
||||
*/
|
||||
define(
|
||||
function () {
|
||||
['./ContextualDomainObject'],
|
||||
function (ContextualDomainObject) {
|
||||
|
||||
/**
|
||||
* Composition capability. A domain object's composition is the set of
|
||||
@@ -38,13 +39,12 @@ define(
|
||||
* @constructor
|
||||
* @implements {Capability}
|
||||
*/
|
||||
function CompositionCapability($injector, contextualize, domainObject) {
|
||||
function CompositionCapability($injector, domainObject) {
|
||||
// Get a reference to the object service from $injector
|
||||
this.injectObjectService = function () {
|
||||
this.objectService = $injector.get("objectService");
|
||||
};
|
||||
|
||||
this.contextualize = contextualize;
|
||||
this.domainObject = domainObject;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ define(
|
||||
CompositionCapability.prototype.invoke = function () {
|
||||
var domainObject = this.domainObject,
|
||||
model = domainObject.getModel(),
|
||||
contextualize = this.contextualize,
|
||||
ids;
|
||||
|
||||
// Then filter out non-existent objects,
|
||||
@@ -125,7 +124,7 @@ define(
|
||||
return ids.filter(function (id) {
|
||||
return objects[id];
|
||||
}).map(function (id) {
|
||||
return contextualize(objects[id], domainObject);
|
||||
return new ContextualDomainObject(objects[id], domainObject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ define(
|
||||
*/
|
||||
function CoreCapabilityProvider(capabilities, $log) {
|
||||
// Filter by invoking the capability's appliesTo method
|
||||
function filterCapabilities(model) {
|
||||
function filterCapabilities(model, id) {
|
||||
return capabilities.filter(function (capability) {
|
||||
return capability.appliesTo ?
|
||||
capability.appliesTo(model) :
|
||||
capability.appliesTo(model, id) :
|
||||
true;
|
||||
});
|
||||
}
|
||||
@@ -75,8 +75,8 @@ define(
|
||||
return result;
|
||||
}
|
||||
|
||||
function getCapabilities(model) {
|
||||
return packageCapabilities(filterCapabilities(model));
|
||||
function getCapabilities(model, id) {
|
||||
return packageCapabilities(filterCapabilities(model, id));
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
['./ContextualDomainObject'],
|
||||
function (ContextualDomainObject) {
|
||||
|
||||
/**
|
||||
* Implements the `instantiation` capability. This allows new domain
|
||||
@@ -70,11 +70,7 @@ define(
|
||||
|
||||
var newObject = this.instantiateFn(model, id);
|
||||
|
||||
this.contextualizeFn = this.contextualizeFn ||
|
||||
this.$injector.get("contextualize");
|
||||
|
||||
|
||||
return this.contextualizeFn(newObject, this.domainObject);
|
||||
return new ContextualDomainObject(newObject, this.domainObject);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
['../capabilities/ContextualDomainObject'],
|
||||
function (ContextualDomainObject) {
|
||||
|
||||
/**
|
||||
* Wrap a domain object such that it has a `context` capability
|
||||
* referring to a specific parent.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* contextualize(domainObject, parentObject)
|
||||
*
|
||||
* Attempting to contextualize an object with a parent that does
|
||||
* not include that object in its composition may have
|
||||
* unpredictable results; a warning will be logged if this occurs.
|
||||
*
|
||||
* @returns {Function}
|
||||
* @memberof platform/core
|
||||
*/
|
||||
function Contextualize($log) {
|
||||
function validate(id, parentObject) {
|
||||
var model = parentObject && parentObject.getModel(),
|
||||
composition = (model || {}).composition || [];
|
||||
if (composition.indexOf(id) === -1) {
|
||||
$log.warn([
|
||||
"Attempted to contextualize",
|
||||
id,
|
||||
"in",
|
||||
parentObject && parentObject.getId(),
|
||||
"but that object does not contain",
|
||||
id,
|
||||
"in its composition.",
|
||||
"Unexpected behavior may follow."
|
||||
].join(" "));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Contextualize this domain object.
|
||||
* @param {DomainObject} domainObject the domain object
|
||||
* to wrap with a context
|
||||
* @param {DomainObject} parentObject the domain object
|
||||
* which should appear as the contextual parent
|
||||
*/
|
||||
return function (domainObject, parentObject) {
|
||||
// Don't validate while editing; consistency is not
|
||||
// necessarily expected due to unsaved changes.
|
||||
var editor = domainObject.getCapability('editor');
|
||||
if (!editor || !editor.inEditContext()) {
|
||||
validate(domainObject.getId(), parentObject);
|
||||
}
|
||||
|
||||
return new ContextualDomainObject(domainObject, parentObject);
|
||||
};
|
||||
}
|
||||
|
||||
return Contextualize;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -56,12 +56,12 @@ define(
|
||||
* @method Type#getDescription
|
||||
*/
|
||||
/**
|
||||
* Get the cssclass associated with this type. cssclass is a
|
||||
* Get the cssClass associated with this type. cssClass is a
|
||||
* string which will appear as an icon (when
|
||||
* displayed in an appropriate font) which visually
|
||||
* distinguish types from one another.
|
||||
*
|
||||
* @returns {string} the cssclass for this type
|
||||
* @returns {string} the cssClass for this type
|
||||
* @method Type#getCssClass
|
||||
*/
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ define(
|
||||
};
|
||||
|
||||
TypeImpl.prototype.getCssClass = function () {
|
||||
return this.typeDef.cssclass;
|
||||
return this.typeDef.cssClass;
|
||||
};
|
||||
|
||||
TypeImpl.prototype.getProperties = function () {
|
||||
|
||||
@@ -41,7 +41,6 @@ define(
|
||||
describe("The composition capability", function () {
|
||||
var mockDomainObject,
|
||||
mockInjector,
|
||||
mockContextualize,
|
||||
mockObjectService,
|
||||
composition;
|
||||
|
||||
@@ -72,19 +71,11 @@ define(
|
||||
return (name === "objectService") && mockObjectService;
|
||||
}
|
||||
};
|
||||
mockContextualize = jasmine.createSpy('contextualize');
|
||||
|
||||
// Provide a minimal (e.g. no error-checking) implementation
|
||||
// of contextualize for simplicity
|
||||
mockContextualize.andCallFake(function (domainObject, parentObject) {
|
||||
return new ContextualDomainObject(domainObject, parentObject);
|
||||
});
|
||||
|
||||
mockObjectService.getObjects.andReturn(mockPromise([]));
|
||||
|
||||
composition = new CompositionCapability(
|
||||
mockInjector,
|
||||
mockContextualize,
|
||||
mockDomainObject
|
||||
);
|
||||
});
|
||||
|
||||
@@ -28,7 +28,6 @@ define(
|
||||
var mockInjector,
|
||||
mockIdentifierService,
|
||||
mockInstantiate,
|
||||
mockContextualize,
|
||||
mockIdentifier,
|
||||
mockNow,
|
||||
mockDomainObject,
|
||||
@@ -37,7 +36,6 @@ define(
|
||||
beforeEach(function () {
|
||||
mockInjector = jasmine.createSpyObj("$injector", ["get"]);
|
||||
mockInstantiate = jasmine.createSpy("instantiate");
|
||||
mockContextualize = jasmine.createSpy("contextualize");
|
||||
mockIdentifierService = jasmine.createSpyObj(
|
||||
'identifierService',
|
||||
['parse', 'generate']
|
||||
@@ -53,8 +51,7 @@ define(
|
||||
|
||||
mockInjector.get.andCallFake(function (key) {
|
||||
return {
|
||||
'instantiate': mockInstantiate,
|
||||
'contextualize': mockContextualize
|
||||
'instantiate': mockInstantiate
|
||||
}[key];
|
||||
});
|
||||
mockIdentifierService.parse.andReturn(mockIdentifier);
|
||||
@@ -85,18 +82,12 @@ define(
|
||||
'hasCapability'
|
||||
]), testModel = { someKey: "some value" };
|
||||
mockInstantiate.andReturn(mockDomainObj);
|
||||
mockContextualize.andCallFake(function (x) {
|
||||
return x;
|
||||
});
|
||||
expect(instantiation.instantiate(testModel))
|
||||
.toBe(mockDomainObj);
|
||||
instantiation.instantiate(testModel);
|
||||
expect(mockInstantiate)
|
||||
.toHaveBeenCalledWith({
|
||||
someKey: "some value",
|
||||
modified: mockNow()
|
||||
}, jasmine.any(String));
|
||||
expect(mockContextualize)
|
||||
.toHaveBeenCalledWith(mockDomainObj, mockDomainObject);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../../src/services/Contextualize"],
|
||||
function (Contextualize) {
|
||||
|
||||
var DOMAIN_OBJECT_METHODS = [
|
||||
'getId',
|
||||
'getModel',
|
||||
'getCapability',
|
||||
'hasCapability',
|
||||
'useCapability'
|
||||
];
|
||||
|
||||
describe("The 'contextualize' service", function () {
|
||||
var mockLog,
|
||||
mockDomainObject,
|
||||
mockParentObject,
|
||||
mockEditor,
|
||||
testParentModel,
|
||||
contextualize;
|
||||
|
||||
beforeEach(function () {
|
||||
testParentModel = { composition: ["abc"] };
|
||||
|
||||
mockLog = jasmine.createSpyObj(
|
||||
"$log",
|
||||
["error", "warn", "info", "debug"]
|
||||
);
|
||||
|
||||
mockDomainObject =
|
||||
jasmine.createSpyObj('domainObject', DOMAIN_OBJECT_METHODS);
|
||||
mockParentObject =
|
||||
jasmine.createSpyObj('parentObject', DOMAIN_OBJECT_METHODS);
|
||||
|
||||
mockEditor =
|
||||
jasmine.createSpyObj('editor', ['inEditContext']);
|
||||
|
||||
mockDomainObject.getId.andReturn("abc");
|
||||
mockDomainObject.getModel.andReturn({});
|
||||
mockParentObject.getId.andReturn("parent");
|
||||
mockParentObject.getModel.andReturn(testParentModel);
|
||||
|
||||
mockEditor.inEditContext.andReturn(false);
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
return c === 'editor' && mockEditor;
|
||||
});
|
||||
|
||||
contextualize = new Contextualize(mockLog);
|
||||
});
|
||||
|
||||
it("attaches a context capability", function () {
|
||||
var contextualizedObject =
|
||||
contextualize(mockDomainObject, mockParentObject);
|
||||
|
||||
expect(contextualizedObject.getId()).toEqual("abc");
|
||||
expect(contextualizedObject.getCapability("context"))
|
||||
.toBeDefined();
|
||||
expect(contextualizedObject.getCapability("context").getParent())
|
||||
.toBe(mockParentObject);
|
||||
});
|
||||
|
||||
it("issues a warning if composition does not match", function () {
|
||||
// Precondition - normally it should not issue a warning
|
||||
contextualize(mockDomainObject, mockParentObject);
|
||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||
|
||||
testParentModel.composition = ["xyz"];
|
||||
|
||||
contextualize(mockDomainObject, mockParentObject);
|
||||
expect(mockLog.warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not issue warnings for objects being edited", function () {
|
||||
mockEditor.inEditContext.andReturn(true);
|
||||
testParentModel.composition = ["xyz"];
|
||||
contextualize(mockDomainObject, mockParentObject);
|
||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -33,7 +33,7 @@ define(
|
||||
key: 'test-type',
|
||||
name: 'Test Type',
|
||||
description: 'A type, for testing',
|
||||
cssclass: 'icon-telemetry-panel',
|
||||
cssClass: 'icon-telemetry-panel',
|
||||
inherits: ['test-parent-1', 'test-parent-2'],
|
||||
features: ['test-feature-1'],
|
||||
properties: [{}],
|
||||
|
||||
@@ -30,18 +30,18 @@ define(
|
||||
testTypeDefinitions = [
|
||||
{
|
||||
key: 'basic',
|
||||
cssclass: "icon-magnify-in",
|
||||
cssClass: "icon-magnify-in",
|
||||
name: "Basic Type"
|
||||
},
|
||||
{
|
||||
key: 'multi1',
|
||||
cssclass: "icon-trash",
|
||||
cssClass: "icon-trash",
|
||||
description: "Multi1 Description",
|
||||
capabilities: ['a1', 'b1']
|
||||
},
|
||||
{
|
||||
key: 'multi2',
|
||||
cssclass: "icon-magnify-out",
|
||||
cssClass: "icon-magnify-out",
|
||||
capabilities: ['a2', 'b2', 'c2']
|
||||
},
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ define([
|
||||
"key": "move",
|
||||
"name": "Move",
|
||||
"description": "Move object to another location.",
|
||||
"cssclass": "icon-move",
|
||||
"cssClass": "icon-move",
|
||||
"category": "contextual",
|
||||
"implementation": MoveAction,
|
||||
"depends": [
|
||||
@@ -79,7 +79,7 @@ define([
|
||||
"key": "copy",
|
||||
"name": "Duplicate",
|
||||
"description": "Duplicate object to another location.",
|
||||
"cssclass": "icon-duplicate",
|
||||
"cssClass": "icon-duplicate",
|
||||
"category": "contextual",
|
||||
"implementation": CopyAction,
|
||||
"depends": [
|
||||
@@ -95,7 +95,7 @@ define([
|
||||
"key": "link",
|
||||
"name": "Create Link",
|
||||
"description": "Create Link to object in another location.",
|
||||
"cssclass": "icon-link",
|
||||
"cssClass": "icon-link",
|
||||
"category": "contextual",
|
||||
"implementation": LinkAction,
|
||||
"depends": [
|
||||
@@ -108,7 +108,7 @@ define([
|
||||
"key": "follow",
|
||||
"name": "Go To Original",
|
||||
"description": "Go to the original, un-linked instance of this object.",
|
||||
"cssclass": "",
|
||||
"cssClass": "",
|
||||
"category": "contextual",
|
||||
"implementation": GoToOriginalAction
|
||||
},
|
||||
@@ -116,7 +116,7 @@ define([
|
||||
"key": "locate",
|
||||
"name": "Set Primary Location",
|
||||
"description": "Set a domain object's primary location.",
|
||||
"cssclass": "",
|
||||
"cssClass": "",
|
||||
"category": "contextual",
|
||||
"implementation": SetPrimaryLocationAction
|
||||
}
|
||||
@@ -132,7 +132,6 @@ define([
|
||||
"provides": "objectService",
|
||||
"implementation": LocatingObjectDecorator,
|
||||
"depends": [
|
||||
"contextualize",
|
||||
"$q",
|
||||
"$log"
|
||||
]
|
||||
|
||||
@@ -47,8 +47,8 @@ define(
|
||||
}
|
||||
return this.policyService.allow(
|
||||
"composition",
|
||||
parentCandidate.getCapability('type'),
|
||||
object.getCapability('type')
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ define(
|
||||
}
|
||||
return this.policyService.allow(
|
||||
"composition",
|
||||
parentCandidate.getCapability('type'),
|
||||
object.getCapability('type')
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
|
||||
define(
|
||||
function () {
|
||||
['../../../core/src/capabilities/ContextualDomainObject'],
|
||||
function (ContextualDomainObject) {
|
||||
|
||||
/**
|
||||
* Ensures that domain objects are loaded with a context capability
|
||||
@@ -31,8 +32,7 @@ define(
|
||||
* @implements {ObjectService}
|
||||
* @memberof platform/entanglement
|
||||
*/
|
||||
function LocatingObjectDecorator(contextualize, $q, $log, objectService) {
|
||||
this.contextualize = contextualize;
|
||||
function LocatingObjectDecorator($q, $log, objectService) {
|
||||
this.$log = $log;
|
||||
this.objectService = objectService;
|
||||
this.$q = $q;
|
||||
@@ -41,7 +41,6 @@ define(
|
||||
LocatingObjectDecorator.prototype.getObjects = function (ids) {
|
||||
var $q = this.$q,
|
||||
$log = this.$log,
|
||||
contextualize = this.contextualize,
|
||||
objectService = this.objectService,
|
||||
result = {};
|
||||
|
||||
@@ -76,7 +75,7 @@ define(
|
||||
return loadObjectInContext(location, exclude)
|
||||
.then(function (parent) {
|
||||
// ...and then contextualize with it!
|
||||
return contextualize(domainObject, parent);
|
||||
return new ContextualDomainObject(domainObject, parent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ define(
|
||||
sections: [
|
||||
{
|
||||
name: 'Location',
|
||||
cssclass: "grows",
|
||||
cssClass: "grows",
|
||||
rows: [
|
||||
{
|
||||
name: label,
|
||||
|
||||
@@ -55,8 +55,8 @@ define(
|
||||
}
|
||||
return this.policyService.allow(
|
||||
"composition",
|
||||
parentCandidate.getCapability('type'),
|
||||
object.getCapability('type')
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ define(
|
||||
validate();
|
||||
expect(policyService.allow).toHaveBeenCalledWith(
|
||||
"composition",
|
||||
parentCandidate.capabilities.type,
|
||||
object.capabilities.type
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ define(
|
||||
validate();
|
||||
expect(mockPolicyService.allow).toHaveBeenCalledWith(
|
||||
"composition",
|
||||
parentCandidate.capabilities.type,
|
||||
object.capabilities.type
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
define(
|
||||
[
|
||||
'../../src/services/LocatingObjectDecorator'
|
||||
'../../src/services/LocatingObjectDecorator',
|
||||
'../../../core/src/capabilities/ContextualDomainObject'
|
||||
],
|
||||
function (LocatingObjectDecorator) {
|
||||
function (LocatingObjectDecorator, ContextualDomainObject) {
|
||||
|
||||
describe("LocatingObjectDecorator", function () {
|
||||
var mockContextualize,
|
||||
mockQ,
|
||||
var mockQ,
|
||||
mockLog,
|
||||
mockObjectService,
|
||||
mockCallback,
|
||||
@@ -57,21 +57,12 @@ define(
|
||||
};
|
||||
testObjects = {};
|
||||
|
||||
mockContextualize = jasmine.createSpy("contextualize");
|
||||
mockQ = jasmine.createSpyObj("$q", ["when", "all"]);
|
||||
mockLog =
|
||||
jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
||||
mockObjectService =
|
||||
jasmine.createSpyObj("objectService", ["getObjects"]);
|
||||
|
||||
mockContextualize.andCallFake(function (domainObject, parentObject) {
|
||||
// Not really what contextualize does, but easy to test!
|
||||
return {
|
||||
testObject: domainObject,
|
||||
testParent: parentObject
|
||||
};
|
||||
});
|
||||
|
||||
mockQ.when.andCallFake(testPromise);
|
||||
mockQ.all.andCallFake(function (promises) {
|
||||
var result = {};
|
||||
@@ -97,28 +88,21 @@ define(
|
||||
});
|
||||
|
||||
decorator = new LocatingObjectDecorator(
|
||||
mockContextualize,
|
||||
mockQ,
|
||||
mockLog,
|
||||
mockObjectService
|
||||
);
|
||||
});
|
||||
|
||||
it("contextualizes domain objects by location", function () {
|
||||
it("contextualizes domain objects", function () {
|
||||
decorator.getObjects(['b', 'c']).then(mockCallback);
|
||||
expect(mockCallback).toHaveBeenCalledWith({
|
||||
b: {
|
||||
testObject: testObjects.b,
|
||||
testParent: testObjects.a
|
||||
},
|
||||
c: {
|
||||
testObject: testObjects.c,
|
||||
testParent: {
|
||||
testObject: testObjects.b,
|
||||
testParent: testObjects.a
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(mockCallback).toHaveBeenCalled();
|
||||
|
||||
var callbackObj = mockCallback.mostRecentCall.args[0];
|
||||
expect(testObjects.b.getCapability('context')).not.toBeDefined();
|
||||
expect(testObjects.c.getCapability('context')).not.toBeDefined();
|
||||
expect(callbackObj.b.getCapability('context')).toBeDefined();
|
||||
expect(callbackObj.c.getCapability('context')).toBeDefined();
|
||||
});
|
||||
|
||||
it("warns on cycle detection", function () {
|
||||
|
||||
@@ -123,8 +123,8 @@ define(
|
||||
validate();
|
||||
expect(policyService.allow).toHaveBeenCalledWith(
|
||||
"composition",
|
||||
parentCandidate.capabilities.type,
|
||||
object.capabilities.type
|
||||
parentCandidate,
|
||||
object
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
54
platform/features/autoflow/plugin.js
Executable file
54
platform/features/autoflow/plugin.js
Executable file
@@ -0,0 +1,54 @@
|
||||
define([
|
||||
'text!./res/templates/autoflow-tabular.html',
|
||||
'./src/AutoflowTabularController',
|
||||
'./src/MCTAutoflowTable'
|
||||
], function (
|
||||
autoflowTabularTemplate,
|
||||
AutoflowTabularController,
|
||||
MCTAutoflowTable
|
||||
) {
|
||||
return function (options) {
|
||||
return function (openmct) {
|
||||
openmct.legacyRegistry.register("platform/features/autoflow", {
|
||||
"name": "WARP Telemetry Adapter",
|
||||
"description": "Retrieves telemetry from the WARP Server and provides related types and views.",
|
||||
"resources": "res",
|
||||
"extensions": {
|
||||
"views": [
|
||||
{
|
||||
"key": "autoflow",
|
||||
"name": "Autoflow Tabular",
|
||||
"cssClass": "icon-packet",
|
||||
"description": "A tabular view of packet contents.",
|
||||
"template": autoflowTabularTemplate,
|
||||
"type": options && options.type,
|
||||
"needs": [
|
||||
"telemetry"
|
||||
],
|
||||
"delegation": true
|
||||
}
|
||||
],
|
||||
"controllers": [
|
||||
{
|
||||
"key": "AutoflowTabularController",
|
||||
"implementation": AutoflowTabularController,
|
||||
"depends": [
|
||||
"$scope",
|
||||
"$timeout",
|
||||
"telemetrySubscriber"
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": [
|
||||
{
|
||||
"key": "mctAutoflowTable",
|
||||
"implementation": MCTAutoflowTable
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
openmct.legacyRegistry.enable("platform/features/autoflow");
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
26
platform/features/autoflow/res/templates/autoflow-tabular.html
Executable file
26
platform/features/autoflow/res/templates/autoflow-tabular.html
Executable file
@@ -0,0 +1,26 @@
|
||||
<div class="items-holder abs contents autoflow obj-value-format"
|
||||
ng-controller="AutoflowTabularController as autoflow">
|
||||
<div class="abs l-flex-row holder t-autoflow-header l-autoflow-header">
|
||||
<mct-include key="'input-filter'"
|
||||
ng-model="autoflow.filter"
|
||||
class="flex-elem">
|
||||
</mct-include>
|
||||
<div class="flex-elem grows t-last-update" title="Last Update">{{autoflow.updated()}}</div>
|
||||
<a title="Change column width"
|
||||
class="s-button flex-elem icon-arrows-right-left change-column-width"
|
||||
ng-click="autoflow.increaseColumnWidth()"></a>
|
||||
</div>
|
||||
<div class="abs t-autoflow-items l-autoflow-items"
|
||||
mct-resize="autoflow.setBounds(bounds)"
|
||||
mct-resize-interval="50">
|
||||
<mct-autoflow-table values="autoflow.rangeValues()"
|
||||
objects="autoflow.getTelemetryObjects()"
|
||||
rows="autoflow.getRows()"
|
||||
classes="autoflow.classes()"
|
||||
updated="autoflow.updated()"
|
||||
column-width="autoflow.columnWidth()"
|
||||
counter="autoflow.counter()"
|
||||
>
|
||||
</mct-autoflow-table>
|
||||
</div>
|
||||
</div>
|
||||
169
platform/features/autoflow/src/AutoflowTableLinker.js
Executable file
169
platform/features/autoflow/src/AutoflowTableLinker.js
Executable file
@@ -0,0 +1,169 @@
|
||||
/*global angular*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
|
||||
/**
|
||||
* The link step for the `mct-autoflow-table` directive;
|
||||
* watches scope and updates the DOM appropriately.
|
||||
* See documentation in `MCTAutoflowTable.js` for the rationale
|
||||
* for including this directive, as well as for an explanation
|
||||
* of which values are placed in scope.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Scope} scope the scope for this usage of the directive
|
||||
* @param element the jqLite-wrapped element which used this directive
|
||||
*/
|
||||
function AutoflowTableLinker(scope, element) {
|
||||
var objects, // Domain objects at last structure refresh
|
||||
rows, // Number of rows from last structure refresh
|
||||
priorClasses = {},
|
||||
valueSpans = {}; // Span elements to put data values in
|
||||
|
||||
// Create a new name-value pair in the specified column
|
||||
function createListItem(domainObject, ul) {
|
||||
// Create a new li, and spans to go in it.
|
||||
var li = angular.element('<li>'),
|
||||
titleSpan = angular.element('<span>'),
|
||||
valueSpan = angular.element('<span>');
|
||||
|
||||
// Place spans in the li, and li into the column.
|
||||
// valueSpan must precede titleSpan in the DOM due to new CSS float approach
|
||||
li.append(valueSpan).append(titleSpan);
|
||||
ul.append(li);
|
||||
|
||||
// Style appropriately
|
||||
li.addClass('l-autoflow-row');
|
||||
titleSpan.addClass('l-autoflow-item l');
|
||||
valueSpan.addClass('l-autoflow-item r l-obj-val-format');
|
||||
|
||||
// Set text/tooltip for the name-value row
|
||||
titleSpan.text(domainObject.getModel().name);
|
||||
titleSpan.attr("title", domainObject.getModel().name);
|
||||
|
||||
// Keep a reference to the span which will hold the
|
||||
// data value, to populate in the next refreshValues call
|
||||
valueSpans[domainObject.getId()] = valueSpan;
|
||||
|
||||
return li;
|
||||
}
|
||||
|
||||
// Create a new column of name-value pairs in this table.
|
||||
function createColumn(el) {
|
||||
// Create a ul
|
||||
var ul = angular.element('<ul>');
|
||||
|
||||
// Add it into the mct-autoflow-table
|
||||
el.append(ul);
|
||||
|
||||
// Style appropriately
|
||||
ul.addClass('l-autoflow-col');
|
||||
|
||||
// Get the current col width and apply at time of column creation
|
||||
// Important to do this here, as new columns could be created after
|
||||
// the user has changed the width.
|
||||
ul.css('width', scope.columnWidth + 'px');
|
||||
|
||||
// Return it, so some li elements can be added
|
||||
return ul;
|
||||
}
|
||||
|
||||
// Change the width of the columns when user clicks the resize button.
|
||||
function resizeColumn() {
|
||||
element.find('ul').css('width', scope.columnWidth + 'px');
|
||||
}
|
||||
|
||||
// Rebuild the DOM associated with this table.
|
||||
function rebuild(domainObjects, rowCount) {
|
||||
var activeColumn;
|
||||
|
||||
// Empty out our cached span elements
|
||||
valueSpans = {};
|
||||
|
||||
// Start with an empty DOM beneath this directive
|
||||
element.html("");
|
||||
|
||||
// Add DOM elements for each domain object being displayed
|
||||
// in this table.
|
||||
domainObjects.forEach(function (object, index) {
|
||||
// Start a new column if we'd run out of room
|
||||
if (index % rowCount === 0) {
|
||||
activeColumn = createColumn(element);
|
||||
}
|
||||
// Add the DOM elements for that object to whichever
|
||||
// column (a `ul` element) is current.
|
||||
createListItem(object, activeColumn);
|
||||
});
|
||||
}
|
||||
|
||||
// Update spans with values, as made available via the
|
||||
// `values` attribute of this directive.
|
||||
function refreshValues() {
|
||||
// Get the available values
|
||||
var values = scope.values || {},
|
||||
classes = scope.classes || {};
|
||||
|
||||
// Populate all spans with those values (or clear
|
||||
// those spans if no value is available)
|
||||
(objects || []).forEach(function (object) {
|
||||
var id = object.getId(),
|
||||
span = valueSpans[id],
|
||||
value;
|
||||
|
||||
if (span) {
|
||||
// Look up the value...
|
||||
value = values[id];
|
||||
// ...and convert to empty string if it's undefined
|
||||
value = value === undefined ? "" : value;
|
||||
span.attr("data-value", value);
|
||||
|
||||
// Update the span
|
||||
span.text(value);
|
||||
span.attr("title", value);
|
||||
span.removeClass(priorClasses[id]);
|
||||
span.addClass(classes[id]);
|
||||
priorClasses[id] = classes[id];
|
||||
}
|
||||
// Also need stale/alert/ok class
|
||||
// on span
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh the DOM for this table, if necessary
|
||||
function refreshStructure() {
|
||||
// Only rebuild if number of rows or set of objects
|
||||
// has changed; otherwise, our structure is still valid.
|
||||
if (scope.objects !== objects ||
|
||||
scope.rows !== rows) {
|
||||
|
||||
// Track those values to support future refresh checks
|
||||
objects = scope.objects;
|
||||
rows = scope.rows;
|
||||
|
||||
// Rebuild the DOM
|
||||
rebuild(objects || [], rows || 1);
|
||||
|
||||
// Refresh all data values shown
|
||||
refreshValues();
|
||||
}
|
||||
}
|
||||
|
||||
// Changing the domain objects in use or the number
|
||||
// of rows should trigger a structure change (DOM rebuild)
|
||||
scope.$watch("objects", refreshStructure);
|
||||
scope.$watch("rows", refreshStructure);
|
||||
|
||||
// When the current column width has been changed, resize the column
|
||||
scope.$watch('columnWidth', resizeColumn);
|
||||
|
||||
// When the last-updated time ticks,
|
||||
scope.$watch("updated", refreshValues);
|
||||
|
||||
// Update displayed values when the counter changes.
|
||||
scope.$watch("counter", refreshValues);
|
||||
|
||||
}
|
||||
|
||||
return AutoflowTableLinker;
|
||||
}
|
||||
);
|
||||
324
platform/features/autoflow/src/AutoflowTabularController.js
Executable file
324
platform/features/autoflow/src/AutoflowTabularController.js
Executable file
@@ -0,0 +1,324 @@
|
||||
|
||||
define(
|
||||
['moment'],
|
||||
function (moment) {
|
||||
|
||||
var ROW_HEIGHT = 16,
|
||||
SLIDER_HEIGHT = 10,
|
||||
INITIAL_COLUMN_WIDTH = 225,
|
||||
MAX_COLUMN_WIDTH = 525,
|
||||
COLUMN_WIDTH_STEP = 25,
|
||||
DEBOUNCE_INTERVAL = 100,
|
||||
DATE_FORMAT = "YYYY-DDD HH:mm:ss.SSS\\Z",
|
||||
NOT_UPDATED = "No updates",
|
||||
EMPTY_ARRAY = [];
|
||||
|
||||
/**
|
||||
* Responsible for supporting the autoflow tabular view.
|
||||
* Implements the all-over logic which drives that view,
|
||||
* mediating between template-provided areas, the included
|
||||
* `mct-autoflow-table` directive, and the underlying
|
||||
* domain object model.
|
||||
* @constructor
|
||||
*/
|
||||
function AutflowTabularController(
|
||||
$scope,
|
||||
$timeout,
|
||||
telemetrySubscriber
|
||||
) {
|
||||
var filterValue = "",
|
||||
filterValueLowercase = "",
|
||||
subscription,
|
||||
filteredObjects = [],
|
||||
lastUpdated = {},
|
||||
updateText = NOT_UPDATED,
|
||||
rangeValues = {},
|
||||
classes = {},
|
||||
limits = {},
|
||||
updatePending = false,
|
||||
lastBounce = Number.NEGATIVE_INFINITY,
|
||||
columnWidth = INITIAL_COLUMN_WIDTH,
|
||||
rows = 1,
|
||||
counter = 0;
|
||||
|
||||
// Trigger an update of the displayed table by incrementing
|
||||
// the counter that it watches.
|
||||
function triggerDisplayUpdate() {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
// Check whether or not an object's name matches the
|
||||
// user-entered filter value.
|
||||
function filterObject(domainObject) {
|
||||
return (domainObject.getModel().name || "")
|
||||
.toLowerCase()
|
||||
.indexOf(filterValueLowercase) !== -1;
|
||||
}
|
||||
|
||||
// Comparator for sorting points back into packet order
|
||||
function compareObject(objectA, objectB) {
|
||||
var indexA = objectA.getModel().index || 0,
|
||||
indexB = objectB.getModel().index || 0;
|
||||
return indexA - indexB;
|
||||
}
|
||||
|
||||
// Update the list of currently-displayed objects; these
|
||||
// will be the subset of currently subscribed-to objects
|
||||
// which match a user-entered filter.
|
||||
function doUpdateFilteredObjects() {
|
||||
// Generate the list
|
||||
filteredObjects = (
|
||||
subscription ?
|
||||
subscription.getTelemetryObjects() :
|
||||
[]
|
||||
).filter(filterObject).sort(compareObject);
|
||||
|
||||
// Clear the pending flag
|
||||
updatePending = false;
|
||||
|
||||
// Track when this occurred, so that we can wait
|
||||
// a whole before updating again.
|
||||
lastBounce = Date.now();
|
||||
|
||||
triggerDisplayUpdate();
|
||||
}
|
||||
|
||||
// Request an update to the list of current objects; this may
|
||||
// run on a timeout to avoid excessive calls, e.g. while the user
|
||||
// is typing a filter.
|
||||
function updateFilteredObjects() {
|
||||
// Don't do anything if an update is already scheduled
|
||||
if (!updatePending) {
|
||||
if (Date.now() > lastBounce + DEBOUNCE_INTERVAL) {
|
||||
// Update immediately if it's been long enough
|
||||
doUpdateFilteredObjects();
|
||||
} else {
|
||||
// Otherwise, update later, and track that we have
|
||||
// an update pending so that subsequent calls can
|
||||
// be ignored.
|
||||
updatePending = true;
|
||||
$timeout(doUpdateFilteredObjects, DEBOUNCE_INTERVAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Track the latest data values for this domain object
|
||||
function recordData(telemetryObject) {
|
||||
// Get latest domain/range values for this object.
|
||||
var id = telemetryObject.getId(),
|
||||
domainValue = subscription.getDomainValue(telemetryObject),
|
||||
rangeValue = subscription.getRangeValue(telemetryObject);
|
||||
|
||||
// Track the most recent timestamp change observed...
|
||||
if (domainValue !== undefined && domainValue !== lastUpdated[id]) {
|
||||
lastUpdated[id] = domainValue;
|
||||
// ... and update the displayable text for that timestamp
|
||||
updateText = isNaN(domainValue) ? "" :
|
||||
moment.utc(domainValue).format(DATE_FORMAT);
|
||||
}
|
||||
|
||||
// Store data values into the rangeValues structure, which
|
||||
// will be used to populate the table itself.
|
||||
// Note that we want full precision here.
|
||||
rangeValues[id] = rangeValue;
|
||||
|
||||
// Update limit states as well
|
||||
classes[id] = limits[id] && (limits[id].evaluate({
|
||||
// This relies on external knowledge that the
|
||||
// range value of a telemetry point is encoded
|
||||
// in its datum as "value."
|
||||
value: rangeValue
|
||||
}) || {}).cssClass;
|
||||
}
|
||||
|
||||
|
||||
// Look at telemetry objects from the subscription; this is watched
|
||||
// to detect changes from the subscription.
|
||||
function subscribedTelemetry() {
|
||||
return subscription ?
|
||||
subscription.getTelemetryObjects() : EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
// Update the data values which will be used to populate the table
|
||||
function updateValues() {
|
||||
subscribedTelemetry().forEach(recordData);
|
||||
triggerDisplayUpdate();
|
||||
}
|
||||
|
||||
// Getter-setter function for user-entered filter text.
|
||||
function filter(value) {
|
||||
// If value was specified, we're a setter
|
||||
if (value !== undefined) {
|
||||
// Store the new value
|
||||
filterValue = value;
|
||||
filterValueLowercase = value.toLowerCase();
|
||||
// Change which objects appear in the table
|
||||
updateFilteredObjects();
|
||||
}
|
||||
|
||||
// Always act as a getter
|
||||
return filterValue;
|
||||
}
|
||||
|
||||
// Update the bounds (width and height) of this view;
|
||||
// called from the mct-resize directive. Recalculates how
|
||||
// many rows should appear in the contained table.
|
||||
function setBounds(bounds) {
|
||||
var availableSpace = bounds.height - SLIDER_HEIGHT;
|
||||
rows = Math.max(1, Math.floor(availableSpace / ROW_HEIGHT));
|
||||
}
|
||||
|
||||
// Increment the current column width, up to the defined maximum.
|
||||
// When the max is hit, roll back to the default.
|
||||
function increaseColumnWidth() {
|
||||
columnWidth += COLUMN_WIDTH_STEP;
|
||||
// Cycle down to the initial width instead of exceeding max
|
||||
columnWidth = columnWidth > MAX_COLUMN_WIDTH ?
|
||||
INITIAL_COLUMN_WIDTH : columnWidth;
|
||||
}
|
||||
|
||||
// Get displayable text for last-updated value
|
||||
function updated() {
|
||||
return updateText;
|
||||
}
|
||||
|
||||
// Unsubscribe, if a subscription is active.
|
||||
function releaseSubscription() {
|
||||
if (subscription) {
|
||||
subscription.unsubscribe();
|
||||
subscription = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Update set of telemetry objects managed by this view
|
||||
function updateTelemetryObjects(telemetryObjects) {
|
||||
updateFilteredObjects();
|
||||
limits = {};
|
||||
telemetryObjects.forEach(function (telemetryObject) {
|
||||
var id = telemetryObject.getId();
|
||||
limits[id] = telemetryObject.getCapability('limit');
|
||||
});
|
||||
}
|
||||
|
||||
// Create a subscription for the represented domain object.
|
||||
// This will resolve capability delegation as necessary.
|
||||
function makeSubscription(domainObject) {
|
||||
// Unsubscribe, if there is an existing subscription
|
||||
releaseSubscription();
|
||||
|
||||
// Clear updated timestamp
|
||||
lastUpdated = {};
|
||||
updateText = NOT_UPDATED;
|
||||
|
||||
// Create a new subscription; telemetrySubscriber gets
|
||||
// to do the meaningful work here.
|
||||
subscription = domainObject && telemetrySubscriber.subscribe(
|
||||
domainObject,
|
||||
updateValues
|
||||
);
|
||||
|
||||
// Our set of in-view telemetry objects may have changed,
|
||||
// so update the set that is being passed down to the table.
|
||||
updateFilteredObjects();
|
||||
}
|
||||
|
||||
// Watch for changes to the set of objects which have telemetry
|
||||
$scope.$watch(subscribedTelemetry, updateTelemetryObjects);
|
||||
|
||||
// Watch for the represented domainObject (this field will
|
||||
// be populated by mct-representation)
|
||||
$scope.$watch("domainObject", makeSubscription);
|
||||
|
||||
// Make sure we unsubscribe when this view is destroyed.
|
||||
$scope.$on("$destroy", releaseSubscription);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the number of rows which should be shown in this table.
|
||||
* @return {number} the number of rows to show
|
||||
*/
|
||||
getRows: function () {
|
||||
return rows;
|
||||
},
|
||||
/**
|
||||
* Get the objects which should currently be displayed in
|
||||
* this table. This will be watched, so the return value
|
||||
* should be stable when this list is unchanging. Only
|
||||
* objects which match the user-entered filter value should
|
||||
* be returned here.
|
||||
* @return {DomainObject[]} the domain objects to include in
|
||||
* this table.
|
||||
*/
|
||||
getTelemetryObjects: function () {
|
||||
return filteredObjects;
|
||||
},
|
||||
/**
|
||||
* Set the bounds (width/height) of this autoflow tabular view.
|
||||
* The template must ensure that these bounds are tracked on
|
||||
* the table area only.
|
||||
* @param bounds the bounds; and object with `width` and
|
||||
* `height` properties, both as numbers, in pixels.
|
||||
*/
|
||||
setBounds: setBounds,
|
||||
/**
|
||||
* Increments the width of the autoflow column.
|
||||
* Setting does not yet persist.
|
||||
*/
|
||||
increaseColumnWidth: increaseColumnWidth,
|
||||
/**
|
||||
* Get-or-set the user-supplied filter value.
|
||||
* @param {string} [value] the new filter value; omit to use
|
||||
* as a getter
|
||||
* @returns {string} the user-supplied filter value
|
||||
*/
|
||||
filter: filter,
|
||||
/**
|
||||
* Get all range values for use in this table. These will be
|
||||
* returned as an object of key-value pairs, where keys are
|
||||
* domain object IDs, and values are the most recently observed
|
||||
* data values associated with those objects, formatted for
|
||||
* display.
|
||||
* @returns {object.<string,string>} most recent values
|
||||
*/
|
||||
rangeValues: function () {
|
||||
return rangeValues;
|
||||
},
|
||||
/**
|
||||
* Get CSS classes to apply to specific rows, representing limit
|
||||
* states and/or stale states. These are returned as key-value
|
||||
* pairs where keys are domain object IDs, and values are CSS
|
||||
* classes to display for domain objects with those IDs.
|
||||
* @returns {object.<string,string>} CSS classes
|
||||
*/
|
||||
classes: function () {
|
||||
return classes;
|
||||
},
|
||||
/**
|
||||
* Get the "last updated" text for this view; this will be
|
||||
* the most recent timestamp observed for any telemetry-
|
||||
* providing object, formatted for display.
|
||||
* @returns {string} the time of the most recent update
|
||||
*/
|
||||
updated: updated,
|
||||
/**
|
||||
* Get the current column width, in pixels.
|
||||
* @returns {number} column width
|
||||
*/
|
||||
columnWidth: function () {
|
||||
return columnWidth;
|
||||
},
|
||||
/**
|
||||
* Keep a counter and increment this whenever the display
|
||||
* should be updated; this will be watched by the
|
||||
* `mct-autoflow-table`.
|
||||
* @returns {number} a counter value
|
||||
*/
|
||||
counter: function () {
|
||||
return counter;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return AutflowTabularController;
|
||||
}
|
||||
);
|
||||
60
platform/features/autoflow/src/MCTAutoflowTable.js
Executable file
60
platform/features/autoflow/src/MCTAutoflowTable.js
Executable file
@@ -0,0 +1,60 @@
|
||||
|
||||
define(
|
||||
["./AutoflowTableLinker"],
|
||||
function (AutoflowTableLinker) {
|
||||
|
||||
/**
|
||||
* The `mct-autoflow-table` directive specifically supports
|
||||
* autoflow tabular views; it is not intended for use outside
|
||||
* of that view.
|
||||
*
|
||||
* This directive is responsible for creating the structure
|
||||
* of the table in this view, and for updating its values.
|
||||
* While this is achievable using a regular Angular template,
|
||||
* this is undesirable from the perspective of performance
|
||||
* due to the number of watches that can be involved for large
|
||||
* tables. Instead, this directive will maintain a small number
|
||||
* of watches, rebuilding table structure only when necessary,
|
||||
* and updating displayed values in the more common case of
|
||||
* new data arriving.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function MCTAutoflowTable() {
|
||||
return {
|
||||
// Only applicable at the element level
|
||||
restrict: "E",
|
||||
|
||||
// The link function; handles DOM update/manipulation
|
||||
link: AutoflowTableLinker,
|
||||
|
||||
// Parameters to pass from attributes into scope
|
||||
scope: {
|
||||
// Set of domain objects to show in the table
|
||||
objects: "=",
|
||||
|
||||
// Values for those objects, by ID
|
||||
values: "=",
|
||||
|
||||
// CSS classes to show for objects, by ID
|
||||
classes: "=",
|
||||
|
||||
// Number of rows to show before autoflowing
|
||||
rows: "=",
|
||||
|
||||
// Time of last update; watched to refresh values
|
||||
updated: "=",
|
||||
|
||||
// Current width of the autoflow column
|
||||
columnWidth: "=",
|
||||
|
||||
// A counter used to trigger display updates
|
||||
counter: "="
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return MCTAutoflowTable;
|
||||
|
||||
}
|
||||
);
|
||||
178
platform/features/autoflow/test/AutoflowTableLinkerSpec.js
Executable file
178
platform/features/autoflow/test/AutoflowTableLinkerSpec.js
Executable file
@@ -0,0 +1,178 @@
|
||||
|
||||
define(
|
||||
["../src/AutoflowTableLinker"],
|
||||
function (AutoflowTableLinker) {
|
||||
|
||||
describe("The mct-autoflow-table linker", function () {
|
||||
var cachedAngular,
|
||||
mockAngular,
|
||||
mockScope,
|
||||
mockElement,
|
||||
mockElements,
|
||||
linker;
|
||||
|
||||
// Utility function to generate more mock elements
|
||||
function createMockElement(html) {
|
||||
var mockEl = jasmine.createSpyObj(
|
||||
"element-" + html,
|
||||
[
|
||||
"append",
|
||||
"addClass",
|
||||
"removeClass",
|
||||
"text",
|
||||
"attr",
|
||||
"html",
|
||||
"css",
|
||||
"find"
|
||||
]
|
||||
);
|
||||
mockEl.testHtml = html;
|
||||
mockEl.append.andReturn(mockEl);
|
||||
mockElements.push(mockEl);
|
||||
return mockEl;
|
||||
}
|
||||
|
||||
function createMockDomainObject(id) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject-" + id,
|
||||
["getId", "getModel"]
|
||||
);
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn({name: id.toUpperCase()});
|
||||
return mockDomainObject;
|
||||
}
|
||||
|
||||
function fireWatch(watchExpression, value) {
|
||||
mockScope.$watch.calls.forEach(function (call) {
|
||||
if (call.args[0] === watchExpression) {
|
||||
call.args[1](value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// AutoflowTableLinker accesses Angular in the global
|
||||
// scope, since it is not injectable; we simulate that
|
||||
// here by adding/removing it to/from the window object.
|
||||
beforeEach(function () {
|
||||
mockElements = [];
|
||||
|
||||
mockAngular = jasmine.createSpyObj("angular", ["element"]);
|
||||
mockScope = jasmine.createSpyObj("scope", ["$watch"]);
|
||||
mockElement = createMockElement('<div>');
|
||||
|
||||
mockAngular.element.andCallFake(createMockElement);
|
||||
|
||||
if (window.angular !== undefined) {
|
||||
cachedAngular = window.angular;
|
||||
}
|
||||
window.angular = mockAngular;
|
||||
|
||||
linker = new AutoflowTableLinker(mockScope, mockElement);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
if (cachedAngular !== undefined) {
|
||||
window.angular = cachedAngular;
|
||||
} else {
|
||||
delete window.angular;
|
||||
}
|
||||
});
|
||||
|
||||
it("watches for changes in inputs", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"objects",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"rows",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"counter",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("changes structure when domain objects change", function () {
|
||||
// Set up scope
|
||||
mockScope.rows = 4;
|
||||
mockScope.objects = ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
.map(createMockDomainObject);
|
||||
|
||||
// Fire an update to the set of objects
|
||||
fireWatch("objects");
|
||||
|
||||
// Should have rebuilt with two columns of
|
||||
// four and two rows each; first, by clearing...
|
||||
expect(mockElement.html).toHaveBeenCalledWith("");
|
||||
|
||||
// Should have appended two columns...
|
||||
expect(mockElement.append.calls.length).toEqual(2);
|
||||
|
||||
// ...which should have received two and four rows each
|
||||
expect(mockElement.append.calls[0].args[0].append.calls.length)
|
||||
.toEqual(4);
|
||||
expect(mockElement.append.calls[1].args[0].append.calls.length)
|
||||
.toEqual(2);
|
||||
});
|
||||
|
||||
it("updates values", function () {
|
||||
var mockSpans;
|
||||
|
||||
mockScope.objects = ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
.map(createMockDomainObject);
|
||||
mockScope.values = { a: 0 };
|
||||
|
||||
// Fire an update to the set of values
|
||||
fireWatch("objects");
|
||||
fireWatch("updated");
|
||||
|
||||
// Get all created spans
|
||||
mockSpans = mockElements.filter(function (mockElem) {
|
||||
return mockElem.testHtml === '<span>';
|
||||
});
|
||||
|
||||
// First span should be a, should have gotten this value.
|
||||
// This test detects, in particular, WTD-749
|
||||
expect(mockSpans[0].text).toHaveBeenCalledWith('A');
|
||||
expect(mockSpans[1].text).toHaveBeenCalledWith(0);
|
||||
});
|
||||
|
||||
it("listens for changes in column width", function () {
|
||||
var mockUL = createMockElement("<ul>");
|
||||
mockElement.find.andReturn(mockUL);
|
||||
mockScope.columnWidth = 200;
|
||||
fireWatch("columnWidth", mockScope.columnWidth);
|
||||
expect(mockUL.css).toHaveBeenCalledWith("width", "200px");
|
||||
});
|
||||
|
||||
it("updates CSS classes", function () {
|
||||
var mockSpans;
|
||||
|
||||
mockScope.objects = ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
.map(createMockDomainObject);
|
||||
mockScope.values = { a: "a value to find" };
|
||||
mockScope.classes = { a: 'class-a' };
|
||||
|
||||
// Fire an update to the set of values
|
||||
fireWatch("objects");
|
||||
fireWatch("updated");
|
||||
|
||||
// Figure out which span holds the relevant value...
|
||||
mockSpans = mockElements.filter(function (mockElem) {
|
||||
return mockElem.testHtml === '<span>';
|
||||
}).filter(function (mockSpan) {
|
||||
var attrCalls = mockSpan.attr.calls;
|
||||
return attrCalls.some(function (call) {
|
||||
return call.args[0] === 'title' &&
|
||||
call.args[1] === mockScope.values.a;
|
||||
});
|
||||
});
|
||||
|
||||
// ...and make sure it also has had its class applied
|
||||
expect(mockSpans[0].addClass)
|
||||
.toHaveBeenCalledWith(mockScope.classes.a);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
341
platform/features/autoflow/test/AutoflowTabularControllerSpec.js
Executable file
341
platform/features/autoflow/test/AutoflowTabularControllerSpec.js
Executable file
@@ -0,0 +1,341 @@
|
||||
|
||||
define(
|
||||
["../src/AutoflowTabularController"],
|
||||
function (AutoflowTabularController) {
|
||||
|
||||
describe("The autoflow tabular controller", function () {
|
||||
var mockScope,
|
||||
mockTimeout,
|
||||
mockSubscriber,
|
||||
mockDomainObject,
|
||||
mockSubscription,
|
||||
controller;
|
||||
|
||||
// Fire watches that are registered as functions.
|
||||
function fireFnWatches() {
|
||||
mockScope.$watch.calls.forEach(function (call) {
|
||||
if (typeof call.args[0] === 'function') {
|
||||
call.args[1](call.args[0]());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj(
|
||||
"$scope",
|
||||
["$on", "$watch"]
|
||||
);
|
||||
mockTimeout = jasmine.createSpy("$timeout");
|
||||
mockSubscriber = jasmine.createSpyObj(
|
||||
"telemetrySubscriber",
|
||||
["subscribe"]
|
||||
);
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
["getId", "getModel", "getCapability"]
|
||||
);
|
||||
mockSubscription = jasmine.createSpyObj(
|
||||
"subscription",
|
||||
[
|
||||
"unsubscribe",
|
||||
"getTelemetryObjects",
|
||||
"getDomainValue",
|
||||
"getRangeValue"
|
||||
]
|
||||
);
|
||||
|
||||
mockSubscriber.subscribe.andReturn(mockSubscription);
|
||||
mockDomainObject.getModel.andReturn({name: "something"});
|
||||
|
||||
controller = new AutoflowTabularController(
|
||||
mockScope,
|
||||
mockTimeout,
|
||||
mockSubscriber
|
||||
);
|
||||
});
|
||||
|
||||
it("listens for the represented domain object", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"domainObject",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("provides a getter-setter function for filtering", function () {
|
||||
expect(controller.filter()).toEqual("");
|
||||
controller.filter("something");
|
||||
expect(controller.filter()).toEqual("something");
|
||||
});
|
||||
|
||||
it("tracks bounds and adjust number of rows accordingly", function () {
|
||||
// Rows are 15px high, and need room for an 10px slider
|
||||
controller.setBounds({ width: 700, height: 120 });
|
||||
expect(controller.getRows()).toEqual(6); // 110 usable height / 16px
|
||||
controller.setBounds({ width: 700, height: 240 });
|
||||
expect(controller.getRows()).toEqual(14); // 230 usable height / 16px
|
||||
});
|
||||
|
||||
it("subscribes to a represented object's telemetry", function () {
|
||||
// Set up subscription, scope
|
||||
mockSubscription.getTelemetryObjects
|
||||
.andReturn([mockDomainObject]);
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
|
||||
// Invoke the watcher with represented domain object
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Should have subscribed to it
|
||||
expect(mockSubscriber.subscribe).toHaveBeenCalledWith(
|
||||
mockDomainObject,
|
||||
jasmine.any(Function)
|
||||
);
|
||||
|
||||
// Should report objects as reported from subscription
|
||||
expect(controller.getTelemetryObjects())
|
||||
.toEqual([mockDomainObject]);
|
||||
});
|
||||
|
||||
it("releases subscriptions on destroy", function () {
|
||||
// Set up subscription...
|
||||
mockSubscription.getTelemetryObjects
|
||||
.andReturn([mockDomainObject]);
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Verify precondition
|
||||
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
|
||||
|
||||
// Make sure we're listening for $destroy
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
"$destroy",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
|
||||
// Fire a destroy event
|
||||
mockScope.$on.mostRecentCall.args[1]();
|
||||
|
||||
// Should have unsubscribed
|
||||
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("presents latest values and latest update state", function () {
|
||||
// Make sure values are available
|
||||
mockSubscription.getDomainValue.andReturn(402654321123);
|
||||
mockSubscription.getRangeValue.andReturn(789);
|
||||
mockDomainObject.getId.andReturn('testId');
|
||||
|
||||
// Set up subscription...
|
||||
mockSubscription.getTelemetryObjects
|
||||
.andReturn([mockDomainObject]);
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Fire subscription callback
|
||||
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
||||
|
||||
// ...and exposed the results for template to consume
|
||||
expect(controller.updated()).toEqual("1982-278 08:25:21.123Z");
|
||||
expect(controller.rangeValues().testId).toEqual(789);
|
||||
});
|
||||
|
||||
it("sorts domain objects by index", function () {
|
||||
var testIndexes = { a: 2, b: 1, c: 3, d: 0 },
|
||||
mockDomainObjects = Object.keys(testIndexes).sort().map(function (id) {
|
||||
var mockDomainObj = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
["getId", "getModel"]
|
||||
);
|
||||
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn({ index: testIndexes[id] });
|
||||
|
||||
return mockDomainObj;
|
||||
});
|
||||
|
||||
// Expose those domain objects...
|
||||
mockSubscription.getTelemetryObjects.andReturn(mockDomainObjects);
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
// Fire subscription callback
|
||||
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
||||
|
||||
// Controller should expose same objects, but sorted by index from model
|
||||
expect(controller.getTelemetryObjects()).toEqual([
|
||||
mockDomainObjects[3], // d, index=0
|
||||
mockDomainObjects[1], // b, index=1
|
||||
mockDomainObjects[0], // a, index=2
|
||||
mockDomainObjects[2] // c, index=3
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses a timeout to throttle update", function () {
|
||||
// Set up subscription...
|
||||
mockSubscription.getTelemetryObjects
|
||||
.andReturn([mockDomainObject]);
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
|
||||
// Set the object in view; should not need a timeout
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockTimeout.calls.length).toEqual(0);
|
||||
|
||||
// Next call should schedule an update on a timeout
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockTimeout.calls.length).toEqual(1);
|
||||
|
||||
// ...but this last one should not, since existing
|
||||
// timeout will cover it
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockTimeout.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it("allows changing column width", function () {
|
||||
var initialWidth = controller.columnWidth();
|
||||
controller.increaseColumnWidth();
|
||||
expect(controller.columnWidth()).toBeGreaterThan(initialWidth);
|
||||
});
|
||||
|
||||
describe("filter", function () {
|
||||
var doFilter,
|
||||
filteredObjects,
|
||||
filteredObjectNames;
|
||||
|
||||
beforeEach(function () {
|
||||
var telemetryObjects,
|
||||
updateFilteredObjects;
|
||||
|
||||
telemetryObjects = [
|
||||
'DEF123',
|
||||
'abc789',
|
||||
'456abc',
|
||||
'4ab3cdef',
|
||||
'hjs[12].*(){}^\\'
|
||||
].map(function (objectName, index) {
|
||||
var mockTelemetryObject = jasmine.createSpyObj(
|
||||
objectName,
|
||||
["getId", "getModel"]
|
||||
);
|
||||
|
||||
mockTelemetryObject.getId.andReturn(objectName);
|
||||
mockTelemetryObject.getModel.andReturn({
|
||||
name: objectName,
|
||||
index: index
|
||||
});
|
||||
|
||||
return mockTelemetryObject;
|
||||
});
|
||||
|
||||
mockSubscription
|
||||
.getTelemetryObjects
|
||||
.andReturn(telemetryObjects);
|
||||
|
||||
// Trigger domainObject change to create subscription.
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
|
||||
updateFilteredObjects = function () {
|
||||
filteredObjects = controller.getTelemetryObjects();
|
||||
filteredObjectNames = filteredObjects.map(function (o) {
|
||||
return o.getModel().name;
|
||||
});
|
||||
};
|
||||
|
||||
doFilter = function (term) {
|
||||
controller.filter(term);
|
||||
// Filter is debounced so we have to force it to occur.
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
updateFilteredObjects();
|
||||
};
|
||||
|
||||
updateFilteredObjects();
|
||||
});
|
||||
|
||||
it("initially shows all objects", function () {
|
||||
expect(filteredObjectNames).toEqual([
|
||||
'DEF123',
|
||||
'abc789',
|
||||
'456abc',
|
||||
'4ab3cdef',
|
||||
'hjs[12].*(){}^\\'
|
||||
]);
|
||||
});
|
||||
|
||||
it("by blank string matches all objects", function () {
|
||||
doFilter('');
|
||||
expect(filteredObjectNames).toEqual([
|
||||
'DEF123',
|
||||
'abc789',
|
||||
'456abc',
|
||||
'4ab3cdef',
|
||||
'hjs[12].*(){}^\\'
|
||||
]);
|
||||
});
|
||||
|
||||
it("exactly matches an object name", function () {
|
||||
doFilter('4ab3cdef');
|
||||
expect(filteredObjectNames).toEqual(['4ab3cdef']);
|
||||
});
|
||||
|
||||
it("partially matches object names", function () {
|
||||
doFilter('abc');
|
||||
expect(filteredObjectNames).toEqual([
|
||||
'abc789',
|
||||
'456abc'
|
||||
]);
|
||||
});
|
||||
|
||||
it("matches case insensitive names", function () {
|
||||
doFilter('def');
|
||||
expect(filteredObjectNames).toEqual([
|
||||
'DEF123',
|
||||
'4ab3cdef'
|
||||
]);
|
||||
});
|
||||
|
||||
it("works as expected with special characters", function () {
|
||||
doFilter('[12]');
|
||||
expect(filteredObjectNames).toEqual(['hjs[12].*(){}^\\']);
|
||||
doFilter('.*');
|
||||
expect(filteredObjectNames).toEqual(['hjs[12].*(){}^\\']);
|
||||
doFilter('.*()');
|
||||
expect(filteredObjectNames).toEqual(['hjs[12].*(){}^\\']);
|
||||
doFilter('.*?');
|
||||
expect(filteredObjectNames).toEqual([]);
|
||||
doFilter('.+');
|
||||
expect(filteredObjectNames).toEqual([]);
|
||||
});
|
||||
|
||||
it("exposes CSS classes from limits", function () {
|
||||
var id = mockDomainObject.getId(),
|
||||
testClass = "some-css-class",
|
||||
mockLimitCapability =
|
||||
jasmine.createSpyObj('limit', ['evaluate']);
|
||||
|
||||
mockDomainObject.getCapability.andCallFake(function (key) {
|
||||
return key === 'limit' && mockLimitCapability;
|
||||
});
|
||||
mockLimitCapability.evaluate
|
||||
.andReturn({ cssClass: testClass });
|
||||
|
||||
mockSubscription.getTelemetryObjects
|
||||
.andReturn([mockDomainObject]);
|
||||
|
||||
fireFnWatches();
|
||||
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
||||
|
||||
expect(controller.classes()[id]).toEqual(testClass);
|
||||
});
|
||||
|
||||
it("exposes a counter that changes with each update", function () {
|
||||
var i, prior;
|
||||
|
||||
for (i = 0; i < 10; i += 1) {
|
||||
prior = controller.counter();
|
||||
expect(controller.counter()).toEqual(prior);
|
||||
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
||||
expect(controller.counter()).not.toEqual(prior);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
39
platform/features/autoflow/test/MCTAutoflowTableSpec.js
Executable file
39
platform/features/autoflow/test/MCTAutoflowTableSpec.js
Executable file
@@ -0,0 +1,39 @@
|
||||
|
||||
define(
|
||||
["../src/MCTAutoflowTable"],
|
||||
function (MCTAutoflowTable) {
|
||||
|
||||
describe("The mct-autoflow-table directive", function () {
|
||||
var mctAutoflowTable;
|
||||
|
||||
beforeEach(function () {
|
||||
mctAutoflowTable = new MCTAutoflowTable();
|
||||
});
|
||||
|
||||
// Real functionality is contained/tested in the linker,
|
||||
// so just check to make sure we're exposing the directive
|
||||
// appropriately.
|
||||
it("is applicable at the element level", function () {
|
||||
expect(mctAutoflowTable.restrict).toEqual("E");
|
||||
});
|
||||
|
||||
it("two-ways binds needed scope variables", function () {
|
||||
expect(mctAutoflowTable.scope).toEqual({
|
||||
objects: "=",
|
||||
values: "=",
|
||||
rows: "=",
|
||||
updated: "=",
|
||||
classes: "=",
|
||||
columnWidth: "=",
|
||||
counter: "="
|
||||
});
|
||||
});
|
||||
|
||||
it("provides a link function", function () {
|
||||
expect(mctAutoflowTable.link).toEqual(jasmine.any(Function));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -136,7 +136,7 @@ define([
|
||||
],
|
||||
"category": "contextual",
|
||||
"name": "Start",
|
||||
"cssclass": "icon-play",
|
||||
"cssClass": "icon-play",
|
||||
"priority": "preferred"
|
||||
},
|
||||
{
|
||||
@@ -147,7 +147,7 @@ define([
|
||||
],
|
||||
"category": "contextual",
|
||||
"name": "Restart at 0",
|
||||
"cssclass": "icon-refresh",
|
||||
"cssClass": "icon-refresh",
|
||||
"priority": "preferred"
|
||||
}
|
||||
],
|
||||
@@ -155,7 +155,7 @@ define([
|
||||
{
|
||||
"key": "clock",
|
||||
"name": "Clock",
|
||||
"cssclass": "icon-clock",
|
||||
"cssClass": "icon-clock",
|
||||
"description": "A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts.",
|
||||
"priority": 101,
|
||||
"features": [
|
||||
@@ -183,7 +183,7 @@ define([
|
||||
"name": "hh:mm:ss"
|
||||
}
|
||||
],
|
||||
"cssclass": "l-inline"
|
||||
"cssClass": "l-inline"
|
||||
},
|
||||
{
|
||||
"control": "select",
|
||||
@@ -197,7 +197,7 @@ define([
|
||||
"name": "24hr"
|
||||
}
|
||||
],
|
||||
"cssclass": "l-inline"
|
||||
"cssClass": "l-inline"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -212,7 +212,7 @@ define([
|
||||
{
|
||||
"key": "timer",
|
||||
"name": "Timer",
|
||||
"cssclass": "icon-timer",
|
||||
"cssClass": "icon-timer",
|
||||
"description": "A timer that counts up or down to a datetime. Timers can be started, stopped and reset whenever needed, and support a variety of display formats. Each Timer displays the same value to all users. Timers can be added to Display Layouts.",
|
||||
"priority": 100,
|
||||
"features": [
|
||||
|
||||
@@ -131,11 +131,11 @@ define(
|
||||
/**
|
||||
* Get the CSS class to display the right icon
|
||||
* for the start/restart button.
|
||||
* @returns {string} cssclass to display
|
||||
* @returns {string} cssClass to display
|
||||
*/
|
||||
TimerController.prototype.buttonCssClass = function () {
|
||||
return this.relevantAction ?
|
||||
this.relevantAction.getMetadata().cssclass : "";
|
||||
this.relevantAction.getMetadata().cssClass : "";
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user