Compare commits

..

96 Commits
cli ... open115

Author SHA1 Message Date
Victor Woeltjen
2848a8458b [Time Conductor] Avoid exception
Avoid exception when trying to generate a single datum in
cases where there is no data yet available.
2015-09-25 11:05:18 -07:00
Victor Woeltjen
cbaf45afe9 [Time Conductor] Update specs
nasa/openmctweb#115
2015-09-25 10:40:19 -07:00
Victor Woeltjen
ff1fd26efc [Time Conductor] Change method name
Prefer simpler method names for public API.
2015-09-24 17:09:06 -07:00
Victor Woeltjen
4ced6c44a6 [Time Conductor] Ignore empty series
...when updating Fixed Position view.
2015-09-24 17:01:50 -07:00
Victor Woeltjen
13525a67c2 [Time Conductor] Fix domain-based calculations
...in example telemetry, to support development work
on time conductor.
2015-09-24 13:21:51 -07:00
Victor Woeltjen
cc6b6538d5 Merge branch 'open1515' into open115 2015-09-24 12:19:08 -07:00
Victor Woeltjen
0c7de98195 [Time Conductor] Use active domain in binary search 2015-09-24 12:18:47 -07:00
Victor Woeltjen
1214a32c26 [Common UI] Avoid apply-in-a-digest
Don't invoke  from mct-resize when first observing
an element's size during linking; observed issue in the
context of adding domain selector to time conductor.
2015-09-24 11:20:07 -07:00
Victor Woeltjen
6bd8e7a47c Merge remote-tracking branch 'github/master' into open1515 2015-09-24 11:17:13 -07:00
Victor Woeltjen
3d8aec2d01 [Time Conductor] Pass domain with events 2015-09-23 17:26:56 -07:00
Victor Woeltjen
928e31b548 [Common UI] Avoid apply-in-a-digest
Don't invoke  from mct-resize when first observing
an element's size during linking; observed issue in the
context of adding domain selector to time conductor.
2015-09-23 17:22:32 -07:00
Victor Woeltjen
f182d1f2c4 [Time Conductor] Include domain selection in requests
...as well as use as default in a telemetry series.
2015-09-23 17:14:40 -07:00
Victor Woeltjen
d238b669a5 [Time Conductor] Show domain options 2015-09-23 17:09:38 -07:00
Victor Woeltjen
5d5a7c26c5 [Time Conductor] Maintain domain state
Maintain domain state in the time conductor; add a default list of
domains to choose from.
2015-09-23 16:53:12 -07:00
Victor Woeltjen
0b0cee3afb [Example] Add domain
Add a second domain to example telemetry, to support
addition of a domain selector to the time conductor;
nasa/openmctweb#115
2015-09-23 16:43:58 -07:00
Victor Woeltjen
0260e6fff4 Merge branch 'open1515' into open115 2015-09-23 16:05:09 -07:00
Victor Woeltjen
f4e53a946d [Time Conductor] Remove from active bundles
Remove time conductor from set of active bundles pending
clean up of markup/CSS.
2015-09-16 18:14:30 -07:00
Victor Woeltjen
de71bde62f [Test Conductor] Add test case for requery
WTD-1515
2015-09-16 17:00:56 -07:00
Victor Woeltjen
8f24e014e0 [Time Conductor] Add skeleton specs
Add skeleton specs to new classes added for date-time
picker in time conductor. WTD-1515
2015-09-16 16:51:28 -07:00
Victor Woeltjen
190f5fd0ea [Time Conductor] Update failing specs
WTD-1515
2015-09-16 15:23:08 -07:00
Victor Woeltjen
ad29fb0f92 [Time Conductor] Populate FP from historical
Populate fixed position view from historical
telemetry when first loaded. WTD-1515
2015-09-16 13:38:47 -07:00
Victor Woeltjen
fcd073c010 [Time Conductor] Tweak plot requery
Tweak approach to requerying in plot, and track
pending state so there is a visual indication
that plotted data may be incomplete during
panning with time conductor. WTD-1515
2015-09-16 11:05:41 -07:00
Victor Woeltjen
071368c3b9 [Time Conductor] Fix throttle bug
Fix a timing/ordering issue in throttle which
allowed some throttled invocations to be ignored.
WTD-1515
2015-09-16 11:04:07 -07:00
Victor Woeltjen
7a97588aa5 [Time Conductor] Remove debugging statement
WTD-1515
2015-09-16 10:30:45 -07:00
Victor Woeltjen
f776561303 [Time Conductor] Allow arguments for throttled functions
WTD-1515. Ensures that bounds passed in from
the time controller get appropriately captured.
2015-09-16 10:18:57 -07:00
Victor Woeltjen
e34fe1a289 [Time Conductor] Tweak position, appearance
...of datetime picker popups. WTD-1515
2015-09-15 18:51:44 -07:00
Victor Woeltjen
70d9587c9b [Time Conductor] Wire in datetime pickers
WTD-1515
2015-09-15 18:48:00 -07:00
Victor Woeltjen
9a78b63065 [Time Conductor] Try to rewrite datetime picker as control 2015-09-15 18:37:36 -07:00
Victor Woeltjen
6c497f3c36 [Time Conductor] Start adding datetime picker
WTD-1515
2015-09-15 18:09:46 -07:00
Victor Woeltjen
d951b794e3 [Time Conductor] Support date choice
...from date-time picker. WTD-1515
2015-09-15 15:55:13 -07:00
Victor Woeltjen
797046aca4 [Time Conductor] Populate datetime picker
WTD-1515
2015-09-15 15:24:54 -07:00
Victor Woeltjen
cf76583ed7 [Time Conductor] Add inline styles to datetime-picker 2015-09-15 14:50:05 -07:00
Victor Woeltjen
6f28ab0145 [Time Conductor] Begin adding custom date picker
WTD-1515
2015-09-15 13:08:05 -07:00
Victor Woeltjen
9ebf157ec0 [Time Conductor] Test telemetry service decorator
WTD-1515
2015-09-15 11:18:28 -07:00
Victor Woeltjen
493c63be44 [Time Conductor] Test series wrapping
WTD-1515
2015-09-15 10:58:10 -07:00
Victor Woeltjen
f29951140f [Time Conductor] Add license header, JSDoc
WTD-1515
2015-09-15 10:22:43 -07:00
Victor Woeltjen
d0b5bb2d21 [Time Conductor] Begin using date-time controls
WTD-1515
2015-09-15 10:00:41 -07:00
Victor Woeltjen
cd98886a43 [Time Conductor] Add license header
WTD-1515
2015-09-15 08:59:57 -07:00
Victor Woeltjen
4549828cae Merge remote-tracking branch 'github/master' into open1515 2015-09-15 08:57:49 -07:00
Victor Woeltjen
d0478c3433 [Scrolling List] Check for existence of limit
Check for existence of limit capability while evaluating
limits in a scrolling list view. WTD-1515
2015-09-14 16:37:29 -07:00
Victor Woeltjen
53369ec0dc [Time Conductor] Avoid searching outside of series
Don't look up domain values while subsetting a
telemetry series until after checking to ensure
that there is some segment of the series left
to search. WTD-1515
2015-09-14 16:36:41 -07:00
Victor Woeltjen
de99969f0a [Time Controller] Return range values
Delegate retrieval of range values appropriately in
conductor-driven telemetry series subset. WTD-1515
2015-09-14 14:39:19 -07:00
Victor Woeltjen
24449d2dcc [Time Controller] Fix series subsetting
Fix binary search implementation used to subset
telemetry series for time conductor. WTD-1515
2015-09-14 11:44:50 -07:00
Victor Woeltjen
f42c5ca1e5 [Time Conductor] Subset to display bounds
WTD-1515
2015-09-14 11:25:42 -07:00
Victor Woeltjen
890aafc203 [Time Controller] Filter out realtime updates
Filter out realtime updates that are outside of the time
controller's range. WTD-1515
2015-09-14 10:02:59 -07:00
Victor Woeltjen
2a14cf2dfc [Time Controller] Only listen for display-bounds changes
...from plot. WTD-1515
2015-09-11 11:31:12 -07:00
Victor Woeltjen
62962e119e [Time Controller] Decorate telemetry service
Decorate telemetry service instead of capability service
to enforce time conductor bounds. WTD-1515.
2015-09-10 16:17:48 -07:00
Victor Woeltjen
2229e868ce [Time Conductor] Fix logic around end times
Fix logic for updating end times after refactoring
to clarify variable/property naming, WTD-1515
2015-09-10 13:24:50 -07:00
Victor Woeltjen
8d209f4d19 [Time Controller] Fix middle-drag bug
Fix bug in middle-drag introduced by refactoring,
WTD-1515.
2015-09-10 11:34:31 -07:00
Victor Woeltjen
86bb89a162 [Time Controller] Update spec
Update spec for ConductorRepresenter to reflect changes
to model properties expected by TimeRangeController.
WTD-1515
2015-09-10 11:31:40 -07:00
Victor Woeltjen
2758250833 [Time Conductor] Fix JSDoc
Fix copy-paste error. WTD-1515
2015-09-10 11:27:50 -07:00
Victor Woeltjen
7d20351a6a [Time Conductor] Clean up code style
Clean up code style in TelemetrySubscription, for
changes associated with WTD-1515.
2015-09-10 11:20:09 -07:00
Victor Woeltjen
78fae345da [Time Conductor] Rename TimeConductorController
Rename TimeConductorController to TimeRangeController, to
reflect that this is intended to serve as a more general
control. Additionally, stop using arrays for inner and
outer bounds and instead use explicit start/end properties,
for clarity. WTD-1515
2015-09-10 10:58:47 -07:00
Victor Woeltjen
4c79c9a1b1 [Time Conductor] Clarify start/end naming
WTD-1515
2015-09-10 10:21:21 -07:00
Victor Woeltjen
2ec9956d44 [Time Conductor] Incorporate feedback from code review
Retain reference to scope in ConductorRepresenter
directly via this, instead of revealing via
a closure-bound function. This approach is not necessary
to avoid https://docs.angularjs.org/error/ng/cpws in
this circumstance.  WTD-1515
2015-09-10 10:16:28 -07:00
Victor Woeltjen
e3b191b5dc [Time Controller] Update failing specs
Update failing specs to reflect support for time conductor,
WTD-1515
2015-09-09 16:52:46 -07:00
Victor Woeltjen
a4dda695dd [Time Controller] Get conductor working with fixed pos.
WTD-1515
2015-09-09 16:46:00 -07:00
Victor Woeltjen
0d710209b1 Merge remote-tracking branch 'github/master' into open1515 2015-09-09 10:05:21 -07:00
Victor Woeltjen
fdbc91131b [Time Controller] Update bundle definition
...for Fixed Position view to reflect changes to dependencies,
WTD-1515.
2015-09-08 17:18:39 -07:00
Victor Woeltjen
d2dfec3ce7 [Time Controller] Simplify retrieval of datum objects
...for historical data. Supports WTD-1515
2015-09-08 17:03:58 -07:00
Victor Woeltjen
351181d38e [Time Controller] Allow datum retrieval from histories
WTD-1515
2015-09-08 16:58:15 -07:00
Victor Woeltjen
760f4b818f [Time Conductor] Update fixed position from history
WTD-1515
2015-09-08 16:53:06 -07:00
Victor Woeltjen
c026bfa17d [Time Conductor] Begin adding support to fixed position
Begin adding support for universal time controller to
fixed position view, WTD-1515.
2015-09-08 16:37:10 -07:00
Victor Woeltjen
47b97a504e [Telemetry] Document TelemetryRequest
Document TelemetryRequest to record new parameters in
support of the time conductor, WTD-1515
2015-09-08 16:28:01 -07:00
Victor Woeltjen
29c460556a [Representers] Destroy representers
Invoke the destroy methods of any active representers when
a scope is destroyed; supports time controller, which needs
to accurately track when it has or hasn't been attached to
a view. WTD-1515
2015-09-04 16:00:43 -07:00
Victor Woeltjen
4d276888e1 [Plot] Update failining spec
WTD-1515
2015-09-04 15:53:55 -07:00
Victor Woeltjen
142af3db77 [Time Controller] Add JSDoc
WTD-1515
2015-09-04 15:51:46 -07:00
Victor Woeltjen
b66759e519 [Plot] Initially establish bounds
Initially establish domain bounds with time controller,
WTD-1515
2015-09-04 15:31:47 -07:00
Victor Woeltjen
c58ffb4a52 [Time Controller] Update inner span
Update inner span when outer dates change (if needed),
WTD-1515
2015-09-04 15:15:09 -07:00
Victor Woeltjen
600ff1a3ee [Plot] Requery on event
Requery on a query change event from a time conductor,
WTD-1515
2015-09-04 15:07:46 -07:00
Victor Woeltjen
77d11e1bcf [Time Controller] Fix sine wave generation
Generate sine wave correctly when start time has been specified,
WTD-1515
2015-09-04 14:24:45 -07:00
Victor Woeltjen
d158aa6028 [Plot] Follow time conductor more smoothly
WTD-1515
2015-09-04 14:04:09 -07:00
Victor Woeltjen
c2985d61b7 [Plot] Follow universal time controller
Follow displayable area of universal time controller,
WTD-1515
2015-09-04 13:57:26 -07:00
Victor Woeltjen
3ce40ab870 [Time Controller] Fix capability decoration
WTD-1515
2015-09-04 13:02:36 -07:00
Victor Woeltjen
bfb19dea74 [Time Controller] Use start time in example
WTD-1515
2015-09-04 12:52:02 -07:00
Victor Woeltjen
01a6d2e6a7 [Time Controller] Test ConductorRepresenter
WTD-1515
2015-09-04 12:44:49 -07:00
Victor Woeltjen
af462ff3ee [Time Controller] Begin adding mocks
Begin adding/configuring mocks to support testing
ConductorRepresenter, WTD-1515
2015-09-04 12:12:21 -07:00
Victor Woeltjen
5c1d209eff [Time Controller] Simplify ConductorRepresenter
WTD-1515
2015-09-04 11:53:51 -07:00
Victor Woeltjen
8a76c3a425 [Time Controller] Test conductor's telemetry capability
WTD-1515
2015-09-04 10:57:50 -07:00
Victor Woeltjen
9ccd0b9188 [Time Conductor] Test capability decorator
WTD-1515
2015-09-04 10:47:38 -07:00
Victor Woeltjen
f83588d980 [Time Controller] Begin adding test cases
WTD-1515
2015-09-04 10:32:01 -07:00
Victor Woeltjen
a481b377cb [Time Conductor] Add terminology note to readme
WTD-1515
2015-09-04 10:24:18 -07:00
Victor Woeltjen
35ff4efbca [Time Conductor] Add placeholder specs
Add empty specs for classes related to time conductor, WTD-1515
2015-09-04 09:44:08 -07:00
Victor Woeltjen
436e010738 [Time Conductor] Broadcast changes
WTD-1515
2015-09-03 15:59:46 -07:00
Victor Woeltjen
bf4765fcb6 [Time Controller] Bind displayed control to state
Bind changes to the displayed time controller to
changes to the underlying state of the time conductor,
WTD-1515.
2015-09-03 15:13:03 -07:00
Victor Woeltjen
dbfb8b9861 [Time Controller] Add capability decorator
WTD-1515
2015-09-03 14:58:49 -07:00
Victor Woeltjen
681cd0bb9c [Time Controller] Add conductor service
WTD-1515.
2015-09-03 14:53:23 -07:00
Victor Woeltjen
b668fb58fb [Time Controller] Show only outermost controller
WTD-1515
2015-09-03 11:44:11 -07:00
Victor Woeltjen
f74da6b935 [Time Controller] Add overflow hidden
Add overflow: hidden so that time controller does not exceed
edges of the screen. WTD-1515
2015-09-03 11:40:40 -07:00
Victor Woeltjen
e4dec21ceb [Time Controller] Add telemetry capability wrapper
WTD-1515
2015-09-03 11:38:06 -07:00
Victor Woeltjen
fc2860810b [Time Controller] Allow manual date entry
WTD-1515
2015-09-03 11:03:17 -07:00
Victor Woeltjen
9d6b70f433 [Time Conductor] Handle middle drag
WTD-1515
2015-09-02 17:25:41 -07:00
Victor Woeltjen
57a947eaef [Time Conductor] Accept drag gestures
WTD-1515
2015-09-02 17:19:20 -07:00
Victor Woeltjen
a18cc50a43 [Time Conductor] Begin binding control to data 2015-09-02 16:53:10 -07:00
Victor Woeltjen
91fe3d798f [Time Conductor] Begin adding controller
WTD-1515
2015-09-02 16:31:58 -07:00
Victor Woeltjen
e873389655 [Conductor] Add time conductor widget
Add widget for the time conductor using a representer,
WTD-1515.
2015-09-02 15:57:52 -07:00
65 changed files with 2731 additions and 775 deletions

