mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 17:57:04 +00:00
[Events] Real-time telemetry version
Creating an additional event list which can handle real time data, not historical data. #18.
This commit is contained in:
parent
d2fe71d82b
commit
f6298c162c
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": "messages",
|
||||||
|
"name": "RT Messages",
|
||||||
|
"glyph": "5",
|
||||||
|
"description": "Scrolling list of messages.",
|
||||||
|
"templateUrl": "templates/messages.html",
|
||||||
|
"needs": [ "telemetry" ],
|
||||||
|
"delegation": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"controllers": [
|
||||||
|
{
|
||||||
|
"key": "RTEventListController",
|
||||||
|
"implementation": "RTEventListController.js",
|
||||||
|
"depends": [ "$scope", "telemetryHandler", "telemetryFormatter" ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
{
|
||||||
|
"key": "mctDataTable",
|
||||||
|
"implementation": "directives/MCTDataTable.js",
|
||||||
|
"depends": [ "$window" ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"policies": [
|
||||||
|
{
|
||||||
|
"category": "view",
|
||||||
|
"implementation": "policies/MessagesViewPolicy.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
37
platform/features/rtevents/res/templates/mct-data-table.html
Normal file
37
platform/features/rtevents/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/rtevents/res/templates/messages.html
Normal file
29
platform/features/rtevents/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/rtevents/src/DomainColumn.js
Normal file
67
platform/features/rtevents/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;
|
||||||
|
}
|
||||||
|
);
|
139
platform/features/rtevents/src/RTEventListController.js
Normal file
139
platform/features/rtevents/src/RTEventListController.js
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 RTScrollingListController is responsible for populating
|
||||||
|
* the contents of the scrolling list 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 = [];
|
||||||
|
|
||||||
|
if (telemetryObjects > 1 || id !== firstId) {
|
||||||
|
columns.push(new NameColumn());
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}));
|
||||||
|
rows.splice(ROW_COUNT, Number.MAX_VALUE);
|
||||||
|
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 RTScrollingListController;
|
||||||
|
}
|
||||||
|
);
|
67
platform/features/rtevents/src/RangeColumn.js
Normal file
67
platform/features/rtevents/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/rtevents/src/directives/MCTDataTable.js
Normal file
74
platform/features/rtevents/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;
|
||||||
|
}
|
||||||
|
);
|
@ -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/rtevents/test/DomainColumnSpec.js
Normal file
84
platform/features/rtevents/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/rtevents/test/RTEventListControllerSpec.js
Normal file
110
platform/features/rtevents/test/RTEventListControllerSpec.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"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
81
platform/features/rtevents/test/RangeColumnSpec.js
Normal file
81
platform/features/rtevents/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,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,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,
|
||||||
|
testType,
|
||||||
|
telemetryType,
|
||||||
|
policy;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
['getModel']
|
||||||
|
);
|
||||||
|
mockDomainObject.getModel.andCallFake(function (c) {
|
||||||
|
return {type: testType};
|
||||||
|
});
|
||||||
|
|
||||||
|
policy = new MessagesViewPolicy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("disallows the message view for objects without string telemetry", function () {
|
||||||
|
telemetryType = 'notString';
|
||||||
|
expect(policy.allow({ key: 'messages' }, mockDomainObject))
|
||||||
|
.toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows the message view for objects with string telemetry", function () {
|
||||||
|
telemetryType = '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/rtevents/test/suite.json
Normal file
7
platform/features/rtevents/test/suite.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
"DomainColumn",
|
||||||
|
"EventListController",
|
||||||
|
"EventListPopulator",
|
||||||
|
"policies/MessagesViewPolicy",
|
||||||
|
"RangeColumn"
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user