Compare commits
12 Commits
eagle-spri
...
summary-wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c869b42982 | ||
|
|
0a4879d938 | ||
|
|
7d8987422d | ||
|
|
761064f487 | ||
|
|
9f640c24fb | ||
|
|
5e3ca00b2a | ||
|
|
1283c1a4c7 | ||
|
|
41e9e97a71 | ||
|
|
27eabdd867 | ||
|
|
2ebb5d2cf0 | ||
|
|
9a537e2e0d | ||
|
|
8eec5062b4 |
@@ -21,6 +21,5 @@
|
||||
"shadow": "outer",
|
||||
"strict": "implied",
|
||||
"undef": true,
|
||||
"unused": "vars",
|
||||
"latedef": "nofunc"
|
||||
"unused": "vars"
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ and [`gulp`](http://gulpjs.com/).
|
||||
|
||||
To build Open MCT for deployment:
|
||||
|
||||
`npm run prepare`
|
||||
`npm run prepublish`
|
||||
|
||||
This will compile and minify JavaScript sources, as well as copy over assets.
|
||||
The contents of the `dist` folder will contain a runnable Open MCT
|
||||
|
||||
10
circle.yml
10
circle.yml
@@ -1,11 +1,3 @@
|
||||
machine:
|
||||
node:
|
||||
version: 4.7.0
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
- npm install -g npm@latest
|
||||
|
||||
deployment:
|
||||
production:
|
||||
branch: master
|
||||
@@ -24,4 +16,4 @@ test:
|
||||
general:
|
||||
branches:
|
||||
ignore:
|
||||
- gh-pages
|
||||
- gh-pages
|
||||
|
||||
@@ -2283,7 +2283,7 @@ To install build dependencies (only needs to be run once):
|
||||
|
||||
To build:
|
||||
|
||||
`npm run prepare`
|
||||
`npm run prepublish`
|
||||
|
||||
This will compile and minify JavaScript sources, as well as copy over assets.
|
||||
The contents of the `dist` folder will contain a runnable Open MCT
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
# Security Guide
|
||||
|
||||
Open MCT is a rich client with plugin support that executes as a single page
|
||||
web application in a browser environment. Security concerns and
|
||||
vulnerabilities associated with the web as a platform should be considered
|
||||
before deploying Open MCT (or any other web application) for mission or
|
||||
production usage.
|
||||
|
||||
This document describes several important points to consider when developing
|
||||
for or deploying Open MCT securely. Other resources such as
|
||||
[Open Web Application Security Project (OWASP)](https://www.owasp.org)
|
||||
provide a deeper and more general overview of security for web applications.
|
||||
|
||||
|
||||
## Security Model
|
||||
|
||||
Open MCT has been architected assuming the following deployment pattern:
|
||||
|
||||
* A tagged, tested Open MCT version will be used.
|
||||
* Externally authored plugins will be installed.
|
||||
* A server will provide persistent storage, telemetry, and other shared data.
|
||||
* Authorization, authentication, and auditing will be handled by a server.
|
||||
|
||||
|
||||
## Security Procedures
|
||||
|
||||
The Open MCT team secures our code base using a combination of code review,
|
||||
dependency review, and periodic security reviews. Static analysis performed
|
||||
during automated verification additionally safeguards against common
|
||||
coding errors which may result in vulnerabilities.
|
||||
|
||||
|
||||
### Code Review
|
||||
|
||||
All contributions are reviewed by internal team members. External
|
||||
contributors receive increased scrutiny for security and quality,
|
||||
and must sign a licensing agreement.
|
||||
|
||||
### Dependency Review
|
||||
|
||||
Before integrating third-party dependencies, they are reviewed for security
|
||||
and quality, with consideration given to authors and users of these
|
||||
dependencies, as well as review of open source code.
|
||||
|
||||
### Periodic Security Reviews
|
||||
|
||||
Open MCT's code, design, and architecture are periodically reviewed
|
||||
(approximately annually) for common security issues, such as the
|
||||
[OWASP Top Ten](https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project).
|
||||
|
||||
|
||||
## Security Concerns
|
||||
|
||||
Certain security concerns deserve special attention when deploying Open MCT,
|
||||
or when authoring plugins.
|
||||
|
||||
### Identity Spoofing
|
||||
|
||||
Open MCT issues calls to web services with the privileges of a logged in user.
|
||||
Compromised sources (either for Open MCT itself or a plugin) could
|
||||
therefore allow malicious code to execute with those privileges.
|
||||
|
||||
To avoid this:
|
||||
|
||||
* Serve Open MCT and other scripts over SSL (https rather than http)
|
||||
to prevent man-in-the-middle attacks.
|
||||
* Exercise precautions such as security reviews for any plugins or
|
||||
applications built for or with Open MCT to reject malicious changes.
|
||||
|
||||
### Information Disclosure
|
||||
|
||||
If Open MCT is used to handle or display sensitive data, any components
|
||||
(such as adapter plugins) must take care to avoid leaking or disclosing
|
||||
this information. For example, avoid sending sensitive data to third-party
|
||||
servers or insecure APIs.
|
||||
|
||||
### Data Tampering
|
||||
|
||||
The web application architecture leaves open the possibility that direct
|
||||
calls will be made to back-end services, circumventing Open MCT entirely.
|
||||
As such, Open MCT assumes that server components will perform any necessary
|
||||
data validation during calls issues to the server.
|
||||
|
||||
Additionally, plugins which serialize and write data to the server must
|
||||
escape that data to avoid database injection attacks, and similar.
|
||||
|
||||
### Repudiation
|
||||
|
||||
Open MCT assumes that servers log any relevant interactions and associates
|
||||
these with a user identity; the specific user actions taken within the
|
||||
application are assumed not to be of concern for auditing.
|
||||
|
||||
In the absence of server-side logging, users may disclaim (maliciously,
|
||||
mistakenly, or otherwise) actions taken within the system without any
|
||||
way to prove otherwise.
|
||||
|
||||
If keeping client-level interactions is important, this will need to be
|
||||
implemented via a plugin.
|
||||
|
||||
### Denial-of-service
|
||||
|
||||
Open MCT assumes that server-side components will be insulated against
|
||||
denial-of-service attacks. Services should only permit resource-intensive
|
||||
tasks to be initiated by known or trusted users.
|
||||
|
||||
### Elevation of Privilege
|
||||
|
||||
Corollary to the assumption that servers guide against identity spoofing,
|
||||
Open MCT assumes that services do not allow a user to act with
|
||||
inappropriately escalated privileges. Open MCT cannot protect against
|
||||
such escalation; in the clearest case, a malicious actor could interact
|
||||
with web services directly to exploit such a vulnerability.
|
||||
|
||||
## Additional Reading
|
||||
|
||||
The following resources have been used as a basis for identifying potential
|
||||
security threats to Open MCT deployments in preparation of this document:
|
||||
|
||||
* [STRIDE model](https://www.owasp.org/index.php/Threat_Risk_Modeling#STRIDE)
|
||||
* [Attack Surface Analysis Cheat Sheet](https://www.owasp.org/index.php/Attack_Surface_Analysis_Cheat_Sheet)
|
||||
* [XSS Prevention Cheat Sheet](https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet)
|
||||
@@ -215,6 +215,8 @@ define([
|
||||
{
|
||||
key: "sin",
|
||||
name: "Sine",
|
||||
format: 'printf',
|
||||
sprintf: '%0.2f',
|
||||
hints: {
|
||||
range: 1
|
||||
}
|
||||
@@ -222,6 +224,8 @@ define([
|
||||
{
|
||||
key: "cos",
|
||||
name: "Cosine",
|
||||
format: 'printf',
|
||||
sprintf: '%0.2f',
|
||||
hints: {
|
||||
range: 2
|
||||
}
|
||||
|
||||
146
example/plotOptions/bundle.js
Normal file
146
example/plotOptions/bundle.js
Normal file
@@ -0,0 +1,146 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2017, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
'legacyRegistry',
|
||||
'../../platform/commonUI/browse/src/InspectorRegion',
|
||||
'../../platform/commonUI/regions/src/Region'
|
||||
], function (
|
||||
legacyRegistry,
|
||||
InspectorRegion,
|
||||
Region
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Add a 'plot options' region part to the inspector region for the
|
||||
* Telemetry Plot type only. {@link InspectorRegion} is a default region
|
||||
* implementation that is added automatically to all types. In order to
|
||||
* customize what appears in the inspector region, you can start from a
|
||||
* blank slate by using Region, or customize the default inspector
|
||||
* region by using {@link InspectorRegion}.
|
||||
*/
|
||||
var plotInspector = new InspectorRegion(),
|
||||
/**
|
||||
* Two region parts are defined here. One that appears only in browse
|
||||
* mode, and one that appears only in edit mode. For not they both point
|
||||
* to the same representation, but a different key could be used here to
|
||||
* include a customized representation for edit mode.
|
||||
*/
|
||||
plotOptionsBrowseRegion = new Region({
|
||||
name: "plot-options",
|
||||
title: "Plot Options",
|
||||
modes: ['browse'],
|
||||
content: {
|
||||
key: "plot-options-browse"
|
||||
}
|
||||
}),
|
||||
plotOptionsEditRegion = new Region({
|
||||
name: "plot-options",
|
||||
title: "Plot Options",
|
||||
modes: ['edit'],
|
||||
content: {
|
||||
key: "plot-options-browse"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Both parts are added, and policies of type 'region' will determine
|
||||
* which is shown based on domain object state. A default policy is
|
||||
* provided which will check the 'modes' attribute of the region part
|
||||
* definition.
|
||||
*/
|
||||
plotInspector.addRegion(plotOptionsBrowseRegion);
|
||||
plotInspector.addRegion(plotOptionsEditRegion);
|
||||
|
||||
legacyRegistry.register("example/plotType", {
|
||||
"name": "Plot Type",
|
||||
"description": "Example illustrating registration of a new object type",
|
||||
"extensions": {
|
||||
"types": [
|
||||
{
|
||||
"key": "plot",
|
||||
"name": "Example Telemetry Plot",
|
||||
"cssClass": "icon-telemetry-panel",
|
||||
"description": "For development use. A plot for displaying telemetry.",
|
||||
"priority": 10,
|
||||
"delegates": [
|
||||
"telemetry"
|
||||
],
|
||||
"features": "creation",
|
||||
"contains": [
|
||||
{
|
||||
"has": "telemetry"
|
||||
}
|
||||
],
|
||||
"model": {
|
||||
"composition": []
|
||||
},
|
||||
"inspector": plotInspector,
|
||||
"telemetry": {
|
||||
"source": "generator",
|
||||
"domains": [
|
||||
{
|
||||
"key": "time",
|
||||
"name": "Time"
|
||||
},
|
||||
{
|
||||
"key": "yesterday",
|
||||
"name": "Yesterday"
|
||||
},
|
||||
{
|
||||
"key": "delta",
|
||||
"name": "Delta",
|
||||
"format": "example.delta"
|
||||
}
|
||||
],
|
||||
"ranges": [
|
||||
{
|
||||
"key": "sin",
|
||||
"name": "Sine"
|
||||
},
|
||||
{
|
||||
"key": "cos",
|
||||
"name": "Cosine"
|
||||
}
|
||||
]
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"name": "Period",
|
||||
"control": "textfield",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "period",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"period"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
/*global require,__dirname*/
|
||||
|
||||
require("v8-compile-cache");
|
||||
|
||||
var gulp = require('gulp'),
|
||||
sourcemaps = require('gulp-sourcemaps'),
|
||||
path = require('path'),
|
||||
@@ -179,4 +177,4 @@ gulp.task('install', [ 'assets', 'scripts' ]);
|
||||
|
||||
gulp.task('verify', [ 'lint', 'test', 'checkstyle' ]);
|
||||
|
||||
gulp.task('build', [ 'verify', 'install' ]);
|
||||
gulp.task('build', [ 'verify', 'install' ]);
|
||||
|
||||
@@ -37,13 +37,14 @@ module.exports = function(config) {
|
||||
{pattern: 'bower_components/**/*.js', included: false},
|
||||
{pattern: 'node_modules/d3-*/**/*.js', included: false},
|
||||
{pattern: 'node_modules/vue/**/*.js', included: false},
|
||||
{pattern: 'src/**/*', included: false},
|
||||
{pattern: 'src/**/*.js', included: false},
|
||||
{pattern: 'example/**/*.html', included: false},
|
||||
{pattern: 'example/**/*.js', included: false},
|
||||
{pattern: 'example/**/*.json', included: false},
|
||||
{pattern: 'platform/**/*.js', included: false},
|
||||
{pattern: 'warp/**/*.js', included: false},
|
||||
{pattern: 'platform/**/*.html', included: false},
|
||||
{pattern: 'src/**/*.html', included: false},
|
||||
'test-main.js'
|
||||
],
|
||||
|
||||
@@ -88,8 +89,7 @@ module.exports = function(config) {
|
||||
"dist/reports/coverage",
|
||||
check: {
|
||||
global: {
|
||||
lines: 80,
|
||||
excludes: ['src/plugins/plot/**/*.js']
|
||||
lines: 80
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ requirejs.config({
|
||||
"vue": "node_modules/vue/dist/vue.min",
|
||||
"zepto": "bower_components/zepto/zepto.min",
|
||||
"lodash": "bower_components/lodash/lodash",
|
||||
"d3-selection": "node_modules/d3-selection/dist/d3-selection.min",
|
||||
"d3-selection": "node_modules/d3-selection/build/d3-selection.min",
|
||||
"d3-scale": "node_modules/d3-scale/build/d3-scale.min",
|
||||
"d3-axis": "node_modules/d3-axis/build/d3-axis.min",
|
||||
"d3-array": "node_modules/d3-array/build/d3-array.min",
|
||||
@@ -49,7 +49,8 @@ requirejs.config({
|
||||
"d3-format": "node_modules/d3-format/build/d3-format.min",
|
||||
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
|
||||
"d3-time": "node_modules/d3-time/build/d3-time.min",
|
||||
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min"
|
||||
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
|
||||
"printj": "node_modules/printj/dist/printj.min"
|
||||
},
|
||||
"shim": {
|
||||
"angular": {
|
||||
@@ -101,7 +102,6 @@ define([
|
||||
var openmct = new MCT();
|
||||
|
||||
openmct.legacyRegistry = defaultRegistry;
|
||||
openmct.install(openmct.plugins.Plot());
|
||||
|
||||
if (typeof BUILD_CONSTANTS !== 'undefined') {
|
||||
openmct.install(buildInfo(BUILD_CONSTANTS));
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openmct",
|
||||
"version": "0.13.3-SNAPSHOT",
|
||||
"version": "0.12.1-SNAPSHOT",
|
||||
"description": "The Open MCT core platform",
|
||||
"dependencies": {
|
||||
"d3-array": "^1.0.2",
|
||||
@@ -28,7 +28,7 @@
|
||||
"gulp-jshint-html-reporter": "^0.1.3",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-requirejs-optimize": "^0.3.1",
|
||||
"gulp-sass": "^3.1.0",
|
||||
"gulp-sass": "^2.2.0",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"jasmine-core": "^2.3.0",
|
||||
"jscs-html-reporter": "^0.1.0",
|
||||
@@ -49,9 +49,9 @@
|
||||
"mkdirp": "^0.5.1",
|
||||
"moment": "^2.11.1",
|
||||
"node-bourbon": "^4.2.3",
|
||||
"printj": "^1.1.0",
|
||||
"requirejs": "2.1.x",
|
||||
"split": "^1.0.0",
|
||||
"v8-compile-cache": "^1.1.0"
|
||||
"split": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
@@ -61,7 +61,7 @@
|
||||
"jsdoc": "jsdoc -c jsdoc.json -R API.md -r -d dist/docs/api",
|
||||
"otherdoc": "node docs/gendocs.js --in docs/src --out dist/docs --suppress-toc 'docs/src/index.md|docs/src/process/index.md'",
|
||||
"docs": "npm run jsdoc ; npm run otherdoc",
|
||||
"prepare": "node ./node_modules/bower/bin/bower install && node ./node_modules/gulp/bin/gulp.js install"
|
||||
"prepublish": "node ./node_modules/bower/bin/bower install && node ./node_modules/gulp/bin/gulp.js install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
ng-class="{ last:($index + 1) === contextualParents.length }">
|
||||
<mct-representation key="'label'"
|
||||
mct-object="parent"
|
||||
ng-click="parent.getCapability('action').perform('navigate')"
|
||||
class="location-item">
|
||||
</mct-representation>
|
||||
</span>
|
||||
@@ -50,7 +49,6 @@
|
||||
ng-class="{ last:($index + 1) === primaryParents.length }">
|
||||
<mct-representation key="'label'"
|
||||
mct-object="parent"
|
||||
ng-click="parent.getCapability('action').perform('navigate')"
|
||||
class="location-item">
|
||||
</mct-representation>
|
||||
</span>
|
||||
|
||||
@@ -28,6 +28,16 @@ define(
|
||||
[],
|
||||
function () {
|
||||
|
||||
function isDirty(domainObject) {
|
||||
var navigatedObject = domainObject,
|
||||
editorCapability = navigatedObject &&
|
||||
navigatedObject.getCapability("editor");
|
||||
|
||||
return editorCapability &&
|
||||
editorCapability.isEditContextRoot() &&
|
||||
editorCapability.dirty();
|
||||
}
|
||||
|
||||
function cancelEditing(domainObject) {
|
||||
var navigatedObject = domainObject,
|
||||
editorCapability = navigatedObject &&
|
||||
@@ -49,7 +59,10 @@ define(
|
||||
|
||||
var removeCheck = navigationService
|
||||
.checkBeforeNavigation(function () {
|
||||
return "Continuing will cause the loss of any unsaved changes.";
|
||||
if (isDirty(domainObject)) {
|
||||
return "Continuing will cause the loss of any unsaved changes.";
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
|
||||
@@ -52,22 +52,8 @@ define(
|
||||
}
|
||||
|
||||
function setSelection(selection) {
|
||||
if (!selection[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.mutationListener) {
|
||||
self.mutationListener();
|
||||
delete self.mutationListener;
|
||||
}
|
||||
|
||||
var domainObject = selection[0].context.oldItem;
|
||||
self.refreshComposition(domainObject);
|
||||
|
||||
if (domainObject) {
|
||||
self.mutationListener = domainObject.getCapability('mutation')
|
||||
.listen(self.refreshComposition.bind(self, domainObject));
|
||||
}
|
||||
self.scope.selection = selection;
|
||||
self.refreshComposition(selection);
|
||||
}
|
||||
|
||||
$scope.filterBy = filterBy;
|
||||
@@ -84,19 +70,19 @@ define(
|
||||
/**
|
||||
* Gets the composition for the selected object and populates the scope with it.
|
||||
*
|
||||
* @param domainObject the selected object
|
||||
* @param selection the selection object
|
||||
* @private
|
||||
*/
|
||||
ElementsController.prototype.refreshComposition = function (domainObject) {
|
||||
var refreshTracker = {};
|
||||
this.currentRefresh = refreshTracker;
|
||||
ElementsController.prototype.refreshComposition = function (selection) {
|
||||
if (!selection[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedObjectComposition = selection[0].context.oldItem.useCapability('composition');
|
||||
|
||||
var selectedObjectComposition = domainObject && domainObject.useCapability('composition');
|
||||
if (selectedObjectComposition) {
|
||||
selectedObjectComposition.then(function (composition) {
|
||||
if (this.currentRefresh === refreshTracker) {
|
||||
this.scope.composition = composition;
|
||||
}
|
||||
this.scope.composition = composition;
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.scope.composition = [];
|
||||
|
||||
@@ -44,17 +44,11 @@ define(
|
||||
this.selectedObj = undefined;
|
||||
|
||||
openmct.selection.on('change', function (selection) {
|
||||
var selected = selection[0];
|
||||
|
||||
if (selected && selected.context.toolbar) {
|
||||
this.select(selected.context.toolbar);
|
||||
if (selection[0] && selection[0].context.toolbar) {
|
||||
this.select(selection[0].context.toolbar);
|
||||
} else {
|
||||
this.deselect();
|
||||
}
|
||||
|
||||
if (selected && selected.context.viewProxy) {
|
||||
this.proxy(selected.context.viewProxy);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -104,10 +104,10 @@ define(
|
||||
mockEditorCapability.isEditContextRoot.andReturn(false);
|
||||
mockEditorCapability.dirty.andReturn(false);
|
||||
|
||||
expect(checkFn()).toBe("Continuing will cause the loss of any unsaved changes.");
|
||||
expect(checkFn()).toBe(false);
|
||||
|
||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||
expect(checkFn()).toBe("Continuing will cause the loss of any unsaved changes.");
|
||||
expect(checkFn()).toBe(false);
|
||||
|
||||
mockEditorCapability.dirty.andReturn(true);
|
||||
expect(checkFn())
|
||||
|
||||
@@ -29,48 +29,9 @@ define(
|
||||
var mockScope,
|
||||
mockOpenMCT,
|
||||
mockSelection,
|
||||
mockDomainObject,
|
||||
mockMutationCapability,
|
||||
mockCompositionCapability,
|
||||
mockCompositionObjects,
|
||||
mockComposition,
|
||||
mockUnlisten,
|
||||
selectable = [],
|
||||
controller;
|
||||
|
||||
function mockPromise(value) {
|
||||
return {
|
||||
then: function (thenFunc) {
|
||||
return mockPromise(thenFunc(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createDomainObject() {
|
||||
return {
|
||||
useCapability: function () {
|
||||
return mockCompositionCapability;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockComposition = ["a", "b"];
|
||||
mockCompositionObjects = mockComposition.map(createDomainObject);
|
||||
mockCompositionCapability = mockPromise(mockCompositionObjects);
|
||||
|
||||
mockUnlisten = jasmine.createSpy('unlisten');
|
||||
mockMutationCapability = jasmine.createSpyObj("mutationCapability", [
|
||||
"listen"
|
||||
]);
|
||||
mockMutationCapability.listen.andReturn(mockUnlisten);
|
||||
mockDomainObject = jasmine.createSpyObj("domainObject", [
|
||||
"getCapability",
|
||||
"useCapability"
|
||||
]);
|
||||
mockDomainObject.useCapability.andReturn(mockCompositionCapability);
|
||||
mockDomainObject.getCapability.andReturn(mockMutationCapability);
|
||||
|
||||
mockScope = jasmine.createSpyObj("$scope", ['$on']);
|
||||
mockSelection = jasmine.createSpyObj("selection", [
|
||||
'on',
|
||||
@@ -82,14 +43,6 @@ define(
|
||||
selection: mockSelection
|
||||
};
|
||||
|
||||
selectable[0] = {
|
||||
context: {
|
||||
oldItem: mockDomainObject
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(ElementsController.prototype, 'refreshComposition').andCallThrough();
|
||||
|
||||
controller = new ElementsController(mockScope, mockOpenMCT);
|
||||
});
|
||||
|
||||
@@ -122,63 +75,6 @@ define(
|
||||
expect(objects.filter(mockScope.searchElements).length).toBe(4);
|
||||
});
|
||||
|
||||
it("refreshes composition on selection", function () {
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(ElementsController.prototype.refreshComposition).toHaveBeenCalledWith(mockDomainObject);
|
||||
});
|
||||
|
||||
it("listens on mutation and refreshes composition", function () {
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(mockDomainObject.getCapability).toHaveBeenCalledWith('mutation');
|
||||
expect(mockMutationCapability.listen).toHaveBeenCalled();
|
||||
expect(ElementsController.prototype.refreshComposition.calls.length).toBe(1);
|
||||
|
||||
mockMutationCapability.listen.mostRecentCall.args[0](mockDomainObject);
|
||||
|
||||
expect(ElementsController.prototype.refreshComposition.calls.length).toBe(2);
|
||||
});
|
||||
|
||||
it("cleans up mutation listener when selection changes", function () {
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(mockMutationCapability.listen).toHaveBeenCalled();
|
||||
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(mockUnlisten).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not listen on mutation for element proxy selectable", function () {
|
||||
selectable[0] = {
|
||||
context: {
|
||||
elementProxy: {}
|
||||
}
|
||||
};
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(mockDomainObject.getCapability).not.toHaveBeenCalledWith('mutation');
|
||||
});
|
||||
|
||||
it("checks concurrent changes to composition", function () {
|
||||
var secondMockComposition = ["a", "b", "c"],
|
||||
secondMockCompositionObjects = secondMockComposition.map(createDomainObject),
|
||||
firstCompositionCallback,
|
||||
secondCompositionCallback;
|
||||
|
||||
spyOn(mockCompositionCapability, "then").andCallThrough();
|
||||
|
||||
controller.refreshComposition(mockDomainObject);
|
||||
controller.refreshComposition(mockDomainObject);
|
||||
|
||||
firstCompositionCallback = mockCompositionCapability.then.calls[0].args[0];
|
||||
secondCompositionCallback = mockCompositionCapability.then.calls[1].args[0];
|
||||
secondCompositionCallback(secondMockCompositionObjects);
|
||||
firstCompositionCallback(mockCompositionObjects);
|
||||
|
||||
expect(mockScope.composition).toBe(secondMockCompositionObjects);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -77,14 +77,6 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.s-menu {
|
||||
border-radius: $basicCr;
|
||||
@include containerSubtle($colorMenuBg, $colorMenuFg);
|
||||
@include boxShdw($shdwMenu);
|
||||
@include txtShdw($shdwMenuText);
|
||||
padding: $interiorMarginSm 0;
|
||||
}
|
||||
|
||||
.menu {
|
||||
border-radius: $basicCr;
|
||||
@include containerSubtle($colorMenuBg, $colorMenuFg);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
$ohH: $btnFrameH;
|
||||
$bc: $colorInteriorBorder;
|
||||
&.child-frame.panel {
|
||||
border: 1px solid transparent;
|
||||
z-index: 0; // Needed to prevent child-frame controls from showing through when another child-frame is above
|
||||
&:not(.no-frame) {
|
||||
background: $colorBodyBg;
|
||||
@@ -90,7 +91,7 @@
|
||||
|
||||
&.no-frame {
|
||||
background: transparent !important;
|
||||
border-color: transparent;
|
||||
border: none;
|
||||
.object-browse-bar .right {
|
||||
$m: 0;
|
||||
background: rgba(black, 0.3);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
.s-hover-border {
|
||||
border: 1px solid transparent;
|
||||
&:hover {
|
||||
border-color: rgba($colorSelectableSelectedPrimary, 0.5) !important;
|
||||
}
|
||||
|
||||
@@ -65,10 +65,6 @@ define(
|
||||
options = Object.create(OPTIONS);
|
||||
options.marginX = -bubbleSpaceLR;
|
||||
|
||||
// prevent bubble from appearing right under pointer,
|
||||
// which causes hover callback to be called multiple times
|
||||
options.offsetX = 1;
|
||||
|
||||
// On a phone, bubble takes up more screen real estate,
|
||||
// so position it differently (toward the bottom)
|
||||
if (this.agentService.isPhone()) {
|
||||
|
||||
@@ -50,11 +50,7 @@ define(
|
||||
view.show(container);
|
||||
} else {
|
||||
self.providerView = false;
|
||||
var selectedItem = selection[0].context.oldItem;
|
||||
|
||||
if (selectedItem) {
|
||||
$scope.inspectorKey = selectedItem.getCapability("type").typeDef.inspector;
|
||||
}
|
||||
$scope.inspectorKey = selection[0].context.oldItem.getCapability("type").typeDef.inspector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -272,8 +272,7 @@ define([
|
||||
"$scope",
|
||||
"$q",
|
||||
"dialogService",
|
||||
"openmct",
|
||||
"$element"
|
||||
"openmct"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
ng-controller="FixedController as controller">
|
||||
|
||||
<!-- Background grid -->
|
||||
<div class="l-grid-holder" ng-click="controller.bypassSelection($event)">
|
||||
<div class="l-grid-holder" ng-click="controller.clearSelection()">
|
||||
<div class="l-grid l-grid-x"
|
||||
ng-if="!controller.getGridSize()[0] < 3"
|
||||
ng-style="{ 'background-size': controller.getGridSize() [0] + 'px 100%' }"></div>
|
||||
@@ -35,28 +35,35 @@
|
||||
<!-- Fixed position elements -->
|
||||
<div ng-repeat="element in controller.getElements()"
|
||||
class="l-fixed-position-item s-selectable s-moveable s-hover-border"
|
||||
ng-class="{
|
||||
's-not-selected': controller.selected() && !controller.selected(element),
|
||||
's-selected': controller.selected(element)
|
||||
}"
|
||||
ng-style="element.style"
|
||||
mct-selectable="controller.getContext(element)"
|
||||
mct-init-select="controller.shouldSelect(element)">
|
||||
ng-click="controller.select(element, $event)">
|
||||
<mct-include key="element.template"
|
||||
parameters="{ gridSize: controller.getGridSize() }"
|
||||
ng-model="element">
|
||||
</mct-include>
|
||||
</mct-include>
|
||||
</div>
|
||||
|
||||
<!-- Selection highlight, handles -->
|
||||
<span class="s-selected s-moveable" ng-if="controller.isElementSelected()">
|
||||
<span class="s-selected s-moveable" ng-if="controller.selected()">
|
||||
<div class="l-fixed-position-item t-edit-handle-holder"
|
||||
mct-drag-down="controller.moveHandle().startDrag()"
|
||||
mct-drag-down="controller.moveHandle().startDrag(controller.selected())"
|
||||
mct-drag="controller.moveHandle().continueDrag(delta)"
|
||||
mct-drag-up="controller.endDrag()"
|
||||
ng-style="controller.getSelectedElementStyle()">
|
||||
mct-drag-up="controller.moveHandle().endDrag()"
|
||||
ng-style="controller.selected().style"
|
||||
ng-click="$event.stopPropagation()">
|
||||
</div>
|
||||
<div ng-repeat="handle in controller.handles()"
|
||||
class="l-fixed-position-item-handle edit-corner"
|
||||
ng-style="handle.style()"
|
||||
mct-drag-down="handle.startDrag()"
|
||||
mct-drag="handle.continueDrag(delta)"
|
||||
mct-drag-up="controller.endDrag(handle)">
|
||||
mct-drag-up="handle.endDrag()"
|
||||
ng-click="$event.stopPropagation()">
|
||||
</div>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -47,7 +47,7 @@ define(
|
||||
* @constructor
|
||||
* @param {Scope} $scope the controller's Angular scope
|
||||
*/
|
||||
function FixedController($scope, $q, dialogService, openmct, $element) {
|
||||
function FixedController($scope, $q, dialogService, openmct) {
|
||||
this.names = {}; // Cache names by ID
|
||||
this.values = {}; // Cache values by ID
|
||||
this.elementProxiesById = {};
|
||||
@@ -55,11 +55,9 @@ define(
|
||||
this.telemetryObjects = [];
|
||||
this.subscriptions = [];
|
||||
this.openmct = openmct;
|
||||
this.$element = $element;
|
||||
this.$scope = $scope;
|
||||
|
||||
this.gridSize = $scope.domainObject && $scope.domainObject.getModel().layoutGrid;
|
||||
this.fixedViewSelectable = false;
|
||||
|
||||
var self = this;
|
||||
[
|
||||
@@ -89,8 +87,9 @@ define(
|
||||
|
||||
// Update the style for a selected element
|
||||
function updateSelectionStyle() {
|
||||
if (self.selectedElementProxy) {
|
||||
self.selectedElementProxy.style = convertPosition(self.selectedElementProxy);
|
||||
var element = self.selection && self.selection.get();
|
||||
if (element) {
|
||||
element.style = convertPosition(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,19 +136,25 @@ define(
|
||||
|
||||
// Decorate elements in the current configuration
|
||||
function refreshElements() {
|
||||
var elements = (($scope.configuration || {}).elements || []);
|
||||
// Cache selection; we are instantiating new proxies
|
||||
// so we may want to restore this.
|
||||
var selected = self.selection && self.selection.get(),
|
||||
elements = (($scope.configuration || {}).elements || []),
|
||||
index = -1; // Start with a 'not-found' value
|
||||
|
||||
// Find the selection in the new array
|
||||
if (selected !== undefined) {
|
||||
index = elements.indexOf(selected.element);
|
||||
}
|
||||
|
||||
// Create the new proxies...
|
||||
self.elementProxies = elements.map(makeProxyElement);
|
||||
|
||||
// If selection is not in array, select parent.
|
||||
// Otherwise, set the element to select after refresh.
|
||||
if (self.selectedElementProxy) {
|
||||
var index = elements.indexOf(self.selectedElementProxy.element);
|
||||
if (index === -1) {
|
||||
self.$element[0].click();
|
||||
} else if (!self.elementToSelectAfterRefresh) {
|
||||
self.elementToSelectAfterRefresh = self.elementProxies[index].element;
|
||||
// Clear old selection, and restore if appropriate
|
||||
if (self.selection) {
|
||||
self.selection.deselect();
|
||||
if (index > -1) {
|
||||
self.select(self.elementProxies[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,12 +224,12 @@ define(
|
||||
$scope.configuration.elements || [];
|
||||
// Store the position of this element.
|
||||
$scope.configuration.elements.push(element);
|
||||
|
||||
self.elementToSelectAfterRefresh = element;
|
||||
|
||||
// Refresh displayed elements
|
||||
refreshElements();
|
||||
|
||||
// Select the newly-added element
|
||||
self.select(
|
||||
self.elementProxies[self.elementProxies.length - 1]
|
||||
);
|
||||
// Mark change as persistable
|
||||
if ($scope.commit) {
|
||||
$scope.commit("Dropped an element.");
|
||||
@@ -258,36 +263,21 @@ define(
|
||||
self.getTelemetry($scope.domainObject);
|
||||
}
|
||||
|
||||
// Sets the selectable object in response to the selection change event.
|
||||
function setSelection(selectable) {
|
||||
var selection = selectable[0];
|
||||
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection.context.elementProxy) {
|
||||
self.selectedElementProxy = selection.context.elementProxy;
|
||||
self.mvHandle = self.generateDragHandle(self.selectedElementProxy);
|
||||
self.resizeHandles = self.generateDragHandles(self.selectedElementProxy);
|
||||
} else {
|
||||
// Make fixed view selectable if it's not already.
|
||||
if (!self.fixedViewSelectable && selectable.length === 1) {
|
||||
self.fixedViewSelectable = true;
|
||||
selection.context.viewProxy = new FixedProxy(addElement, $q, dialogService);
|
||||
self.openmct.selection.select(selection);
|
||||
}
|
||||
|
||||
self.resizeHandles = [];
|
||||
self.mvHandle = undefined;
|
||||
self.selectedElementProxy = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
this.elementProxies = [];
|
||||
this.generateDragHandle = generateDragHandle;
|
||||
this.generateDragHandles = generateDragHandles;
|
||||
this.updateSelectionStyle = updateSelectionStyle;
|
||||
|
||||
// Track current selection state
|
||||
$scope.$watch("selection", function (selection) {
|
||||
this.selection = selection;
|
||||
|
||||
// Expose the view's selection proxy
|
||||
if (this.selection) {
|
||||
this.selection.proxy(
|
||||
new FixedProxy(addElement, $q, dialogService)
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Detect changes to grid size
|
||||
$scope.$watch("model.layoutGrid", updateElementPositions);
|
||||
@@ -308,13 +298,10 @@ define(
|
||||
$scope.$on("$destroy", function () {
|
||||
self.unsubscribe();
|
||||
self.openmct.time.off("bounds", updateDisplayBounds);
|
||||
self.openmct.selection.off("change", setSelection);
|
||||
});
|
||||
|
||||
// Respond to external bounds changes
|
||||
this.openmct.time.on("bounds", updateDisplayBounds);
|
||||
this.openmct.selection.on('change', setSelection);
|
||||
this.$element.on('click', this.bypassSelection.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,10 +360,10 @@ define(
|
||||
*/
|
||||
FixedController.prototype.updateView = function (telemetryObject, datum) {
|
||||
var metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||
var valueMetadata = this.chooseValueMetadataToDisplay(metadata);
|
||||
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(valueMetadata, datum);
|
||||
var telemetryKeyToDisplay = this.chooseTelemetryKeyToDisplay(metadata);
|
||||
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(telemetryKeyToDisplay, datum, metadata);
|
||||
var limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
|
||||
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, valueMetadata);
|
||||
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, telemetryKeyToDisplay);
|
||||
|
||||
this.setDisplayedValue(
|
||||
telemetryObject,
|
||||
@@ -389,28 +376,29 @@ define(
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
FixedController.prototype.getFormattedTelemetryValueForKey = function (valueMetadata, datum) {
|
||||
FixedController.prototype.getFormattedTelemetryValueForKey = function (telemetryKeyToDisplay, datum, metadata) {
|
||||
var valueMetadata = metadata.value(telemetryKeyToDisplay);
|
||||
var formatter = this.openmct.telemetry.getValueFormatter(valueMetadata);
|
||||
|
||||
return formatter.format(datum);
|
||||
return formatter.format(datum[valueMetadata.key]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
FixedController.prototype.chooseValueMetadataToDisplay = function (metadata) {
|
||||
FixedController.prototype.chooseTelemetryKeyToDisplay = function (metadata) {
|
||||
// If there is a range value, show that preferentially
|
||||
var valueMetadata = metadata.valuesForHints(['range'])[0];
|
||||
var telemetryKeyToDisplay = metadata.valuesForHints(['range'])[0];
|
||||
|
||||
// If no range is defined, default to the highest priority non time-domain data.
|
||||
if (valueMetadata === undefined) {
|
||||
if (telemetryKeyToDisplay === undefined) {
|
||||
var valuesOrderedByPriority = metadata.values();
|
||||
valueMetadata = valuesOrderedByPriority.filter(function (values) {
|
||||
return !(values.hints.domain);
|
||||
telemetryKeyToDisplay = valuesOrderedByPriority.filter(function (valueMetadata) {
|
||||
return !(valueMetadata.hints.domain);
|
||||
})[0];
|
||||
}
|
||||
|
||||
return valueMetadata;
|
||||
return telemetryKeyToDisplay.source;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -504,56 +492,42 @@ define(
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the element should be selected or not.
|
||||
*
|
||||
* @param elementProxy the element to check
|
||||
* @returns {boolean} true if the element should be selected.
|
||||
* Check if the element is currently selected, or (if no
|
||||
* argument is supplied) get the currently selected element.
|
||||
* @returns {boolean} true if selected
|
||||
*/
|
||||
FixedController.prototype.shouldSelect = function (elementProxy) {
|
||||
if (elementProxy.element === this.elementToSelectAfterRefresh) {
|
||||
delete this.elementToSelectAfterRefresh;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
FixedController.prototype.selected = function (element) {
|
||||
var selection = this.selection;
|
||||
return selection && ((arguments.length > 0) ?
|
||||
selection.selected(element) : selection.get());
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the active user selection in this view.
|
||||
* @param element the element to select
|
||||
*/
|
||||
FixedController.prototype.select = function select(element, event) {
|
||||
if (event) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
if (this.selection) {
|
||||
// Update selection...
|
||||
this.selection.select(element);
|
||||
// ...as well as move, resize handles
|
||||
this.mvHandle = this.generateDragHandle(element);
|
||||
this.resizeHandles = this.generateDragHandles(element);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if an element is currently selected.
|
||||
*
|
||||
* @returns {boolean} true if an element is selected.
|
||||
* Clear the current user selection.
|
||||
*/
|
||||
FixedController.prototype.isElementSelected = function () {
|
||||
return (this.selectedElementProxy) ? true : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the style for the selected element.
|
||||
*
|
||||
* @returns {string} element style
|
||||
*/
|
||||
FixedController.prototype.getSelectedElementStyle = function () {
|
||||
return (this.selectedElementProxy) ? this.selectedElementProxy.style : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the selected element.
|
||||
*
|
||||
* @returns the selected element
|
||||
*/
|
||||
FixedController.prototype.getSelectedElement = function () {
|
||||
return this.selectedElementProxy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevents the event from bubbling up if drag is in progress.
|
||||
*/
|
||||
FixedController.prototype.bypassSelection = function ($event) {
|
||||
if (this.dragInProgress) {
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
return;
|
||||
FixedController.prototype.clearSelection = function () {
|
||||
if (this.selection) {
|
||||
this.selection.deselect();
|
||||
this.resizeHandles = [];
|
||||
this.mvHandle = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -574,38 +548,6 @@ define(
|
||||
return this.mvHandle;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the selection context.
|
||||
*
|
||||
* @param elementProxy the element proxy
|
||||
* @returns {object} the context object which includes elementProxy and toolbar
|
||||
*/
|
||||
FixedController.prototype.getContext = function (elementProxy) {
|
||||
return {
|
||||
elementProxy: elementProxy,
|
||||
toolbar: elementProxy
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* End drag.
|
||||
*
|
||||
* @param handle the resize handle
|
||||
*/
|
||||
FixedController.prototype.endDrag = function (handle) {
|
||||
this.dragInProgress = true;
|
||||
|
||||
setTimeout(function () {
|
||||
this.dragInProgress = false;
|
||||
}.bind(this), 0);
|
||||
|
||||
if (handle) {
|
||||
handle.endDrag();
|
||||
} else {
|
||||
this.moveHandle().endDrag();
|
||||
}
|
||||
};
|
||||
|
||||
return FixedController;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -65,7 +65,7 @@ define(
|
||||
* Start a drag gesture. This should be called when a drag
|
||||
* begins to track initial state.
|
||||
*/
|
||||
FixedDragHandle.prototype.startDrag = function () {
|
||||
FixedDragHandle.prototype.startDrag = function startDrag() {
|
||||
// Cache initial x/y positions
|
||||
this.dragging = {
|
||||
x: this.elementHandle.x(),
|
||||
|
||||
@@ -55,8 +55,8 @@ define(
|
||||
* @param element the fixed position element, as stored in its
|
||||
* configuration
|
||||
* @param index the element's index within its array
|
||||
* @param {Array} elements the full array of elements
|
||||
* @param {number[]} gridSize the current layout grid size in [x,y] from
|
||||
* @param {Array} elements the full array of elements
|
||||
*/
|
||||
function ElementProxy(element, index, elements, gridSize) {
|
||||
/**
|
||||
|
||||
@@ -21,14 +21,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
[
|
||||
"../src/FixedController",
|
||||
"zepto"
|
||||
],
|
||||
function (
|
||||
FixedController,
|
||||
$
|
||||
) {
|
||||
["../src/FixedController"],
|
||||
function (FixedController) {
|
||||
|
||||
describe("The Fixed Position controller", function () {
|
||||
var mockScope,
|
||||
@@ -52,9 +46,6 @@ define(
|
||||
mockMetadata,
|
||||
mockTimeSystem,
|
||||
mockLimitEvaluator,
|
||||
mockSelection,
|
||||
$element = [],
|
||||
selectable = [],
|
||||
controller;
|
||||
|
||||
// Utility function; find a watch for a given expression
|
||||
@@ -106,8 +97,8 @@ define(
|
||||
'telemetryFormatter',
|
||||
['format']
|
||||
);
|
||||
mockFormatter.format.andCallFake(function (valueMetadata) {
|
||||
return "Formatted " + valueMetadata.value;
|
||||
mockFormatter.format.andCallFake(function (value) {
|
||||
return "Formatted " + value;
|
||||
});
|
||||
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
@@ -189,30 +180,17 @@ define(
|
||||
|
||||
mockScope.model = testModel;
|
||||
mockScope.configuration = testConfiguration;
|
||||
|
||||
selectable[0] = {
|
||||
context: {
|
||||
oldItem: mockDomainObject
|
||||
}
|
||||
};
|
||||
mockSelection = jasmine.createSpyObj("selection", [
|
||||
'select',
|
||||
'on',
|
||||
'off',
|
||||
'get'
|
||||
]);
|
||||
mockSelection.get.andCallThrough();
|
||||
mockScope.selection = jasmine.createSpyObj(
|
||||
'selection',
|
||||
['select', 'get', 'selected', 'deselect', 'proxy']
|
||||
);
|
||||
|
||||
mockOpenMCT = {
|
||||
time: mockConductor,
|
||||
telemetry: mockTelemetryAPI,
|
||||
composition: mockCompositionAPI,
|
||||
selection: mockSelection
|
||||
composition: mockCompositionAPI
|
||||
};
|
||||
|
||||
$element = $('<div></div>');
|
||||
spyOn($element[0], 'click');
|
||||
|
||||
mockMetadata = jasmine.createSpyObj('mockMetadata', [
|
||||
'valuesForHints',
|
||||
'value',
|
||||
@@ -248,11 +226,11 @@ define(
|
||||
mockScope,
|
||||
mockQ,
|
||||
mockDialogService,
|
||||
mockOpenMCT,
|
||||
$element
|
||||
mockOpenMCT
|
||||
);
|
||||
|
||||
findWatch("model.layoutGrid")(testModel.layoutGrid);
|
||||
findWatch("selection")(mockScope.selection);
|
||||
});
|
||||
|
||||
it("subscribes when a domain object is available", function () {
|
||||
@@ -328,41 +306,41 @@ define(
|
||||
});
|
||||
|
||||
it("allows elements to be selected", function () {
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
selectable[0].context.elementProxy = controller.getElements()[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(controller.isElementSelected()).toBe(true);
|
||||
});
|
||||
|
||||
it("allows selection retrieval", function () {
|
||||
var elements;
|
||||
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
elements = controller.getElements();
|
||||
selectable[0].context.elementProxy = elements[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
|
||||
expect(controller.getSelectedElement()).toEqual(elements[1]);
|
||||
controller.select(elements[1]);
|
||||
expect(mockScope.selection.select)
|
||||
.toHaveBeenCalledWith(elements[1]);
|
||||
});
|
||||
|
||||
it("selects the parent view when selected element is removed", function () {
|
||||
it("allows selection retrieval", function () {
|
||||
// selected with no arguments should give the current
|
||||
// selection
|
||||
var elements;
|
||||
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
var elements = controller.getElements();
|
||||
selectable[0].context.elementProxy = elements[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
elements = controller.getElements();
|
||||
controller.select(elements[1]);
|
||||
mockScope.selection.get.andReturn(elements[1]);
|
||||
expect(controller.selected()).toEqual(elements[1]);
|
||||
});
|
||||
|
||||
elements[1].remove();
|
||||
testModel.modified = 2;
|
||||
it("allows selections to be cleared", function () {
|
||||
var elements;
|
||||
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
expect($element[0].click).toHaveBeenCalled();
|
||||
elements = controller.getElements();
|
||||
controller.select(elements[1]);
|
||||
controller.clearSelection();
|
||||
expect(controller.selected(elements[1])).toBeFalsy();
|
||||
});
|
||||
|
||||
it("retains selections during refresh", function () {
|
||||
@@ -374,21 +352,23 @@ define(
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
elements = controller.getElements();
|
||||
selectable[0].context.elementProxy = elements[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
controller.select(elements[1]);
|
||||
|
||||
expect(controller.getSelectedElement()).toEqual(elements[1]);
|
||||
// Verify precondition
|
||||
expect(mockScope.selection.select.calls.length).toEqual(1);
|
||||
|
||||
// Mimic selection behavior
|
||||
mockScope.selection.get.andReturn(elements[1]);
|
||||
|
||||
elements[2].remove();
|
||||
testModel.modified = 2;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
elements = controller.getElements();
|
||||
|
||||
// Verify removal, as test assumes this
|
||||
expect(elements.length).toEqual(2);
|
||||
|
||||
expect(controller.shouldSelect(elements[1])).toBe(true);
|
||||
expect(mockScope.selection.select.calls.length).toEqual(2);
|
||||
});
|
||||
|
||||
it("Displays received values for telemetry elements", function () {
|
||||
@@ -525,25 +505,21 @@ define(
|
||||
});
|
||||
|
||||
it("exposes a view-level selection proxy", function () {
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
var selection = mockOpenMCT.selection.select.mostRecentCall.args[0];
|
||||
|
||||
expect(mockOpenMCT.selection.select).toHaveBeenCalled();
|
||||
expect(selection.context.viewProxy).toBeDefined();
|
||||
expect(mockScope.selection.proxy).toHaveBeenCalledWith(
|
||||
jasmine.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes drag handles", function () {
|
||||
var handles;
|
||||
|
||||
// Select something so that drag handles are expected
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
selectable[0].context.elementProxy = controller.getElements()[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
controller.select(controller.getElements()[1]);
|
||||
|
||||
// Should have a non-empty array of handles
|
||||
handles = controller.handles();
|
||||
|
||||
expect(handles).toEqual(jasmine.any(Array));
|
||||
expect(handles.length).not.toEqual(0);
|
||||
|
||||
@@ -556,14 +532,15 @@ define(
|
||||
});
|
||||
|
||||
it("exposes a move handle", function () {
|
||||
var handle;
|
||||
|
||||
// Select something so that drag handles are expected
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
selectable[0].context.elementProxy = controller.getElements()[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
controller.select(controller.getElements()[1]);
|
||||
|
||||
// Should have a move handle
|
||||
var handle = controller.moveHandle();
|
||||
handle = controller.moveHandle();
|
||||
|
||||
// And it should have start/continue/end drag methods
|
||||
expect(handle.startDrag).toEqual(jasmine.any(Function));
|
||||
@@ -574,40 +551,26 @@ define(
|
||||
it("updates selection style during drag", function () {
|
||||
var oldStyle;
|
||||
|
||||
// Select something so that drag handles are expected
|
||||
testModel.modified = 1;
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
|
||||
selectable[0].context.elementProxy = controller.getElements()[1];
|
||||
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
|
||||
controller.select(controller.getElements()[1]);
|
||||
mockScope.selection.get.andReturn(controller.getElements()[1]);
|
||||
|
||||
// Get style
|
||||
oldStyle = controller.getSelectedElementStyle();
|
||||
oldStyle = controller.selected().style;
|
||||
|
||||
// Start a drag gesture
|
||||
controller.moveHandle().startDrag();
|
||||
|
||||
// Haven't moved yet; style shouldn't have updated yet
|
||||
expect(controller.getSelectedElementStyle()).toEqual(oldStyle);
|
||||
expect(controller.selected().style).toEqual(oldStyle);
|
||||
|
||||
// Drag a little
|
||||
controller.moveHandle().continueDrag([1000, 100]);
|
||||
|
||||
// Style should have been updated
|
||||
expect(controller.getSelectedElementStyle()).not.toEqual(oldStyle);
|
||||
});
|
||||
|
||||
it("cleans up slection on scope destroy", function () {
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
'$destroy',
|
||||
jasmine.any(Function)
|
||||
);
|
||||
|
||||
mockScope.$on.mostRecentCall.args[1]();
|
||||
|
||||
expect(mockOpenMCT.selection.off).toHaveBeenCalledWith(
|
||||
'change',
|
||||
jasmine.any(Function)
|
||||
);
|
||||
expect(controller.selected().style).not.toEqual(oldStyle);
|
||||
});
|
||||
|
||||
describe("on display bounds changes", function () {
|
||||
@@ -697,7 +660,7 @@ define(
|
||||
source: 'range'
|
||||
}
|
||||
]);
|
||||
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
|
||||
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
|
||||
expect(key).toEqual('range');
|
||||
});
|
||||
|
||||
@@ -719,7 +682,7 @@ define(
|
||||
}
|
||||
}
|
||||
]);
|
||||
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
|
||||
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
|
||||
expect(key).toEqual('image');
|
||||
});
|
||||
|
||||
@@ -739,14 +702,6 @@ define(
|
||||
expect(controller.getElements()[0].cssClass).toEqual("alarm-a");
|
||||
});
|
||||
});
|
||||
|
||||
it("listens for selection change events", function () {
|
||||
expect(mockOpenMCT.selection.on).toHaveBeenCalledWith(
|
||||
'change',
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -268,6 +268,7 @@ define([
|
||||
|
||||
legacyRegistry.register('adapter', this.legacyBundle);
|
||||
legacyRegistry.enable('adapter');
|
||||
this.install(this.plugins.Plot());
|
||||
/**
|
||||
* Fired by [MCT]{@link module:openmct.MCT} when the application
|
||||
* is started.
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
define([
|
||||
'./CompositionAPI',
|
||||
'./CompositionCollection'
|
||||
], function (
|
||||
CompositionAPI,
|
||||
CompositionCollection
|
||||
) {
|
||||
|
||||
describe('The Composition API', function () {
|
||||
var publicAPI;
|
||||
var compositionAPI;
|
||||
var topicService;
|
||||
var mutationTopic;
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
mutationTopic = jasmine.createSpyObj('mutationTopic', [
|
||||
'listen'
|
||||
]);
|
||||
topicService = jasmine.createSpy('topicService');
|
||||
topicService.andReturn(mutationTopic);
|
||||
publicAPI = {};
|
||||
publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [
|
||||
'get'
|
||||
]);
|
||||
publicAPI.objects.get.andCallFake(function (identifier) {
|
||||
return Promise.resolve({identifier: identifier});
|
||||
});
|
||||
publicAPI.$injector = jasmine.createSpyObj('$injector', [
|
||||
'get'
|
||||
]);
|
||||
publicAPI.$injector.get.andReturn(topicService);
|
||||
compositionAPI = new CompositionAPI(publicAPI);
|
||||
});
|
||||
|
||||
it('returns falsy if an object does not support composition', function () {
|
||||
expect(compositionAPI.get({})).toBeFalsy();
|
||||
});
|
||||
|
||||
describe('default composition', function () {
|
||||
var domainObject;
|
||||
var composition;
|
||||
|
||||
beforeEach(function () {
|
||||
domainObject = {
|
||||
name: 'test folder',
|
||||
identifier: {
|
||||
namespace: 'test',
|
||||
key: '1'
|
||||
},
|
||||
composition: [
|
||||
{
|
||||
namespace: 'test',
|
||||
key: 'a'
|
||||
}
|
||||
]
|
||||
};
|
||||
composition = compositionAPI.get(domainObject);
|
||||
});
|
||||
|
||||
it('returns composition collection', function () {
|
||||
expect(composition).toBeDefined();
|
||||
expect(composition).toEqual(jasmine.any(CompositionCollection));
|
||||
});
|
||||
|
||||
it('loads composition from domain object', function () {
|
||||
var listener = jasmine.createSpy('addListener');
|
||||
var loaded = false;
|
||||
composition.on('add', listener);
|
||||
composition.load()
|
||||
.then(function () {
|
||||
loaded = true;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return loaded;
|
||||
});
|
||||
runs(function () {
|
||||
expect(listener.calls.length).toBe(1);
|
||||
expect(listener).toHaveBeenCalledWith({
|
||||
identifier: {namespace: 'test', key: 'a'}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Implement add/removal in new default provider.
|
||||
xit('synchronizes changes between instances', function () {
|
||||
var otherComposition = compositionAPI.get(domainObject);
|
||||
var addListener = jasmine.createSpy('addListener');
|
||||
var removeListener = jasmine.createSpy('removeListener');
|
||||
var otherAddListener = jasmine.createSpy('otherAddListener');
|
||||
var otherRemoveListener = jasmine.createSpy('otherRemoveListener');
|
||||
composition.on('add', addListener);
|
||||
composition.on('remove', removeListener);
|
||||
otherComposition.on('add', otherAddListener);
|
||||
otherComposition.on('remove', otherRemoveListener);
|
||||
var loaded = false;
|
||||
Promise.all([composition.load(), otherComposition.load()])
|
||||
.then(function () {
|
||||
loaded = true;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return loaded;
|
||||
});
|
||||
runs(function () {
|
||||
expect(addListener).toHaveBeenCalled();
|
||||
expect(otherAddListener).toHaveBeenCalled();
|
||||
expect(removeListener).not.toHaveBeenCalled();
|
||||
expect(otherRemoveListener).not.toHaveBeenCalled();
|
||||
|
||||
var object = addListener.mostRecentCall.args[0];
|
||||
composition.remove(object);
|
||||
expect(removeListener).toHaveBeenCalled();
|
||||
expect(otherRemoveListener).toHaveBeenCalled();
|
||||
|
||||
addListener.reset();
|
||||
otherAddListener.reset();
|
||||
composition.add(object);
|
||||
expect(addListener).toHaveBeenCalled();
|
||||
expect(otherAddListener).toHaveBeenCalled();
|
||||
|
||||
removeListener.reset();
|
||||
otherRemoveListener.reset();
|
||||
otherComposition.remove(object);
|
||||
expect(removeListener).toHaveBeenCalled();
|
||||
expect(otherRemoveListener).toHaveBeenCalled();
|
||||
|
||||
addListener.reset();
|
||||
otherAddListener.reset();
|
||||
otherComposition.add(object);
|
||||
expect(addListener).toHaveBeenCalled();
|
||||
expect(otherAddListener).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('static custom composition', function () {
|
||||
var customProvider;
|
||||
var domainObject;
|
||||
var composition;
|
||||
|
||||
beforeEach(function () {
|
||||
// A simple custom provider, returns the same composition for
|
||||
// all objects of a given type.
|
||||
customProvider = {
|
||||
appliesTo: function (object) {
|
||||
return object.type === 'custom-object-type';
|
||||
},
|
||||
load: function (object) {
|
||||
return Promise.resolve([
|
||||
{
|
||||
namespace: 'custom',
|
||||
key: 'thing'
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
domainObject = {
|
||||
identifier: {
|
||||
namespace: 'test',
|
||||
key: '1'
|
||||
},
|
||||
type: 'custom-object-type'
|
||||
};
|
||||
compositionAPI.addProvider(customProvider);
|
||||
composition = compositionAPI.get(domainObject);
|
||||
});
|
||||
|
||||
it('supports listening and loading', function () {
|
||||
var listener = jasmine.createSpy('addListener');
|
||||
var loaded = false;
|
||||
composition.on('add', listener);
|
||||
composition.load()
|
||||
.then(function () {
|
||||
loaded = true;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return loaded;
|
||||
});
|
||||
runs(function () {
|
||||
expect(listener.calls.length).toBe(1);
|
||||
expect(listener).toHaveBeenCalledWith({
|
||||
identifier: {namespace: 'custom', key: 'thing'}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('dynamic custom composition', function () {
|
||||
var customProvider;
|
||||
var domainObject;
|
||||
var composition;
|
||||
|
||||
beforeEach(function () {
|
||||
// A dynamic provider, loads an empty composition and exposes
|
||||
// listener functions.
|
||||
customProvider = jasmine.createSpyObj('dynamicProvider', [
|
||||
'appliesTo',
|
||||
'load',
|
||||
'on',
|
||||
'off'
|
||||
]);
|
||||
|
||||
customProvider.appliesTo.andReturn('true');
|
||||
customProvider.load.andReturn(Promise.resolve([]));
|
||||
|
||||
domainObject = {
|
||||
identifier: {
|
||||
namespace: 'test',
|
||||
key: '1'
|
||||
},
|
||||
type: 'custom-object-type'
|
||||
};
|
||||
compositionAPI.addProvider(customProvider);
|
||||
composition = compositionAPI.get(domainObject);
|
||||
});
|
||||
|
||||
it('supports listening and loading', function () {
|
||||
var addListener = jasmine.createSpy('addListener');
|
||||
var removeListener = jasmine.createSpy('removeListener');
|
||||
var loaded = false;
|
||||
composition.on('add', addListener);
|
||||
composition.on('remove', removeListener);
|
||||
expect(customProvider.on).toHaveBeenCalledWith(
|
||||
domainObject,
|
||||
'add',
|
||||
jasmine.any(Function),
|
||||
jasmine.any(CompositionCollection)
|
||||
);
|
||||
expect(customProvider.on).toHaveBeenCalledWith(
|
||||
domainObject,
|
||||
'remove',
|
||||
jasmine.any(Function),
|
||||
jasmine.any(CompositionCollection)
|
||||
);
|
||||
var add = customProvider.on.calls[0].args[2];
|
||||
var remove = customProvider.on.calls[1].args[2];
|
||||
composition.load()
|
||||
.then(function () {
|
||||
loaded = true;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return loaded;
|
||||
});
|
||||
runs(function () {
|
||||
expect(addListener).not.toHaveBeenCalled();
|
||||
expect(removeListener).not.toHaveBeenCalled();
|
||||
add({namespace: 'custom', key: 'thing'});
|
||||
});
|
||||
waitsFor(function () {
|
||||
return addListener.calls.length > 0;
|
||||
});
|
||||
runs(function () {
|
||||
expect(addListener).toHaveBeenCalledWith({
|
||||
identifier: {namespace: 'custom', key: 'thing'}
|
||||
});
|
||||
remove(addListener.mostRecentCall.args[0]);
|
||||
});
|
||||
waitsFor(function () {
|
||||
return removeListener.calls.length > 0;
|
||||
});
|
||||
runs(function () {
|
||||
expect(removeListener).toHaveBeenCalledWith({
|
||||
identifier: {namespace: 'custom', key: 'thing'}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -76,22 +76,20 @@ define([
|
||||
throw new Error('Event not supported by composition: ' + event);
|
||||
}
|
||||
|
||||
if (this.provider.on && this.provider.off) {
|
||||
if (event === 'add') {
|
||||
this.provider.on(
|
||||
this.domainObject,
|
||||
'add',
|
||||
this.onProviderAdd,
|
||||
this
|
||||
);
|
||||
} if (event === 'remove') {
|
||||
this.provider.on(
|
||||
this.domainObject,
|
||||
'remove',
|
||||
this.onProviderRemove,
|
||||
this
|
||||
);
|
||||
}
|
||||
if (event === 'add') {
|
||||
this.provider.on(
|
||||
this.domainObject,
|
||||
'add',
|
||||
this.onProviderAdd,
|
||||
this
|
||||
);
|
||||
} if (event === 'remove') {
|
||||
this.provider.on(
|
||||
this.domainObject,
|
||||
'remove',
|
||||
this.onProviderRemove,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
this.listeners[event].push({
|
||||
@@ -126,22 +124,20 @@ define([
|
||||
if (this.listeners[event].length === 0) {
|
||||
// Remove provider listener if this is the last callback to
|
||||
// be removed.
|
||||
if (this.provider.off && this.provider.on) {
|
||||
if (event === 'add') {
|
||||
this.provider.off(
|
||||
this.domainObject,
|
||||
'add',
|
||||
this.onProviderAdd,
|
||||
this
|
||||
);
|
||||
} else if (event === 'remove') {
|
||||
this.provider.off(
|
||||
this.domainObject,
|
||||
'remove',
|
||||
this.onProviderRemove,
|
||||
this
|
||||
);
|
||||
}
|
||||
if (event === 'add') {
|
||||
this.provider.off(
|
||||
this.domainObject,
|
||||
'add',
|
||||
this.onProviderAdd,
|
||||
this
|
||||
);
|
||||
} else if (event === 'remove') {
|
||||
this.provider.off(
|
||||
this.domainObject,
|
||||
'remove',
|
||||
this.onProviderRemove,
|
||||
this
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -100,7 +100,7 @@ define([
|
||||
delete valueMetadata.hints.y;
|
||||
}
|
||||
|
||||
if (valueMetadata.format === 'enum') {
|
||||
if (valueMetadata.format == 'enum') {
|
||||
if (!valueMetadata.values) {
|
||||
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
'lodash'
|
||||
'lodash',
|
||||
'printj'
|
||||
], function (
|
||||
_
|
||||
_,
|
||||
printj
|
||||
) {
|
||||
|
||||
// TODO: needs reference to formatService;
|
||||
@@ -65,12 +67,18 @@ define([
|
||||
this.formatter.parse = function (string) {
|
||||
if (typeof string === "string") {
|
||||
if (this.enumerations.byString.hasOwnProperty(string)) {
|
||||
return this.enumerations.byString[string];
|
||||
return this.enumerations.byString[string]
|
||||
}
|
||||
}
|
||||
return Number(string);
|
||||
}.bind(this);
|
||||
}
|
||||
if (valueMetadata.sprintf) {
|
||||
this.formatter = numberFormatter;
|
||||
this.formatter.format = function (value) {
|
||||
return printj.sprintf(valueMetadata.sprintf, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TelemetryValueFormatter.prototype.parse = function (datum) {
|
||||
|
||||
@@ -38,6 +38,7 @@ define([
|
||||
'../example/msl/bundle',
|
||||
'../example/notifications/bundle',
|
||||
'../example/persistence/bundle',
|
||||
'../example/plotOptions/bundle',
|
||||
'../example/policy/bundle',
|
||||
'../example/profiling/bundle',
|
||||
'../example/scratchpad/bundle',
|
||||
|
||||
114
src/plugins/plot/README.md
Normal file
114
src/plugins/plot/README.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# plot
|
||||
|
||||
# One more time-- celebration.
|
||||
|
||||
PlotConfigurationModel -- backed by Plot Object model.
|
||||
PlotSeries[]
|
||||
PlotSeries
|
||||
XAxis
|
||||
YAxis
|
||||
|
||||
|
||||
PlotStateModel
|
||||
PlotSeries[]
|
||||
PlotSeries -- handles loading of data, data, etc.
|
||||
XAxis
|
||||
YAxis
|
||||
|
||||
|
||||
TelemetryPointPlot
|
||||
Creates a placeholder PlotConfigurationModel each time.
|
||||
|
||||
OverlayPlot
|
||||
|
||||
StackedPlot -- has an array of subplots.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The `plot-reborn` bundle provides directives for composing plot based views.
|
||||
It also exposes domain objects for plotting telemetry points.
|
||||
|
||||
## chart
|
||||
Chart defines a directive for charting data. It is the main interface between
|
||||
the drawing API and a plot controller.
|
||||
|
||||
## plot
|
||||
Plot defines a directive for plotting data, and provides some types it
|
||||
uses to do so: the PlotAxis and the PlotSeries.
|
||||
|
||||
## TelemetryPlot
|
||||
Telemetry plot includes controllers needed to connect to telemetry providers.
|
||||
|
||||
|
||||
|
||||
MCTChart is a directive for charting data.
|
||||
|
||||
## Types
|
||||
|
||||
* OverlayPlot: can be used on any domain object that has or delegates a
|
||||
telemetry capability.
|
||||
|
||||
-> View: OverlayPlot
|
||||
|
||||
* StackedPlot: can be used on any domain object that delegates telemetry or
|
||||
delegates composition of elements that have telemetry.
|
||||
|
||||
-> View: StackedPlot
|
||||
|
||||
|
||||
## Series
|
||||
* label
|
||||
* data
|
||||
* color
|
||||
* markers (yes/no)
|
||||
* scale
|
||||
- maps
|
||||
|
||||
## Directives
|
||||
|
||||
* `mct-chart`: an element that takes `series`, `viewport`, and
|
||||
`rectangles` and plots the data. Adding points to a series after it has
|
||||
been initially plotted can be done either by recreating the series object
|
||||
or by broadcasting "series:data:add" with arguments `event`, `seriesIndex`,
|
||||
`points`. This will append `points` to the `series` at index `seriesIndex`.
|
||||
|
||||
* `mct-plot`: A directive that wraps a mct-chart and handles user interactions
|
||||
with that plot. It emits events that a parent view can use for coordinating
|
||||
functionality:
|
||||
* emits a `user:viewport:change:start` event when the viewport begins being
|
||||
changed by a user, to allow any parent controller to prevent viewport
|
||||
modifications while the user is interacting with the plot.
|
||||
* emits a `user:viewport:change:end` event when the user has finished
|
||||
changing the viewport. This allows a controller on a parent scope to
|
||||
track viewport history and provide any necessary functionality
|
||||
around viewport changes, e.g. viewport history.
|
||||
|
||||
* `mct-overlay-plot`: A directive that takes `domainObject` and plots either a
|
||||
single series of data (in the case of a single telemetry object) or multiple
|
||||
series of data (in the case of a object which delegates telemetry).
|
||||
|
||||
## Controllers
|
||||
|
||||
NOTE: this section not accurate. Essentially, these controllers format data for
|
||||
the mct-chart directive. They also handle live viewport updating, as well as
|
||||
managing all transformations from domain objects to views.
|
||||
|
||||
* StackPlotController: Uses the composition capability of a StackPlot domain
|
||||
object to retrieve SubPlots and render them with individual PlotControllers.
|
||||
* PlotController: Uses either a domain object that delegates telemetry or a
|
||||
domain object with telemetry to and feeds that data to the mct-chart
|
||||
directive.
|
||||
|
||||
## TODOS:
|
||||
|
||||
* [ ] Re-implement history stack.
|
||||
* [ ] Re-implement plot pallette.
|
||||
* [ ] Re-implement stacked plot viewport synchronization (share viewport object)
|
||||
* [ ] Other things?
|
||||
* [ ] Handle edge cases with marquee zoom/panning.
|
||||
* [ ] Tidy code.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,12 +14,11 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
@@ -216,7 +215,7 @@ define([
|
||||
"features": "creation",
|
||||
"contains": [
|
||||
"telemetry.plot.overlay",
|
||||
{"has": "telemetry"}
|
||||
{"has": "telemetry"},
|
||||
],
|
||||
"model": {
|
||||
"composition": []
|
||||
@@ -243,8 +242,8 @@ define([
|
||||
});
|
||||
|
||||
openmct.legacyRegistry.enable("openmct/plot");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return PlotPlugin;
|
||||
return PlotPlugin
|
||||
});
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<div class="gl-plot plot-legend-{{legend.get('position')}} {{legend.get('expanded')? 'plot-legend-expanded' : 'plot-legend-collapsed'}}">
|
||||
<div class="gl-plot-legend flex-elem l-flex-row"
|
||||
ng-class="{ 'hover-on-plot': !!highlights.length }"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,7 +14,7 @@
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
Open MCT Web includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,7 +14,7 @@
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
Open MCT Web includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<div ng-if="domainObject.getCapability('editor').inEditContext()">
|
||||
<mct-representation key="'plot-options-edit'"
|
||||
mct-object="domainObject">
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<span ng-controller="PlotController as controller"
|
||||
class="abs holder holder-plot has-control-bar"
|
||||
ng-class="{
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<span ng-controller="StackedPlotController as stackedPlot"
|
||||
class="abs holder holder-plot has-control-bar t-plot-stacked"
|
||||
ng-class="{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT, Copyright (c) 2014-2017, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
/*global define,Float32Array*/
|
||||
|
||||
define([
|
||||
'../lib/extend',
|
||||
@@ -28,6 +7,7 @@ define([
|
||||
extend,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function MCTChartAlarmPointSet(series, chart, offset) {
|
||||
this.series = series;
|
||||
@@ -40,12 +20,12 @@ define([
|
||||
this.listenTo(series, 'reset', this.reset, this);
|
||||
this.listenTo(series, 'destroy', this.destroy, this);
|
||||
series.data.forEach(function (point, index) {
|
||||
this.append(point, index, series);
|
||||
this.append(point, index, series)
|
||||
}, this);
|
||||
}
|
||||
|
||||
MCTChartAlarmPointSet.prototype.append = function (datum) {
|
||||
if (datum.mctLimitState) {
|
||||
if (datum._limit) {
|
||||
this.points.push({
|
||||
x: this.offset.xVal(datum, this.series),
|
||||
y: this.offset.yVal(datum, this.series),
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,requestAnimationFrame,Float32Array*/
|
||||
|
||||
/**
|
||||
@@ -42,6 +21,7 @@ function (
|
||||
eventHelpers,
|
||||
_
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var MARKER_SIZE = 6.0,
|
||||
HIGHLIGHT_SIZE = MARKER_SIZE * 2.0;
|
||||
@@ -75,6 +55,7 @@ function (
|
||||
this.$scope.$watch('highlights', this.scheduleDraw);
|
||||
this.$scope.$watch('rectangles', this.scheduleDraw);
|
||||
this.config.series.forEach(this.onSeriesAdd, this);
|
||||
window.chart = this;
|
||||
}
|
||||
|
||||
eventHelpers.extend(MCTChartController.prototype);
|
||||
@@ -166,17 +147,17 @@ function (
|
||||
});
|
||||
this.pointSets.forEach(function (pointSet) {
|
||||
pointSet.reset();
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
MCTChartController.prototype.setOffset = function (offsetPoint, index, series) {
|
||||
MCTChartController.prototype.setOffset = function (point, index, series) {
|
||||
if (this.offset.x && this.offset.y) {
|
||||
return;
|
||||
}
|
||||
|
||||
var offsets = {
|
||||
x: series.getXVal(offsetPoint),
|
||||
y: series.getYVal(offsetPoint)
|
||||
x: series.getXVal(point),
|
||||
y: series.getYVal(point)
|
||||
};
|
||||
|
||||
this.offset.x = function (x) {
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
/*global define,requestAnimationFrame,Float32Array*/
|
||||
|
||||
/**
|
||||
* Module defining MCTChart. Created by vwoeltje on 11/12/14.
|
||||
@@ -29,6 +8,7 @@ define([
|
||||
], function (
|
||||
MCTChartController
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var TEMPLATE = "<canvas style='position: absolute; background: none; width: 100%; height: 100%;'></canvas>";
|
||||
TEMPLATE += TEMPLATE;
|
||||
@@ -53,7 +33,7 @@ define([
|
||||
controller: MCTChartController,
|
||||
scope: {
|
||||
config: "=",
|
||||
draw: "=",
|
||||
draw: "=" ,
|
||||
rectangles: "=",
|
||||
series: "=",
|
||||
xAxis: "=theXAxis",
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
@@ -26,6 +5,7 @@ define([
|
||||
], function (
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var MCTChartLineLinear = MCTChartSeriesElement.extend({
|
||||
addPoint: function (point, start, count) {
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
@@ -26,6 +5,7 @@ define([
|
||||
], function (
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var MCTChartLineStepAfter = MCTChartSeriesElement.extend({
|
||||
removePoint: function (point, index, count) {
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
@@ -26,6 +5,7 @@ define([
|
||||
], function (
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var MCTChartPointSet = MCTChartSeriesElement.extend({
|
||||
addPoint: function (point, start, count) {
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,Float32Array*/
|
||||
|
||||
define([
|
||||
@@ -28,6 +7,7 @@ define([
|
||||
extend,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function MCTChartSeriesElement(series, chart, offset) {
|
||||
this.series = series;
|
||||
@@ -40,7 +20,7 @@ define([
|
||||
this.listenTo(series, 'reset', this.reset, this);
|
||||
this.listenTo(series, 'destroy', this.destroy, this);
|
||||
series.data.forEach(function (point, index) {
|
||||
this.append(point, index, series);
|
||||
this.append(point, index, series)
|
||||
}, this);
|
||||
}
|
||||
|
||||
@@ -96,7 +76,7 @@ define([
|
||||
this.count -= (vertexCount / 2);
|
||||
};
|
||||
|
||||
MCTChartSeriesElement.prototype.makePoint = function (point, series) {
|
||||
MCTChartSeriesElement.prototype.makePoint = function(point, series) {
|
||||
if (!this.offset.xVal) {
|
||||
this.chart.setOffset(point, undefined, series);
|
||||
}
|
||||
@@ -126,8 +106,9 @@ define([
|
||||
this.isTempBuffer = true;
|
||||
}
|
||||
var target = insertionPoint + pointsRequired,
|
||||
start = insertionPoint;
|
||||
for (; start < target; start++) {
|
||||
start = insertionPoint,
|
||||
end = this.count * 2 + pointsRequired;
|
||||
for (;start < target; start++) {
|
||||
this.buffer.splice(start, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
/*global define, Promise*/
|
||||
|
||||
define([
|
||||
'lodash',
|
||||
@@ -34,6 +13,7 @@ define([
|
||||
extend,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function Collection(options) {
|
||||
if (options.models) {
|
||||
@@ -107,9 +87,7 @@ define([
|
||||
Collection.prototype.indexOf = function (model) {
|
||||
return _.findIndex(
|
||||
this.models,
|
||||
function (m) {
|
||||
return m === model;
|
||||
}
|
||||
function (m) { return m === model; }
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
define([
|
||||
'./Model'
|
||||
], function (
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
/*global define, Promise*/
|
||||
|
||||
define([
|
||||
'lodash',
|
||||
@@ -32,6 +11,7 @@ define([
|
||||
extend,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function Model(options) {
|
||||
if (!options) {
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
/*global define, Promise*/
|
||||
|
||||
define([
|
||||
'./Collection',
|
||||
@@ -38,6 +17,7 @@ define([
|
||||
LegendModel,
|
||||
_
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* PlotConfiguration model stores the configuration of a plot and some
|
||||
@@ -85,19 +65,6 @@ define([
|
||||
|
||||
this.listenTo(this, 'destroy', this.onDestroy, this);
|
||||
},
|
||||
/**
|
||||
* Retrieve the persisted series config for a given identifier.
|
||||
*/
|
||||
getPersistedSeriesConfig: function (identifier) {
|
||||
var domainObject = this.get('domainObject');
|
||||
if (!domainObject.configuration || !domainObject.configuration.series) {
|
||||
return;
|
||||
}
|
||||
return domainObject.configuration.series.filter(function (seriesConfig) {
|
||||
return seriesConfig.identifier.key === identifier.key &&
|
||||
seriesConfig.identifier.namespace === identifier.namespace;
|
||||
})[0];
|
||||
},
|
||||
/**
|
||||
* Update the domain object with the given value.
|
||||
*/
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
@@ -32,6 +11,7 @@ define([
|
||||
extend,
|
||||
EventEmitter
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Plot series handle interpreting telemetry metadata for a single telemetry
|
||||
@@ -101,7 +81,7 @@ define([
|
||||
markers: true,
|
||||
markerSize: 2.0,
|
||||
alarmMarkers: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -165,13 +145,10 @@ define([
|
||||
return;
|
||||
}
|
||||
var valueMetadata = this.metadata.value(newKey);
|
||||
var persistedConfig = this.get('persistedConfiguration');
|
||||
if (!persistedConfig || !persistedConfig.interpolate) {
|
||||
if (valueMetadata.format === 'enum') {
|
||||
this.set('interpolate', 'stepAfter');
|
||||
} else {
|
||||
this.set('interpolate', 'linear');
|
||||
}
|
||||
if (valueMetadata.format === 'enum') {
|
||||
this.set('interpolate', 'stepAfter');
|
||||
} else {
|
||||
this.set('interpolate', 'linear');
|
||||
}
|
||||
this.evaluate = function (datum) {
|
||||
return this.limitEvaluator.evaluate(datum, valueMetadata);
|
||||
@@ -181,11 +158,11 @@ define([
|
||||
},
|
||||
|
||||
formatX: function (point) {
|
||||
return this.formats[this.get('xKey')].format(point);
|
||||
return this.formats[this.get('xKey')].format(point)
|
||||
},
|
||||
|
||||
formatY: function (point) {
|
||||
return this.formats[this.get('yKey')].format(point);
|
||||
return this.formats[this.get('yKey')].format(point)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -236,6 +213,8 @@ define([
|
||||
* @returns {Promise}
|
||||
*/
|
||||
load: function (options) {
|
||||
this.resetOnAppend = true;
|
||||
|
||||
return this.fetch(options)
|
||||
.then(function (res) {
|
||||
this.emit('load');
|
||||
@@ -311,7 +290,7 @@ define([
|
||||
}
|
||||
}
|
||||
this.updateStats(point);
|
||||
point.mctLimitState = this.evaluate(point);
|
||||
point._limit = this.evaluate(point);
|
||||
this.data.splice(insertIndex, 0, point);
|
||||
this.emit('add', point, insertIndex, this);
|
||||
},
|
||||
|
||||
@@ -1,36 +1,13 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
define([
|
||||
'./PlotSeries',
|
||||
'./Collection',
|
||||
'./Model',
|
||||
'../lib/color',
|
||||
'lodash'
|
||||
'../lib/color'
|
||||
], function (
|
||||
PlotSeries,
|
||||
Collection,
|
||||
Model,
|
||||
color,
|
||||
_
|
||||
color
|
||||
) {
|
||||
|
||||
var SeriesCollection = Collection.extend({
|
||||
@@ -41,7 +18,6 @@ define([
|
||||
this.palette = new color.ColorPalette();
|
||||
this.listenTo(this, 'add', this.onSeriesAdd, this);
|
||||
this.listenTo(this, 'remove', this.onSeriesRemove, this);
|
||||
this.listenTo(this.plot, 'change:domainObject', this.trackPersistedConfig, this);
|
||||
|
||||
var domainObject = this.plot.get('domainObject');
|
||||
if (domainObject.telemetry) {
|
||||
@@ -50,14 +26,6 @@ define([
|
||||
this.watchTelemetryContainer(domainObject);
|
||||
}
|
||||
},
|
||||
trackPersistedConfig: function (domainObject) {
|
||||
domainObject.configuration.series.forEach(function (seriesConfig) {
|
||||
var series = this.byIdentifier(seriesConfig.identifier);
|
||||
if (series) {
|
||||
series.set('persistedConfiguration', seriesConfig);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
watchTelemetryContainer: function (domainObject) {
|
||||
var composition = this.openmct.composition.get(domainObject);
|
||||
this.listenTo(composition, 'add', this.addTelemetryObject, this);
|
||||
@@ -84,9 +52,6 @@ define([
|
||||
seriesConfig = JSON.parse(JSON.stringify(seriesConfig));
|
||||
}
|
||||
|
||||
seriesConfig.persistedConfiguration =
|
||||
this.plot.getPersistedSeriesConfig(domainObject.identifier);
|
||||
|
||||
this.add(new PlotSeries({
|
||||
model: seriesConfig,
|
||||
domainObject: domainObject,
|
||||
@@ -110,11 +75,11 @@ define([
|
||||
// to defer mutation of our plot object, otherwise we might
|
||||
// mutate an outdated version of the plotObject.
|
||||
setTimeout(function () {
|
||||
var newPlotObject = this.plot.get('domainObject');
|
||||
var cSeries = newPlotObject.configuration.series.slice();
|
||||
var plotObject = this.plot.get('domainObject');
|
||||
var cSeries = plotObject.configuration.series.slice();
|
||||
cSeries.splice(index, 1);
|
||||
this.openmct.objects.mutate(newPlotObject, 'configuration.series', cSeries);
|
||||
}.bind(this));
|
||||
this.openmct.objects.mutate(plotObject, 'configuration.series', cSeries);
|
||||
}.bind(this))
|
||||
}
|
||||
},
|
||||
onSeriesAdd: function (series) {
|
||||
@@ -137,19 +102,12 @@ define([
|
||||
},
|
||||
updateColorPalette: function (newColor, oldColor) {
|
||||
this.palette.remove(newColor);
|
||||
var seriesWithColor = this.filter(function (series) {
|
||||
var seriesWithColor = this.series.filter(function (series) {
|
||||
return series.get('color') === newColor;
|
||||
})[0];
|
||||
if (!seriesWithColor) {
|
||||
this.palette.return(oldColor);
|
||||
}
|
||||
},
|
||||
byIdentifier: function (identifier) {
|
||||
return this.filter(function (series) {
|
||||
var seriesIdentifier = series.get('identifier');
|
||||
return seriesIdentifier.namespace === identifier.namespace &&
|
||||
seriesIdentifier.key === identifier.key;
|
||||
})[0];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
define([
|
||||
'./Model'
|
||||
], function (
|
||||
@@ -56,14 +35,12 @@ define([
|
||||
this.set('label', xMetadata.name);
|
||||
this.set('format', xFormat.format.bind(xFormat));
|
||||
} else {
|
||||
this.set('format', function (x) {
|
||||
return x;
|
||||
});
|
||||
this.set('format', function (x) { return x;});
|
||||
this.set('label', newKey);
|
||||
}
|
||||
this.plot.series.forEach(function (plotSeries) {
|
||||
plotSeries.set('xKey', newKey);
|
||||
plotSeries.reset();
|
||||
this.plot.series.forEach(function (series) {
|
||||
series.set('xKey', newKey);
|
||||
series.reset();
|
||||
});
|
||||
},
|
||||
defaults: function (options) {
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
define([
|
||||
'./Model',
|
||||
'lodash'
|
||||
@@ -27,27 +6,27 @@ define([
|
||||
_
|
||||
) {
|
||||
|
||||
/**
|
||||
* YAxis model
|
||||
*
|
||||
* TODO: docstrings.
|
||||
/**
|
||||
* YAxis model
|
||||
*
|
||||
* has the following Model properties:
|
||||
*
|
||||
* `autoscale`: boolean, whether or not to autoscale.
|
||||
* `autoscalePadding`: float, percent of padding to display in plots.
|
||||
* `displayRange`: the current display range for the x Axis.
|
||||
* `format`: the formatter for the axis.
|
||||
* `frozen`: boolean, if true, displayRange will not be updated automatically.
|
||||
* Used to temporarily disable automatic updates during user interaction.
|
||||
* `label`: label to display on axis.
|
||||
* `stats`: Min and Max Values of data, automatically updated by observing
|
||||
* plot series.
|
||||
* `values`: for enumerated types, an array of possible display values.
|
||||
* `range`: the user-configured range to use for display, when autoscale is
|
||||
* disabled.
|
||||
*
|
||||
*/
|
||||
* TODO: docstrings.
|
||||
*
|
||||
* has the following Model properties:
|
||||
*
|
||||
* `autoscale`: boolean, whether or not to autoscale.
|
||||
* `autoscalePadding`: float, percent of padding to display in plots.
|
||||
* `displayRange`: the current display range for the x Axis.
|
||||
* `format`: the formatter for the axis.
|
||||
* `frozen`: boolean, if true, displayRange will not be updated automatically.
|
||||
* Used to temporarily disable automatic updates during user interaction.
|
||||
* `label`: label to display on axis.
|
||||
* `stats`: Min and Max Values of data, automatically updated by observing
|
||||
* plot series.
|
||||
* `values`: for enumerated types, an array of possible display values.
|
||||
* `range`: the user-configured range to use for display, when autoscale is
|
||||
* disabled.
|
||||
*
|
||||
*/
|
||||
var YAxisModel = Model.extend({
|
||||
initialize: function (options) {
|
||||
this.plot = options.plot;
|
||||
@@ -88,7 +67,7 @@ define([
|
||||
}
|
||||
return {
|
||||
min: range.min - padding,
|
||||
max: range.max + padding
|
||||
max: range.max + padding,
|
||||
};
|
||||
},
|
||||
updatePadding: function (newPadding) {
|
||||
@@ -167,7 +146,7 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var yKey = sampleSeries.get('yKey');
|
||||
var yKey = sampleSeries.get('yKey')
|
||||
var yMetadata = sampleSeries.metadata.value(yKey);
|
||||
var yFormat = sampleSeries.formats[yKey];
|
||||
this.set('format', yFormat.format.bind(yFormat));
|
||||
|
||||
@@ -1,33 +1,13 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
define([
|
||||
], function (
|
||||
) {
|
||||
|
||||
var CONFIG_STORE = {};
|
||||
|
||||
function ConfigStore() {
|
||||
this.store = {};
|
||||
this.tracking = {};
|
||||
}
|
||||
|
||||
ConfigStore.prototype.track = function (id) {
|
||||
if (!this.tracking[id]) {
|
||||
this.tracking[id] = 0;
|
||||
@@ -42,7 +22,7 @@ define([
|
||||
this.store[id].destroy();
|
||||
delete this.store[id];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ConfigStore.prototype.add = function (id, config) {
|
||||
this.store[id] = config;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*global define*/
|
||||
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,18 +16,16 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
|
||||
define([
|
||||
|
||||
], function (
|
||||
|
||||
) {
|
||||
define([],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Create a new draw API utilizing the Canvas's 2D API for rendering.
|
||||
@@ -39,8 +39,8 @@ define([
|
||||
this.c2d = canvas.getContext('2d');
|
||||
this.width = canvas.width;
|
||||
this.height = canvas.height;
|
||||
this.dimensions = [this.width, this.height];
|
||||
this.origin = [0, 0];
|
||||
this.dimensions = [ this.width, this.height ];
|
||||
this.origin = [ 0, 0 ];
|
||||
|
||||
if (!this.c2d) {
|
||||
throw new Error("Canvas 2d API unavailable.");
|
||||
@@ -153,7 +153,7 @@ define([
|
||||
limitSize
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return Draw2D;
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/* global console */
|
||||
/*global define,console */
|
||||
|
||||
define(
|
||||
[
|
||||
|
||||
@@ -1,31 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,Float32Array*/
|
||||
|
||||
|
||||
define([
|
||||
|
||||
], function (
|
||||
|
||||
) {
|
||||
define([],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
// WebGL shader sources (for drawing plain colors)
|
||||
var FRAGMENT_SHADER = [
|
||||
@@ -220,7 +197,7 @@ define([
|
||||
limitSize
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return DrawWebGL;
|
||||
});
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define(function () {
|
||||
/**
|
||||
@@ -30,8 +10,8 @@ define(function () {
|
||||
return {
|
||||
restrict: "A",
|
||||
link: function ($scope, $element) {
|
||||
var splitter = $element.parent();
|
||||
|
||||
var splitter = $element.parent(),
|
||||
elementsContainer;
|
||||
while (splitter[0].tagName !== 'MCT-SPLIT-PANE') {
|
||||
splitter = splitter.parent();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
[
|
||||
'./Region'
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*global define*/
|
||||
define([
|
||||
'./Region'
|
||||
], function (
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*global define*/
|
||||
define([
|
||||
'./InspectorRegion',
|
||||
'./PlotBrowseRegion',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,11 +14,12 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
'../configuration/configStore',
|
||||
@@ -31,7 +32,7 @@ define([
|
||||
objectUtils,
|
||||
_
|
||||
) {
|
||||
|
||||
"use strict";
|
||||
/**
|
||||
* The LayoutController is responsible for supporting the
|
||||
* Layout view. It arranges frames according to saved configuration
|
||||
@@ -48,6 +49,7 @@ define([
|
||||
|
||||
this.configId = $scope.domainObject.getId();
|
||||
this.setUpScope();
|
||||
window.config = this;
|
||||
}
|
||||
|
||||
eventHelpers.extend(PlotOptionsController.prototype);
|
||||
@@ -126,7 +128,7 @@ define([
|
||||
newRange.max = Number(range.max);
|
||||
}
|
||||
return newRange;
|
||||
}, function validateRange(range) {
|
||||
}, function validateRange (range) {
|
||||
if (!range) {
|
||||
return 'Need range';
|
||||
}
|
||||
@@ -176,7 +178,7 @@ define([
|
||||
value: o.key
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
var seriesObject = series.domainObject;
|
||||
var seriesId = objectUtils.makeKeyString(seriesObject.identifier);
|
||||
var configPath = 'configuration.series[' + index + '].';
|
||||
@@ -202,7 +204,7 @@ define([
|
||||
this.config.series.forEach(this.removeSeries, this);
|
||||
this.$scope.form.series = [];
|
||||
this.config.series.forEach(this.addSeries, this);
|
||||
};
|
||||
}
|
||||
|
||||
PlotOptionsController.prototype.removeSeries = function (series) {
|
||||
this.stopListening(series);
|
||||
@@ -218,14 +220,10 @@ define([
|
||||
objectPath
|
||||
) {
|
||||
if (!coerce) {
|
||||
coerce = function (v) {
|
||||
return v;
|
||||
};
|
||||
coerce = function (v) { return v; };
|
||||
}
|
||||
if (!validate) {
|
||||
validate = function () {
|
||||
return true;
|
||||
};
|
||||
validate = function () { return true; };
|
||||
}
|
||||
this.listenTo(model, 'change:' + prop, function (newVal, oldVal) {
|
||||
if (!_.isEqual(coerce(_.get(this.$scope, scopePath)), coerce(newVal))) {
|
||||
@@ -248,7 +246,7 @@ define([
|
||||
if (objectPath && this.$scope.domainObject.getCapability('editor').isEditContextRoot()) {
|
||||
this.openmct.objects.mutate(this.domainObject, objectPath, coerce(newVal));
|
||||
}
|
||||
}
|
||||
};
|
||||
}, this);
|
||||
_.set(this.$scope, scopePath, coerce(model.get(prop)));
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,17 +14,17 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
|
||||
], function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A class for encapsulating structure and behaviour of the plot
|
||||
@@ -39,7 +39,7 @@ define([
|
||||
Defined below are the form structures for the plot options.
|
||||
*/
|
||||
this.xAxisForm = {
|
||||
name: 'x-axis',
|
||||
name:'x-axis',
|
||||
sections: [{
|
||||
name: 'x-axis',
|
||||
rows: [
|
||||
@@ -67,10 +67,10 @@ define([
|
||||
]
|
||||
}
|
||||
]
|
||||
}]};
|
||||
}]};
|
||||
|
||||
this.yAxisForm = {
|
||||
name: 'y-axis',
|
||||
name:'y-axis',
|
||||
sections: [{
|
||||
// Will need to be repeated for each y-axis, with a
|
||||
// distinct name for each. Ideally the name of the axis
|
||||
@@ -123,7 +123,7 @@ define([
|
||||
}]
|
||||
};
|
||||
this.plotSeriesForm = {
|
||||
name: 'Series Options',
|
||||
name:'Series Options',
|
||||
sections: [
|
||||
{
|
||||
rows: [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
@@ -14,52 +14,53 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/* global console */
|
||||
|
||||
/*global define, console*/
|
||||
define(function () {
|
||||
'use strict';
|
||||
|
||||
var COLOR_PALETTE = [
|
||||
[0x20, 0xB2, 0xAA],
|
||||
[0x9A, 0xCD, 0x32],
|
||||
[0xFF, 0x8C, 0x00],
|
||||
[0xD2, 0xB4, 0x8C],
|
||||
[0x40, 0xE0, 0xD0],
|
||||
[0x41, 0x69, 0xFF],
|
||||
[0xFF, 0xD7, 0x00],
|
||||
[0x6A, 0x5A, 0xCD],
|
||||
[0xEE, 0x82, 0xEE],
|
||||
[0xCC, 0x99, 0x66],
|
||||
[0x99, 0xCC, 0xCC],
|
||||
[0x66, 0xCC, 0x33],
|
||||
[0xFF, 0xCC, 0x00],
|
||||
[0xFF, 0x66, 0x33],
|
||||
[0xCC, 0x66, 0xFF],
|
||||
[0xFF, 0x00, 0x66],
|
||||
[0xFF, 0xFF, 0x00],
|
||||
[0x80, 0x00, 0x80],
|
||||
[0x00, 0x86, 0x8B],
|
||||
[0x00, 0x8A, 0x00],
|
||||
[0xFF, 0x00, 0x00],
|
||||
[0x00, 0x00, 0xFF],
|
||||
[0xF5, 0xDE, 0xB3],
|
||||
[0xBC, 0x8F, 0x8F],
|
||||
[0x46, 0x82, 0xB4],
|
||||
[0xFF, 0xAF, 0xAF],
|
||||
[0x43, 0xCD, 0x80],
|
||||
[0xCD, 0xC1, 0xC5],
|
||||
[0xA0, 0x52, 0x2D],
|
||||
[0x64, 0x95, 0xED]
|
||||
[ 0x20, 0xB2, 0xAA ],
|
||||
[ 0x9A, 0xCD, 0x32 ],
|
||||
[ 0xFF, 0x8C, 0x00 ],
|
||||
[ 0xD2, 0xB4, 0x8C ],
|
||||
[ 0x40, 0xE0, 0xD0 ],
|
||||
[ 0x41, 0x69, 0xFF ],
|
||||
[ 0xFF, 0xD7, 0x00 ],
|
||||
[ 0x6A, 0x5A, 0xCD ],
|
||||
[ 0xEE, 0x82, 0xEE ],
|
||||
[ 0xCC, 0x99, 0x66 ],
|
||||
[ 0x99, 0xCC, 0xCC ],
|
||||
[ 0x66, 0xCC, 0x33 ],
|
||||
[ 0xFF, 0xCC, 0x00 ],
|
||||
[ 0xFF, 0x66, 0x33 ],
|
||||
[ 0xCC, 0x66, 0xFF ],
|
||||
[ 0xFF, 0x00, 0x66 ],
|
||||
[ 0xFF, 0xFF, 0x00 ],
|
||||
[ 0x80, 0x00, 0x80 ],
|
||||
[ 0x00, 0x86, 0x8B ],
|
||||
[ 0x00, 0x8A, 0x00 ],
|
||||
[ 0xFF, 0x00, 0x00 ],
|
||||
[ 0x00, 0x00, 0xFF ],
|
||||
[ 0xF5, 0xDE, 0xB3 ],
|
||||
[ 0xBC, 0x8F, 0x8F ],
|
||||
[ 0x46, 0x82, 0xB4 ],
|
||||
[ 0xFF, 0xAF, 0xAF ],
|
||||
[ 0x43, 0xCD, 0x80 ],
|
||||
[ 0xCD, 0xC1, 0xC5 ],
|
||||
[ 0xA0, 0x52, 0x2D ],
|
||||
[ 0x64, 0x95, 0xED ]
|
||||
];
|
||||
|
||||
function isDefaultColor(color) {
|
||||
var a = color.asIntegerArray();
|
||||
return COLOR_PALETTE.some(function (b) {
|
||||
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
||||
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,9 +83,9 @@ define(function () {
|
||||
);
|
||||
}
|
||||
return new Color([
|
||||
parseInt(hexString.slice(1, 3), 16),
|
||||
parseInt(hexString.slice(3, 5), 16),
|
||||
parseInt(hexString.slice(5, 7), 16)
|
||||
parseInt(hexString.slice(1,3), 16),
|
||||
parseInt(hexString.slice(3,5), 16),
|
||||
parseInt(hexString.slice(5,7), 16)
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -100,12 +101,12 @@ define(function () {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return color as a string using #-prefixed six-digit RGB hex notation
|
||||
* (e.g. #FF0000). See http://www.w3.org/TR/css3-color/#rgb-color.
|
||||
*
|
||||
* @return {string} the color, as a style-friendly string
|
||||
*/
|
||||
/**
|
||||
* Return color as a string using #-prefixed six-digit RGB hex notation
|
||||
* (e.g. #FF0000). See http://www.w3.org/TR/css3-color/#rgb-color.
|
||||
*
|
||||
* @return {string} the color, as a style-friendly string
|
||||
*/
|
||||
|
||||
Color.prototype.asHexString = function () {
|
||||
return '#' + this.integerArray.map(function (c) {
|
||||
@@ -142,7 +143,7 @@ define(function () {
|
||||
return new Color(color);
|
||||
});
|
||||
this.colorGroups = [[], [], []];
|
||||
for (var i = 0; i < allColors.length; i++) {
|
||||
for (var l = allColors.length, i = 0; i < allColors.length; i++) {
|
||||
this.colorGroups[i % 3].push(allColors[i]);
|
||||
}
|
||||
this.reset();
|
||||
|
||||
@@ -1,31 +1,11 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*jscs:disable disallowDanglingUnderscores */
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
|
||||
], function (
|
||||
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var helperFunctions = {
|
||||
listenTo: function (object, event, callback, context) {
|
||||
|
||||
@@ -1,34 +1,13 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*jscs:disable disallowDanglingUnderscores */
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
|
||||
], function (
|
||||
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function extend(props) {
|
||||
/*jshint validthis: true*/
|
||||
var parent = this,
|
||||
child,
|
||||
Surrogate;
|
||||
@@ -36,9 +15,7 @@ define([
|
||||
if (props && props.hasOwnProperty('constructor')) {
|
||||
child = props.constructor;
|
||||
} else {
|
||||
child = function () {
|
||||
return parent.apply(this, arguments);
|
||||
};
|
||||
child = function () { return parent.apply(this, arguments); };
|
||||
}
|
||||
|
||||
Object.keys(parent).forEach(function copyStaticProperties(propKey) {
|
||||
@@ -46,9 +23,7 @@ define([
|
||||
});
|
||||
|
||||
// Surrogate allows inheriting from parent without invoking constructor.
|
||||
Surrogate = function () {
|
||||
this.constructor = child;
|
||||
};
|
||||
Surrogate = function () { this.constructor = child; };
|
||||
Surrogate.prototype = parent.prototype;
|
||||
child.prototype = new Surrogate();
|
||||
|
||||
|
||||
@@ -1,31 +1,11 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*jscs:disable disallowDanglingUnderscores */
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
|
||||
], function (
|
||||
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A scale has an input domain and an output range. It provides functions
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
'./LinearScale',
|
||||
@@ -27,6 +7,7 @@ define([
|
||||
LinearScale,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* MCTPlotController handles user interactions with the plot canvas.
|
||||
@@ -53,11 +34,12 @@ define([
|
||||
this.listenTo(this.$scope, 'plot:clearHistory', this.clear, this);
|
||||
|
||||
this.initialize();
|
||||
window.control = this;
|
||||
}
|
||||
|
||||
MCTPlotController.$inject = ['$scope', '$element', '$window'];
|
||||
|
||||
eventHelpers.extend(MCTPlotController.prototype);
|
||||
eventHelpers.extend(MCTPlotController.prototype)
|
||||
|
||||
MCTPlotController.prototype.initialize = function () {
|
||||
this.$canvas = this.$element.find('canvas');
|
||||
@@ -202,9 +184,7 @@ define([
|
||||
};
|
||||
|
||||
MCTPlotController.prototype.updateMarquee = function () {
|
||||
if (!this.marquee) {
|
||||
return;
|
||||
}
|
||||
if (!this.marquee) { return; }
|
||||
this.marquee.end = this.positionOverPlot;
|
||||
};
|
||||
|
||||
@@ -252,9 +232,7 @@ define([
|
||||
|
||||
MCTPlotController.prototype.updatePan = function () {
|
||||
// calculate offset between points. Apply that offset to viewport.
|
||||
if (!this.pan) {
|
||||
return;
|
||||
}
|
||||
if (!this.pan) { return; }
|
||||
var dX = this.pan.start.x - this.positionOverPlot.x,
|
||||
dY = this.pan.start.y - this.positionOverPlot.y,
|
||||
xRange = this.config.xAxis.get('displayRange'),
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,window*/
|
||||
|
||||
define([
|
||||
'./MCTPlotController',
|
||||
@@ -27,6 +7,7 @@ define([
|
||||
MCTPlotController,
|
||||
PlotTemplate
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function MCTPlot() {
|
||||
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define, setTimeout*/
|
||||
|
||||
define([
|
||||
'lodash',
|
||||
@@ -27,6 +7,7 @@ define([
|
||||
_,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var e10 = Math.sqrt(50),
|
||||
e5 = Math.sqrt(10),
|
||||
@@ -62,9 +43,7 @@ define([
|
||||
|
||||
var precision = Math.max(0, -(+exponential.slice(i + 1)));
|
||||
|
||||
if (precision > 20) {
|
||||
precision = 20;
|
||||
}
|
||||
if (precision > 20) precision = 20;
|
||||
|
||||
return precision;
|
||||
}
|
||||
@@ -117,6 +96,12 @@ define([
|
||||
this.$scope = $scope;
|
||||
this.$element = $element;
|
||||
|
||||
if (!window.ticks) {
|
||||
window.ticks = [];
|
||||
}
|
||||
|
||||
window.ticks.push(this);
|
||||
|
||||
this.tickCount = 4;
|
||||
this.tickUpdate = false;
|
||||
this.listenTo(this.axis, 'change:displayRange', this.updateTicks, this);
|
||||
@@ -165,7 +150,7 @@ define([
|
||||
};
|
||||
|
||||
MCTTicksController.prototype.updateTicks = function () {
|
||||
var range = this.axis.get('displayRange');
|
||||
var range = this.axis.get('displayRange')
|
||||
if (!range) {
|
||||
delete this.$scope.min;
|
||||
delete this.$scope.max;
|
||||
@@ -198,7 +183,7 @@ define([
|
||||
};
|
||||
}, this);
|
||||
|
||||
if (newTicks.length && typeof newTicks[0].text === 'string') {
|
||||
if (newTicks.length && typeof newTicks[0].text === 'string' ) {
|
||||
var tickText = newTicks.map(function (t) {
|
||||
return t.text;
|
||||
});
|
||||
@@ -213,9 +198,10 @@ define([
|
||||
}
|
||||
});
|
||||
}
|
||||
this.$scope.ticks = newTicks;
|
||||
this.$scope.ticks = newTicks
|
||||
this.shouldCheckWidth = true;
|
||||
}
|
||||
// todo: break out tick updating.
|
||||
this.scheduleTickUpdate();
|
||||
};
|
||||
|
||||
@@ -231,8 +217,8 @@ define([
|
||||
if (this.shouldCheckWidth) {
|
||||
this.$scope.$digest();
|
||||
var element = this.$element[0],
|
||||
tickElements = element.querySelectorAll('.gl-plot-tick > span'),
|
||||
tickWidth = Number([].reduce.call(tickElements, function (memo, first) {
|
||||
ticks = element.querySelectorAll('.gl-plot-tick > span'),
|
||||
tickWidth = Number([].reduce.call(ticks, function (memo, first) {
|
||||
return Math.max(memo, first.offsetWidth);
|
||||
}, 0));
|
||||
|
||||
|
||||
@@ -1,30 +1,11 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,window*/
|
||||
|
||||
define([
|
||||
'./MCTTicksController'
|
||||
], function (
|
||||
MCTTicksController
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function MCTTicksDirective() {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
@@ -49,10 +49,6 @@ define(
|
||||
this.EXPORT_IMAGE_TIMEOUT = 1000;
|
||||
}
|
||||
|
||||
function changeBackgroundColor(element, color) {
|
||||
element.style.backgroundColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an HTML element into a base64 encoded image
|
||||
* as a BLOB, PNG, or JPG.
|
||||
@@ -60,24 +56,16 @@ define(
|
||||
* @param {string} type of image to convert the element to
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.renderElement = function (element, type, color) {
|
||||
ExportImageService.prototype.renderElement = function (element, type) {
|
||||
var defer = this.$q.defer(),
|
||||
validTypes = ["png", "jpg", "jpeg"],
|
||||
renderTimeout,
|
||||
originalColor;
|
||||
renderTimeout;
|
||||
|
||||
if (validTypes.indexOf(type) === -1) {
|
||||
this.$log.error("Invalid type requested. Try: (" + validTypes.join(",") + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (color) {
|
||||
// Save color to be restored later
|
||||
originalColor = element.style.backgroundColor || '';
|
||||
// Defaulting to white so we can see the chart when printed
|
||||
changeBackgroundColor(element, color);
|
||||
}
|
||||
|
||||
renderTimeout = this.$timeout(function () {
|
||||
defer.reject("html2canvas timed out");
|
||||
this.$log.warn("html2canvas timed out");
|
||||
@@ -86,9 +74,6 @@ define(
|
||||
try {
|
||||
html2canvas(element, {
|
||||
onrendered: function (canvas) {
|
||||
if (color) {
|
||||
changeBackgroundColor(element, originalColor);
|
||||
}
|
||||
switch (type.toLowerCase()) {
|
||||
case "png":
|
||||
canvas.toBlob(defer.resolve, "image/png");
|
||||
@@ -107,40 +92,11 @@ define(
|
||||
this.$log.warn("html2canvas failed with error: " + e);
|
||||
}
|
||||
|
||||
defer.promise.finally(function () {
|
||||
renderTimeout.cancel();
|
||||
if (color) {
|
||||
changeBackgroundColor(element, originalColor);
|
||||
}
|
||||
});
|
||||
defer.promise.finally(renderTimeout.cancel);
|
||||
|
||||
return defer.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a screenshot of a DOM node and exports to JPG.
|
||||
* @param {node} element to be exported
|
||||
* @param {string} filename the exported image
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.exportJPG = function (element, filename, color) {
|
||||
return this.renderElement(element, "jpeg", color).then(function (img) {
|
||||
saveAs(img, filename);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a screenshot of a DOM node and exports to PNG.
|
||||
* @param {node} element to be exported
|
||||
* @param {string} filename the exported image
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.exportPNG = function (element, filename, color) {
|
||||
return this.renderElement(element, "png", color).then(function (img) {
|
||||
saveAs(img, filename);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* canvas.toBlob() not supported in IE < 10, Opera, and Safari. This polyfill
|
||||
* implements the method in browsers that would not otherwise support it.
|
||||
@@ -165,6 +121,30 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a screenshot of a DOM node and exports to JPG.
|
||||
* @param {node} element to be exported
|
||||
* @param {string} filename the exported image
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.exportJPG = function (element, filename) {
|
||||
return this.renderElement(element, "jpeg").then(function (img) {
|
||||
saveAs(img, filename);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a screenshot of a DOM node and exports to PNG.
|
||||
* @param {node} element to be exported
|
||||
* @param {string} filename the exported image
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.exportPNG = function (element, filename) {
|
||||
return this.renderElement(element, "png").then(function (img) {
|
||||
saveAs(img, filename);
|
||||
});
|
||||
};
|
||||
|
||||
polyfillToBlob();
|
||||
|
||||
return ExportImageService;
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
'text!../../res/templates/plot.html'
|
||||
|
||||
@@ -1,26 +1,4 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*jscs:disable disallowDanglingUnderscores */
|
||||
/*global define,Promise*/
|
||||
|
||||
define([
|
||||
'lodash',
|
||||
@@ -33,6 +11,7 @@ define([
|
||||
configStore,
|
||||
eventHelpers
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
TODO: Need to separate off plot configuration and specifying of defaults,
|
||||
@@ -71,6 +50,7 @@ define([
|
||||
this.config.series.forEach(this.addSeries, this);
|
||||
|
||||
this.followTimeConductor();
|
||||
window.plot = this;
|
||||
}
|
||||
|
||||
eventHelpers.extend(PlotController.prototype);
|
||||
@@ -95,7 +75,7 @@ define([
|
||||
PlotController.prototype.addSeries = function (series) {
|
||||
this.listenTo(series, 'change:yKey', function () {
|
||||
this.loadSeriesData(series);
|
||||
}, this);
|
||||
}, this)
|
||||
this.loadSeriesData(series);
|
||||
};
|
||||
|
||||
@@ -217,7 +197,7 @@ define([
|
||||
*/
|
||||
PlotController.prototype.exportJPG = function () {
|
||||
this.hideExportButtons = true;
|
||||
this.exportImageService.exportJPG(this.$element[0], 'plot.jpg', 'white')
|
||||
this.exportImageService.exportJPG(this.$element[0], 'plot.jpg')
|
||||
.finally(function () {
|
||||
this.hideExportButtons = false;
|
||||
}.bind(this));
|
||||
@@ -228,7 +208,7 @@ define([
|
||||
*/
|
||||
PlotController.prototype.exportPNG = function () {
|
||||
this.hideExportButtons = true;
|
||||
this.exportImageService.exportPNG(this.$element[0], 'plot.png', 'white')
|
||||
this.exportImageService.exportPNG(this.$element[0], 'plot.png')
|
||||
.finally(function () {
|
||||
this.hideExportButtons = false;
|
||||
}.bind(this));
|
||||
|
||||
@@ -1,30 +1,11 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define */
|
||||
|
||||
define([
|
||||
'lodash'
|
||||
], function (
|
||||
_
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
function StackedPlotController($scope, openmct, objectService, $element, exportImageService) {
|
||||
var tickWidth = 0,
|
||||
@@ -49,14 +30,11 @@ define([
|
||||
}
|
||||
|
||||
function onDomainObjectChange(domainObject) {
|
||||
var thisRequest = {
|
||||
var thisRequest = currentRequest = $scope.currentRequest = {
|
||||
pending: 0
|
||||
};
|
||||
currentRequest = thisRequest;
|
||||
$scope.currentRequest = thisRequest;
|
||||
var telemetryObjects = $scope.telemetryObjects = [];
|
||||
var thisTickWidthMap = {};
|
||||
tickWidthMap = thisTickWidthMap;
|
||||
var thisTickWidthMap = tickWidthMap = {};
|
||||
|
||||
if (unlisten) {
|
||||
unlisten();
|
||||
|
||||
@@ -31,8 +31,7 @@ define([
|
||||
'./summaryWidget/plugin',
|
||||
'./URLIndicatorPlugin/URLIndicatorPlugin',
|
||||
'./telemetryMean/plugin',
|
||||
'./plot/plugin',
|
||||
'./staticRootPlugin/plugin'
|
||||
'./plot/plugin'
|
||||
], function (
|
||||
_,
|
||||
UTCTimeSystem,
|
||||
@@ -44,8 +43,7 @@ define([
|
||||
SummaryWidget,
|
||||
URLIndicatorPlugin,
|
||||
TelemetryMean,
|
||||
PlotPlugin,
|
||||
StaticRootPlugin
|
||||
PlotPlugin
|
||||
) {
|
||||
var bundleMap = {
|
||||
CouchDB: 'platform/persistence/couch',
|
||||
@@ -68,8 +66,6 @@ define([
|
||||
|
||||
plugins.ImportExport = ImportExport;
|
||||
|
||||
plugins.StaticRootPlugin = StaticRootPlugin;
|
||||
|
||||
/**
|
||||
* A tabular view showing the latest values of multiple telemetry points at
|
||||
* once. Formatted so that labels and values are aligned.
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
define([
|
||||
'../../api/objects/object-utils'
|
||||
], function (
|
||||
objectUtils
|
||||
) {
|
||||
/**
|
||||
* Transforms an import json blob into a object map that can be used to
|
||||
* provide objects. Rewrites root identifier in import data with provided
|
||||
* rootIdentifier, and rewrites all child object identifiers so that they
|
||||
* exist in the same namespace as the rootIdentifier.
|
||||
*/
|
||||
function rewriteObjectIdentifiers(importData, rootIdentifier) {
|
||||
var rootId = importData.rootId;
|
||||
var objectString = JSON.stringify(importData.openmct);
|
||||
|
||||
Object.keys(importData.openmct).forEach(function (originalId, i) {
|
||||
var newId;
|
||||
if (originalId === rootId) {
|
||||
newId = objectUtils.makeKeyString(rootIdentifier);
|
||||
} else {
|
||||
newId = objectUtils.makeKeyString({
|
||||
namespace: rootIdentifier.namespace,
|
||||
key: i
|
||||
});
|
||||
}
|
||||
while (objectString.indexOf(originalId) !== -1) {
|
||||
objectString = objectString.replace(
|
||||
'"' + originalId + '"',
|
||||
'"' + newId + '"'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return JSON.parse(objectString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convets all objects in an object make from old format objects to new
|
||||
* format objects.
|
||||
*/
|
||||
function convertToNewObjects(oldObjectMap) {
|
||||
return Object.keys(oldObjectMap)
|
||||
.reduce(function (newObjectMap, key) {
|
||||
newObjectMap[key] = objectUtils.toNewFormat(oldObjectMap[key], key);
|
||||
return newObjectMap;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/* Set the root location correctly for a top-level object */
|
||||
function setRootLocation(objectMap, rootIdentifier) {
|
||||
objectMap[objectUtils.makeKeyString(rootIdentifier)].location = 'ROOT';
|
||||
return objectMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes importData (as provided by the ImportExport plugin) and exposes
|
||||
* an object provider to fetch those objects.
|
||||
*/
|
||||
function StaticModelProvider(importData, rootIdentifier) {
|
||||
var oldFormatObjectMap = rewriteObjectIdentifiers(importData, rootIdentifier);
|
||||
var newFormatObjectMap = convertToNewObjects(oldFormatObjectMap);
|
||||
this.objectMap = setRootLocation(newFormatObjectMap, rootIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard "Get".
|
||||
*/
|
||||
StaticModelProvider.prototype.get = function (identifier) {
|
||||
var keyString = objectUtils.makeKeyString(identifier);
|
||||
if (this.objectMap[keyString]) {
|
||||
return this.objectMap[keyString];
|
||||
}
|
||||
throw new Error(keyString + ' not found in import models.');
|
||||
};
|
||||
|
||||
return StaticModelProvider;
|
||||
|
||||
});
|
||||
@@ -1,133 +0,0 @@
|
||||
define([
|
||||
'./StaticModelProvider',
|
||||
'text!./static-provider-test.json'
|
||||
], function (
|
||||
StaticModelProvider,
|
||||
testStaticDataText
|
||||
) {
|
||||
|
||||
describe('StaticModelProvider', function () {
|
||||
|
||||
var staticProvider;
|
||||
|
||||
beforeEach(function () {
|
||||
var staticData = JSON.parse(testStaticDataText);
|
||||
staticProvider = new StaticModelProvider(staticData, {
|
||||
namespace: 'my-import',
|
||||
key: 'root'
|
||||
});
|
||||
});
|
||||
|
||||
describe('rootObject', function () {
|
||||
var rootModel;
|
||||
|
||||
beforeEach(function () {
|
||||
rootModel = staticProvider.get({
|
||||
namespace: 'my-import',
|
||||
key: 'root'
|
||||
});
|
||||
});
|
||||
|
||||
it('is located at top level', function () {
|
||||
expect(rootModel.location).toBe('ROOT');
|
||||
});
|
||||
|
||||
it('has new-format identifier', function () {
|
||||
expect(rootModel.identifier).toEqual({
|
||||
namespace: 'my-import',
|
||||
key: 'root'
|
||||
});
|
||||
});
|
||||
|
||||
it('has new-format composition', function () {
|
||||
expect(rootModel.composition).toContain({
|
||||
namespace: 'my-import',
|
||||
key: '1'
|
||||
});
|
||||
expect(rootModel.composition).toContain({
|
||||
namespace: 'my-import',
|
||||
key: '2'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('childObjects', function () {
|
||||
var swg;
|
||||
var layout;
|
||||
var fixed;
|
||||
|
||||
beforeEach(function () {
|
||||
swg = staticProvider.get({
|
||||
namespace: 'my-import',
|
||||
key: '1'
|
||||
});
|
||||
layout = staticProvider.get({
|
||||
namespace: 'my-import',
|
||||
key: '2'
|
||||
});
|
||||
fixed = staticProvider.get({
|
||||
namespace: 'my-import',
|
||||
key: '3'
|
||||
});
|
||||
});
|
||||
|
||||
it('match expected ordering', function () {
|
||||
// this is a sanity check to make sure the identifiers map in
|
||||
// the correct order.
|
||||
expect(swg.type).toBe('generator');
|
||||
expect(layout.type).toBe('layout');
|
||||
expect(fixed.type).toBe('telemetry.fixed');
|
||||
});
|
||||
|
||||
it('have new-style identifiers', function () {
|
||||
expect(swg.identifier).toEqual({
|
||||
namespace: 'my-import',
|
||||
key: '1'
|
||||
});
|
||||
expect(layout.identifier).toEqual({
|
||||
namespace: 'my-import',
|
||||
key: '2'
|
||||
});
|
||||
expect(fixed.identifier).toEqual({
|
||||
namespace: 'my-import',
|
||||
key: '3'
|
||||
});
|
||||
});
|
||||
|
||||
it('have new-style composition', function () {
|
||||
expect(layout.composition).toContain({
|
||||
namespace: 'my-import',
|
||||
key: '1'
|
||||
});
|
||||
expect(layout.composition).toContain({
|
||||
namespace: 'my-import',
|
||||
key: '3'
|
||||
});
|
||||
expect(fixed.composition).toContain({
|
||||
namespace: 'my-import',
|
||||
key: '1'
|
||||
});
|
||||
});
|
||||
|
||||
it('rewrites locations', function () {
|
||||
expect(swg.location).toBe('my-import:root');
|
||||
expect(layout.location).toBe('my-import:root');
|
||||
expect(fixed.location).toBe('my-import:2');
|
||||
});
|
||||
|
||||
it('rewrites matched identifiers in objects', function () {
|
||||
expect(layout.configuration.layout.panels['my-import:1'])
|
||||
.toBeDefined();
|
||||
expect(layout.configuration.layout.panels['my-import:3'])
|
||||
.toBeDefined();
|
||||
expect(layout.configuration.layout.panels['483c00d4-bb1d-4b42-b29a-c58e06b322a0'])
|
||||
.not.toBeDefined();
|
||||
expect(layout.configuration.layout.panels['20273193-f069-49e9-b4f7-b97a87ed755d'])
|
||||
.not.toBeDefined();
|
||||
expect(fixed.configuration['fixed-display'].elements[0].id)
|
||||
.toBe('my-import:1');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
define([
|
||||
'./StaticModelProvider'
|
||||
], function (
|
||||
StaticModelProvider
|
||||
) {
|
||||
/**
|
||||
* Static Root Plugin: takes an export file and exposes it as a new root
|
||||
* object.
|
||||
*/
|
||||
function StaticRootPlugin(namespace, exportUrl) {
|
||||
|
||||
var rootIdentifier = {
|
||||
namespace: namespace,
|
||||
key: 'root'
|
||||
};
|
||||
|
||||
var cachedProvider;
|
||||
|
||||
var loadProvider = function () {
|
||||
return fetch(exportUrl)
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (importData) {
|
||||
cachedProvider = new StaticModelProvider(importData, rootIdentifier);
|
||||
return cachedProvider;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var getProvider = function () {
|
||||
if (!cachedProvider) {
|
||||
cachedProvider = loadProvider();
|
||||
}
|
||||
return Promise.resolve(cachedProvider);
|
||||
};
|
||||
|
||||
return function install(openmct) {
|
||||
openmct.objects.addRoot(rootIdentifier);
|
||||
openmct.objects.addProvider(namespace, {
|
||||
get: function (identifier) {
|
||||
return getProvider().then(function (provider) {
|
||||
return provider.get(identifier);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return StaticRootPlugin;
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
{"openmct":{"a9122832-4b6e-43ea-8219-5359c14c5de8":{"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0","d2ac3ae4-0af2-49fe-81af-adac09936215"],"name":"import-provider-test","type":"folder","notes":"test data for import provider.","modified":1508522673278,"location":"mine","persisted":1508522673278},"483c00d4-bb1d-4b42-b29a-c58e06b322a0":{"telemetry":{"period":10,"amplitude":1,"offset":0,"dataRateInHz":1,"values":[{"key":"utc","name":"Time","format":"utc","hints":{"domain":1,"priority":0},"source":"utc"},{"key":"yesterday","name":"Yesterday","format":"utc","hints":{"domain":2,"priority":1},"source":"yesterday"},{"key":"sin","name":"Sine","hints":{"range":1,"priority":2},"source":"sin"},{"key":"cos","name":"Cosine","hints":{"range":2,"priority":3},"source":"cos"}]},"name":"SWG-10","type":"generator","modified":1508522652874,"location":"a9122832-4b6e-43ea-8219-5359c14c5de8","persisted":1508522652874},"d2ac3ae4-0af2-49fe-81af-adac09936215":{"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0","20273193-f069-49e9-b4f7-b97a87ed755d"],"name":"Layout","type":"layout","configuration":{"layout":{"panels":{"483c00d4-bb1d-4b42-b29a-c58e06b322a0":{"position":[0,0],"dimensions":[17,8]},"20273193-f069-49e9-b4f7-b97a87ed755d":{"position":[0,8],"dimensions":[17,1],"hasFrame":false}}}},"modified":1508522745580,"location":"a9122832-4b6e-43ea-8219-5359c14c5de8","persisted":1508522745580},"20273193-f069-49e9-b4f7-b97a87ed755d":{"layoutGrid":[64,16],"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0"],"name":"FP Test","type":"telemetry.fixed","configuration":{"fixed-display":{"elements":[{"type":"fixed.telemetry","x":0,"y":0,"id":"483c00d4-bb1d-4b42-b29a-c58e06b322a0","stroke":"transparent","color":"","titled":true,"width":8,"height":2,"useGrid":true,"size":"24px"}]}},"modified":1508522717619,"location":"d2ac3ae4-0af2-49fe-81af-adac09936215","persisted":1508522717619}},"rootId":"a9122832-4b6e-43ea-8219-5359c14c5de8"}
|
||||
@@ -15,6 +15,8 @@ define([
|
||||
EventEmitter,
|
||||
$
|
||||
) {
|
||||
|
||||
var CURRENT_CONDITION_COUNT = 0;
|
||||
/**
|
||||
* Represents an individual condition for a summary widget rule. Manages the
|
||||
* associated inputs and view.
|
||||
@@ -26,6 +28,13 @@ define([
|
||||
* selects with configuration data
|
||||
*/
|
||||
function Condition(conditionConfig, index, conditionManager) {
|
||||
if (CURRENT_CONDITION_COUNT > 2000) {
|
||||
console.error('Too many Summary Widget Conditions in use, please ' +
|
||||
'simplify your logic or remove unnecessary summary ' +
|
||||
'widgets from the current display.');
|
||||
throw 'TOO MANY CONDITIONS';
|
||||
}
|
||||
CURRENT_CONDITION_COUNT += 1;
|
||||
eventHelpers.extend(this);
|
||||
this.config = conditionConfig;
|
||||
this.index = index;
|
||||
@@ -37,6 +46,9 @@ define([
|
||||
|
||||
this.deleteButton = $('.t-delete', this.domElement);
|
||||
this.duplicateButton = $('.t-duplicate', this.domElement);
|
||||
this.conditionContents = $('.t-condition-context', this.domElement)
|
||||
this.selectContainer = $('.t-configuration', this.domElement)
|
||||
this.inputArea = $('.t-value-inputs', this.domElement)
|
||||
|
||||
this.selects = {};
|
||||
this.valueInputs = [];
|
||||
@@ -106,10 +118,10 @@ define([
|
||||
});
|
||||
|
||||
Object.values(this.selects).forEach(function (select) {
|
||||
$('.t-configuration', self.domElement).append(select.getDOM());
|
||||
self.selectContainer.append(select.getDOM());
|
||||
});
|
||||
|
||||
this.listenTo($(this.domElement), 'input', onValueInput);
|
||||
this.listenTo(this.domElement, 'input', onValueInput);
|
||||
}
|
||||
|
||||
Condition.prototype.getDOM = function (container) {
|
||||
@@ -148,6 +160,7 @@ define([
|
||||
|
||||
Condition.prototype.destroy = function () {
|
||||
this.stopListening();
|
||||
CURRENT_CONDITION_COUNT -= 1;
|
||||
Object.values(this.selects).forEach(function (select) {
|
||||
select.destroy();
|
||||
});
|
||||
@@ -172,13 +185,12 @@ define([
|
||||
*/
|
||||
Condition.prototype.generateValueInputs = function (operation) {
|
||||
var evaluator = this.conditionManager.getEvaluator(),
|
||||
inputArea = $('.t-value-inputs', this.domElement),
|
||||
inputCount,
|
||||
inputType,
|
||||
newInput,
|
||||
index = 0;
|
||||
|
||||
inputArea.html('');
|
||||
this.inputArea.html('');
|
||||
this.valueInputs = [];
|
||||
|
||||
if (evaluator.getInputCount(operation)) {
|
||||
@@ -190,7 +202,7 @@ define([
|
||||
}
|
||||
newInput = $('<input class="sm" type = "' + inputType + '" value = "' + this.config.values[index] + '"> </input>');
|
||||
this.valueInputs.push(newInput.get(0));
|
||||
inputArea.append(newInput);
|
||||
this.inputArea.append(newInput);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ define([], function () {
|
||||
this.operations = {
|
||||
equalTo: {
|
||||
operation: function (input) {
|
||||
return input[0] === input[1];
|
||||
return Number(input[0]) === Number(input[1]);
|
||||
},
|
||||
text: 'is equal to',
|
||||
appliesTo: ['number'],
|
||||
@@ -66,7 +66,7 @@ define([], function () {
|
||||
},
|
||||
notEqualTo: {
|
||||
operation: function (input) {
|
||||
return input[0] !== input[1];
|
||||
return Number(input[0]) !== Number(input[1]);
|
||||
},
|
||||
text: 'is not equal to',
|
||||
appliesTo: ['number'],
|
||||
@@ -77,7 +77,7 @@ define([], function () {
|
||||
},
|
||||
greaterThan: {
|
||||
operation: function (input) {
|
||||
return input[0] > input[1];
|
||||
return Number(input[0]) > Number(input[1]);
|
||||
},
|
||||
text: 'is greater than',
|
||||
appliesTo: ['number'],
|
||||
@@ -88,7 +88,7 @@ define([], function () {
|
||||
},
|
||||
lessThan: {
|
||||
operation: function (input) {
|
||||
return input[0] < input[1];
|
||||
return Number(input[0]) < Number(input[1]);
|
||||
},
|
||||
text: 'is less than',
|
||||
appliesTo: ['number'],
|
||||
@@ -99,7 +99,7 @@ define([], function () {
|
||||
},
|
||||
greaterThanOrEq: {
|
||||
operation: function (input) {
|
||||
return input[0] >= input[1];
|
||||
return Number(input[0]) >= Number(input[1]);
|
||||
},
|
||||
text: 'is greater than or equal to',
|
||||
appliesTo: ['number'],
|
||||
@@ -110,7 +110,7 @@ define([], function () {
|
||||
},
|
||||
lessThanOrEq: {
|
||||
operation: function (input) {
|
||||
return input[0] <= input[1];
|
||||
return Number(input[0]) <= Number(input[1]);
|
||||
},
|
||||
text: 'is less than or equal to',
|
||||
appliesTo: ['number'],
|
||||
@@ -121,7 +121,7 @@ define([], function () {
|
||||
},
|
||||
between: {
|
||||
operation: function (input) {
|
||||
return input[0] > input[1] && input[0] < input[2];
|
||||
return Number(input[0]) > Number(input[1]) && Number(input[0]) < Number(input[2]);
|
||||
},
|
||||
text: 'is between',
|
||||
appliesTo: ['number'],
|
||||
@@ -132,7 +132,7 @@ define([], function () {
|
||||
},
|
||||
notBetween: {
|
||||
operation: function (input) {
|
||||
return input[0] < input[1] || input[0] > input[2];
|
||||
return Number(input[0]) < Number(input[1]) || Number(input[0]) > Number(input[2]);
|
||||
},
|
||||
text: 'is not between',
|
||||
appliesTo: ['number'],
|
||||
@@ -206,17 +206,6 @@ define([], function () {
|
||||
getDescription: function () {
|
||||
return ' is undefined';
|
||||
}
|
||||
},
|
||||
isDefined: {
|
||||
operation: function (input) {
|
||||
return typeof input[0] !== 'undefined';
|
||||
},
|
||||
text: 'is defined',
|
||||
appliesTo: ['string', 'number'],
|
||||
inputCount: 0,
|
||||
getDescription: function () {
|
||||
return ' is defined';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -315,12 +304,9 @@ define([], function () {
|
||||
op = this.operations[operation] && this.operations[operation].operation;
|
||||
input = telemetryValue && telemetryValue.concat(values);
|
||||
validator = op && this.inputValidators[this.operations[operation].appliesTo[0]];
|
||||
|
||||
if (op && input && validator) {
|
||||
if (this.operations[operation].appliesTo.length === 2) {
|
||||
return (this.validateNumberInput(input) || this.validateStringInput(input)) && op(input);
|
||||
} else {
|
||||
return validator(input) && op(input);
|
||||
}
|
||||
return validator(input) && op(input);
|
||||
} else {
|
||||
throw new Error('Malformed condition');
|
||||
}
|
||||
@@ -335,6 +321,7 @@ define([], function () {
|
||||
ConditionEvaluator.prototype.validateNumberInput = function (input) {
|
||||
var valid = true;
|
||||
input.forEach(function (value) {
|
||||
value = Number(value);
|
||||
valid = valid && (typeof value === 'number');
|
||||
});
|
||||
return valid;
|
||||
|
||||
@@ -33,6 +33,8 @@ define([
|
||||
eventHelpers.extend(this);
|
||||
var self = this;
|
||||
|
||||
this.generateDescription = _.debounce(this.generateDescription.bind(this));
|
||||
|
||||
this.config = ruleConfig;
|
||||
this.domainObject = domainObject;
|
||||
this.openmct = openmct;
|
||||
@@ -62,6 +64,7 @@ define([
|
||||
this.deleteButton = $('.t-delete', this.domElement);
|
||||
this.duplicateButton = $('.t-duplicate', this.domElement);
|
||||
this.addConditionButton = $('.add-condition', this.domElement);
|
||||
this.insertBefore = $('li:last-of-type', this.conditionArea);
|
||||
|
||||
/**
|
||||
* The text inputs for this rule: any input included in this object will
|
||||
@@ -302,11 +305,18 @@ define([
|
||||
};
|
||||
|
||||
/**
|
||||
* Mutate thet domain object with this rule's local configuration
|
||||
* Mutate thet domain object with this rule's local configuration, if it has
|
||||
* changed.
|
||||
*/
|
||||
Rule.prototype.updateDomainObject = function () {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.ruleConfigById.' +
|
||||
this.config.id, this.config);
|
||||
var path = 'configuration.ruleConfigById.' + this.config.id,
|
||||
newConfig = this.config,
|
||||
oldConfig = _.get(this.domainObject, path);
|
||||
|
||||
if (_.isEqual(newConfig, oldConfig)) {
|
||||
return;
|
||||
}
|
||||
this.openmct.objects.mutate(this.domainObject, path, this.config);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -407,9 +417,9 @@ define([
|
||||
this.addConditionButton.show();
|
||||
self.conditions.forEach(function (condition) {
|
||||
$condition = condition.getDOM();
|
||||
$('li:last-of-type', self.conditionArea).before($condition);
|
||||
self.insertBefore.before($condition);
|
||||
if (loopCnt > 0) {
|
||||
$('.t-condition-context', $condition).html(triggerContextStr + ' when');
|
||||
condition.conditionContents.html(triggerContextStr + ' when');
|
||||
}
|
||||
loopCnt++;
|
||||
});
|
||||
@@ -440,6 +450,7 @@ define([
|
||||
this.eventEmitter.emit('conditionChange');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Build a human-readable description from this rule's conditions
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,8 @@ define([
|
||||
self.onEdit([]);
|
||||
}
|
||||
});
|
||||
|
||||
this.executingRules = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +265,7 @@ define([
|
||||
var activeRule = this.rulesById[this.activeId];
|
||||
this.applyStyle($('#widget', this.domElement), activeRule.getProperty('style'));
|
||||
$('#widget', this.domElement).prop('title', activeRule.getProperty('message'));
|
||||
$('#widgetLabel', this.domElement).html(activeRule.getProperty('label'));
|
||||
$('#widgetLabel', this.domElement)[0].innerText = activeRule.getProperty('label');
|
||||
$('#widgetLabel', this.domElement).removeClass().addClass('label widget-label ' + activeRule.getProperty('icon'));
|
||||
};
|
||||
|
||||
@@ -271,11 +273,17 @@ define([
|
||||
* Get the active rule and update the Widget's appearance.
|
||||
*/
|
||||
SummaryWidget.prototype.executeRules = function () {
|
||||
this.activeId = this.conditionManager.executeRules(
|
||||
this.domainObject.configuration.ruleOrder,
|
||||
this.rulesById
|
||||
);
|
||||
this.updateWidget();
|
||||
if (!this.executingRules) {
|
||||
this.executingRules = true;
|
||||
setTimeout(function () {
|
||||
this.activeId = this.conditionManager.executeRules(
|
||||
this.domainObject.configuration.ruleOrder,
|
||||
this.rulesById
|
||||
);
|
||||
this.updateWidget();
|
||||
this.executingRules = false;
|
||||
}.bind(this), 100);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -361,13 +369,20 @@ define([
|
||||
};
|
||||
|
||||
}
|
||||
ruleConfig = this.domainObject.configuration.ruleConfigById[ruleId];
|
||||
this.rulesById[ruleId] = new Rule(ruleConfig, this.domainObject, this.openmct,
|
||||
this.conditionManager, this.widgetDnD, this.container);
|
||||
this.rulesById[ruleId].on('remove', this.refreshRules, this);
|
||||
this.rulesById[ruleId].on('duplicate', this.duplicateRule, this);
|
||||
this.rulesById[ruleId].on('change', this.updateWidget, this);
|
||||
this.rulesById[ruleId].on('conditionChange', this.executeRules, this);
|
||||
try {
|
||||
ruleConfig = JSON.parse(JSON.stringify(this.domainObject.configuration.ruleConfigById[ruleId]));
|
||||
this.rulesById[ruleId] = new Rule(ruleConfig, this.domainObject, this.openmct,
|
||||
this.conditionManager, this.widgetDnD, this.container);
|
||||
this.rulesById[ruleId].on('remove', this.refreshRules, this);
|
||||
this.rulesById[ruleId].on('duplicate', this.duplicateRule, this);
|
||||
this.rulesById[ruleId].on('change', this.updateWidget, this);
|
||||
this.rulesById[ruleId].on('conditionChange', this.executeRules, this);
|
||||
} catch (e) {
|
||||
if (e === 'TOO MANY CONDITIONS') {
|
||||
$('#widgetLabel', this.domElement)[0].innerText = 'TOO MANY CONDITIONS';
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,8 @@ define([
|
||||
|
||||
this.deleteButton = $('.t-delete', this.domElement);
|
||||
this.duplicateButton = $('.t-duplicate', this.domElement);
|
||||
this.equalTo = $('.equal-to', this.domElement);
|
||||
|
||||
|
||||
this.selects = {};
|
||||
this.valueInputs = [];
|
||||
@@ -57,6 +59,13 @@ define([
|
||||
if (property === 'key') {
|
||||
self.generateValueInput(value);
|
||||
}
|
||||
if (property === 'object') {
|
||||
if (!value) {
|
||||
self.equalTo.hide();
|
||||
} else {
|
||||
self.equalTo.show();
|
||||
}
|
||||
}
|
||||
self.eventEmitter.emit('change', {
|
||||
value: value,
|
||||
property: property,
|
||||
|
||||
@@ -60,13 +60,13 @@ define([
|
||||
self.generateOptions();
|
||||
}
|
||||
self.select.setSelected(self.config.key);
|
||||
self.objectSelect.on('change', onObjectChange, this);
|
||||
}
|
||||
|
||||
if (self.manager.metadataLoadCompleted()) {
|
||||
onMetadataLoad();
|
||||
}
|
||||
|
||||
this.objectSelect.on('change', onObjectChange, this);
|
||||
this.manager.on('metadata', onMetadataLoad);
|
||||
|
||||
return this.select;
|
||||
|
||||
@@ -21,6 +21,7 @@ define([
|
||||
var self = this;
|
||||
|
||||
this.domElement = $(selectTemplate);
|
||||
this.$select = $('select', this.domElement);
|
||||
this.options = [];
|
||||
this.eventEmitter = new EventEmitter();
|
||||
this.supportedCallbacks = ['change'];
|
||||
@@ -40,7 +41,7 @@ define([
|
||||
self.eventEmitter.emit('change', value[0]);
|
||||
}
|
||||
|
||||
this.listenTo($('select', this.domElement), 'change', onChange, this);
|
||||
this.listenTo(this.$select, 'change', onChange, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,16 +75,16 @@ define([
|
||||
var self = this,
|
||||
selectedIndex = 0;
|
||||
|
||||
selectedIndex = $('select', this.domElement).prop('selectedIndex');
|
||||
selectedIndex = this.$select.prop('selectedIndex');
|
||||
$('option', this.domElement).remove();
|
||||
|
||||
self.options.forEach(function (option, index) {
|
||||
$('select', self.domElement)
|
||||
self.$select
|
||||
.append('<option value = "' + option[0] + '"' + ' >' +
|
||||
option[1] + '</option>');
|
||||
});
|
||||
|
||||
$('select', this.domElement).prop('selectedIndex', selectedIndex);
|
||||
this.$select.prop('selectedIndex', selectedIndex);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ define([
|
||||
selectedIndex = index;
|
||||
}
|
||||
});
|
||||
$('select', this.domElement).prop('selectedIndex', selectedIndex);
|
||||
this.$select.prop('selectedIndex', selectedIndex);
|
||||
|
||||
selectedOption = this.options[selectedIndex];
|
||||
this.eventEmitter.emit('change', selectedOption[0]);
|
||||
@@ -131,17 +132,15 @@ define([
|
||||
* @return {string}
|
||||
*/
|
||||
Select.prototype.getSelected = function () {
|
||||
return $('select', this.domElement).prop('value');
|
||||
return this.$select.prop('value');
|
||||
};
|
||||
|
||||
Select.prototype.hide = function () {
|
||||
$(this.domElement).addClass('hidden');
|
||||
$('.equal-to').addClass('hidden');
|
||||
this.domElement.addClass('hidden');
|
||||
};
|
||||
|
||||
Select.prototype.show = function () {
|
||||
$(this.domElement).removeClass('hidden');
|
||||
$('.equal-to').removeClass('hidden');
|
||||
this.domElement.removeClass('hidden');
|
||||
};
|
||||
|
||||
Select.prototype.destroy = function () {
|
||||
|
||||
@@ -325,10 +325,6 @@ define(['../src/ConditionEvaluator'], function (ConditionEvaluator) {
|
||||
testOperation = testEvaluator.operations.isUndefined.operation;
|
||||
expect(testOperation([1])).toEqual(false);
|
||||
expect(testOperation([])).toEqual(true);
|
||||
//isDefined
|
||||
testOperation = testEvaluator.operations.isDefined.operation;
|
||||
expect(testOperation([1])).toEqual(true);
|
||||
expect(testOperation([])).toEqual(false);
|
||||
});
|
||||
|
||||
it('can produce a description for all supported operations', function () {
|
||||
|
||||
@@ -115,7 +115,7 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
element.addEventListener('click', selectCapture);
|
||||
|
||||
if (select) {
|
||||
element.click();
|
||||
this.select(selectable);
|
||||
}
|
||||
|
||||
return function () {
|
||||
|
||||
@@ -66,7 +66,7 @@ requirejs.config({
|
||||
"vue": "node_modules/vue/dist/vue.min",
|
||||
"zepto": "bower_components/zepto/zepto.min",
|
||||
"lodash": "bower_components/lodash/lodash",
|
||||
"d3-selection": "node_modules/d3-selection/dist/d3-selection.min",
|
||||
"d3-selection": "node_modules/d3-selection/build/d3-selection.min",
|
||||
"d3-scale": "node_modules/d3-scale/build/d3-scale.min",
|
||||
"d3-axis": "node_modules/d3-axis/build/d3-axis.min",
|
||||
"d3-array": "node_modules/d3-array/build/d3-array.min",
|
||||
|
||||
Reference in New Issue
Block a user