From 44b16f9dd9aee91fba2af9b87b1107452de85201 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 24 Dec 2014 11:23:59 -0800 Subject: [PATCH] [Telemetry] Use telemetryFormatter in scrolling list Use the injected telemetryFormatter in scrolling list views, instead of replicating this functionality. WTD-599. --- platform/features/scrolling/bundle.json | 2 +- platform/features/scrolling/src/DomainColumn.js | 17 +++++++---------- platform/features/scrolling/src/RangeColumn.js | 9 ++++++--- .../scrolling/src/ScrollingListController.js | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/platform/features/scrolling/bundle.json b/platform/features/scrolling/bundle.json index e2763b03fc..4e23da788e 100644 --- a/platform/features/scrolling/bundle.json +++ b/platform/features/scrolling/bundle.json @@ -16,7 +16,7 @@ { "key": "ScrollingListController", "implementation": "ScrollingListController.js", - "depends": [ "$scope" ] + "depends": [ "$scope", "telemetryFormatter" ] } ] } diff --git a/platform/features/scrolling/src/DomainColumn.js b/platform/features/scrolling/src/DomainColumn.js index cf4383a37a..8a9f41de9d 100644 --- a/platform/features/scrolling/src/DomainColumn.js +++ b/platform/features/scrolling/src/DomainColumn.js @@ -4,14 +4,10 @@ * Module defining DomainColumn. Created by vwoeltje on 11/18/14. */ define( - ["../../plot/lib/moment.min"], + [], function () { "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 * (typically, timestamps.) Used by the ScrollingListController. @@ -20,8 +16,10 @@ define( * @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) { + function DomainColumn(domainMetadata, telemetryFormatter) { return { /** * Get the title to display in this column's header. @@ -36,10 +34,9 @@ define( * @returns {string} the text to display */ getValue: function (domainObject, data, index) { - return moment.utc(data.getDomainValue( - index, - domainMetadata.key - )).format(DATE_FORMAT); + return telemetryFormatter.formatDomainValue( + data.getDomainValue(index, domainMetadata.key) + ); } }; } diff --git a/platform/features/scrolling/src/RangeColumn.js b/platform/features/scrolling/src/RangeColumn.js index f710b31a05..9277519574 100644 --- a/platform/features/scrolling/src/RangeColumn.js +++ b/platform/features/scrolling/src/RangeColumn.js @@ -16,8 +16,10 @@ define( * @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) { + function RangeColumn(rangeMetadata, telemetryFormatter) { return { /** * Get the title to display in this column's header. @@ -32,8 +34,9 @@ define( * @returns {string} the text to display */ getValue: function (domainObject, data, index) { - var value = data.getRangeValue(index, rangeMetadata.key); - return value && value.toFixed(3); + return telemetryFormatter.formatRangeValue( + data.getRangeValue(index, rangeMetadata.key) + ); } }; } diff --git a/platform/features/scrolling/src/ScrollingListController.js b/platform/features/scrolling/src/ScrollingListController.js index 8ef0bb4a4a..737346fe9a 100644 --- a/platform/features/scrolling/src/ScrollingListController.js +++ b/platform/features/scrolling/src/ScrollingListController.js @@ -15,7 +15,7 @@ define( * the contents of the scrolling list view. * @constructor */ - function ScrollingListController($scope) { + function ScrollingListController($scope, formatter) { var populator; @@ -49,7 +49,7 @@ define( var key = domain.key; if (key && !domainKeys[key]) { domainKeys[key] = true; - columns.push(new DomainColumn(domain)); + columns.push(new DomainColumn(domain, formatter)); } } @@ -59,7 +59,7 @@ define( var key = range.key; if (key && !rangeKeys[key]) { 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 // were described in metadata. 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) { - columns.push(new RangeColumn({ name: "Value" })); + columns.push(new RangeColumn({name: "Value"}, formatter)); } // We have all columns now; use them to initializer