mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
[Telemetry] Use telemetryFormatter in scrolling list
Use the injected telemetryFormatter in scrolling list views, instead of replicating this functionality. WTD-599.
This commit is contained in:
@ -16,7 +16,7 @@
|
|||||||
{
|
{
|
||||||
"key": "ScrollingListController",
|
"key": "ScrollingListController",
|
||||||
"implementation": "ScrollingListController.js",
|
"implementation": "ScrollingListController.js",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope", "telemetryFormatter" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,10 @@
|
|||||||
* Module defining DomainColumn. Created by vwoeltje on 11/18/14.
|
* Module defining DomainColumn. Created by vwoeltje on 11/18/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
["../../plot/lib/moment.min"],
|
[],
|
||||||
function () {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Date format to use for domain values; in particular,
|
|
||||||
// use day-of-year instead of month/day
|
|
||||||
var DATE_FORMAT = "YYYY-DDD HH:mm:ss";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A column which will report telemetry domain values
|
* A column which will report telemetry domain values
|
||||||
* (typically, timestamps.) Used by the ScrollingListController.
|
* (typically, timestamps.) Used by the ScrollingListController.
|
||||||
@ -20,8 +16,10 @@ define(
|
|||||||
* @param domainMetadata an object with the machine- and human-
|
* @param domainMetadata an object with the machine- and human-
|
||||||
* readable names for this domain (in `key` and `name`
|
* readable names for this domain (in `key` and `name`
|
||||||
* fields, respectively.)
|
* fields, respectively.)
|
||||||
|
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||||
|
* formatting service, for making values human-readable.
|
||||||
*/
|
*/
|
||||||
function DomainColumn(domainMetadata) {
|
function DomainColumn(domainMetadata, telemetryFormatter) {
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get the title to display in this column's header.
|
* Get the title to display in this column's header.
|
||||||
@ -36,10 +34,9 @@ define(
|
|||||||
* @returns {string} the text to display
|
* @returns {string} the text to display
|
||||||
*/
|
*/
|
||||||
getValue: function (domainObject, data, index) {
|
getValue: function (domainObject, data, index) {
|
||||||
return moment.utc(data.getDomainValue(
|
return telemetryFormatter.formatDomainValue(
|
||||||
index,
|
data.getDomainValue(index, domainMetadata.key)
|
||||||
domainMetadata.key
|
);
|
||||||
)).format(DATE_FORMAT);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@ define(
|
|||||||
* @param rangeMetadata an object with the machine- and human-
|
* @param rangeMetadata an object with the machine- and human-
|
||||||
* readable names for this range (in `key` and `name`
|
* readable names for this range (in `key` and `name`
|
||||||
* fields, respectively.)
|
* fields, respectively.)
|
||||||
|
* @param {TelemetryFormatter} telemetryFormatter the telemetry
|
||||||
|
* formatting service, for making values human-readable.
|
||||||
*/
|
*/
|
||||||
function RangeColumn(rangeMetadata) {
|
function RangeColumn(rangeMetadata, telemetryFormatter) {
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get the title to display in this column's header.
|
* Get the title to display in this column's header.
|
||||||
@ -32,8 +34,9 @@ define(
|
|||||||
* @returns {string} the text to display
|
* @returns {string} the text to display
|
||||||
*/
|
*/
|
||||||
getValue: function (domainObject, data, index) {
|
getValue: function (domainObject, data, index) {
|
||||||
var value = data.getRangeValue(index, rangeMetadata.key);
|
return telemetryFormatter.formatRangeValue(
|
||||||
return value && value.toFixed(3);
|
data.getRangeValue(index, rangeMetadata.key)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ define(
|
|||||||
* the contents of the scrolling list view.
|
* the contents of the scrolling list view.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ScrollingListController($scope) {
|
function ScrollingListController($scope, formatter) {
|
||||||
var populator;
|
var populator;
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ define(
|
|||||||
var key = domain.key;
|
var key = domain.key;
|
||||||
if (key && !domainKeys[key]) {
|
if (key && !domainKeys[key]) {
|
||||||
domainKeys[key] = true;
|
domainKeys[key] = true;
|
||||||
columns.push(new DomainColumn(domain));
|
columns.push(new DomainColumn(domain, formatter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ define(
|
|||||||
var key = range.key;
|
var key = range.key;
|
||||||
if (key && !rangeKeys[key]) {
|
if (key && !rangeKeys[key]) {
|
||||||
rangeKeys[key] = true;
|
rangeKeys[key] = true;
|
||||||
columns.push(new RangeColumn(range));
|
columns.push(new RangeColumn(range, formatter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,10 +86,10 @@ define(
|
|||||||
// Add default domain, range columns if none
|
// Add default domain, range columns if none
|
||||||
// were described in metadata.
|
// were described in metadata.
|
||||||
if (Object.keys(domainKeys).length < 1) {
|
if (Object.keys(domainKeys).length < 1) {
|
||||||
columns.push(new DomainColumn({ name: "Time" }));
|
columns.push(new DomainColumn({name: "Time"}, formatter));
|
||||||
}
|
}
|
||||||
if (Object.keys(rangeKeys).length < 1) {
|
if (Object.keys(rangeKeys).length < 1) {
|
||||||
columns.push(new RangeColumn({ name: "Value" }));
|
columns.push(new RangeColumn({name: "Value"}, formatter));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have all columns now; use them to initializer
|
// We have all columns now; use them to initializer
|
||||||
|
Reference in New Issue
Block a user