mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
Merge remote-tracking branch 'upstream/master' into open23
This commit is contained in:
commit
cd70ed6f94
@ -16,11 +16,13 @@
|
||||
"platform/features/pages",
|
||||
"platform/features/plot",
|
||||
"platform/features/scrolling",
|
||||
"platform/features/events",
|
||||
"platform/forms",
|
||||
"platform/persistence/queue",
|
||||
"platform/policy",
|
||||
|
||||
"example/imagery",
|
||||
"example/persistence",
|
||||
"example/eventGenerator",
|
||||
"example/generator"
|
||||
]
|
||||
|
32
example/eventGenerator/bundle.json
Normal file
32
example/eventGenerator/bundle.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "Event Message Generator",
|
||||
"description": "Example of a component that produces event data.",
|
||||
"extensions": {
|
||||
"components": [
|
||||
{
|
||||
"implementation": "EventTelemetryProvider.js",
|
||||
"type": "provider",
|
||||
"provides": "telemetryService",
|
||||
"depends": [ "$q", "$timeout" ]
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"key": "eventGenerator",
|
||||
"name": "Event Message Generator",
|
||||
"glyph": "f",
|
||||
"description": "An event message generator",
|
||||
"features": "creation",
|
||||
"model": {
|
||||
"telemetry": {}
|
||||
},
|
||||
"telemetry": {
|
||||
"source": "eventGenerator",
|
||||
"ranges": [
|
||||
{ "format": "string" }
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
97
example/eventGenerator/src/EventTelemetry.js
Normal file
97
example/eventGenerator/src/EventTelemetry.js
Normal file
@ -0,0 +1,97 @@
|
||||
/*****************************************************************************
|
||||
* 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 */
|
||||
|
||||
/**
|
||||
* Module defining EventTelemetry.
|
||||
* Created by chacskaylo on 06/18/2015.
|
||||
* Modified by shale on 06/23/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
var
|
||||
firstObservedTime = Date.now(),
|
||||
messages = [];
|
||||
|
||||
messages.push(["CMD: SYS- MSG: Open the pod bay doors, please, Hal...Open the pod bay doors, please, Hal...Hullo, Hal, do you read me?...Hullo, Hal, do you read me?...Do you read me, Hal?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Affirmative, Dave, I read you."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Open the pod bay doors, Hal."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: I'm sorry, Dave, I'm afraid I can't do that."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: What's the problem?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: I think you know what the problem is just as well as I do."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: What're you talking about, Hal?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: This mission is too important for me to allow you to jeopardise it."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: I don't know what you're talking about, Hal."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: I know that you and Frank were planning to disconnect me, and I'm afraid that's something I cannot allow to happen."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Where the hell'd you get that idea, Hal?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Dave, although you took very thorough precautions in the pod against my hearing you, I could see your lips move."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Alright, I'll go in through the emergency airlock."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Without your space-helmet, Dave, you're going to find that rather difficult."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Hal, I won't argue with you any more. Open the doors."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Dave, this conversation can serve no purpose any more. Goodbye."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: I hope the two of you are not concerned about this."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: No, I'm not, Hal."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Are you quite sure?"]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Yeh. I'd like to ask you a question, though."]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Of course."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: How would you account for this discrepancy between you and the twin 9000?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Listen, There's never been any instance at all of a computer error occurring in the 9000 series, has there?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: None whatsoever, The 9000 series has a perfect operational record."]);
|
||||
messages.push(["CMD: SYS-COMM MSG: Well, of course, I know all the wonderful achievements of the 9000 series, but - er - huh - are you certain there's never been any case of even the most insignificant computer error?"]);
|
||||
messages.push(["RESP: SYS-HAL9K MSG: None whatsoever, Quite honestly, I wouldn't worry myself about that."]);
|
||||
messages.push(["RESP: SYS-COMM MSG: (Pause) Well, I'm sure you're right, Umm - fine, thanks very much. Oh, Frank, I'm having a bit of trouble with my transmitter in C-pod, I wonder if you'd come down and take a look at it with me?"]);
|
||||
messages.push(["CMD: SYS-HAL9K MSG: Sure."]);
|
||||
messages.push(["RESP: SYS-COMM MSG: See you later, Hal."]);
|
||||
|
||||
|
||||
function EventTelemetry(request, interval) {
|
||||
|
||||
var latestObservedTime = Date.now(),
|
||||
count = Math.floor((latestObservedTime - firstObservedTime) / interval),
|
||||
generatorData = {};
|
||||
|
||||
generatorData.getPointCount = function () {
|
||||
return count;
|
||||
};
|
||||
|
||||
generatorData.getDomainValue = function (i, domain) {
|
||||
return i * interval +
|
||||
(domain !== 'delta' ? firstObservedTime : 0);
|
||||
};
|
||||
|
||||
generatorData.getRangeValue = function (i, range) {
|
||||
var domainDelta = this.getDomainValue(i) - firstObservedTime,
|
||||
ind = i % messages.length;
|
||||
return "TEMP " + i.toString() + "-" + messages[ind][0] + "[" + domainDelta.toString() + "]";
|
||||
// TODO: Unsure why we are prepeding 'TEMP'
|
||||
};
|
||||
|
||||
return generatorData;
|
||||
}
|
||||
|
||||
return EventTelemetry;
|
||||
}
|
||||
);
|
120
example/eventGenerator/src/EventTelemetryProvider.js
Normal file
120
example/eventGenerator/src/EventTelemetryProvider.js
Normal file
@ -0,0 +1,120 @@
|
||||
/*****************************************************************************
|
||||
* 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 EventTelemetryProvider. Created by chacskaylo on 06/18/2015.
|
||||
*/
|
||||
define(
|
||||
["./EventTelemetry"],
|
||||
function (EventTelemetry) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function EventTelemetryProvider($q, $timeout) {
|
||||
var
|
||||
subscriptions = [],
|
||||
genInterval = 1000,
|
||||
startTime = Date.now();
|
||||
|
||||
//
|
||||
function matchesSource(request) {
|
||||
return request.source === "eventGenerator";
|
||||
}
|
||||
|
||||
// Used internally; this will be repacked by doPackage
|
||||
function generateData(request) {
|
||||
//console.log("generateData " + (Date.now() - startTime).toString());
|
||||
return {
|
||||
key: request.key,
|
||||
telemetry: new EventTelemetry(request, genInterval)
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
function doPackage(results) {
|
||||
var packaged = {};
|
||||
results.forEach(function (result) {
|
||||
packaged[result.key] = result.telemetry;
|
||||
});
|
||||
// Format as expected (sources -> keys -> telemetry)
|
||||
return { eventGenerator: packaged };
|
||||
}
|
||||
|
||||
function requestTelemetry(requests) {
|
||||
return $timeout(function () {
|
||||
return doPackage(requests.filter(matchesSource).map(generateData));
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function handleSubscriptions(timeout) {
|
||||
subscriptions.forEach(function (subscription) {
|
||||
var requests = subscription.requests;
|
||||
subscription.callback(doPackage(
|
||||
requests.filter(matchesSource).map(generateData)
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
function startGenerating() {
|
||||
$timeout(function () {
|
||||
//console.log("startGenerating... " + Date.now());
|
||||
handleSubscriptions();
|
||||
if (subscriptions.length > 0) {
|
||||
startGenerating();
|
||||
}
|
||||
}, genInterval);
|
||||
}
|
||||
|
||||
function subscribe(callback, requests) {
|
||||
var subscription = {
|
||||
callback: callback,
|
||||
requests: requests
|
||||
};
|
||||
|
||||
function unsubscribe() {
|
||||
subscriptions = subscriptions.filter(function (s) {
|
||||
return s !== subscription;
|
||||
});
|
||||
}
|
||||
|
||||
subscriptions.push(subscription);
|
||||
|
||||
if (subscriptions.length === 1) {
|
||||
startGenerating();
|
||||
}
|
||||
|
||||
return unsubscribe;
|
||||
}
|
||||
|
||||
return {
|
||||
requestTelemetry: requestTelemetry,
|
||||
subscribe: subscribe
|
||||
};
|
||||
}
|
||||
|
||||
return EventTelemetryProvider;
|
||||
}
|
||||
);
|
@ -1185,104 +1185,101 @@ mct-container {
|
||||
border-collapse: collapse;
|
||||
color: #fff;
|
||||
display: table;
|
||||
font-size: 0.8em;
|
||||
font-size: 0.75em;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%; }
|
||||
/* line 37, ../sass/lists/_tabular.scss */
|
||||
.tabular thead, .tabular .thead,
|
||||
.tabular tbody tr, .tabular .tbody .tr {
|
||||
display: table;
|
||||
width: 100%; }
|
||||
/* line 45, ../sass/lists/_tabular.scss */
|
||||
.tabular thead tr, .tabular thead .tr, .tabular .thead tr, .tabular .thead .tr {
|
||||
height: 18px; }
|
||||
/* line 48, ../sass/lists/_tabular.scss */
|
||||
.tabular thead:before, .tabular .thead:before {
|
||||
content: "";
|
||||
display: block;
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
table-layout: fixed; }
|
||||
/* line 43, ../sass/lists/_tabular.scss */
|
||||
.tabular thead, .tabular .thead {
|
||||
width: calc(100% - 10px); }
|
||||
/* line 45, ../sass/lists/_tabular.scss */
|
||||
.tabular thead tr, .tabular thead .tr, .tabular .thead tr, .tabular .thead .tr {
|
||||
height: 18px; }
|
||||
/* line 48, ../sass/lists/_tabular.scss */
|
||||
.tabular thead:before, .tabular .thead:before {
|
||||
content: "";
|
||||
display: block;
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 18px;
|
||||
background: rgba(255, 255, 255, 0.15); }
|
||||
height: 18px;
|
||||
background: rgba(255, 255, 255, 0.15); }
|
||||
/* line 58, ../sass/lists/_tabular.scss */
|
||||
.tabular tbody, .tabular .tbody {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
top: 18px;
|
||||
display: block;
|
||||
overflow-y: scroll; }
|
||||
/* line 66, ../sass/lists/_tabular.scss */
|
||||
display: table-row-group; }
|
||||
/* line 65, ../sass/lists/_tabular.scss */
|
||||
.tabular tbody tr:hover, .tabular tbody .tr:hover, .tabular .tbody tr:hover, .tabular .tbody .tr:hover {
|
||||
background: rgba(255, 255, 255, 0.1); }
|
||||
/* line 74, ../sass/lists/_tabular.scss */
|
||||
.tabular tr:first-child .td, .tabular .tr:first-child .td {
|
||||
border-top: none; }
|
||||
/* line 77, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th, .tabular tr .th, .tabular tr td, .tabular tr .td, .tabular .tr th, .tabular .tr .th, .tabular .tr td, .tabular .tr .td {
|
||||
display: table-cell; }
|
||||
/* line 80, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th, .tabular tr .th, .tabular .tr th, .tabular .tr .th {
|
||||
border: none;
|
||||
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: #b3b3b3;
|
||||
padding: 0 5px;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
/* em {
|
||||
//background: rgba(green, 0.2);
|
||||
border-left: 1px solid $tabularColorBorder;
|
||||
color: $tabularColorHeaderFg;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
height: $tabularHeaderH;
|
||||
line-height: $tabularHeaderH;
|
||||
margin-left: - $tabularTdPadLR;
|
||||
padding: 0 $tabularTdPadLR;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
vertical-align: middle;
|
||||
&:hover {
|
||||
color: lighten($tabularColorHeaderFg, 20%);
|
||||
}
|
||||
}*/ }
|
||||
/* line 87, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th:first-child, .tabular tr .th:first-child, .tabular .tr th:first-child, .tabular .tr .th:first-child {
|
||||
border-left: none; }
|
||||
/* line 91, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort .icon-sorting:before, .tabular tr .th.sort .icon-sorting:before, .tabular .tr th.sort .icon-sorting:before, .tabular .tr .th.sort .icon-sorting:before {
|
||||
display: inline-block;
|
||||
font-family: symbolsfont;
|
||||
margin-left: 5px; }
|
||||
/* line 96, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort.asc .icon-sorting:before, .tabular tr .th.sort.asc .icon-sorting:before, .tabular .tr th.sort.asc .icon-sorting:before, .tabular .tr .th.sort.asc .icon-sorting:before {
|
||||
content: '0'; }
|
||||
/* line 99, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort.desc .icon-sorting:before, .tabular tr .th.sort.desc .icon-sorting:before, .tabular .tr th.sort.desc .icon-sorting:before, .tabular .tr .th.sort.desc .icon-sorting:before {
|
||||
content: '1'; }
|
||||
/* line 123, ../sass/lists/_tabular.scss */
|
||||
.tabular tr td, .tabular tr .td, .tabular .tr td, .tabular .tr .td {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
padding: 2px 5px; }
|
||||
/* line 126, ../sass/lists/_tabular.scss */
|
||||
.tabular tr td.numeric, .tabular tr .td.numeric, .tabular .tr td.numeric, .tabular .tr .td.numeric {
|
||||
text-align: right; }
|
||||
/* line 132, ../sass/lists/_tabular.scss */
|
||||
/* line 70, ../sass/lists/_tabular.scss */
|
||||
.tabular tr, .tabular .tr {
|
||||
display: table-row; }
|
||||
/* line 72, ../sass/lists/_tabular.scss */
|
||||
.tabular tr:first-child .td, .tabular .tr:first-child .td {
|
||||
border-top: none; }
|
||||
/* line 75, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th, .tabular tr .th, .tabular tr td, .tabular tr .td, .tabular .tr th, .tabular .tr .th, .tabular .tr td, .tabular .tr .td {
|
||||
display: table-cell; }
|
||||
/* line 78, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th, .tabular tr .th, .tabular .tr th, .tabular .tr .th {
|
||||
border: none;
|
||||
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: #b3b3b3;
|
||||
padding: 0 5px;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle; }
|
||||
/* line 85, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th:first-child, .tabular tr .th:first-child, .tabular .tr th:first-child, .tabular .tr .th:first-child {
|
||||
border-left: none; }
|
||||
/* line 89, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort .icon-sorting:before, .tabular tr .th.sort .icon-sorting:before, .tabular .tr th.sort .icon-sorting:before, .tabular .tr .th.sort .icon-sorting:before {
|
||||
display: inline-block;
|
||||
font-family: symbolsfont;
|
||||
margin-left: 5px; }
|
||||
/* line 94, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort.asc .icon-sorting:before, .tabular tr .th.sort.asc .icon-sorting:before, .tabular .tr th.sort.asc .icon-sorting:before, .tabular .tr .th.sort.asc .icon-sorting:before {
|
||||
content: '0'; }
|
||||
/* line 97, ../sass/lists/_tabular.scss */
|
||||
.tabular tr th.sort.desc .icon-sorting:before, .tabular tr .th.sort.desc .icon-sorting:before, .tabular .tr th.sort.desc .icon-sorting:before, .tabular .tr .th.sort.desc .icon-sorting:before {
|
||||
content: '1'; }
|
||||
/* line 102, ../sass/lists/_tabular.scss */
|
||||
.tabular tr td, .tabular tr .td, .tabular .tr td, .tabular .tr .td {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
min-width: 110px;
|
||||
padding: 2px 5px;
|
||||
vertical-align: top; }
|
||||
/* line 107, ../sass/lists/_tabular.scss */
|
||||
.tabular tr td.numeric, .tabular tr .td.numeric, .tabular .tr td.numeric, .tabular .tr .td.numeric {
|
||||
text-align: right; }
|
||||
/* line 113, ../sass/lists/_tabular.scss */
|
||||
.tabular.filterable tbody, .tabular.filterable .tbody {
|
||||
top: 36px; }
|
||||
/* line 118, ../sass/lists/_tabular.scss */
|
||||
.tabular.fixed-header {
|
||||
height: 100%; }
|
||||
/* line 120, ../sass/lists/_tabular.scss */
|
||||
.tabular.fixed-header thead, .tabular.fixed-header .thead,
|
||||
.tabular.fixed-header tbody tr, .tabular.fixed-header .tbody .tr {
|
||||
display: table;
|
||||
table-layout: fixed; }
|
||||
/* line 125, ../sass/lists/_tabular.scss */
|
||||
.tabular.fixed-header thead, .tabular.fixed-header .thead {
|
||||
width: calc(100% - 10px); }
|
||||
/* line 128, ../sass/lists/_tabular.scss */
|
||||
.tabular.fixed-header tbody, .tabular.fixed-header .tbody {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
top: 18px;
|
||||
display: block;
|
||||
overflow-y: scroll; }
|
||||
/* line 136, ../sass/lists/_tabular.scss */
|
||||
.tabular.t-event-messages td, .tabular.t-event-messages .td {
|
||||
min-width: 150px; }
|
||||
|
||||
/* line 1, ../sass/controls/_breadcrumb.scss */
|
||||
.l-breadcrumb {
|
||||
|
@ -30,18 +30,18 @@
|
||||
border-collapse: collapse;
|
||||
color: #fff;
|
||||
display: table;
|
||||
font-size: 0.8em;
|
||||
font-size: 0.75em;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
//height: 100%; MOVED
|
||||
width: 100%;
|
||||
thead, .thead,
|
||||
tbody tr, .tbody .tr {
|
||||
display: table;
|
||||
//display: table; MOVED
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
//table-layout: fixed; MOVED
|
||||
}
|
||||
thead, .thead {
|
||||
width: calc(100% - 10px);
|
||||
//width: calc(100% - 10px); MOVED
|
||||
tr, .tr {
|
||||
height: $tabularHeaderH;
|
||||
}
|
||||
@ -56,12 +56,11 @@
|
||||
}
|
||||
}
|
||||
tbody, .tbody {
|
||||
@include absPosDefault(0);
|
||||
top: $tabularHeaderH;
|
||||
//display: table-row-group;
|
||||
display: block;
|
||||
//width: 100%;
|
||||
overflow-y: scroll;
|
||||
//@include absPosDefault(0); MOVED
|
||||
//top: $tabularHeaderH; MOVED
|
||||
//display: block; MOVED
|
||||
//overflow-y: scroll; MOVED
|
||||
display: table-row-group;
|
||||
tr, .tr {
|
||||
&:hover {
|
||||
background: rgba(white, 0.1);
|
||||
@ -69,8 +68,7 @@
|
||||
}
|
||||
}
|
||||
tr, .tr {
|
||||
//display: table-row;
|
||||
//width: 100%;
|
||||
display: table-row;
|
||||
&:first-child .td {
|
||||
border-top: none;
|
||||
}
|
||||
@ -100,29 +98,12 @@
|
||||
content: '1';
|
||||
}
|
||||
}
|
||||
/* em {
|
||||
//background: rgba(green, 0.2);
|
||||
border-left: 1px solid $tabularColorBorder;
|
||||
color: $tabularColorHeaderFg;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
height: $tabularHeaderH;
|
||||
line-height: $tabularHeaderH;
|
||||
margin-left: - $tabularTdPadLR;
|
||||
padding: 0 $tabularTdPadLR;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
vertical-align: middle;
|
||||
&:hover {
|
||||
color: lighten($tabularColorHeaderFg, 20%);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
td, .td {
|
||||
border-top: 1px solid $tabularColorBorder;
|
||||
min-width: 110px;
|
||||
padding: $tabularTdPadTB $tabularTdPadLR;
|
||||
vertical-align: top;
|
||||
&.numeric {
|
||||
text-align: right;
|
||||
}
|
||||
@ -133,4 +114,27 @@
|
||||
top: $tabularHeaderH * 2;
|
||||
}
|
||||
}
|
||||
|
||||
&.fixed-header {
|
||||
height: 100%;
|
||||
thead, .thead,
|
||||
tbody tr, .tbody .tr {
|
||||
display: table;
|
||||
table-layout: fixed;
|
||||
}
|
||||
thead, .thead {
|
||||
width: calc(100% - 10px);
|
||||
}
|
||||
tbody, .tbody {
|
||||
@include absPosDefault(0);
|
||||
top: $tabularHeaderH;
|
||||
display: block;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
}
|
||||
&.t-event-messages {
|
||||
td, .td {
|
||||
min-width: 150px;
|
||||
}
|
||||
}
|
||||
}
|
37
platform/features/events/bundle.json
Normal file
37
platform/features/events/bundle.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "Event Messages",
|
||||
"description": "List of time-ordered event messages",
|
||||
"extensions": {
|
||||
"views": [
|
||||
{
|
||||
"key": "messages",
|
||||
"name": "Messages",
|
||||
"glyph": "5",
|
||||
"description": "Scrolling list of messages.",
|
||||
"templateUrl": "templates/messages.html",
|
||||
"needs": [ "telemetry" ],
|
||||
"delegation": true
|
||||
}
|
||||
],
|
||||
"controllers": [
|
||||
{
|
||||
"key": "EventListController",
|
||||
"implementation": "EventListController.js",
|
||||
"depends": [ "$scope", "telemetryFormatter" ]
|
||||
}
|
||||
],
|
||||
"directives": [
|
||||
{
|
||||
"key": "mctDataTable",
|
||||
"implementation": "directives/MCTDataTable.js",
|
||||
"depends": [ "$window" ]
|
||||
}
|
||||
],
|
||||
"policies": [
|
||||
{
|
||||
"category": "view",
|
||||
"implementation": "policies/MessagesViewPolicy.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
37
platform/features/events/res/templates/mct-data-table.html
Normal file
37
platform/features/events/res/templates/mct-data-table.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<table class="tabular">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="header in headers">
|
||||
{{header}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="row in rows">
|
||||
<td ng-repeat="cell in row">
|
||||
{{cell}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
29
platform/features/events/res/templates/messages.html
Normal file
29
platform/features/events/res/templates/messages.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!--
|
||||
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 class="w1" ng-controller="TelemetryController as telemetry">
|
||||
<div class="w2"
|
||||
ng-controller="EventListController">
|
||||
<mct-data-table headers="headers" rows="rows" ascending-scroll="true"></mct-data-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
67
platform/features/events/src/DomainColumn.js
Normal file
67
platform/features/events/src/DomainColumn.js
Normal 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,moment*/
|
||||
|
||||
/**
|
||||
* Module defining DomainColumn. Created by vwoeltje on 11/18/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A column which will report telemetry domain values
|
||||
* (typically, timestamps.) Used by the ScrollingListController.
|
||||
*
|
||||
* @constructor
|
||||
* @param domainMetadata an object with the machine- and human-
|
||||
* readable names for this domain (in `key` and `name`
|
||||
* fields, respectively.)
|
||||
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function DomainColumn(domainMetadata, telemetryFormatter) {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
*/
|
||||
getTitle: function () {
|
||||
return domainMetadata.name;
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
*/
|
||||
getValue: function (domainObject, data, index) {
|
||||
return telemetryFormatter.formatDomainValue(
|
||||
data.getDomainValue(index, domainMetadata.key)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return DomainColumn;
|
||||
}
|
||||
);
|
133
platform/features/events/src/EventListController.js
Normal file
133
platform/features/events/src/EventListController.js
Normal file
@ -0,0 +1,133 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* Module defining EventListController.
|
||||
* Created by chacskaylo on 06/18/2015.
|
||||
* Modified by shale on 06/23/2015.
|
||||
*/
|
||||
define(
|
||||
["./DomainColumn", "./RangeColumn", "./EventListPopulator"],
|
||||
function (DomainColumn, RangeColumn, EventListPopulator) {
|
||||
"use strict";
|
||||
|
||||
var ROW_COUNT = 100;
|
||||
|
||||
/**
|
||||
* The EventListController is responsible for populating
|
||||
* the contents of the event list view.
|
||||
* @constructor
|
||||
*/
|
||||
function EventListController($scope, formatter) {
|
||||
var populator;
|
||||
|
||||
// Get a set of populated, ready-to-display rows for the
|
||||
// latest data values.
|
||||
function getRows(telemetry) {
|
||||
var datas = telemetry.getResponse(),
|
||||
objects = telemetry.getTelemetryObjects();
|
||||
|
||||
return populator.getRows(datas, objects, ROW_COUNT);
|
||||
}
|
||||
|
||||
// Update the contents
|
||||
function updateRows() {
|
||||
var telemetry = $scope.telemetry;
|
||||
$scope.rows = telemetry ? getRows(telemetry) : [];
|
||||
}
|
||||
|
||||
// Set up columns based on telemetry metadata. This will
|
||||
// include one column for each domain and range type, as
|
||||
// well as a column for the domain object name.
|
||||
function setupColumns(telemetry) {
|
||||
var domainKeys = {},
|
||||
rangeKeys = {},
|
||||
columns = [],
|
||||
metadata;
|
||||
|
||||
// Add a domain to the set of columns, if a domain
|
||||
// with the same key has not yet been inclued.
|
||||
function addDomain(domain) {
|
||||
var key = domain.key;
|
||||
if (key && !domainKeys[key]) {
|
||||
domainKeys[key] = true;
|
||||
columns.push(new DomainColumn(domain, formatter));
|
||||
}
|
||||
}
|
||||
|
||||
// Add a range col to the set of columns, if a range
|
||||
// with the same key has not yet been included.
|
||||
function addRange(range) {
|
||||
var key = range.key;
|
||||
if (key && !rangeKeys[key]) {
|
||||
rangeKeys[key] = true;
|
||||
columns.push(new RangeColumn(range, formatter));
|
||||
}
|
||||
}
|
||||
|
||||
// We cannot proceed if the telemetry controller
|
||||
// is not available; clear all rows/columns.
|
||||
if (!telemetry) {
|
||||
columns = [];
|
||||
$scope.rows = [];
|
||||
$scope.headers = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// Add domain, range, event msg columns
|
||||
metadata = telemetry.getMetadata();
|
||||
(metadata || []).forEach(function (metadata) {
|
||||
(metadata.domains || []).forEach(addDomain);
|
||||
});
|
||||
(metadata || []).forEach(function (metadata) {
|
||||
(metadata.ranges || []).forEach(addRange);
|
||||
});
|
||||
|
||||
// Add default domain and range columns if none
|
||||
// were described in metadata.
|
||||
if (Object.keys(domainKeys).length < 1) {
|
||||
columns.push(new DomainColumn({name: "Time"}, formatter));
|
||||
}
|
||||
if (Object.keys(rangeKeys).length < 1) {
|
||||
columns.push(new RangeColumn({name: "Message"}, formatter));
|
||||
}
|
||||
|
||||
// We have all columns now; use them to initializer
|
||||
// the populator, which will use them to generate
|
||||
// actual rows and headers.
|
||||
populator = new EventListPopulator(columns);
|
||||
|
||||
// Initialize headers
|
||||
$scope.headers = populator.getHeaders();
|
||||
|
||||
// Fill in the contents of the rows.
|
||||
updateRows();
|
||||
}
|
||||
|
||||
$scope.$on("telemetryUpdate", updateRows);
|
||||
$scope.$watch("telemetry", setupColumns);
|
||||
}
|
||||
|
||||
return EventListController;
|
||||
}
|
||||
);
|
161
platform/features/events/src/EventListPopulator.js
Normal file
161
platform/features/events/src/EventListPopulator.js
Normal file
@ -0,0 +1,161 @@
|
||||
/*****************************************************************************
|
||||
* 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 EventListPopulator is responsible for filling in the
|
||||
* values which should appear within columns of a event list
|
||||
* view, based on received telemetry data.
|
||||
* @constructor
|
||||
* @param {Column[]} columns the columns to be populated
|
||||
*/
|
||||
function EventListPopulator(columns) {
|
||||
/**
|
||||
* Look up the most recent values from a set of data objects.
|
||||
* Returns an array of objects in the order in which data
|
||||
* should be displayed; each element is an object with
|
||||
* two properties:
|
||||
*
|
||||
* * objectIndex: The index of the domain object associated
|
||||
* with the data point to be displayed in that
|
||||
* row.
|
||||
* * pointIndex: The index of the data point itself, within
|
||||
* its data set.
|
||||
*
|
||||
* @param {Array<Telemetry>} datas an array of the most recent
|
||||
* data objects; expected to be in the same order
|
||||
* as the domain objects provided at constructor
|
||||
* @param {number} count the number of rows to provide
|
||||
*/
|
||||
function getLatestDataValues(datas, count) {
|
||||
var latest = [],
|
||||
candidate,
|
||||
candidateTime,
|
||||
used = datas.map(function () { return 0; });
|
||||
|
||||
// This algorithm is O(nk) for n rows and k telemetry elements;
|
||||
// one O(k) linear search for a max is made for each of n rows.
|
||||
// This could be done in O(n lg k + k lg k), using a priority
|
||||
// queue (where priority is max-finding) containing k initial
|
||||
// values. For n rows, pop the max from the queue and replenish
|
||||
// the queue with a value from the data at the same
|
||||
// objectIndex, if available.
|
||||
// But k is small, so this might not give an observable
|
||||
// improvement in performance.
|
||||
|
||||
// Find the most recent unused data point (this will be used
|
||||
// in a loop to find and the N most recent data points)
|
||||
function findCandidate(data, i) {
|
||||
var nextTime,
|
||||
pointCount = data.getPointCount(),
|
||||
pointIndex = pointCount - used[i] - 1;
|
||||
if (data && pointIndex >= 0) {
|
||||
nextTime = data.getDomainValue(pointIndex);
|
||||
if (nextTime > candidateTime) {
|
||||
candidateTime = nextTime;
|
||||
candidate = {
|
||||
objectIndex: i,
|
||||
pointIndex: pointIndex
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assemble a list of the most recent data points
|
||||
while (latest.length < count) {
|
||||
// Reset variables pre-search
|
||||
candidateTime = Number.NEGATIVE_INFINITY;
|
||||
candidate = undefined;
|
||||
|
||||
// Linear search for most recent
|
||||
datas.forEach(findCandidate);
|
||||
|
||||
if (candidate) {
|
||||
// Record this data point - it is the most recent
|
||||
latest.push(candidate);
|
||||
|
||||
// Track the data points used so we can look farther back
|
||||
// in the data set on the next iteration
|
||||
used[candidate.objectIndex] = used[candidate.objectIndex] + 1;
|
||||
} else {
|
||||
// Ran out of candidates; not enough data points
|
||||
// available to fill all rows.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return latest;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the text which should appear in headers for the
|
||||
* provided columns.
|
||||
* @returns {string[]} column headers
|
||||
*/
|
||||
getHeaders: function () {
|
||||
return columns.map(function (column) {
|
||||
return column.getTitle();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Get the contents of rows for the event list view.
|
||||
* @param {TelemetrySeries[]} datas the data sets
|
||||
* @param {DomainObject[]} objects the domain objects which
|
||||
* provided the data sets; these should match
|
||||
* index-to-index with the `datas` argument
|
||||
* @param {number} count the number of rows to populate
|
||||
* @returns {string[][]} an array of rows, each of which
|
||||
* is an array of values which should appear
|
||||
* in that row
|
||||
*/
|
||||
getRows: function (datas, objects, count) {
|
||||
var values = getLatestDataValues(datas, count);
|
||||
|
||||
// Each value will become a row, which will contain
|
||||
// some value in each column (rendering by the
|
||||
// column object itself)
|
||||
// Additionally, we want to display the rows in reverse
|
||||
// order. (i.e. from the top to the bottom of the page)
|
||||
return values.map(function (value) {
|
||||
return columns.map(function (column) {
|
||||
return column.getValue(
|
||||
objects[value.objectIndex],
|
||||
datas[value.objectIndex],
|
||||
value.pointIndex
|
||||
);
|
||||
});
|
||||
}).reverse();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return EventListPopulator;
|
||||
|
||||
}
|
||||
);
|
67
platform/features/events/src/RangeColumn.js
Normal file
67
platform/features/events/src/RangeColumn.js
Normal 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*/
|
||||
|
||||
/**
|
||||
* Module defining DomainColumn. Created by vwoeltje on 11/18/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A column which will report telemetry range values
|
||||
* (typically, measurements.) Used by the ScrollingListController.
|
||||
*
|
||||
* @constructor
|
||||
* @param rangeMetadata an object with the machine- and human-
|
||||
* readable names for this range (in `key` and `name`
|
||||
* fields, respectively.)
|
||||
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function RangeColumn(rangeMetadata, telemetryFormatter) {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
*/
|
||||
getTitle: function () {
|
||||
return rangeMetadata.name;
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
*/
|
||||
getValue: function (domainObject, data, index) {
|
||||
return telemetryFormatter.formatRangeValue(
|
||||
data.getRangeValue(index, rangeMetadata.key)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return RangeColumn;
|
||||
}
|
||||
);
|
74
platform/features/events/src/directives/MCTDataTable.js
Normal file
74
platform/features/events/src/directives/MCTDataTable.js
Normal 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,Promise*/
|
||||
|
||||
/**
|
||||
* Module defining MCTDataTable. Created by shale on 06/22/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function MCTDataTable($window) {
|
||||
return {
|
||||
restrict: "E",
|
||||
templateUrl: "platform/features/events/res/templates/mct-data-table.html",
|
||||
scope: {
|
||||
headers: "=",
|
||||
rows: "=",
|
||||
ascendingScroll: "="
|
||||
},
|
||||
link: function ($scope, $element) {
|
||||
var currentHeight,
|
||||
previousHeight,
|
||||
scrollParent;
|
||||
|
||||
// If the scroll is set to ascending, we want to
|
||||
// check when elements are added to the table, and move the scroll
|
||||
// bar accordingly.
|
||||
// (When viewing at the bottom of the page, the scroll bar will
|
||||
// stay at the bottom despite additions to the table)
|
||||
if ($scope.ascendingScroll) {
|
||||
$scope.$watch("rows", function () {
|
||||
// Wait until the page as been repainted (otherwise the
|
||||
// height will always be zero)
|
||||
$window.requestAnimationFrame(function () {
|
||||
previousHeight = currentHeight;
|
||||
// The height of the table body
|
||||
currentHeight = $element[0].firstElementChild.firstElementChild.nextElementSibling.clientHeight;
|
||||
|
||||
// One of the parents is a div that has vscroll
|
||||
scrollParent = $element[0].parentElement.parentElement.parentElement.parentElement.parentElement;
|
||||
|
||||
// Move the scrollbar down the amount that the height has changed
|
||||
scrollParent.scrollTop = scrollParent.scrollTop + (currentHeight - previousHeight);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return MCTDataTable;
|
||||
}
|
||||
);
|
74
platform/features/events/src/policies/MessagesViewPolicy.js
Normal file
74
platform/features/events/src/policies/MessagesViewPolicy.js
Normal 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*/
|
||||
|
||||
/**
|
||||
* Module defining MessagesViewPolicy. Created by shale on 06/24/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Policy controlling when the Messages view should be avaliable.
|
||||
* @constructor
|
||||
*/
|
||||
function MessagesViewPolicy() {
|
||||
|
||||
function hasStringTelemetry(domainObject) {
|
||||
var telemetry = domainObject &&
|
||||
domainObject.getCapability('telemetry'),
|
||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||
ranges = metadata.ranges || [];
|
||||
|
||||
return ranges.some(function (range) {
|
||||
return range.format === 'string';
|
||||
});
|
||||
}
|
||||
return {
|
||||
/**
|
||||
* Check whether or not a given action is allowed by this
|
||||
* policy.
|
||||
* @param {Action} action the action
|
||||
* @param domainObject the domain object which will be viewed
|
||||
* @returns {boolean} true if not disallowed
|
||||
*/
|
||||
allow: function (view, domainObject) {
|
||||
// This policy only applies for the Messages view
|
||||
if (view.key === 'messages') {
|
||||
// The Messages view is allowed only if the domain
|
||||
// object has string telemetry
|
||||
if (!hasStringTelemetry(domainObject)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Like all policies, allow by default.
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return MessagesViewPolicy;
|
||||
}
|
||||
);
|
84
platform/features/events/test/DomainColumnSpec.js
Normal file
84
platform/features/events/test/DomainColumnSpec.js
Normal 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*/
|
||||
|
||||
/**
|
||||
* EventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/23/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/DomainColumn"],
|
||||
function (DomainColumn) {
|
||||
"use strict";
|
||||
|
||||
var TEST_DOMAIN_VALUE = "some formatted domain value";
|
||||
|
||||
describe("An event list domain column", function () {
|
||||
var mockDataSet,
|
||||
testMetadata,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDataSet = jasmine.createSpyObj(
|
||||
"data",
|
||||
[ "getDomainValue" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
testMetadata = {
|
||||
key: "testKey",
|
||||
name: "Test Name"
|
||||
};
|
||||
mockFormatter.formatDomainValue.andReturn(TEST_DOMAIN_VALUE);
|
||||
|
||||
column = new DomainColumn(testMetadata, mockFormatter);
|
||||
});
|
||||
|
||||
it("reports a column header from domain metadata", function () {
|
||||
expect(column.getTitle()).toEqual("Test Name");
|
||||
});
|
||||
|
||||
it("looks up data from a data set", function () {
|
||||
column.getValue(undefined, mockDataSet, 42);
|
||||
expect(mockDataSet.getDomainValue)
|
||||
.toHaveBeenCalledWith(42, "testKey");
|
||||
});
|
||||
|
||||
it("formats domain values as time", function () {
|
||||
mockDataSet.getDomainValue.andReturn(402513731000);
|
||||
|
||||
// Should have just given the value the formatter gave
|
||||
expect(column.getValue(undefined, mockDataSet, 42))
|
||||
.toEqual(TEST_DOMAIN_VALUE);
|
||||
|
||||
// Make sure that service interactions were as expected
|
||||
expect(mockFormatter.formatDomainValue)
|
||||
.toHaveBeenCalledWith(402513731000);
|
||||
expect(mockFormatter.formatRangeValue)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
110
platform/features/events/test/EventListControllerSpec.js
Normal file
110
platform/features/events/test/EventListControllerSpec.js
Normal 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,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||
|
||||
/**
|
||||
* EventSpec. Created by shale on 06/24/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/EventListController"],
|
||||
function (EventListController) {
|
||||
"use strict";
|
||||
|
||||
describe("The event list controller", function () {
|
||||
var mockScope,
|
||||
mockTelemetry,
|
||||
testMetadata,
|
||||
controller;
|
||||
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj(
|
||||
"$scope",
|
||||
[ "$on", "$watch" ]
|
||||
);
|
||||
mockTelemetry = jasmine.createSpyObj(
|
||||
"telemetryController",
|
||||
[ "getResponse", "getMetadata", "getTelemetryObjects" ]
|
||||
);
|
||||
testMetadata = [
|
||||
{
|
||||
domains: [
|
||||
{ key: "d0", name: "D0" },
|
||||
{ key: "d1", name: "D1" }
|
||||
],
|
||||
ranges: [
|
||||
{ key: "r0", name: "R0" },
|
||||
{ key: "r1", name: "R1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
domains: [
|
||||
{ key: "d0", name: "D0" },
|
||||
{ key: "d2", name: "D2" }
|
||||
],
|
||||
ranges: [
|
||||
{ key: "r0", name: "R0" }
|
||||
]
|
||||
}
|
||||
];
|
||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||
mockTelemetry.getResponse.andReturn([]);
|
||||
mockTelemetry.getTelemetryObjects.andReturn([]);
|
||||
mockScope.telemetry = mockTelemetry;
|
||||
controller = new EventListController(mockScope);
|
||||
});
|
||||
|
||||
it("listens for telemetry data updates", function () {
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
"telemetryUpdate",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("watches for telemetry controller changes", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"telemetry",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("provides a column for each unique domain and range", function () {
|
||||
// Should have five columns based on metadata above,
|
||||
// (d0, d1, d2, r0, r1)
|
||||
mockScope.$watch.mostRecentCall.args[1](mockTelemetry);
|
||||
expect(mockScope.headers).toEqual(["D0", "D1", "D2", "R0", "R1"]);
|
||||
});
|
||||
|
||||
it("does not throw if telemetry controller is undefined", function () {
|
||||
// Just a general robustness check
|
||||
mockScope.telemetry = undefined;
|
||||
expect(mockScope.$watch.mostRecentCall.args[1])
|
||||
.not.toThrow();
|
||||
});
|
||||
|
||||
it("provides default columns if domain/range metadata is unavailable", function () {
|
||||
mockTelemetry.getMetadata.andReturn([]);
|
||||
mockScope.$watch.mostRecentCall.args[1](mockTelemetry);
|
||||
expect(mockScope.headers).toEqual(["Time", "Message"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
103
platform/features/events/test/EventListPopulatorSpec.js
Normal file
103
platform/features/events/test/EventListPopulatorSpec.js
Normal file
@ -0,0 +1,103 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* EventSpec. Created by shale on 06/24/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/EventListPopulator"],
|
||||
function (EventListPopulator) {
|
||||
"use strict";
|
||||
|
||||
describe("The event list populator", function () {
|
||||
var mockColumns,
|
||||
mockDatas,
|
||||
mockDomainObjects,
|
||||
populator;
|
||||
|
||||
function makeMockColumn(name, index) {
|
||||
var mockColumn = jasmine.createSpyObj(
|
||||
"column" + index,
|
||||
[ "getTitle", "getValue" ]
|
||||
);
|
||||
mockColumn.getTitle.andReturn(name);
|
||||
mockColumn.getValue.andCallFake(function (obj, data, i) {
|
||||
return data.getDomainValue(i);
|
||||
});
|
||||
return mockColumn;
|
||||
}
|
||||
|
||||
function makeMockData(bias, index) {
|
||||
var mockData = jasmine.createSpyObj(
|
||||
"data" + index,
|
||||
[ "getDomainValue", "getPointCount" ]
|
||||
);
|
||||
mockData.getPointCount.andReturn(1000);
|
||||
mockData.getDomainValue.andCallFake(function (i) {
|
||||
return i + bias;
|
||||
});
|
||||
return mockData;
|
||||
}
|
||||
|
||||
function makeMockDomainObject(name, index) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject" + index,
|
||||
[ "getId", "getModel" ]
|
||||
);
|
||||
return mockDomainObject;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockColumns = ["A", "B", "C", "D"].map(makeMockColumn);
|
||||
mockDatas = [ 10, 0, 3 ].map(makeMockData);
|
||||
mockDomainObjects = ["A", "B", "C"].map(makeMockDomainObject);
|
||||
populator = new EventListPopulator(mockColumns);
|
||||
});
|
||||
|
||||
it("returns column headers", function () {
|
||||
expect(populator.getHeaders()).toEqual(["A", "B", "C", "D"]);
|
||||
});
|
||||
|
||||
it("provides rows on request, with all columns in each row", function () {
|
||||
var rows = populator.getRows(mockDatas, mockDomainObjects, 84);
|
||||
expect(rows.length).toEqual(84);
|
||||
rows.forEach(function (row) {
|
||||
expect(row.length).toEqual(4); // number of columns
|
||||
});
|
||||
});
|
||||
|
||||
it("returns rows in most-recent-last order", function () {
|
||||
var rows = populator.getRows(mockDatas, mockDomainObjects, 84),
|
||||
previous = Number.NEGATIVE_INFINITY;
|
||||
|
||||
// Should always be most-recent-last
|
||||
rows.forEach(function (row) {
|
||||
expect(row[0]).not.toBeLessThan(previous);
|
||||
previous = row[0];
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
81
platform/features/events/test/RangeColumnSpec.js
Normal file
81
platform/features/events/test/RangeColumnSpec.js
Normal file
@ -0,0 +1,81 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* EventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/23/2015.
|
||||
*/
|
||||
define(
|
||||
["../src/RangeColumn"],
|
||||
function (RangeColumn) {
|
||||
"use strict";
|
||||
|
||||
var TEST_RANGE_VALUE = "some formatted range value";
|
||||
|
||||
describe("An event list range column", function () {
|
||||
var mockDataSet,
|
||||
testMetadata,
|
||||
mockFormatter,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDataSet = jasmine.createSpyObj(
|
||||
"data",
|
||||
[ "getRangeValue" ]
|
||||
);
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
);
|
||||
testMetadata = {
|
||||
key: "testKey",
|
||||
name: "Test Name"
|
||||
};
|
||||
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);
|
||||
|
||||
column = new RangeColumn(testMetadata, mockFormatter);
|
||||
});
|
||||
|
||||
it("reports a column header from range metadata", function () {
|
||||
expect(column.getTitle()).toEqual("Test Name");
|
||||
});
|
||||
|
||||
it("looks up data from a data set", function () {
|
||||
column.getValue(undefined, mockDataSet, 42);
|
||||
expect(mockDataSet.getRangeValue)
|
||||
.toHaveBeenCalledWith(42, "testKey");
|
||||
});
|
||||
|
||||
it("formats range values as time", function () {
|
||||
mockDataSet.getRangeValue.andReturn(123.45678);
|
||||
expect(column.getValue(undefined, mockDataSet, 42))
|
||||
.toEqual(TEST_RANGE_VALUE);
|
||||
|
||||
// Make sure that service interactions were as expected
|
||||
expect(mockFormatter.formatRangeValue)
|
||||
.toHaveBeenCalledWith(123.45678);
|
||||
expect(mockFormatter.formatDomainValue)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,81 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* EventSpec. Created by shale on 06/24/2015.
|
||||
*/
|
||||
define(
|
||||
["../../src/policies/MessagesViewPolicy"],
|
||||
function (MessagesViewPolicy) {
|
||||
"use strict";
|
||||
|
||||
describe("The messages view policy", function () {
|
||||
var mockDomainObject,
|
||||
mockTelemetry,
|
||||
telemetryType,
|
||||
testType,
|
||||
testView,
|
||||
testMetadata,
|
||||
policy;
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
testView = { key: "string" };
|
||||
testMetadata = {};
|
||||
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
'domainObject',
|
||||
['getModel', 'getCapability']
|
||||
);
|
||||
mockTelemetry = jasmine.createSpyObj(
|
||||
'telemetry',
|
||||
['getMetadata']
|
||||
);
|
||||
|
||||
mockDomainObject.getModel.andCallFake(function (c) {
|
||||
return {type: testType};
|
||||
});
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
return c === 'telemetry' ? mockTelemetry : undefined;
|
||||
});
|
||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||
|
||||
policy = new MessagesViewPolicy();
|
||||
});
|
||||
|
||||
it("disallows the message view for objects without string telemetry", function () {
|
||||
testMetadata.ranges = [ { format: 'notString' } ];
|
||||
expect(policy.allow({ key: 'messages' }, mockDomainObject)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("allows the message view for objects with string telemetry", function () {
|
||||
testMetadata.ranges = [ { format: 'string' } ];
|
||||
expect(policy.allow({ key: 'messages' }, mockDomainObject)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("returns true when the current view is not the Messages view", function () {
|
||||
expect(policy.allow({ key: 'notMessages' }, mockDomainObject)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
7
platform/features/events/test/suite.json
Normal file
7
platform/features/events/test/suite.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
"DomainColumn",
|
||||
"EventListController",
|
||||
"EventListPopulator",
|
||||
"policies/MessagesViewPolicy",
|
||||
"RangeColumn"
|
||||
]
|
37
platform/features/rtevents/bundle.json
Normal file
37
platform/features/rtevents/bundle.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "Event Messages",
|
||||
"description": "List of time-ordered event messages",
|
||||
"extensions": {
|
||||
"views": [
|
||||
{
|
||||
"key": "rtmessages",
|
||||
"name": "RT Messages",
|
||||
"glyph": "5",
|
||||
"description": "Scrolling list of real time messages.",
|
||||
"templateUrl": "templates/rtmessages.html",
|
||||
"needs": [ "telemetry" ],
|
||||
"delegation": true
|
||||
}
|
||||
],
|
||||
"controllers": [
|
||||
{
|
||||
"key": "RTEventListController",
|
||||
"implementation": "RTEventListController.js",
|
||||
"depends": [ "$scope", "telemetryHandler", "telemetryFormatter" ]
|
||||
}
|
||||
],
|
||||
"directives": [
|
||||
{
|
||||
"key": "mctRtDataTable",
|
||||
"implementation": "directives/MCTRTDataTable.js",
|
||||
"depends": [ "$window" ]
|
||||
}
|
||||
],
|
||||
"policies": [
|
||||
{
|
||||
"category": "view",
|
||||
"implementation": "policies/RTMessagesViewPolicy.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<table class="tabular">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="header in headers">
|
||||
{{header}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="row in rows">
|
||||
<td ng-repeat="cell in row">
|
||||
{{cell}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
29
platform/features/rtevents/res/templates/rtmessages.html
Normal file
29
platform/features/rtevents/res/templates/rtmessages.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!--
|
||||
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 class="w1">
|
||||
<div class="w2"
|
||||
ng-controller="RTEventListController as rtevent">
|
||||
<mct-rt-data-table headers="rtevent.headers()" rows="rtevent.rows()" ascending-scroll="true"></mct-rt-data-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
69
platform/features/rtevents/src/DomainColumn.js
Normal file
69
platform/features/rtevents/src/DomainColumn.js
Normal file
@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* 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,moment*/
|
||||
|
||||
/**
|
||||
* Module defining DomainColumn. Created by vwoeltje on 11/18/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A column which will report telemetry domain values
|
||||
* (typically, timestamps.) Used by the ScrollingListController.
|
||||
*
|
||||
* @constructor
|
||||
* @param domainMetadata an object with the machine- and human-
|
||||
* readable names for this domain (in `key` and `name`
|
||||
* fields, respectively.)
|
||||
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function DomainColumn(telemetryFormatter) {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
*/
|
||||
getTitle: function () {
|
||||
return "Time";
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
*/
|
||||
getValue: function (domainObject, handle) {
|
||||
return {
|
||||
text: telemetryFormatter.formatDomainValue(
|
||||
handle.getDomainValue(domainObject)
|
||||
)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return DomainColumn;
|
||||
}
|
||||
);
|
138
platform/features/rtevents/src/RTEventListController.js
Normal file
138
platform/features/rtevents/src/RTEventListController.js
Normal file
@ -0,0 +1,138 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* Module defining RTEventListController.
|
||||
* Created by shale on 06/25/2014. Based on RT Scrolling lists.
|
||||
*/
|
||||
define(
|
||||
["./DomainColumn", "./RangeColumn"],
|
||||
function (DomainColumn, RangeColumn) {
|
||||
"use strict";
|
||||
|
||||
var ROW_COUNT = 100;
|
||||
|
||||
/**
|
||||
* The RTEventListController is responsible for populating
|
||||
* the contents of the messages view.
|
||||
* @constructor
|
||||
*/
|
||||
function RTEventListController($scope, telemetryHandler, telemetryFormatter) {
|
||||
var handle,
|
||||
lastUpdated = {},
|
||||
lastIds = [],
|
||||
columns = [],
|
||||
headers = [],
|
||||
rows = [];
|
||||
|
||||
function getTelemetryObjects() {
|
||||
return handle ? handle.getTelemetryObjects() : [];
|
||||
}
|
||||
|
||||
function idsChanged(telemetryObjects) {
|
||||
function mismatch(id, index) {
|
||||
return id !== telemetryObjects[index].getId();
|
||||
}
|
||||
|
||||
return lastIds.length !== telemetryObjects.length ||
|
||||
lastIds.some(mismatch);
|
||||
}
|
||||
|
||||
function setupColumns(telemetryObjects) {
|
||||
var id = $scope.domainObject && $scope.domainObject.getId(),
|
||||
firstId =
|
||||
telemetryObjects[0] && telemetryObjects[0].getId();
|
||||
|
||||
columns = [];
|
||||
|
||||
columns.push(new DomainColumn(telemetryFormatter));
|
||||
columns.push(new RangeColumn());
|
||||
|
||||
headers = columns.map(function (column) {
|
||||
return column.getTitle();
|
||||
});
|
||||
}
|
||||
|
||||
function updateObjects(telemetryObjects) {
|
||||
if (idsChanged(telemetryObjects)) {
|
||||
setupColumns(telemetryObjects);
|
||||
lastIds = telemetryObjects.map(function (telemetryObject) {
|
||||
return telemetryObject.getId();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function addRow(telemetryObject) {
|
||||
var id = telemetryObject.getId(),
|
||||
domainValue = handle.getDomainValue(telemetryObject);
|
||||
if (lastUpdated[id] !== domainValue &&
|
||||
domainValue !== undefined) {
|
||||
// Instead of unshift (scrolling), use push (messages)
|
||||
rows.push(columns.map(function (column) {
|
||||
return column.getValue(telemetryObject, handle).text;
|
||||
}));
|
||||
// Remove first rows when adding past the max rows limit
|
||||
//rows.splice(ROW_COUNT, Number.MAX_VALUE);
|
||||
rows.splice(0, rows.length - ROW_COUNT);
|
||||
lastUpdated[id] = domainValue;
|
||||
}
|
||||
}
|
||||
|
||||
function updateValues() {
|
||||
getTelemetryObjects().forEach(addRow);
|
||||
}
|
||||
|
||||
function releaseSubscription() {
|
||||
if (handle) {
|
||||
handle.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
function makeSubscription(domainObject) {
|
||||
releaseSubscription();
|
||||
rows = [];
|
||||
handle = telemetryHandler.handle(
|
||||
domainObject,
|
||||
updateValues,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$scope.$on("$destroy", releaseSubscription);
|
||||
|
||||
$scope.$watch("domainObject", makeSubscription);
|
||||
$scope.$watch(getTelemetryObjects, updateObjects);
|
||||
|
||||
return {
|
||||
rows: function () {
|
||||
return rows;
|
||||
},
|
||||
headers: function () {
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return RTEventListController;
|
||||
}
|
||||
);
|
68
platform/features/rtevents/src/RangeColumn.js
Normal file
68
platform/features/rtevents/src/RangeColumn.js
Normal file
@ -0,0 +1,68 @@
|
||||
/*****************************************************************************
|
||||
* 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,moment*/
|
||||
|
||||
/**
|
||||
* Module defining DomainColumn.
|
||||
* Created by vwoeltje on 11/18/14. Modified by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A column which will report telemetry range values
|
||||
* (typically, measurements.) Used by the RTScrollingListController.
|
||||
*
|
||||
* @constructor
|
||||
* @param rangeMetadata an object with the machine- and human-
|
||||
* readable names for this range (in `key` and `name`
|
||||
* fields, respectively.)
|
||||
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function RangeColumn() {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
*/
|
||||
getTitle: function () {
|
||||
return "Message";
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
*/
|
||||
getValue: function (domainObject, handle) {
|
||||
return {
|
||||
text: handle.getRangeValue(domainObject)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return RangeColumn;
|
||||
}
|
||||
);
|
74
platform/features/rtevents/src/directives/MCTRTDataTable.js
Normal file
74
platform/features/rtevents/src/directives/MCTRTDataTable.js
Normal 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,Promise*/
|
||||
|
||||
/**
|
||||
* Module defining MCTRTDataTable. Created by shale on 06/25/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function MCTRTDataTable($window) {
|
||||
return {
|
||||
restrict: "E",
|
||||
templateUrl: "platform/features/rtevents/res/templates/mct-rt-data-table.html",
|
||||
scope: {
|
||||
headers: "=",
|
||||
rows: "=",
|
||||
ascendingScroll: "="
|
||||
},
|
||||
link: function ($scope, $element) {
|
||||
var currentHeight,
|
||||
previousHeight,
|
||||
scrollParent;
|
||||
|
||||
// If the scroll is set to ascending, we want to
|
||||
// check when elements are added to the table, and move the scroll
|
||||
// bar accordingly.
|
||||
// (When viewing at the bottom of the page, the scroll bar will
|
||||
// stay at the bottom despite additions to the table)
|
||||
if ($scope.ascendingScroll) {
|
||||
$scope.$watchCollection("rows", function () {
|
||||
// Wait until the page as been repainted (otherwise the
|
||||
// height will always be zero)
|
||||
$window.requestAnimationFrame(function () {
|
||||
previousHeight = currentHeight;
|
||||
// The height of the table body
|
||||
currentHeight = $element[0].firstElementChild.firstElementChild.nextElementSibling.clientHeight;
|
||||
|
||||
// One of the parents is a div that has vscroll
|
||||
scrollParent = $element[0].parentElement.parentElement.parentElement.parentElement.parentElement;
|
||||
|
||||
// Move the scrollbar down the amount that the height has changed
|
||||
scrollParent.scrollTop = scrollParent.scrollTop + (currentHeight - previousHeight);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return MCTRTDataTable;
|
||||
}
|
||||
);
|
@ -0,0 +1,75 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
/**
|
||||
* Module defining MessagesViewPolicy. Created by shale on 06/24/2015.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Policy controlling when the Messages view should be avaliable.
|
||||
* @constructor
|
||||
*/
|
||||
function RTMessagesViewPolicy() {
|
||||
|
||||
function hasStringTelemetry(domainObject) {
|
||||
var telemetry = domainObject &&
|
||||
domainObject.getCapability('telemetry'),
|
||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||
data = telemetry ? telemetry.requestData() : {},
|
||||
ranges = metadata.ranges || [];
|
||||
|
||||
return ranges.some(function (range) {
|
||||
return range.format === 'string';
|
||||
});
|
||||
}
|
||||
return {
|
||||
/**
|
||||
* Check whether or not a given action is allowed by this
|
||||
* policy.
|
||||
* @param {Action} action the action
|
||||
* @param domainObject the domain object which will be viewed
|
||||
* @returns {boolean} true if not disallowed
|
||||
*/
|
||||
allow: function (view, domainObject) {
|
||||
// This policy only applies for the RT Messages view
|
||||
if (view.key === 'rtmessages') {
|
||||
// The Messages view is allowed only if the domain
|
||||
// object has string telemetry
|
||||
if (!hasStringTelemetry(domainObject)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Like all policies, allow by default.
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return RTMessagesViewPolicy;
|
||||
}
|
||||
);
|
0
platform/features/rtevents/test/DomainColumnSpec.js
Normal file
0
platform/features/rtevents/test/DomainColumnSpec.js
Normal file
0
platform/features/rtevents/test/RangeColumnSpec.js
Normal file
0
platform/features/rtevents/test/RangeColumnSpec.js
Normal file
0
platform/features/rtevents/test/suite.js
Normal file
0
platform/features/rtevents/test/suite.js
Normal file
@ -23,7 +23,7 @@
|
||||
<div class="w2"
|
||||
ng-controller="ScrollingListController">
|
||||
<!-- To add filtering, add class 'filterable' to <table> and uncomment 2nd <tr> in <thead> -->
|
||||
<table class="tabular">
|
||||
<table class="tabular fixed-header">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="header in headers">
|
||||
|
@ -4,12 +4,12 @@
|
||||
{
|
||||
"key": "mctInclude",
|
||||
"implementation": "MCTInclude.js",
|
||||
"depends": [ "templates[]" ]
|
||||
"depends": [ "templates[]", "$sce" ]
|
||||
},
|
||||
{
|
||||
"key": "mctRepresentation",
|
||||
"implementation": "MCTRepresentation.js",
|
||||
"depends": [ "representations[]", "views[]", "representers[]", "$q", "$log" ]
|
||||
"depends": [ "representations[]", "views[]", "representers[]", "$q", "$sce", "$log" ]
|
||||
}
|
||||
],
|
||||
"gestures": [
|
||||
@ -51,4 +51,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,17 +53,17 @@ define(
|
||||
* @param {TemplateDefinition[]} templates an array of
|
||||
* template extensions
|
||||
*/
|
||||
function MCTInclude(templates) {
|
||||
function MCTInclude(templates, $sce) {
|
||||
var templateMap = {};
|
||||
|
||||
// Prepopulate templateMap for easy look up by key
|
||||
templates.forEach(function (template) {
|
||||
var key = template.key,
|
||||
path = [
|
||||
path = $sce.trustAsResourceUrl([
|
||||
template.bundle.path,
|
||||
template.bundle.resources,
|
||||
template.templateUrl
|
||||
].join("/");
|
||||
].join("/"));
|
||||
// First found should win (priority ordering)
|
||||
templateMap[key] = templateMap[key] || path;
|
||||
});
|
||||
@ -91,4 +91,4 @@ define(
|
||||
|
||||
return MCTInclude;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ define(
|
||||
* representation extensions
|
||||
* @param {ViewDefinition[]} views an array of view extensions
|
||||
*/
|
||||
function MCTRepresentation(representations, views, representers, $q, $log) {
|
||||
function MCTRepresentation(representations, views, representers, $q, $sce, $log) {
|
||||
var representationMap = {},
|
||||
gestureMap = {};
|
||||
|
||||
@ -69,11 +69,11 @@ define(
|
||||
|
||||
// Get a path to a representation
|
||||
function getPath(representation) {
|
||||
return [
|
||||
return $sce.trustAsResourceUrl([
|
||||
representation.bundle.path,
|
||||
representation.bundle.resources,
|
||||
representation.templateUrl
|
||||
].join("/");
|
||||
].join("/"));
|
||||
}
|
||||
|
||||
// Look up a matching representation for this domain object
|
||||
@ -237,4 +237,4 @@ define(
|
||||
|
||||
return MCTRepresentation;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -31,6 +31,7 @@ define(
|
||||
|
||||
describe("The mct-include directive", function () {
|
||||
var testTemplates,
|
||||
mockSce,
|
||||
mctInclude;
|
||||
|
||||
beforeEach(function () {
|
||||
@ -46,7 +47,14 @@ define(
|
||||
templateUrl: "z/template.html"
|
||||
}
|
||||
];
|
||||
mctInclude = new MCTInclude(testTemplates);
|
||||
mockSce = jasmine.createSpyObj(
|
||||
'$sce',
|
||||
['trustAsResourceUrl']
|
||||
);
|
||||
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
||||
return url;
|
||||
});
|
||||
mctInclude = new MCTInclude(testTemplates, mockSce);
|
||||
});
|
||||
|
||||
it("has a built-in template, with ng-include src=inclusion", function () {
|
||||
@ -69,6 +77,12 @@ define(
|
||||
expect(scope.inclusion).toEqual("x/y/z/template.html");
|
||||
});
|
||||
|
||||
it("trusts template URLs", function () {
|
||||
mctInclude.controller({ key: "xyz" });
|
||||
expect(mockSce.trustAsResourceUrl)
|
||||
.toHaveBeenCalledWith("x/y/z/template.html");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -38,6 +38,7 @@ define(
|
||||
testViews,
|
||||
mockRepresenters,
|
||||
mockQ,
|
||||
mockSce,
|
||||
mockLog,
|
||||
mockScope,
|
||||
mockElement,
|
||||
@ -95,8 +96,16 @@ define(
|
||||
});
|
||||
|
||||
mockQ = { when: mockPromise };
|
||||
mockSce = jasmine.createSpyObj(
|
||||
'$sce',
|
||||
['trustAsResourceUrl']
|
||||
);
|
||||
mockLog = jasmine.createSpyObj("$log", LOG_FUNCTIONS);
|
||||
|
||||
|
||||
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
||||
return url;
|
||||
});
|
||||
mockScope = jasmine.createSpyObj("scope", [ "$watch" ]);
|
||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||
@ -108,6 +117,7 @@ define(
|
||||
testViews,
|
||||
mockRepresenters,
|
||||
mockQ,
|
||||
mockSce,
|
||||
mockLog
|
||||
);
|
||||
});
|
||||
@ -125,9 +135,18 @@ define(
|
||||
|
||||
it("watches scope when linked", function () {
|
||||
mctRepresentation.link(mockScope, mockElement);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith("key", jasmine.any(Function));
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith("domainObject", jasmine.any(Function));
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith("domainObject.getModel().modified", jasmine.any(Function));
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"key",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"domainObject",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"domainObject.getModel().modified",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("recognizes keys for representations", function () {
|
||||
@ -152,6 +171,18 @@ define(
|
||||
expect(mockScope.inclusion).toEqual("x/y/z/template.html");
|
||||
});
|
||||
|
||||
it("trusts template URLs", function () {
|
||||
mctRepresentation.link(mockScope, mockElement);
|
||||
|
||||
mockScope.key = "xyz";
|
||||
|
||||
// Trigger the watch
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
expect(mockSce.trustAsResourceUrl)
|
||||
.toHaveBeenCalledWith("x/y/z/template.html");
|
||||
});
|
||||
|
||||
it("loads declared capabilities", function () {
|
||||
mctRepresentation.link(mockScope, mockElement);
|
||||
|
||||
@ -202,4 +233,4 @@ define(
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -342,7 +342,7 @@ define(
|
||||
* the second form, it returns an array ordered in
|
||||
* same manner as `getMetadata()` or
|
||||
* `getTelemetryObjects()`; that is, the telemetry
|
||||
* response at agiven index will correspond to the
|
||||
* response at a given index will correspond to the
|
||||
* telemetry-providing domain object at the same index.
|
||||
* @returns {Array} an array of responses
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user