View File

@@ -238,9 +238,6 @@ Commit messages should:
* Contain a reference to a relevant issue number in the body of the commit.
* This is important for traceability; while branch names also provide this,
you cannot tell from looking at a commit what branch it was authored on.
* This may be omitted if the relevant issue is otherwise obvious from the
commit history (that is, if using `git log` from the relevant commit
directly leads to a similar issue reference) to minimize clutter.
* Describe the change that was made, and any useful rationale therefore.
* Comments in code should explain what things do, commit messages describe
how they came to be done that way.

View File

@@ -34,6 +34,10 @@
{
"key": "time",
"name": "Time"
},
{
"key": "yesterday",
"name": "Yesterday"
}
],
"ranges": [
@@ -61,4 +65,4 @@
}
]
}
}
}

View File

@@ -25,8 +25,8 @@
* Module defining SinewaveTelemetryProvider. Created by vwoeltje on 11/12/14.
*/
define(
["./SinewaveTelemetry"],
function (SinewaveTelemetry) {
["./SinewaveTelemetrySeries"],
function (SinewaveTelemetrySeries) {
"use strict";
/**
@@ -45,7 +45,7 @@ define(
function generateData(request) {
return {
key: request.key,
telemetry: new SinewaveTelemetry(request)
telemetry: new SinewaveTelemetrySeries(request)
};
}
@@ -112,4 +112,4 @@ define(
return SinewaveTelemetryProvider;
}
);
);

View File

@@ -29,35 +29,47 @@ define(
function () {
"use strict";
var firstObservedTime = Date.now();
var ONE_DAY = 60 * 60 * 24,
firstObservedTime = Math.floor(Date.now() / 1000) - ONE_DAY;
/**
*
* @constructor
*/
function SinewaveTelemetry(request) {
var latestObservedTime = Date.now(),
count = Math.floor((latestObservedTime - firstObservedTime) / 1000),
period = request.period || 30,
generatorData = {};
function SinewaveTelemetrySeries(request) {
var timeOffset = (request.domain === 'yesterday') ? ONE_DAY : 0,
latestTime = Math.floor(Date.now() / 1000) - timeOffset,
firstTime = firstObservedTime - timeOffset,
endTime = (request.end !== undefined) ?
Math.floor(request.end / 1000) : latestTime,
count = Math.min(endTime, latestTime) - firstTime,
period = +request.period || 30,
generatorData = {},
requestStart = (request.start === undefined) ? firstTime :
Math.max(Math.floor(request.start / 1000), firstTime),
offset = requestStart - firstTime;
if (request.size !== undefined) {
offset = Math.max(offset, count - request.size);
}
generatorData.getPointCount = function () {
return count;
return count - offset;
};
generatorData.getDomainValue = function (i, domain) {
return i * 1000 +
(domain !== 'delta' ? firstObservedTime : 0);
return (i + offset) * 1000 + firstTime * 1000 -
(domain === 'yesterday' ? ONE_DAY : 0);
};
generatorData.getRangeValue = function (i, range) {
range = range || "sin";
return Math[range](i * Math.PI * 2 / period);
return Math[range]((i + offset) * Math.PI * 2 / period);
};
return generatorData;
}
return SinewaveTelemetry;
return SinewaveTelemetrySeries;
}
);
);

View File

@@ -1,22 +0,0 @@
{
"extensions": {
"routes": [
{
"when": "/cli",
"templateUrl": "templates/cli.html"
}
],
"controllers": [
{
"key": "CLIController",
"implementation": "CLIController.js",
"depends": [ "$scope", "navigationService", "objectService" ]
}
],
"stylesheets": [
{
"stylesheetUrl": "stylesheets/cli.css"
}
]
}
}

View File

@@ -1,47 +0,0 @@
.iw-container {
position: absolute;
bottom: 30px;
left: 0;
top: 0;
right: 0;
}
.iw-stdin {
position: absolute;
bottom: 0;
left: 0;
height: 30px;
width: calc(100% - 8px);
margin: 4px;
font-family: monospace;
font-size: 16px;
}
.iw-stdout {
position: absolute;
left: 6px;
right: 6px;
top: 12px;
bottom: 44px;
border: 1px #211 solid;
border-radius: 12px;
padding: 8px;
background: #302;
overflow: auto;
box-shadow: inset 0px 2px 8px 0px rgba(0, 0, 0, 0.5);
}
.iw-stdout span {
display: block;
font-family: monospace;
color: #FD9;
font-size: 16px;
margin-top: 2px;
margin-bottom: 2px;
min-height: 1em;
white-space: pre;
}
.iw-stdout span.iw-user-input {
color: gray;
}

View File

@@ -1,15 +0,0 @@
<div class="abs holder-all browse-mode" ng-controller="CLIController">
<div class="iw-container">
<div class="iw-stdout" mct-scroll-y="stdoutScroll">
<span ng-repeat="line in stdout track by $index"
class="{{line.cssClass}}"
ng-bind="line.text">
</span>
</div>
<form ng-submit="enter(stdin)">
<input type="text" class="iw-stdin" ng-model="stdin" autofocus>
</form>
</div>
<mct-include key="'bottombar'"></mct-include>
</div>

View File

@@ -1,177 +0,0 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(function () {
'use strict';
return function CLIController($scope, navigationService, objectService) {
var unlistenToMutation,
currentComposition = [];
function print(str, cssClass) {
$scope.stdout.push({
text: str,
cssClass: cssClass
});
$scope.stdoutScroll = Number.MAX_VALUE;
}
function pad(str, length) {
while (str.length < length) {
str += " ";
}
return str;
}
function summarize(domainObject) {
var type = domainObject.getCapability("type"),
typeName = type ? type.getName() : "Object",
location = domainObject.getCapability('location'),
isLink = (location && location.isLink()),
suffix = isLink ? " (link)" : "";
return "[" + typeName + "] " + domainObject.getModel().name + suffix;
}
function printComposition(domainObject) {
return domainObject.useCapability("composition").then(function (c) {
currentComposition = c;
c.forEach(function (childObject, i) {
print(i + ") " + summarize(childObject));
});
});
}
function printObject(domainObject, callback) {
// Exclude the root object; nobody wants to see that
if (domainObject.hasCapability("context")) {
print(summarize(domainObject));
}
if (domainObject.hasCapability('composition')) {
printComposition(domainObject).then(callback);
} else {
callback();
}
}
function unlisten() {
if (unlistenToMutation) {
unlistenToMutation();
unlistenToMutation = undefined;
}
}
function navChange(domainObject) {
unlisten();
unlistenToMutation = domainObject.getCapability("mutation")
.listen(function () { printObject(domainObject); });
printObject(domainObject);
}
function findTarget(id) {
if (id === "this") {
return navigationService.getNavigation();
} else {
return currentComposition[parseInt(id, 10)];
}
}
function listActions(domainObject, index) {
// Don't show actions for the root
if (!domainObject.hasCapability('context')) {
return;
}
domainObject.getCapability('action').getActions().forEach(function (a) {
var metadata = a.getMetadata(),
desc = metadata.description,
suffix = index !== undefined ? (" " + index) : "";
print(pad(metadata.key + suffix, 32) + (desc || ""));
});
}
function performAction(domainObject, action) {
domainObject.getCapability('action').perform(action);
}
function handleInput(input) {
var parts = input.split(" "),
targetObject;
if (input.length === 0) {
targetObject = navigationService.getNavigation();
if (targetObject) {
printObject(targetObject, function () {
print("");
listActions(targetObject);
});
}
return;
} else if (parts.length === 1) {
if (isNaN(parseInt(parts[0], 10))) {
targetObject = navigationService.getNavigation();
performAction(targetObject, parts[0]);
return;
}
targetObject = findTarget(parts[0]);
if (targetObject) {
listActions(targetObject, parts[0]);
return;
}
} else if (parts.length === 2) {
targetObject = findTarget(parts[1]);
if (targetObject) {
performAction(targetObject, parts[0]);
return;
}
}
// Any parse-able input should have returned already.
print("SYNTAX ERROR. READY.");
}
if (!navigationService.getNavigation()) {
objectService.getObjects(["ROOT"]).then(function (objects) {
navigationService.setNavigation(objects.ROOT);
});
}
navigationService.addListener(navChange);
$scope.stdout = [];
$scope.stdin = "";
$scope.stdoutScroll = 0;
$scope.enter = function (input) {
$scope.stdin = "";
print("");
print(input, "iw-user-input");
print("");
handleInput(input);
};
$scope.$on("$destroy", function () {
navigationService.removeListener(navChange);
unlisten();
});
};
});

View File

@@ -105,15 +105,9 @@
"actions": [
{
"key": "navigate",
"description": "Browse to this object.",
"implementation": "navigation/NavigateAction.js",
"depends": [ "navigationService", "$q" ]
},
{
"key": "back",
"implementation": "navigation/BackAction.js",
"description": "Navigate to the parent of this object."
},
{
"key": "window",
"name": "Open In New Tab",

View File

@@ -24,7 +24,7 @@
<a
class='type-icon icon ui-symbol s-back'
ng-show="context.getPath().length > 2"
ng-click="domainObject.getCapability('action').perform('back')">
ng-click="context.getParent().getCapability('action').perform('navigate')">
{
</a>

View File

@@ -53,12 +53,11 @@ define(
*/
function CreateAction(type, parent, context, dialogService, creationService, policyService) {
this.metadata = {
key: 'create.' + type.getKey(),
key: 'create',
glyph: type.getGlyph(),
name: type.getName(),
type: type.getKey(),
description: type.getDescription(),
category: [ 'creation' ],
context: context
};

View File

@@ -63,10 +63,7 @@ define(
// domain object to serve as the container for the
// newly-created object (although the user may later
// make a different selection)
if (!destination) {
return [];
}
if (context.category && context.category !== "creation") {
if (key !== 'create' || !destination) {
return [];
}

View File

@@ -41,7 +41,7 @@ define(
// Update the set of Create actions
function refreshActions() {
$scope.createActions = $scope.action ?
$scope.action.getActions({ category: "creation" }) :
$scope.action.getActions('create') :
[];
}

View File

@@ -1,68 +0,0 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
/**
* Module defining NavigateAction. Created by vwoeltje on 11/10/14.
*/
define(
[],
function () {
"use strict";
/**
* The `back` action navigates to the contextual parent of a
* specific domain object.
* @memberof platform/commonUI/browse
* @constructor
* @implements {Action}
*/
function BackAction(context) {
this.domainObject = context.domainObject;
}
/**
* Navigate to the object described in the context.
* @returns {Promise} a promise that is resolved once the
* navigation has been updated
*/
BackAction.prototype.perform = function () {
var parent = this.domainObject.getCapability("context")
.getParent();
return parent.getCapability("action").perform("navigate");
};
/**
* Navigate as an action is only applicable when a domain object
* is described in the action context.
* @param {ActionContext} context the context in which the action
* will be performed
* @returns {boolean} true if applicable
*/
BackAction.appliesTo = function (context) {
return context.domainObject !== undefined &&
context.domainObject.hasCapability("context");
};
return BackAction;
}
);

View File

@@ -53,10 +53,9 @@ define(
// based on whether or not we are currently
// full screen.
var metadata = Object.create(FullscreenAction);
metadata.key = "fullscreen";
metadata.glyph = screenfull.isFullscreen ? "_" : "z";
metadata.description = screenfull.isFullscreen ?
EXIT_FULLSCREEN : ENTER_FULLSCREEN;
EXIT_FULLSCREEN : ENTER_FULLSCREEN;
metadata.group = "windowing";
metadata.context = this.context;
return metadata;

View File

@@ -45,6 +45,16 @@
}
],
"controllers": [
{
"key": "TimeRangeController",
"implementation": "controllers/TimeRangeController.js",
"depends": [ "$scope", "now" ]
},
{
"key": "DateTimePickerController",
"implementation": "controllers/DateTimePickerController.js",
"depends": [ "$scope", "now" ]
},
{
"key": "TreeNodeController",
"implementation": "controllers/TreeNodeController.js",
@@ -105,11 +115,21 @@
"implementation": "directives/MCTDrag.js",
"depends": [ "$document" ]
},
{
"key": "mctClickElsewhere",
"implementation": "directives/MCTClickElsewhere.js",
"depends": [ "$document" ]
},
{
"key": "mctResize",
"implementation": "directives/MCTResize.js",
"depends": [ "$timeout" ]
},
{
"key": "mctPopup",
"implementation": "directives/MCTPopup.js",
"depends": [ "$window", "$document", "$compile", "$interval" ]
},
{
"key": "mctScrollX",
"implementation": "directives/MCTScroll.js",
@@ -213,6 +233,10 @@
{
"key": "selector",
"templateUrl": "templates/controls/selector.html"
},
{
"key": "datetime-picker",
"templateUrl": "templates/controls/datetime-picker.html"
}
],
"licenses": [

View File

@@ -0,0 +1,61 @@
<!--
Open MCT Web, Copyright (c) 2014-2015, United States Government
as represented by the Administrator of the National Aeronautics and Space
Administration. All rights reserved.
Open MCT Web is licensed under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Open MCT Web includes source code licensed under additional open source
licenses. See the Open Source Licenses file (LICENSES.md) included with
this source code distribution or the Licensing information page available
at runtime from the About dialog for additional information.
-->
<div ng-controller="DateTimePickerController">
<div style="vertical-align: top; display: inline-block">
<div style="text-align: center;">
<a ng-click="changeMonth(-1)">&lt;</a>
{{month}} {{year}}
<a ng-click="changeMonth(1)">&gt;</a>
</div>
<div>
<table>
<tr>
<th ng-repeat="day in ['Su','Mo','Tu','We','Th','Fr','Sa']">
{{day}}
</th>
</tr>
<tr ng-repeat="row in table">
<td style="text-align: center;"
ng-repeat="cell in row"
ng-click="select(cell)"
ng-class='{
disabled: !isSelectable(cell),
test: isSelected(cell)
}'>
<div>{{cell.day}}</div>
<div style="font-size: 80%">{{cell.dayOfYear}}</div>
</td>
</tr>
</table>
</div>
</div>
<div style="vertical-align: top; display: inline-block"
ng-repeat="key in ['hours', 'minutes', 'seconds']"
ng-if="options[key]">
<div>{{nameFor(key)}}</div>
<select size="10"
ng-model="time[key]"
ng-options="i for i in optionsFor(key)">
</select>
</div>
</div>

View File

@@ -1,69 +1,96 @@
<!--
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.
NOTES
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.
Ticks:
The thinking is to divide whatever the current time span is by 5,
and assign values accordingly to 5 statically-positioned ticks. So the tick x-position is a static percentage
of the total width available, and the labels change dynamically. This is consistent
with our current approach to the time axis of plots.
I'm keeping the number of ticks low so that when the view portal gets narrow,
the tick labels won't collide with each other. For extra credit, add/remove ticks as the user resizes the view area.
Note: this eval needs to be based on the whatever is containing the
time-controller component, not the whole browser window.
Range indicator and slider knobs:
The left and right properties used in .slider .range-holder and the .knobs are
CSS offsets from the left and right of their respective containers. You
may want or need to calculate those positions as pure offsets from the start datetime
(or left, as it were) and set them as left properties. No problem if so, but
we'll need to tweak the CSS tiny bit to get the center of the knobs to line up
properly on the range left and right bounds.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Open MCT Web includes source code licensed under additional open source
licenses. See the Open Source Licenses file (LICENSES.md) included with
this source code distribution or the Licensing information page available
at runtime from the About dialog for additional information.
-->
<div ng-init="
notes = 'Temporarily using an array to populate ticks so I can see what I\'m doing';
ticks = [
'00:00',
'00:30',
'01:00',
'01:30',
'02:00'
];
"></div>
<div class="l-time-controller" ng-controller="TimeRangeController">
<div class="l-time-range-inputs-holder">
Start: {{startOuterText}}
<span ng-controller="ToggleController as t">
<a class="ui-symbol" ng-click="t.toggle()">p</a>
<mct-popup ng-if="t.isActive()">
<div style="background: #222;"
mct-click-elsewhere="t.setState(false)">
<mct-control key="'datetime-picker'"
ng-model="ngModel.outer"
field="'start'"
options="{ hours: true }">
</mct-control>
</div>
</mct-popup>
</span>
<div class="l-time-controller">
<div class="l-time-range-inputs-holder">
Start: <input type="date" />
End: <input type="date" />
</div>
End: {{endOuterText}}
<span ng-controller="ToggleController as t2">
<a class="ui-symbol" ng-click="t2.toggle()">p</a>
<mct-popup ng-if="t2.isActive()">
<div style="background: #222;"
mct-click-elsewhere="t2.setState(false)">
<mct-control key="'datetime-picker'"
ng-model="ngModel.outer"
field="'end'"
options="{ hours: true }">
</mct-control>
</div>
</mct-popup>
</span>
<div class="l-time-range-slider-holder">
<div class="l-time-range-slider">
<div class="slider">
<div class="slot range-holder">
<div class="range" style="left: 0%; right: 30%;"></div>
</div>
<div class="knob knob-l" style="left: 0%;">
<div class="range-value">05/22 14:46</div>
</div>
<div class="knob knob-r" style="right: 30%;">
<div class="range-value">07/22 01:21</div>
</div>
</div>
</div>
</div>
<div class="l-time-range-ticks-holder">
<div class="l-time-range-ticks">
<div
ng-repeat="tick in ticks"
ng-style="{ left: $index * 25 + '%' }"
class="tick tick-x"
>
<span class="l-time-range-tick-label">{{tick}}</span>
</div>
</div>
</div>
</div>
</div>
<div class="l-time-range-slider-holder">
<div class="l-time-range-slider">
<div class="slider"
mct-resize="spanWidth = bounds.width">
<div class="slot range-holder">
<div class="range"
mct-drag-down="startMiddleDrag()"
mct-drag="middleDrag(delta[0])"
ng-style="{ left: startInnerPct, right: endInnerPct}">
</div>
</div>
<div class="knob knob-l"
mct-drag-down="startLeftDrag()"
mct-drag="leftDrag(delta[0])"
ng-style="{ left: startInnerPct }">
<div class="range-value">{{startInnerText}}</div>
</div>
<div class="knob knob-r"
mct-drag-down="startRightDrag()"
mct-drag="rightDrag(delta[0])"
ng-style="{ right: endInnerPct }">
<div class="range-value">{{endInnerText}}</div>
</div>
</div>
</div>
</div>
<div class="l-time-range-ticks-holder">
<div class="l-time-range-ticks">
<div
ng-repeat="tick in ticks"
ng-style="{ left: $index * (100 / (ticks.length - 1)) + '%' }"
class="tick tick-x"
>
<span class="l-time-range-tick-label">{{tick}}</span>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,202 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
define(
[ 'moment' ],
function (moment) {
'use strict';
var TIME_NAMES = {
'hours': "Hour",
'minutes': "Minute",
'seconds': "Second"
},
MONTHS = moment.months(),
TIME_OPTIONS = (function makeRanges() {
var arr = [];
while (arr.length < 60) {
arr.push(arr.length);
}
return {
hours: arr.slice(0, 24),
minutes: arr,
seconds: arr
};
}());
/**
* Controller to support the date-time picker.
*
* Adds/uses the following properties in scope:
* * `year`: Year being displayed in picker
* * `month`: Month being displayed
* * `table`: Table being displayed; array of arrays of
* * `day`: Day of month
* * `dayOfYear`: Day of year
* * `month`: Month associated with the day
* * `year`: Year associated with the day.
* * `date`: Date chosen
* * `year`: Year selected
* * `month`: Month selected (0-indexed)
* * `day`: Day of month selected
* * `time`: Chosen time (hours/minutes/seconds)
* * `hours`: Hours chosen
* * `minutes`: Minutes chosen
* * `seconds`: Seconds chosen
*
* Months are zero-indexed, day-of-months are one-indexed.
*/
function DateTimePickerController($scope, now) {
var year,
month, // For picker state, not model state
interacted = false;
function generateTable() {
var m = moment.utc({ year: year, month: month }).day(0),
table = [],
row,
col;
for (row = 0; row < 6; row += 1) {
table.push([]);
for (col = 0; col < 7; col += 1) {
table[row].push({
year: m.year(),
month: m.month(),
day: m.date(),
dayOfYear: m.dayOfYear()
});
m.add(1, 'days'); // Next day!
}
}
return table;
}
function updateScopeForMonth() {
$scope.month = MONTHS[month];
$scope.year = year;
$scope.table = generateTable();
}
function updateFromModel(ngModel) {
var m;
m = moment.utc(ngModel);
$scope.date = {
year: m.year(),
month: m.month(),
day: m.date()
};
$scope.time = {
hours: m.hour(),
minutes: m.minute(),
seconds: m.second()
};
//window.alert($scope.date.day + " " + ngModel);
// Zoom to that date in the picker, but
// only if the user hasn't interacted with it yet.
if (!interacted) {
year = m.year();
month = m.month();
updateScopeForMonth();
}
}
function updateFromView() {
var m = moment.utc({
year: $scope.date.year,
month: $scope.date.month,
day: $scope.date.day,
hour: $scope.time.hours,
minute: $scope.time.minutes,
second: $scope.time.seconds
});
$scope.ngModel[$scope.field] = m.valueOf();
}
$scope.isSelectable = function (cell) {
return cell.month === month;
};
$scope.isSelected = function (cell) {
var date = $scope.date || {};
return cell.day === date.day &&
cell.month === date.month &&
cell.year === date.year;
};
$scope.select = function (cell) {
$scope.date = $scope.date || {};
$scope.date.month = cell.month;
$scope.date.year = cell.year;
$scope.date.day = cell.day;
updateFromView();
};
$scope.dateEquals = function (d1, d2) {
return d1.year === d2.year &&
d1.month === d2.month &&
d1.day === d2.day;
};
$scope.changeMonth = function (delta) {
month += delta;
if (month > 11) {
month = 0;
year += 1;
}
if (month < 0) {
month = 11;
year -= 1;
}
interacted = true;
updateScopeForMonth();
};
$scope.nameFor = function (key) {
return TIME_NAMES[key];
};
$scope.optionsFor = function (key) {
return TIME_OPTIONS[key];
};
updateScopeForMonth();
// Ensure some useful default
$scope.ngModel[$scope.field] =
$scope.ngModel[$scope.field] === undefined ?
now() : $scope.ngModel[$scope.field];
$scope.$watch('ngModel[field]', updateFromModel);
$scope.$watchCollection('date', updateFromView);
$scope.$watchCollection('time', updateFromView);
}
return DateTimePickerController;
}
);

View File

@@ -0,0 +1,224 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
define(
['moment'],
function (moment) {
"use strict";
var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
/**
* @memberof platform/commonUI/general
* @constructor
*/
function TimeConductorController($scope, now) {
var tickCount = 2,
initialDragValue;
function formatTimestamp(ts) {
return moment.utc(ts).format(DATE_FORMAT);
}
// From 0.0-1.0 to "0%"-"1%"
function toPercent(p) {
return (100 * p) + "%";
}
function updateTicks() {
var i, p, ts, start, end, span;
end = $scope.ngModel.outer.end;
start = $scope.ngModel.outer.start;
span = end - start;
$scope.ticks = [];
for (i = 0; i < tickCount; i += 1) {
p = i / (tickCount - 1);
ts = p * span + start;
$scope.ticks.push(formatTimestamp(ts));
}
}
function updateSpanWidth(w) {
// Space about 100px apart
tickCount = Math.max(Math.floor(w / 100), 2);
updateTicks();
}
function updateViewForInnerSpanFromModel(ngModel) {
var span = ngModel.outer.end - ngModel.outer.start;
// Expose readable dates for the knobs
$scope.startInnerText = formatTimestamp(ngModel.inner.start);
$scope.endInnerText = formatTimestamp(ngModel.inner.end);
// And positions for the knobs
$scope.startInnerPct =
toPercent((ngModel.inner.start - ngModel.outer.start) / span);
$scope.endInnerPct =
toPercent((ngModel.outer.end - ngModel.inner.end) / span);
}
function defaultBounds() {
var t = now();
return {
start: t - 24 * 3600 * 1000, // One day
end: t
};
}
function copyBounds(bounds) {
return { start: bounds.start, end: bounds.end };
}
function updateViewFromModel(ngModel) {
var t = now();
ngModel = ngModel || {};
ngModel.outer = ngModel.outer || defaultBounds();
ngModel.inner = ngModel.inner || copyBounds(ngModel.outer);
// First, dates for the date pickers for outer bounds
$scope.startOuterDate = new Date(ngModel.outer.start);
$scope.endOuterDate = new Date(ngModel.outer.end);
// Then various updates for the inner span
updateViewForInnerSpanFromModel(ngModel);
// Stick it back is scope (in case we just set defaults)
$scope.ngModel = ngModel;
updateTicks();
}
function startLeftDrag() {
initialDragValue = $scope.ngModel.inner.start;
}
function startRightDrag() {
initialDragValue = $scope.ngModel.inner.end;
}
function startMiddleDrag() {
initialDragValue = {
start: $scope.ngModel.inner.start,
end: $scope.ngModel.inner.end
};
}
function toMillis(pixels) {
var span = $scope.ngModel.outer.end - $scope.ngModel.outer.start;
return (pixels / $scope.spanWidth) * span;
}
function clamp(value, low, high) {
return Math.max(low, Math.min(high, value));
}
function leftDrag(pixels) {
var delta = toMillis(pixels);
$scope.ngModel.inner.start = clamp(
initialDragValue + delta,
$scope.ngModel.outer.start,
$scope.ngModel.inner.end
);
updateViewFromModel($scope.ngModel);
}
function rightDrag(pixels) {
var delta = toMillis(pixels);
$scope.ngModel.inner.end = clamp(
initialDragValue + delta,
$scope.ngModel.inner.start,
$scope.ngModel.outer.end
);
updateViewFromModel($scope.ngModel);
}
function middleDrag(pixels) {
var delta = toMillis(pixels),
edge = delta < 0 ? 'start' : 'end',
opposite = delta < 0 ? 'end' : 'start';
// Adjust the position of the edge in the direction of drag
$scope.ngModel.inner[edge] = clamp(
initialDragValue[edge] + delta,
$scope.ngModel.outer.start,
$scope.ngModel.outer.end
);
// Adjust opposite knob to maintain span
$scope.ngModel.inner[opposite] = $scope.ngModel.inner[edge] +
initialDragValue[opposite] - initialDragValue[edge];
updateViewFromModel($scope.ngModel);
}
function updateOuterStart(t) {
var ngModel = $scope.ngModel;
ngModel.outer.end =
Math.max(ngModel.outer.start, ngModel.outer.end);
ngModel.inner.start =
Math.max(ngModel.outer.start, ngModel.inner.start);
ngModel.inner.end =
Math.max(ngModel.outer.start, ngModel.inner.end);
$scope.startOuterText = formatTimestamp(t);
updateViewForInnerSpanFromModel(ngModel);
}
function updateOuterEnd(t) {
var ngModel = $scope.ngModel;
ngModel.outer.start =
Math.min(ngModel.outer.end, ngModel.outer.start);
ngModel.inner.start =
Math.min(ngModel.outer.end, ngModel.inner.start);
ngModel.inner.end =
Math.min(ngModel.outer.end, ngModel.inner.end);
$scope.endOuterText = formatTimestamp(t);
updateViewForInnerSpanFromModel(ngModel);
}
$scope.startLeftDrag = startLeftDrag;
$scope.startRightDrag = startRightDrag;
$scope.startMiddleDrag = startMiddleDrag;
$scope.leftDrag = leftDrag;
$scope.rightDrag = rightDrag;
$scope.middleDrag = middleDrag;
$scope.state = false;
$scope.ticks = [];
// Initialize scope to defaults
updateViewFromModel($scope.ngModel);
$scope.$watchCollection("ngModel", updateViewFromModel);
$scope.$watch("spanWidth", updateSpanWidth);
$scope.$watch("ngModel.outer.start", updateOuterStart);
$scope.$watch("ngModel.outer.end", updateOuterEnd);
}
return TimeConductorController;
}
);

View File

@@ -0,0 +1,77 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
[],
function () {
"use strict";
/**
* The `mct-click-elsewhere` directive will evaluate its
* associated expression whenever a `mousedown` occurs anywhere
* outside of the element that has the `mct-click-elsewhere`
* directive attached. This is useful for dismissing popups
* and the like.
*/
function MCTClickElsewhere($document) {
// Link; install event handlers.
function link(scope, element, attrs) {
// Keep a reference to the body, to attach/detach
// mouse event handlers; mousedown and mouseup cannot
// only be attached to the element being linked, as the
// mouse may leave this element during the drag.
var body = $document.find('body');
function clickBody(event) {
var x = event.clientX,
y = event.clientY,
rect = element[0].getBoundingClientRect(),
xMin = rect.left,
xMax = xMin + rect.width,
yMin = rect.top,
yMax = yMin + rect.height;
if (x < xMin || x > xMax || y < yMin || y > yMax) {
scope.$eval(attrs.mctClickElsewhere);
}
}
body.on("mousedown", clickBody);
scope.$on("$destroy", function () {
body.off("mousedown", clickBody);
});
}
return {
// mct-drag only makes sense as an attribute
restrict: "A",
// Link function, to install event handlers
link: link
};
}
return MCTClickElsewhere;
}
);

View File

@@ -0,0 +1,70 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
function () {
'use strict';
var TEMPLATE = "<div></div>";
function MCTPopup($window, $document, $compile) {
function link(scope, element, attrs, ctrl, transclude) {
var body = $document.find('body'),
popup = $compile(TEMPLATE)(scope),
winDim = [$window.innerWidth, $window.innerHeight],
rect = element.parent()[0].getBoundingClientRect(),
position = [ rect.left, rect.top ],
isLeft = position[0] <= (winDim[0] / 2),
isTop = position[1] <= (winDim[1] / 2);
popup.css('position', 'absolute');
popup.css(
isLeft ? 'left' : 'right',
(isLeft ? position[0] : (winDim[0] - position[0])) + 'px'
);
popup.css(
isTop ? 'top' : 'bottom',
(isTop ? position[1] : (winDim[1] - position[1])) + 'px'
);
body.append(popup);
transclude(function (clone) {
popup.append(clone);
});
scope.$on('$destroy', function () {
popup.remove();
});
}
return {
restrict: "E",
transclude: true,
link: link,
scope: {}
};
}
return MCTPopup;
}
);

View File

@@ -58,6 +58,7 @@ define(
// Link; start listening for changes to an element's size
function link(scope, element, attrs) {
var lastBounds,
linking = true,
active = true;
// Determine how long to wait before the next update
@@ -74,7 +75,9 @@ define(
lastBounds.width !== bounds.width ||
lastBounds.height !== bounds.height) {
scope.$eval(attrs.mctResize, { bounds: bounds });
scope.$apply(); // Trigger a digest
if (!linking) { // Avoid apply-in-a-digest
scope.$apply();
}
lastBounds = bounds;
}
}
@@ -101,6 +104,9 @@ define(
// Handle the initial callback
onInterval();
// Trigger scope.$apply on subsequent changes
linking = false;
}
return {

View File

@@ -49,22 +49,17 @@ define(
var expr = attrs[attribute],
parsed = $parse(expr);
// Set the element's scroll to match the scope's state
function updateElement(value) {
element[0][property] = value;
}
// Handle event; assign to scroll state to scope
function updateScope() {
parsed.assign(scope, element[0][property]);
scope.$apply(expr);
}
// Set the element's scroll to match the scope's state
function updateElement(value) {
element[0][property] = value;
// Some values may be out of range for the scroll bar,
// so publish the real scroll value back into scope.
if (element[0][property] !== value) {
parsed.assign(scope, element[0][property]);
}
}
// Initialize state in scope
parsed.assign(scope, element[0][property]);

View File

@@ -0,0 +1,63 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../../src/controllers/DateTimePickerController"],
function (DateTimePickerController) {
"use strict";
describe("The DateTimePickerController", function () {
var mockScope,
mockNow,
controller;
function fireWatch(expr, value) {
mockScope.$watch.calls.forEach(function (call) {
if (call.args[0] === expr) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$apply", "$watch", "$watchCollection" ]
);
mockScope.ngModel = {};
mockScope.field = "testField";
mockNow = jasmine.createSpy('now');
controller = new DateTimePickerController(mockScope, mockNow);
});
it("watches the model that was passed in", function () {
expect(mockScope.$watch).toHaveBeenCalledWith(
"ngModel[field]",
jasmine.any(Function)
);
});
});
}
);

View File

@@ -0,0 +1,67 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../../src/controllers/TimeRangeController"],
function (TimeRangeController) {
"use strict";
describe("The TimeRangeController", function () {
var mockScope,
mockNow,
controller;
function fireWatch(expr, value) {
mockScope.$watch.calls.forEach(function (call) {
if (call.args[0] === expr) {
call.args[1](value);
}
});
}
function fireWatchCollection(expr, value) {
mockScope.$watchCollection.calls.forEach(function (call) {
if (call.args[0] === expr) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$apply", "$watch", "$watchCollection" ]
);
mockNow = jasmine.createSpy('now');
controller = new TimeRangeController(mockScope, mockNow);
});
it("watches the model that was passed in", function () {
expect(mockScope.$watchCollection)
.toHaveBeenCalledWith("ngModel", jasmine.any(Function));
});
});
}
);

View File

@@ -0,0 +1,84 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/directives/MCTClickElsewhere"],
function (MCTClickElsewhere) {
"use strict";
var JQLITE_METHODS = [ "on", "off", "find", "parent" ];
describe("The mct-click-elsewhere directive", function () {
var mockDocument,
mockScope,
mockElement,
testAttrs,
mockBody,
mockParentEl,
testRect,
mctClickElsewhere;
function testEvent(x, y) {
return {
pageX: x,
pageY: y,
preventDefault: jasmine.createSpy("preventDefault")
};
}
beforeEach(function () {
mockDocument =
jasmine.createSpyObj("$document", JQLITE_METHODS);
mockScope =
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
mockElement =
jasmine.createSpyObj("element", JQLITE_METHODS);
mockBody =
jasmine.createSpyObj("body", JQLITE_METHODS);
mockParentEl =
jasmine.createSpyObj("parent", ["getBoundingClientRect"]);
testAttrs = {
mctClickElsewhere: "some Angular expression"
};
testRect = {
left: 20,
top: 42,
width: 60,
height: 75
};
mockDocument.find.andReturn(mockBody);
mctClickElsewhere = new MCTClickElsewhere(mockDocument);
mctClickElsewhere.link(mockScope, mockElement, testAttrs);
});
it("is valid as an attribute", function () {
expect(mctClickElsewhere.restrict).toEqual("A");
});
});
}
);

View File

@@ -0,0 +1,105 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/directives/MCTPopup"],
function (MCTPopup) {
"use strict";
var JQLITE_METHODS = [ "on", "off", "find", "parent", "css", "append" ];
describe("The mct-popup directive", function () {
var testWindow,
mockDocument,
mockCompile,
mockScope,
mockElement,
testAttrs,
mockBody,
mockTransclude,
mockParentEl,
testRect,
mctPopup;
function testEvent(x, y) {
return {
pageX: x,
pageY: y,
preventDefault: jasmine.createSpy("preventDefault")
};
}
beforeEach(function () {
testWindow =
{ innerWidth: 600, innerHeight: 300 };
mockDocument =
jasmine.createSpyObj("$document", JQLITE_METHODS);
mockCompile =
jasmine.createSpy("$compile");
mockScope =
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
mockElement =
jasmine.createSpyObj("element", JQLITE_METHODS);
mockBody =
jasmine.createSpyObj("body", JQLITE_METHODS);
mockTransclude =
jasmine.createSpy("transclude");
mockParentEl =
jasmine.createSpyObj("parent", ["getBoundingClientRect"]);
testAttrs = {
mctClickElsewhere: "some Angular expression"
};
testRect = {
left: 20,
top: 42,
width: 60,
height: 75
};
mockDocument.find.andReturn(mockBody);
mockCompile.andReturn(jasmine.createSpy());
mockCompile().andCallFake(function () {
return jasmine.createSpyObj("newElement", JQLITE_METHODS);
});
mockElement.parent.andReturn([mockParentEl]);
mockParentEl.getBoundingClientRect.andReturn(testRect);
mctPopup = new MCTPopup(testWindow, mockDocument, mockCompile);
mctPopup.link(
mockScope,
mockElement,
testAttrs,
null,
mockTransclude
);
});
it("is valid as an element", function () {
expect(mctPopup.restrict).toEqual("E");
});
});
}
);

View File

@@ -3,14 +3,18 @@
"controllers/BottomBarController",
"controllers/ClickAwayController",
"controllers/ContextMenuController",
"controllers/DateTimePickerController",
"controllers/GetterSetterController",
"controllers/SelectorController",
"controllers/SplitPaneController",
"controllers/TimeRangeController",
"controllers/ToggleController",
"controllers/TreeNodeController",
"controllers/ViewSwitcherController",
"directives/MCTClickElsewhere",
"directives/MCTContainer",
"directives/MCTDrag",
"directives/MCTPopup",
"directives/MCTResize",
"directives/MCTScroll",
"services/UrlService",

View File

@@ -36,11 +36,16 @@ define(
*
* Returns a function that, when invoked, will invoke `fn` after
* `delay` milliseconds, only if no other invocations are pending.
* The optional argument `apply` determines whether.
* The optional argument `apply` determines whether or not a
* digest cycle should be triggered.
*
* The returned function will itself return a `Promise` which will
* resolve to the returned value of `fn` whenever that is invoked.
*
* In cases where arguments are provided, only the most recent
* set of arguments will be passed on to the throttled function
* at the time it is executed.
*
* @returns {Function}
* @memberof platform/core
*/
@@ -56,12 +61,14 @@ define(
* @memberof platform/core.Throttle#
*/
return function (fn, delay, apply) {
var activeTimeout;
var promise, // Promise for the result of throttled function
args = [];
// Clear active timeout, so that next invocation starts
// a new one.
function clearActiveTimeout() {
activeTimeout = undefined;
function invoke() {
// Clear the active timeout so a new one starts next time.
promise = undefined;
// Invoke the function with the latest supplied arguments.
return fn.apply(null, args);
}
// Defaults
@@ -69,14 +76,13 @@ define(
apply = apply || false;
return function () {
// Store arguments from this invocation
args = Array.prototype.slice.apply(arguments, [0]);
// Start a timeout if needed
if (!activeTimeout) {
activeTimeout = $timeout(fn, delay, apply);
activeTimeout.then(clearActiveTimeout);
}
promise = promise || $timeout(invoke, delay, apply);
// Return whichever timeout is active (to get
// a promise for the results of fn)
return activeTimeout;
return promise;
};
};
}

View File

@@ -45,7 +45,9 @@ define(
// Verify precondition: Not called at throttle-time
expect(mockTimeout).not.toHaveBeenCalled();
expect(throttled()).toEqual(mockPromise);
expect(mockTimeout).toHaveBeenCalledWith(mockFn, 0, false);
expect(mockFn).not.toHaveBeenCalled();
expect(mockTimeout)
.toHaveBeenCalledWith(jasmine.any(Function), 0, false);
});
it("schedules only one timeout at a time", function () {
@@ -59,10 +61,11 @@ define(
it("schedules additional invocations after resolution", function () {
var throttled = throttle(mockFn);
throttled();
mockPromise.then.mostRecentCall.args[0](); // Resolve timeout
mockTimeout.mostRecentCall.args[0](); // Resolve timeout
throttled();
mockPromise.then.mostRecentCall.args[0]();
mockTimeout.mostRecentCall.args[0]();
throttled();
mockTimeout.mostRecentCall.args[0]();
expect(mockTimeout.calls.length).toEqual(3);
});
});

View File

@@ -30,14 +30,6 @@
"category": "contextual",
"implementation": "actions/LinkAction.js",
"depends": ["locationService", "linkService"]
},
{
"key": "follow",
"name": "Go To Original",
"description": "Go to the original, un-linked instance of this object.",
"glyph": "\u00F4",
"category": "contextual",
"implementation": "actions/GoToOriginalAction.js"
}
],
"components": [
@@ -60,8 +52,7 @@
"key": "location",
"name": "Location Capability",
"description": "Provides a capability for retrieving the location of an object based upon it's context.",
"implementation": "capabilities/LocationCapability",
"depends": [ "$q", "$injector" ]
"implementation": "capabilities/LocationCapability"
}
],
"services": [

View File

@@ -12,41 +12,11 @@ define(
*
* @constructor
*/
function LocationCapability($q, $injector, domainObject) {
function LocationCapability(domainObject) {
this.domainObject = domainObject;
this.$q = $q;
this.$injector = $injector;
return this;
}
/**
* Get an instance of this domain object in its original location.
*
* @returns {Promise.<DomainObject>} a promise for the original
* instance of this domain object
*/
LocationCapability.prototype.getOriginal = function () {
var id;
if (this.isOriginal()) {
return this.$q.when(this.domainObject);
}
id = this.domainObject.getId();
this.objectService =
this.objectService || this.$injector.get("objectService");
// Assume that an object will be correctly contextualized when
// loaded directly from the object service; this is true
// so long as LocatingObjectDecorator is present, and that
// decorator is also contained in this bundle.
return this.objectService.getObjects([id])
.then(function (objects) {
return objects[id];
});
};
/**
* Set the primary location (the parent id) of the current domain
* object.
@@ -108,6 +78,10 @@ define(
return !this.isLink();
};
return LocationCapability;
function createLocationCapability(domainObject) {
return new LocationCapability(domainObject);
}
return createLocationCapability;
}
);

View File

@@ -1,95 +0,0 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/actions/GoToOriginalAction',
'../DomainObjectFactory',
'../ControlledPromise'
],
function (GoToOriginalAction, domainObjectFactory, ControlledPromise) {
'use strict';
describe("The 'go to original' action", function () {
var testContext,
originalDomainObject,
mockLocationCapability,
mockOriginalActionCapability,
originalPromise,
action;
beforeEach(function () {
mockLocationCapability = jasmine.createSpyObj(
'location',
[ 'isLink', 'isOriginal', 'getOriginal' ]
);
mockOriginalActionCapability = jasmine.createSpyObj(
'action',
[ 'perform', 'getActions' ]
);
originalPromise = new ControlledPromise();
mockLocationCapability.getOriginal.andReturn(originalPromise);
mockLocationCapability.isLink.andReturn(true);
mockLocationCapability.isOriginal.andCallFake(function () {
return !mockLocationCapability.isLink();
});
testContext = {
domainObject: domainObjectFactory({
capabilities: {
location: mockLocationCapability
}
})
};
originalDomainObject = domainObjectFactory({
capabilities: {
action: mockOriginalActionCapability
}
});
action = new GoToOriginalAction(testContext);
});
it("is applicable to links", function () {
expect(GoToOriginalAction.appliesTo(testContext))
.toBeTruthy();
});
it("is not applicable to originals", function () {
mockLocationCapability.isLink.andReturn(false);
expect(GoToOriginalAction.appliesTo(testContext))
.toBeFalsy();
});
it("navigates to original objects when performed", function () {
expect(mockOriginalActionCapability.perform)
.not.toHaveBeenCalled();
action.perform();
originalPromise.resolve(originalDomainObject);
expect(mockOriginalActionCapability.perform)
.toHaveBeenCalledWith('navigate');
});
});
}
);

View File

@@ -7,7 +7,6 @@ define(
'../ControlledPromise'
],
function (LocationCapability, domainObjectFactory, ControlledPromise) {
'use strict';
describe("LocationCapability", function () {
@@ -15,17 +14,13 @@ define(
var locationCapability,
persistencePromise,
mutationPromise,
mockQ,
mockInjector,
mockObjectService,
domainObject;
beforeEach(function () {
domainObject = domainObjectFactory({
id: "testObject",
capabilities: {
context: {
getParent: function () {
getParent: function() {
return domainObjectFactory({id: 'root'});
}
},
@@ -40,11 +35,6 @@ define(
}
});
mockQ = jasmine.createSpyObj("$q", ["when"]);
mockInjector = jasmine.createSpyObj("$injector", ["get"]);
mockObjectService =
jasmine.createSpyObj("objectService", ["getObjects"]);
persistencePromise = new ControlledPromise();
domainObject.capabilities.persistence.persist.andReturn(
persistencePromise
@@ -59,11 +49,7 @@ define(
}
);
locationCapability = new LocationCapability(
mockQ,
mockInjector,
domainObject
);
locationCapability = new LocationCapability(domainObject);
});
it("returns contextual location", function () {
@@ -102,57 +88,6 @@ define(
expect(whenComplete).toHaveBeenCalled();
});
describe("when used to load an original instance", function () {
var objectPromise,
qPromise,
originalObjects,
mockCallback;
function resolvePromises() {
if (mockQ.when.calls.length > 0) {
qPromise.resolve(mockQ.when.mostRecentCall.args[0]);
}
if (mockObjectService.getObjects.calls.length > 0) {
objectPromise.resolve(originalObjects);
}
}
beforeEach(function () {
objectPromise = new ControlledPromise();
qPromise = new ControlledPromise();
originalObjects = {
testObject: domainObjectFactory()
};
mockInjector.get.andCallFake(function (key) {
return key === 'objectService' && mockObjectService;
});
mockObjectService.getObjects.andReturn(objectPromise);
mockQ.when.andReturn(qPromise);
mockCallback = jasmine.createSpy('callback');
});
it("provides originals directly", function () {
domainObject.model.location = 'root';
locationCapability.getOriginal().then(mockCallback);
expect(mockCallback).not.toHaveBeenCalled();
resolvePromises();
expect(mockCallback)
.toHaveBeenCalledWith(domainObject);
});
it("loads from the object service for links", function () {
domainObject.model.location = 'some-other-root';
locationCapability.getOriginal().then(mockCallback);
expect(mockCallback).not.toHaveBeenCalled();
resolvePromises();
expect(mockCallback)
.toHaveBeenCalledWith(originalObjects.testObject);
});
});
});
});
}

View File

@@ -1,9 +1,5 @@
[
"actions/AbstractComposeAction",
"actions/CopyAction",
"actions/GoToOriginalAction",
"actions/LinkAction",
"actions/MoveAction",
"services/CopyService",
"services/LinkService",
"services/MoveService",

View File

@@ -0,0 +1,9 @@
Provides the time conductor, a control which appears at the
bottom of the screen allowing telemetry start and end times
to be modified.
Note that the term "time controller" is generally preferred
outside of the code base (e.g. in UI documents, issues, etc.);
the term "time conductor" is being used in code to avoid
confusion with "controllers" in the Model-View-Controller
sense.

View File

@@ -0,0 +1,41 @@
{
"extensions": {
"representers": [
{
"implementation": "ConductorRepresenter.js",
"depends": [ "conductorService", "$compile", "views[]" ]
}
],
"components": [
{
"type": "decorator",
"provides": "telemetryService",
"implementation": "ConductorTelemetryDecorator.js",
"depends": [ "conductorService" ]
}
],
"services": [
{
"key": "conductorService",
"implementation": "ConductorService.js",
"depends": [ "now", "TIME_CONDUCTOR_DOMAINS" ]
}
],
"templates": [
{
"key": "time-conductor",
"templateUrl": "templates/time-conductor.html"
}
],
"constants": [
{
"key": "TIME_CONDUCTOR_DOMAINS",
"value": [
{ "key": "time", "name": "Time" },
{ "key": "yesterday", "name": "Yesterday" }
],
"comment": "Placeholder; to be replaced by inspection of available domains."
}
]
}
}

View File

@@ -0,0 +1,8 @@
<mct-control key="'select'"
ng-model='ngModel'
field="'domain'"
options="ngModel.options">
</mct-control>
<mct-include key="'time-controller'"
ng-model='ngModel.conductor'>
</mct-include>

View File

@@ -0,0 +1,192 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
[],
function () {
"use strict";
var CONDUCTOR_HEIGHT = "100px",
TEMPLATE = [
'<div style=',
'"position: absolute; bottom: 0; width: 100%; ',
'overflow: hidden; ',
'height: ' + CONDUCTOR_HEIGHT + '">',
"<mct-include key=\"'time-conductor'\" ng-model='ngModel'>",
"</mct-include>",
'</div>'
].join(''),
GLOBAL_SHOWING = false;
/**
* The ConductorRepresenter attaches the universal time conductor
* to views.
*
* @implements {Representer}
* @constructor
* @memberof platform/features/conductor
* @param {platform/features/conductor.ConductorService} conductorService
* service which provides the active time conductor
* @param $compile Angular's $compile
* @param {ViewDefinition[]} views all defined views
* @param {Scope} the scope of the representation
* @param element the jqLite-wrapped representation element
*/
function ConductorRepresenter(conductorService, $compile, views, scope, element) {
this.scope = scope;
this.conductorService = conductorService;
this.element = element;
this.views = views;
this.$compile = $compile;
}
// Combine start/end times & domain into a single object
function bounds(start, end, domain) {
return { start: start, end: end, domain: domain };
}
// Update the time conductor from the scope
function wireScope(conductor, conductorScope, repScope) {
function updateConductorOuter() {
conductor.queryStart(conductorScope.ngModel.conductor.outer.start);
conductor.queryEnd(conductorScope.ngModel.conductor.outer.end);
repScope.$broadcast('telemetry:query:bounds', bounds(
conductor.queryStart(),
conductor.queryEnd(),
conductor.domain()
));
}
function updateConductorInner() {
conductor.displayStart(conductorScope.ngModel.conductor.inner.start);
conductor.displayEnd(conductorScope.ngModel.conductor.inner.end);
repScope.$broadcast('telemetry:display:bounds', bounds(
conductor.displayStart(),
conductor.displayEnd(),
conductor.domain()
));
}
function updateDomain(value) {
conductor.domain(value);
repScope.$broadcast('telemetry:display:bounds', bounds(
conductor.displayStart(),
conductor.displayEnd(),
conductor.domain()
));
}
// telemetry domain metadata -> option for a select control
function makeOption(domainOption) {
return {
name: domainOption.name,
value: domainOption.key
};
}
conductorScope.ngModel = {};
conductorScope.ngModel.conductor = {
outer: bounds(conductor.queryStart(), conductor.queryEnd()),
inner: bounds(conductor.displayStart(), conductor.displayEnd())
};
conductorScope.ngModel.options =
conductor.domainOptions().map(makeOption);
conductorScope.ngModel.domain = conductor.domain();
conductorScope
.$watch('ngModel.conductor.outer.start', updateConductorOuter);
conductorScope
.$watch('ngModel.conductor.outer.end', updateConductorOuter);
conductorScope
.$watch('ngModel.conductor.inner.start', updateConductorInner);
conductorScope
.$watch('ngModel.conductor.inner.end', updateConductorInner);
conductorScope
.$watch('ngModel.domain', updateDomain);
repScope.$on('telemetry:view', updateConductorInner);
}
ConductorRepresenter.prototype.conductorScope = function (s) {
return (this.cScope = arguments.length > 0 ?
s : this.cScope);
};
// Handle a specific representation of a specific domain object
ConductorRepresenter.prototype.represent = function represent(representation, representedObject) {
this.destroy();
if (this.views.indexOf(representation) !== -1 && !GLOBAL_SHOWING) {
// Track original states
this.originalHeight = this.element.css('height');
this.hadAbs = this.element.hasClass('abs');
// Create a new scope for the conductor
this.conductorScope(this.scope.$new());
wireScope(
this.conductorService.getConductor(),
this.conductorScope(),
this.scope
);
this.conductorElement =
this.$compile(TEMPLATE)(this.conductorScope());
this.element.after(this.conductorElement[0]);
this.element.addClass('abs');
this.element.css('bottom', CONDUCTOR_HEIGHT);
GLOBAL_SHOWING = true;
}
};
// Respond to the destruction of the current representation.
ConductorRepresenter.prototype.destroy = function destroy() {
// We may not have decided to show in the first place,
// so circumvent any unnecessary cleanup
if (!this.conductorElement) {
return;
}
// Restore the original size of the mct-representation
if (!this.hadAbs) {
this.element.removeClass('abs');
}
this.element.css('height', this.originalHeight);
// ...and remove the conductor
if (this.conductorElement) {
this.conductorElement.remove();
this.conductorElement = undefined;
}
// Finally, destroy its scope
if (this.conductorScope()) {
this.conductorScope().$destroy();
this.conductorScope(undefined);
}
GLOBAL_SHOWING = false;
};
return ConductorRepresenter;
}
);

View File

@@ -19,44 +19,46 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
/*global define */
define(
function () {
"use strict";
['./TimeConductor'],
function (TimeConductor) {
'use strict';
var ONE_DAY_IN_MS = 1000 * 60 * 60 * 24,
SIX_HOURS_IN_MS = ONE_DAY_IN_MS / 4;
/**
* Implements the "Go To Original" action, which follows a link back
* to an original instance of an object.
* Provides a single global instance of the time conductor, which
* controls both query ranges and displayed ranges for telemetry
* data.
*
* @implements {Action}
* @constructor
* @private
* @memberof platform/entanglement
* @param {ActionContext} context the context in which the action
* will be performed
* @memberof platform/features/conductor
* @param {Function} now a function which returns the current time
* as a UNIX timestamp, in milliseconds
*/
function GoToOriginalAction(context) {
this.domainObject = context.domainObject;
function ConductorService(now, domains) {
var initialEnd =
Math.ceil(now() / SIX_HOURS_IN_MS) * SIX_HOURS_IN_MS;
this.conductor = new TimeConductor(
initialEnd - ONE_DAY_IN_MS,
initialEnd,
domains
);
}
GoToOriginalAction.prototype.perform = function () {
return this.domainObject.getCapability("location").getOriginal()
.then(function (originalObject) {
var actionCapability =
originalObject.getCapability("action");
return actionCapability &&
actionCapability.perform("navigate");
});
/**
* Get the global instance of the time conductor.
* @returns {platform/features/conductor.TimeConductor} the
* time conductor
*/
ConductorService.prototype.getConductor = function () {
return this.conductor;
};
GoToOriginalAction.appliesTo = function (context) {
var domainObject = context.domainObject;
return domainObject && domainObject.hasCapability("location")
&& domainObject.getCapability("location").isLink();
};
return GoToOriginalAction;
return ConductorService;
}
);

View File

@@ -0,0 +1,110 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
['./ConductorTelemetrySeries'],
function (ConductorTelemetrySeries) {
'use strict';
/**
* Decorates the `telemetryService` such that requests are
* mediated by the time conductor.
*
* @constructor
* @memberof platform/features/conductor
* @implements {TelemetryService}
* @param {platform/features/conductor.ConductorService} conductorServe
* the service which exposes the global time conductor
* @param {TelemetryService} telemetryService the decorated service
*/
function ConductorTelemetryDecorator(conductorService, telemetryService) {
this.conductorService = conductorService;
this.telemetryService = telemetryService;
}
// Strip out any realtime data series that is outside of the conductor's
// bounds.
ConductorTelemetryDecorator.prototype.pruneNonDisplayable = function (packaged) {
var conductor = this.conductorService.getConductor(),
repackaged = {};
function filterSource(packagedBySource) {
var repackagedBySource = {};
Object.keys(packagedBySource).forEach(function (k) {
repackagedBySource[k] = new ConductorTelemetrySeries(
packagedBySource[k],
conductor
);
});
return repackagedBySource;
}
Object.keys(packaged).forEach(function (source) {
repackaged[source] = filterSource(packaged[source]);
});
return repackaged;
};
ConductorTelemetryDecorator.prototype.amendRequests = function (requests) {
var conductor = this.conductorService.getConductor(),
start = conductor.displayStart(),
end = conductor.displayEnd(),
domain = conductor.domain();
function amendRequest(request) {
request = request || {};
request.start = start;
request.end = end;
request.domain = domain;
return request;
}
return (requests || []).map(amendRequest);
};
ConductorTelemetryDecorator.prototype.requestTelemetry = function (requests) {
var self = this;
return this.telemetryService
.requestTelemetry(this.amendRequests(requests))
.then(function (packaged) {
return self.pruneNonDisplayable(packaged);
});
};
ConductorTelemetryDecorator.prototype.subscribe = function (callback, requests) {
var self = this;
function internalCallback(packagedSeries) {
return callback(self.pruneNonDisplayable(packagedSeries));
}
return this.telemetryService
.subscribe(internalCallback, this.amendRequests(requests));
};
return ConductorTelemetryDecorator;
}
);

View File

@@ -0,0 +1,74 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
function () {
'use strict';
/**
* Bound a series of telemetry such that it only includes
* points from within the time conductor's displayable window.
*
* @param {TelemetrySeries} series the telemetry series
* @param {platform/features/conductor.TimeConductor} the
* time conductor instance which bounds this series
* @constructor
* @implements {TelemetrySeries}
*/
function ConductorTelemetrySeries(series, conductor) {
var max = series.getPointCount() - 1,
domain = conductor.domain();
function binSearch(min, max, value) {
var mid = Math.floor((min + max) / 2);
return min > max ? min :
series.getDomainValue(mid, domain) < value ?
binSearch(mid + 1, max, value) :
binSearch(min, mid - 1, value);
}
this.startIndex = binSearch(0, max, conductor.displayStart());
this.endIndex = binSearch(0, max, conductor.displayEnd());
this.series = series;
this.domain = domain;
}
ConductorTelemetrySeries.prototype.getPointCount = function () {
return Math.max(0, this.endIndex - this.startIndex);
};
ConductorTelemetrySeries.prototype.getDomainValue = function (i, d) {
d = d || this.domain;
return this.series.getDomainValue(i + this.startIndex, d);
};
ConductorTelemetrySeries.prototype.getRangeValue = function (i, r) {
return this.series.getRangeValue(i + this.startIndex, r);
};
return ConductorTelemetrySeries;
}
);

View File

@@ -0,0 +1,129 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
/**
* The time conductor bundle adds a global control to the bottom of the
* outermost viewing area. This controls both the range for time-based
* queries and for time-based displays.
*
* @namespace platform/features/conductor
*/
define(
function () {
'use strict';
/**
* Tracks the current state of the time conductor.
*
* @memberof platform/features/conductor
* @constructor
* @param {number} start the initial start time
* @param {number} end the initial end time
*/
function TimeConductor(start, end, domains) {
this.inner = { start: start, end: end };
this.outer = { start: start, end: end };
this.domains = domains;
this.activeDomain = domains[0].key;
}
/**
* Get or set (if called with an argument) the start time for queries.
* @param {number} [value] the start time to set
* @returns {number} the start time
*/
TimeConductor.prototype.queryStart = function (value) {
if (arguments.length > 0) {
this.outer.start = value;
}
return this.outer.start;
};
/**
* Get or set (if called with an argument) the end time for queries.
* @param {number} [value] the end time to set
* @returns {number} the end time
*/
TimeConductor.prototype.queryEnd = function (value) {
if (arguments.length > 0) {
this.outer.end = value;
}
return this.outer.end;
};
/**
* Get or set (if called with an argument) the start time for displays.
* @param {number} [value] the start time to set
* @returns {number} the start time
*/
TimeConductor.prototype.displayStart = function (value) {
if (arguments.length > 0) {
this.inner.start = value;
}
return this.inner.start;
};
/**
* Get or set (if called with an argument) the end time for displays.
* @param {number} [value] the end time to set
* @returns {number} the end time
*/
TimeConductor.prototype.displayEnd = function (value) {
if (arguments.length > 0) {
this.inner.end = value;
}
return this.inner.end;
};
/**
* Get available domain options which can be used to bound time
* selection.
* @returns {TelemetryDomain[]} available domains
*/
TimeConductor.prototype.domainOptions = function () {
return this.domains;
};
/**
* Get or set (if called with an argument) the active domain.
* @param {string} [key] the key identifying the domain choice
* @returns {TelemetryDomain} the active telemetry domain
*/
TimeConductor.prototype.domain = function (key) {
function matchesKey(domain) {
return domain.key === key;
}
if (arguments.length > 0) {
if (!this.domains.some(matchesKey)) {
throw new Error("Unknown domain " + key);
}
this.activeDomain = key;
}
return this.activeDomain;
};
return TimeConductor;
}
);

View File

@@ -0,0 +1,216 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,afterEach,jasmine*/
define(
["../src/ConductorRepresenter", "./TestTimeConductor"],
function (ConductorRepresenter, TestTimeConductor) {
"use strict";
var SCOPE_METHODS = [
'$on',
'$watch',
'$broadcast',
'$emit',
'$new',
'$destroy'
],
ELEMENT_METHODS = [
'hasClass',
'addClass',
'removeClass',
'css',
'after',
'remove'
];
describe("ConductorRepresenter", function () {
var mockConductorService,
mockCompile,
testViews,
mockScope,
mockElement,
mockConductor,
mockCompiledTemplate,
mockNewScope,
mockNewElement,
representer;
function fireWatch(scope, watch, value) {
scope.$watch.calls.forEach(function (call) {
if (call.args[0] === watch) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockConductorService = jasmine.createSpyObj(
'conductorService',
['getConductor']
);
mockCompile = jasmine.createSpy('$compile');
testViews = [ { someKey: "some value" } ];
mockScope = jasmine.createSpyObj('scope', SCOPE_METHODS);
mockElement = jasmine.createSpyObj('element', ELEMENT_METHODS);
mockConductor = new TestTimeConductor();
mockCompiledTemplate = jasmine.createSpy('template');
mockNewScope = jasmine.createSpyObj('newScope', SCOPE_METHODS);
mockNewElement = jasmine.createSpyObj('newElement', ELEMENT_METHODS);
mockNewElement[0] = mockNewElement;
mockConductorService.getConductor.andReturn(mockConductor);
mockCompile.andReturn(mockCompiledTemplate);
mockCompiledTemplate.andReturn(mockNewElement);
mockScope.$new.andReturn(mockNewScope);
representer = new ConductorRepresenter(
mockConductorService,
mockCompile,
testViews,
mockScope,
mockElement
);
});
afterEach(function () {
representer.destroy();
});
it("adds a conductor to views", function () {
representer.represent(testViews[0], {});
expect(mockElement.after).toHaveBeenCalledWith(mockNewElement);
});
it("adds nothing to non-view representations", function () {
representer.represent({ someKey: "something else" }, {});
expect(mockElement.after).not.toHaveBeenCalled();
});
it("removes the conductor when destroyed", function () {
representer.represent(testViews[0], {});
expect(mockNewElement.remove).not.toHaveBeenCalled();
representer.destroy();
expect(mockNewElement.remove).toHaveBeenCalled();
});
it("destroys any new scope created", function () {
representer.represent(testViews[0], {});
representer.destroy();
expect(mockNewScope.$destroy.calls.length)
.toEqual(mockScope.$new.calls.length);
});
it("exposes conductor state in scope", function () {
mockConductor.queryStart.andReturn(42);
mockConductor.queryEnd.andReturn(12321);
mockConductor.displayStart.andReturn(1977);
mockConductor.displayEnd.andReturn(1984);
representer.represent(testViews[0], {});
expect(mockNewScope.ngModel.conductor).toEqual({
inner: { start: 1977, end: 1984 },
outer: { start: 42, end: 12321 }
});
});
it("updates conductor state from scope", function () {
var testState = {
inner: { start: 42, end: 1984 },
outer: { start: -1977, end: 12321 }
};
representer.represent(testViews[0], {});
mockNewScope.ngModel.conductor = testState;
fireWatch(
mockNewScope,
'ngModel.conductor.inner.start',
testState.inner.start
);
expect(mockConductor.displayStart).toHaveBeenCalledWith(42);
fireWatch(
mockNewScope,
'ngModel.conductor.inner.end',
testState.inner.end
);
expect(mockConductor.displayEnd).toHaveBeenCalledWith(1984);
fireWatch(
mockNewScope,
'ngModel.conductor.outer.start',
testState.outer.start
);
expect(mockConductor.queryStart).toHaveBeenCalledWith(-1977);
fireWatch(
mockNewScope,
'ngModel.conductor.outer.end',
testState.outer.end
);
expect(mockConductor.queryEnd).toHaveBeenCalledWith(12321);
});
it("exposes domain selection in scope", function () {
representer.represent(testViews[0], null);
expect(mockNewScope.ngModel.domain)
.toEqual(mockConductor.domain());
});
it("exposes domain options in scope", function () {
representer.represent(testViews[0], null);
mockConductor.domainOptions().forEach(function (option, i) {
expect(mockNewScope.ngModel.options[i].value)
.toEqual(option.key);
expect(mockNewScope.ngModel.options[i].name)
.toEqual(option.name);
});
});
it("updates domain selection from scope", function () {
var choice;
representer.represent(testViews[0], null);
// Choose a domain that isn't currently selected
mockNewScope.ngModel.options.forEach(function (option) {
if (option.value !== mockNewScope.ngModel.domain) {
choice = option.value;
}
});
expect(mockConductor.domain)
.not.toHaveBeenCalledWith(choice);
mockNewScope.ngModel.domain = choice;
fireWatch(mockNewScope, "ngModel.domain", choice);
expect(mockConductor.domain)
.toHaveBeenCalledWith(choice);
});
});
}
);

View File

@@ -0,0 +1,58 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/ConductorService"],
function (ConductorService) {
"use strict";
var TEST_NOW = 1020304050;
describe("ConductorService", function () {
var mockNow,
conductorService;
beforeEach(function () {
mockNow = jasmine.createSpy('now');
mockNow.andReturn(TEST_NOW);
conductorService = new ConductorService(mockNow, [
{ key: "d1", name: "Domain #1" },
{ key: "d2", name: "Domain #2" }
]);
});
it("initializes a time conductor around the current time", function () {
var conductor = conductorService.getConductor();
expect(conductor.queryStart() <= TEST_NOW).toBeTruthy();
expect(conductor.queryEnd() >= TEST_NOW).toBeTruthy();
expect(conductor.queryEnd() > conductor.queryStart())
.toBeTruthy();
});
it("provides a single shared time conductor instance", function () {
expect(conductorService.getConductor())
.toBe(conductorService.getConductor());
});
});
}
);

View File

@@ -0,0 +1,183 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/ConductorTelemetryDecorator", "./TestTimeConductor"],
function (ConductorTelemetryDecorator, TestTimeConductor) {
"use strict";
describe("ConductorTelemetryDecorator", function () {
var mockTelemetryService,
mockConductorService,
mockConductor,
mockPromise,
mockSeries,
decorator;
function seriesIsInWindow(series) {
var i, v, inWindow = true;
for (i = 0; i < series.getPointCount(); i += 1) {
v = series.getDomainValue(i);
inWindow = inWindow && (v >= mockConductor.displayStart());
inWindow = inWindow && (v <= mockConductor.displayEnd());
}
return inWindow;
}
beforeEach(function () {
mockTelemetryService = jasmine.createSpyObj(
'telemetryService',
[ 'requestTelemetry', 'subscribe' ]
);
mockConductorService = jasmine.createSpyObj(
'conductorService',
['getConductor']
);
mockConductor = new TestTimeConductor();
mockPromise = jasmine.createSpyObj(
'promise',
['then']
);
mockSeries = jasmine.createSpyObj(
'series',
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
);
mockTelemetryService.requestTelemetry.andReturn(mockPromise);
mockConductorService.getConductor.andReturn(mockConductor);
// Prepare test series; make sure it has a broad range of
// domain values, with at least some in the query-able range
mockSeries.getPointCount.andReturn(1000);
mockSeries.getDomainValue.andCallFake(function (i) {
var j = i - 500;
return j * j * j;
});
mockConductor.queryStart.andReturn(-12321);
mockConductor.queryEnd.andReturn(-12321);
mockConductor.displayStart.andReturn(42);
mockConductor.displayEnd.andReturn(1977);
mockConductor.domain.andReturn("testDomain");
decorator = new ConductorTelemetryDecorator(
mockConductorService,
mockTelemetryService
);
});
describe("decorates historical requests", function () {
var request;
beforeEach(function () {
decorator.requestTelemetry([{ someKey: "some value" }]);
request = mockTelemetryService.requestTelemetry
.mostRecentCall.args[0][0];
});
it("with start times", function () {
expect(request.start).toEqual(mockConductor.displayStart());
});
it("with end times", function () {
expect(request.end).toEqual(mockConductor.displayEnd());
});
it("with domain selection", function () {
expect(request.domain).toEqual(mockConductor.domain());
});
});
describe("decorates subscription requests", function () {
var request;
beforeEach(function () {
var mockCallback = jasmine.createSpy('callback');
decorator.subscribe(mockCallback, [{ someKey: "some value" }]);
request = mockTelemetryService.subscribe
.mostRecentCall.args[1][0];
});
it("with start times", function () {
expect(request.start).toEqual(mockConductor.displayStart());
});
it("with end times", function () {
expect(request.end).toEqual(mockConductor.displayEnd());
});
it("with domain selection", function () {
expect(request.domain).toEqual(mockConductor.domain());
});
});
//
// it("adds display start/end times & domain selection to historical requests", function () {
// decorator.requestTelemetry([{ someKey: "some value" }]);
// expect(mockTelemetryService.requestTelemetry)
// .toHaveBeenCalledWith([{
// someKey: "some value",
// start: mockConductor.displayStart(),
// end: mockConductor.displayEnd(),
// domain: jasmine.any(String)
// }]);
// });
//
// it("adds display start/end times & domain selection to subscription requests", function () {
// var mockCallback = jasmine.createSpy('callback');
// decorator.subscribe(mockCallback, [{ someKey: "some value" }]);
// expect(mockTelemetryService.subscribe)
// .toHaveBeenCalledWith(jasmine.any(Function), [{
// someKey: "some value",
// start: mockConductor.displayStart(),
// end: mockConductor.displayEnd(),
// domain: jasmine.any(String)
// }]);
// });
it("prunes historical values to the displayable range", function () {
var packagedTelemetry;
decorator.requestTelemetry([{ source: "abc", key: "xyz" }]);
packagedTelemetry = mockPromise.then.mostRecentCall.args[0]({
"abc": { "xyz": mockSeries }
});
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
.toBeTruthy();
});
it("prunes subscribed values to the displayable range", function () {
var mockCallback = jasmine.createSpy('callback'),
packagedTelemetry;
decorator.subscribe(mockCallback, [{ source: "abc", key: "xyz" }]);
mockTelemetryService.subscribe.mostRecentCall.args[0]({
"abc": { "xyz": mockSeries }
});
packagedTelemetry = mockCallback.mostRecentCall.args[0];
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
.toBeTruthy();
});
});
}
);

View File

@@ -0,0 +1,83 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/ConductorTelemetrySeries", "./TestTimeConductor"],
function (ConductorTelemetrySeries, TestTimeConductor) {
"use strict";
describe("ConductorTelemetrySeries", function () {
var mockSeries,
mockConductor,
testArray,
series;
beforeEach(function () {
testArray = [ -10, 0, 42, 1977, 12321 ];
mockSeries = jasmine.createSpyObj(
'series',
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
);
mockConductor = new TestTimeConductor();
mockSeries.getPointCount.andCallFake(function () {
return testArray.length;
});
mockSeries.getDomainValue.andCallFake(function (i) {
return testArray[i];
});
mockSeries.getRangeValue.andCallFake(function (i) {
return testArray[i] * 2;
});
mockConductor.displayStart.andReturn(0);
mockConductor.displayEnd.andReturn(2000);
series = new ConductorTelemetrySeries(
mockSeries,
mockConductor
);
});
it("reduces the apparent size of a series", function () {
expect(series.getPointCount()).toEqual(3);
});
it("maps domain value indexes to the displayable range", function () {
[0, 1, 2].forEach(function (i) {
expect(series.getDomainValue(i))
.toEqual(mockSeries.getDomainValue(i + 1));
});
});
it("maps range value indexes to the displayable range", function () {
[0, 1, 2].forEach(function (i) {
expect(series.getRangeValue(i))
.toEqual(mockSeries.getRangeValue(i + 1));
});
});
});
}
);

View File

@@ -0,0 +1,48 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,spyOn*/
define(
["../src/TimeConductor"],
function (TimeConductor) {
function TestTimeConductor() {
var self = this;
TimeConductor.apply(this, [
402514200000,
444546000000,
[
{ key: "domain0", name: "Domain #1" },
{ key: "domain1", name: "Domain #2" }
]
]);
Object.keys(TimeConductor.prototype).forEach(function (method) {
spyOn(self, method).andCallThrough();
});
}
TestTimeConductor.prototype = TimeConductor.prototype;
return TestTimeConductor;
}
);

View File

@@ -0,0 +1,84 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/TimeConductor"],
function (TimeConductor) {
"use strict";
describe("TimeConductor", function () {
var testStart,
testEnd,
testDomains,
conductor;
beforeEach(function () {
testStart = 42;
testEnd = 12321;
testDomains = [
{ key: "d1", name: "Domain #1" },
{ key: "d2", name: "Domain #2" }
]
conductor = new TimeConductor(testStart, testEnd, testDomains);
});
it("provides accessors for query/display start/end times", function () {
expect(conductor.queryStart()).toEqual(testStart);
expect(conductor.queryEnd()).toEqual(testEnd);
expect(conductor.displayStart()).toEqual(testStart);
expect(conductor.displayEnd()).toEqual(testEnd);
});
it("provides setters for query/display start/end times", function () {
expect(conductor.queryStart(1)).toEqual(1);
expect(conductor.queryEnd(2)).toEqual(2);
expect(conductor.displayStart(3)).toEqual(3);
expect(conductor.displayEnd(4)).toEqual(4);
expect(conductor.queryStart()).toEqual(1);
expect(conductor.queryEnd()).toEqual(2);
expect(conductor.displayStart()).toEqual(3);
expect(conductor.displayEnd()).toEqual(4);
});
it("exposes domain options", function () {
expect(conductor.domainOptions()).toEqual(testDomains);
});
it("exposes the current domain choice", function () {
expect(conductor.domain()).toEqual(testDomains[0].key);
});
it("allows the domain choice to be changed", function () {
conductor.domain(testDomains[1].key);
expect(conductor.domain()).toEqual(testDomains[1].key);
});
it("throws an error on attempts to set an invalid domain", function () {
expect(function () {
conductor.domain("invalid-domain");
}).toThrow();
});
});
}
);

View File

@@ -0,0 +1,7 @@
[
"ConductorRepresenter",
"ConductorService",
"ConductorTelemetryDecorator",
"ConductorTelemetrySeries",
"TimeConductor"
]

View File

@@ -167,8 +167,9 @@
"$scope",
"$q",
"dialogService",
"telemetrySubscriber",
"telemetryFormatter"
"telemetryHandler",
"telemetryFormatter",
"throttle"
]
}
],

View File

@@ -38,12 +38,13 @@ define(
* @constructor
* @param {Scope} $scope the controller's Angular scope
*/
function FixedController($scope, $q, dialogService, telemetrySubscriber, telemetryFormatter) {
function FixedController($scope, $q, dialogService, telemetryHandler, telemetryFormatter, throttle) {
var self = this,
subscription,
handle,
names = {}, // Cache names by ID
values = {}, // Cache values by ID
elementProxiesById = {};
elementProxiesById = {},
maxDomainValue = Number.POSITIVE_INFINITY;
// Convert from element x/y/width/height to an
// appropriate ng-style argument, to position elements.
@@ -81,25 +82,52 @@ define(
return element.handles().map(generateDragHandle);
}
// Update the displayed value for this object
function updateValue(telemetryObject) {
var id = telemetryObject && telemetryObject.getId(),
// Update the value displayed in elements of this telemetry object
function setDisplayedValue(telemetryObject, value, alarm) {
var id = telemetryObject.getId();
(elementProxiesById[id] || []).forEach(function (element) {
names[id] = telemetryObject.getModel().name;
values[id] = telemetryFormatter.formatRangeValue(value);
element.name = names[id];
element.value = values[id];
element.cssClass = alarm && alarm.cssClass;
});
}
// Update the displayed value for this object, from a specific
// telemetry series
function updateValueFromSeries(telemetryObject, telemetrySeries) {
var index = telemetrySeries.getPointCount() - 1,
limit = telemetryObject &&
telemetryObject.getCapability('limit'),
datum = telemetryObject &&
subscription.getDatum(telemetryObject),
alarm = limit && datum && limit.evaluate(datum);
datum = telemetryObject && handle.getDatum(
telemetryObject,
index
);
if (id) {
(elementProxiesById[id] || []).forEach(function (element) {
names[id] = telemetryObject.getModel().name;
values[id] = telemetryFormatter.formatRangeValue(
subscription.getRangeValue(telemetryObject)
);
element.name = names[id];
element.value = values[id];
element.cssClass = alarm && alarm.cssClass;
});
if (index >= 0) {
setDisplayedValue(
telemetryObject,
telemetrySeries.getRangeValue(index),
limit && datum && limit.evaluate(datum)
);
}
}
// Update the displayed value for this object
function updateValue(telemetryObject) {
var limit = telemetryObject &&
telemetryObject.getCapability('limit'),
datum = telemetryObject &&
handle.getDatum(telemetryObject);
if (telemetryObject &&
(handle.getDomainValue(telemetryObject) < maxDomainValue)) {
setDisplayedValue(
telemetryObject,
handle.getRangeValue(telemetryObject),
limit && datum && limit.evaluate(datum)
);
}
}
@@ -115,8 +143,8 @@ define(
// Update telemetry values based on new data available
function updateValues() {
if (subscription) {
subscription.getTelemetryObjects().forEach(updateValue);
if (handle) {
handle.getTelemetryObjects().forEach(updateValue);
}
}
@@ -178,22 +206,29 @@ define(
// Free up subscription to telemetry
function releaseSubscription() {
if (subscription) {
subscription.unsubscribe();
subscription = undefined;
if (handle) {
handle.unsubscribe();
handle = undefined;
}
}
// Subscribe to telemetry updates for this domain object
function subscribe(domainObject) {
// Release existing subscription (if any)
if (subscription) {
subscription.unsubscribe();
if (handle) {
handle.unsubscribe();
}
// Make a new subscription
subscription = domainObject &&
telemetrySubscriber.subscribe(domainObject, updateValues);
handle = domainObject && telemetryHandler.handle(
domainObject,
updateValues
);
// Request an initial historical telemetry value
handle.request(
{ size: 1 }, // Only need a single data point
updateValueFromSeries
);
}
// Handle changes in the object's composition
@@ -204,6 +239,17 @@ define(
subscribe($scope.domainObject);
}
// Trigger a new query for telemetry data
function updateDisplayBounds(event, bounds) {
maxDomainValue = bounds.end;
if (handle) {
handle.request(
{ size: 1 }, // Only need a single data point
updateValueFromSeries
);
}
}
// Add an element to this view
function addElement(element) {
// Ensure that configuration field is populated
@@ -278,6 +324,9 @@ define(
// Position panes where they are dropped
$scope.$on("mctDrop", handleDrop);
// Respond to external bounds changes
$scope.$on("telemetry:display:bounds", updateDisplayBounds);
}
/**

View File

@@ -30,10 +30,10 @@ define(
var mockScope,
mockQ,
mockDialogService,
mockSubscriber,
mockHandler,
mockFormatter,
mockDomainObject,
mockSubscription,
mockHandle,
mockEvent,
testGrid,
testModel,
@@ -78,9 +78,9 @@ define(
'$scope',
[ "$on", "$watch", "commit" ]
);
mockSubscriber = jasmine.createSpyObj(
'telemetrySubscriber',
[ 'subscribe' ]
mockHandler = jasmine.createSpyObj(
'telemetryHandler',
[ 'handle' ]
);
mockQ = jasmine.createSpyObj('$q', ['when']);
mockDialogService = jasmine.createSpyObj(
@@ -95,9 +95,16 @@ define(
'domainObject',
[ 'getId', 'getModel', 'getCapability' ]
);
mockSubscription = jasmine.createSpyObj(
mockHandle = jasmine.createSpyObj(
'subscription',
[ 'unsubscribe', 'getTelemetryObjects', 'getRangeValue', 'getDatum' ]
[
'unsubscribe',
'getDomainValue',
'getTelemetryObjects',
'getRangeValue',
'getDatum',
'request'
]
);
mockEvent = jasmine.createSpyObj(
'event',
@@ -116,13 +123,14 @@ define(
{ type: "fixed.telemetry", id: 'c', x: 1, y: 1 }
]};
mockSubscriber.subscribe.andReturn(mockSubscription);
mockSubscription.getTelemetryObjects.andReturn(
mockHandler.handle.andReturn(mockHandle);
mockHandle.getTelemetryObjects.andReturn(
testModel.composition.map(makeMockDomainObject)
);
mockSubscription.getRangeValue.andCallFake(function (o) {
mockHandle.getRangeValue.andCallFake(function (o) {
return testValues[o.getId()];
});
mockHandle.getDomainValue.andReturn(12321);
mockFormatter.formatRangeValue.andCallFake(function (v) {
return "Formatted " + v;
});
@@ -137,7 +145,7 @@ define(
mockScope,
mockQ,
mockDialogService,
mockSubscriber,
mockHandler,
mockFormatter
);
});
@@ -145,7 +153,7 @@ define(
it("subscribes when a domain object is available", function () {
mockScope.domainObject = mockDomainObject;
findWatch("domainObject")(mockDomainObject);
expect(mockSubscriber.subscribe).toHaveBeenCalledWith(
expect(mockHandler.handle).toHaveBeenCalledWith(
mockDomainObject,
jasmine.any(Function)
);
@@ -156,13 +164,13 @@ define(
// First pass - should simply should subscribe
findWatch("domainObject")(mockDomainObject);
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
expect(mockSubscriber.subscribe.calls.length).toEqual(1);
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
expect(mockHandler.handle.calls.length).toEqual(1);
// Object changes - should unsubscribe then resubscribe
findWatch("domainObject")(mockDomainObject);
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
expect(mockSubscriber.subscribe.calls.length).toEqual(2);
expect(mockHandle.unsubscribe).toHaveBeenCalled();
expect(mockHandler.handle.calls.length).toEqual(2);
});
it("exposes visible elements based on configuration", function () {
@@ -255,7 +263,7 @@ define(
findWatch("model.composition")(mockScope.model.composition);
// Invoke the subscription callback
mockSubscriber.subscribe.mostRecentCall.args[1]();
mockHandler.handle.mostRecentCall.args[1]();
// Get elements that controller is now exposing
elements = controller.getElements();
@@ -333,11 +341,11 @@ define(
// Make an object available
findWatch('domainObject')(mockDomainObject);
// Also verify precondition
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
// Destroy the scope
findOn('$destroy')();
// Should have unsubscribed
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
expect(mockHandle.unsubscribe).toHaveBeenCalled();
});
it("exposes its grid size", function () {

View File

@@ -65,6 +65,8 @@ define(
subPlotFactory = new SubPlotFactory(telemetryFormatter),
cachedObjects = [],
updater,
lastBounds,
throttledRequery,
handle;
// Populate the scope with axis information (specifically, options
@@ -94,6 +96,17 @@ define(
}
}
// Change the displayable bounds
function setBasePanZoom(bounds) {
var start = bounds.start,
end = bounds.end;
if (updater) {
updater.setDomainBounds(start, end);
self.update();
}
lastBounds = bounds;
}
// Reinstantiate the plot updater (e.g. because we have a
// new subscription.) This will clear the plot.
function recreateUpdater() {
@@ -107,10 +120,15 @@ define(
handle,
($scope.axes[1].active || {}).key
);
// Keep any externally-provided bounds
if (lastBounds) {
setBasePanZoom(lastBounds);
}
}
// Handle new telemetry data in this plot
function updateValues() {
self.pending = false;
if (handle) {
setupModes(handle.getTelemetryObjects());
}
@@ -126,6 +144,7 @@ define(
// Display new historical data as it becomes available
function addHistoricalData(domainObject, series) {
self.pending = false;
updater.addHistorical(domainObject, series);
self.modeOptions.getModeHandler().plotTelemetry(updater);
self.update();
@@ -165,6 +184,19 @@ define(
}
}
// Respond to a display bounds change (requery for data)
function changeDisplayBounds(event, bounds) {
self.pending = true;
releaseSubscription();
throttledRequery();
setBasePanZoom(bounds);
}
// Reestablish/reissue request for telemetry
throttledRequery = throttle(function () {
subscribe($scope.domainObject);
}, 250);
this.modeOptions = new PlotModeOptions([], subPlotFactory);
this.updateValues = updateValues;
@@ -174,12 +206,19 @@ define(
.forEach(updateSubplot);
});
self.pending = true;
// Subscribe to telemetry when a domain object becomes available
$scope.$watch('domainObject', subscribe);
// Respond to external bounds changes
$scope.$on("telemetry:display:bounds", changeDisplayBounds);
// Unsubscribe when the plot is destroyed
$scope.$on("$destroy", releaseSubscription);
// Notify any external observers that a new telemetry view is here
$scope.$emit("telemetry:view");
}
/**
@@ -275,7 +314,7 @@ define(
PlotController.prototype.isRequestPending = function () {
// Placeholder; this should reflect request state
// when requesting historical telemetry
return false;
return this.pending;
};
return PlotController;

View File

@@ -143,8 +143,7 @@ define(
PlotPanZoomStackGroup.prototype.getDepth = function () {
// All stacks are kept in sync, so look up depth
// from the first one.
return this.stacks.length > 0 ?
this.stacks[0].getDepth() : 0;
return this.stacks.length > 0 ? this.stacks[0].getDepth() : 0;
};
/**

View File

@@ -141,10 +141,10 @@ define(
PlotUpdater.prototype.initializeDomainOffset = function (values) {
this.domainOffset =
((this.domainOffset === undefined) && (values.length > 0)) ?
(values.reduce(function (a, b) {
return (a || 0) + (b || 0);
}, 0) / values.length) :
this.domainOffset;
(values.reduce(function (a, b) {
return (a || 0) + (b || 0);
}, 0) / values.length) :
this.domainOffset;
};
// Expand range slightly so points near edges are visible
@@ -159,7 +159,10 @@ define(
// Update dimensions and origin based on extrema of plots
PlotUpdater.prototype.updateBounds = function () {
var bufferArray = this.bufferArray;
var bufferArray = this.bufferArray,
priorDomainOrigin = this.origin[0],
priorDomainDimensions = this.dimensions[0];
if (bufferArray.length > 0) {
this.domainExtrema = bufferArray.map(function (lineBuffer) {
return lineBuffer.getDomainExtrema();
@@ -178,6 +181,18 @@ define(
// Enforce some minimum visible area
this.expandRange();
// Suppress domain changes when pinned
if (this.hasSpecificDomainBounds) {
this.origin[0] = priorDomainOrigin;
this.dimensions[0] = priorDomainDimensions;
if (this.following) {
this.origin[0] = Math.max(
this.domainExtrema[1] - this.dimensions[0],
this.origin[0]
);
}
}
// ...then enforce a fixed duration if needed
if (this.fixedDuration !== undefined) {
this.origin[0] = this.origin[0] + this.dimensions[0] -
@@ -281,6 +296,21 @@ define(
return this.bufferArray;
};
/**
* Set the start and end boundaries (usually time) for the
* domain axis of this updater.
*/
PlotUpdater.prototype.setDomainBounds = function (start, end) {
this.fixedDuration = end - start;
this.origin[0] = start;
this.dimensions[0] = this.fixedDuration;
// Suppress follow behavior if we have windowed in on the past
this.hasSpecificDomainBounds = true;
this.following =
!this.domainExtrema || (end >= this.domainExtrema[1]);
};
/**
* Fill in historical data.
*/

View File

@@ -45,11 +45,19 @@ define(
};
}
function fireEvent(name, args) {
mockScope.$on.calls.forEach(function (call) {
if (call.args[0] === name) {
call.args[1].apply(null, args || []);
}
});
}
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$watch", "$on" ]
[ "$watch", "$on", "$emit" ]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
@@ -87,6 +95,7 @@ define(
mockHandle.getMetadata.andReturn([{}]);
mockHandle.getDomainValue.andReturn(123);
mockHandle.getRangeValue.andReturn(42);
mockScope.domainObject = mockDomainObject;
controller = new PlotController(
mockScope,
@@ -212,7 +221,12 @@ define(
});
it("indicates if a request is pending", function () {
// Placeholder; need to support requesting telemetry
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
expect(controller.isRequestPending()).toBeTruthy();
mockHandle.request.mostRecentCall.args[1](
mockDomainObject,
mockSeries
);
expect(controller.isRequestPending()).toBeFalsy();
});
@@ -233,10 +247,20 @@ define(
// Also verify precondition
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
// Destroy the scope
mockScope.$on.mostRecentCall.args[1]();
fireEvent("$destroy");
// Should have unsubscribed
expect(mockHandle.unsubscribe).toHaveBeenCalled();
});
it("requeries when displayable bounds change", function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
expect(mockHandle.request.calls.length).toEqual(1);
fireEvent("telemetry:display:bounds", [
{},
{ start: 10, end: 100 }
]);
expect(mockHandle.request.calls.length).toEqual(2);
});
});
}
);

View File

@@ -55,7 +55,7 @@ define(
var range = this.rangeMetadata.key,
limit = domainObject.getCapability('limit'),
value = datum[range],
alarm = limit.evaluate(datum, range);
alarm = limit && limit.evaluate(datum, range);
return {
cssClass: alarm && alarm.cssClass,

View File

@@ -136,6 +136,14 @@ define(
}
}
// Destroy (deallocate any resources associated with) any
// active representers.
function destroyRepresenters() {
activeRepresenters.forEach(function (activeRepresenter) {
activeRepresenter.destroy();
});
}
// General-purpose refresh mechanism; should set up the scope
// as appropriate for current representation key and
// domain object.
@@ -152,10 +160,8 @@ define(
// via the "inclusion" field
$scope.inclusion = representation && getPath(representation);
// Any existing gestures are no longer valid; release them.
activeRepresenters.forEach(function (activeRepresenter) {
activeRepresenter.destroy();
});
// Any existing representers are no longer valid; release them.
destroyRepresenters();
// Log if a key was given, but no matching representation
// was found.
@@ -209,6 +215,10 @@ define(
// model's "modified" field, by the mutation capability.
$scope.$watch("domainObject.getModel().modified", refreshCapabilities);
// Make sure any resources allocated by representers also get
// released.
$scope.$on("$destroy", destroyRepresenters);
// Do one initial refresh, so that we don't need another
// digest iteration just to populate the scope. Failure to
// do this can result in unstable digest cycles, which

View File

@@ -106,7 +106,7 @@ define(
mockSce.trustAsResourceUrl.andCallFake(function (url) {
return url;
});
mockScope = jasmine.createSpyObj("scope", [ "$watch" ]);
mockScope = jasmine.createSpyObj("scope", [ "$watch", "$on" ]);
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);

View File

@@ -31,6 +31,30 @@ define(
function () {
"use strict";
/**
* Describes a request for telemetry data. Note that responses
* may contain either a sub- or superset of the requested data.
* @typedef TelemetryRequest
* @property {string} source an identifier for the relevant
* source of telemetry data
* @property {string} key an identifier for the specific
* series of telemetry data provided by that source
* @property {number} [start] the earliest domain value of
* interest for that telemetry data; for time-based
* domains, this is in milliseconds since the start
* of 1970
* @property {number} [end] the latest domain value of interest
* for that telemetry data; for time-based domains,
* this is in milliseconds since 1970
* @property {string} [domain] the domain for the query; if
* omitted, this will be whatever the "normal"
* domain is for a given telemetry series (the
* first domain from its metadata)
* @property {number} [size] if set, indicates the maximum number
* of data points of interest for this request (more
* recent domain values will be preferred)
*/
/**
* Request telemetry data.
* @param {TelemetryRequest[]} requests and array of

View File

@@ -79,8 +79,7 @@ define(
/**
* Change the request duration.
* @param {object|number} request the duration of historical
* data to look at; or, the request to issue
* @param {TelemetryRequest} request the request to issue
* @param {Function} [callback] a callback that will be
* invoked as new data becomes available, with the
* domain object for which new data is available.
@@ -107,6 +106,29 @@ define(
.then(issueRequests);
};
/**
* Get the latest telemetry datum for this domain object. This
* will be from real-time telemetry, unless an index is specified,
* in which case it will be pulled from the historical telemetry
* series at the specified index. If there is no latest available
* datum, this will return undefined.
*
* @param {DomainObject} domainObject the object of interest
* @param {number} [index] the index of the data of interest
* @returns {TelemetryDatum} the most recent datum
*/
self.getDatum = function (telemetryObject, index) {
function makeNewDatum(series) {
return series ?
subscription.makeDatum(telemetryObject, series, index) :
undefined;
}
return typeof index !== 'number' ?
subscription.getDatum(telemetryObject) :
makeNewDatum(this.getSeries(telemetryObject));
};
return self;
}

View File

@@ -123,25 +123,6 @@ define(
telemetryCapability.getMetadata();
}
// From a telemetry series, retrieve a single data point
// containing all fields for domains/ranges
function makeDatum(domainObject, series, index) {
var metadata = lookupMetadata(domainObject),
result = {};
(metadata.domains || []).forEach(function (domain) {
result[domain.key] =
series.getDomainValue(index, domain.key);
});
(metadata.ranges || []).forEach(function (range) {
result[range.key] =
series.getRangeValue(index, range.key);
});
return result;
}
// Update the latest telemetry data for a specific
// domain object. This will notify listeners.
function update(domainObject, series) {
@@ -160,7 +141,7 @@ define(
pool.put(domainObject.getId(), {
domain: series.getDomainValue(count - 1),
range: series.getRangeValue(count - 1),
datum: makeDatum(domainObject, series, count - 1)
datum: self.makeDatum(domainObject, series, count - 1)
});
}
}
@@ -188,6 +169,11 @@ define(
function cacheObjectReferences(objects) {
self.telemetryObjects = objects;
self.metadatas = objects.map(lookupMetadata);
self.metadataById = {};
objects.forEach(function (obj, i) {
self.metadataById[obj.getId()] = self.metadatas[i];
});
// Fire callback, as this will be the first time that
// telemetry objects are available, or these objects
// will have changed.
@@ -241,6 +227,34 @@ define(
this.unlistenToMutation = addMutationListener();
}
/**
* From a telemetry series, retrieve a single data point
* containing all fields for domains/ranges
* @private
*/
TelemetrySubscription.prototype.makeDatum = function (domainObject, series, index) {
var id = domainObject && domainObject.getId(),
metadata = (id && this.metadataById[id]) || {},
result = {};
(metadata.domains || []).forEach(function (domain) {
result[domain.key] =
series.getDomainValue(index, domain.key);
});
(metadata.ranges || []).forEach(function (range) {
result[range.key] =
series.getRangeValue(index, range.key);
});
return result;
};
/**
* Terminate all underlying subscriptions.
* @private
*/
TelemetrySubscription.prototype.unsubscribeAll = function () {
var $q = this.$q;
return this.unsubscribePromise.then(function (unsubscribes) {

View File

@@ -6,7 +6,7 @@
<groupId>gov.nasa.arc.wtd</groupId>
<artifactId>open-mct-web</artifactId>
<name>Open MCT Web</name>
<version>0.8.2-SNAPSHOT</version>
<version>0.8.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>