From 51852e1322b0f5fb958fe49f1f8a4c7cab535c99 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 9 Jun 2015 10:06:54 -0700 Subject: [PATCH] [Limits] Use datum for limits in scrolling list view Utilize 'datum' API when displaying limits in a scrolling list view, WTD-1223. --- .../scrolling/src/ScrollingListController.js | 20 ++++++------- .../scrolling/src/ScrollingListPopulator.js | 30 +++++++++++++++++-- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/platform/features/scrolling/src/ScrollingListController.js b/platform/features/scrolling/src/ScrollingListController.js index c175825c69..f61e178964 100644 --- a/platform/features/scrolling/src/ScrollingListController.js +++ b/platform/features/scrolling/src/ScrollingListController.js @@ -58,11 +58,10 @@ define( // 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) { + function setupColumns(metadatas) { var domainKeys = {}, rangeKeys = {}, - columns = [], - metadata; + columns = []; // Add a domain to the set of columns, if a domain // with the same key has not yet been inclued. @@ -84,9 +83,9 @@ define( } } - // We cannot proceed if the telemetry controller - // is not available; clear all rows/columns. - if (!telemetry) { + // We cannot proceed if metadata is not available; + // clear all rows/columns. + if (!Array.isArray(metadatas)) { columns = []; $scope.rows = []; $scope.headers = []; @@ -96,11 +95,10 @@ define( columns = [ new NameColumn() ]; // Add domain, range columns - metadata = telemetry.getMetadata(); - (metadata || []).forEach(function (metadata) { + metadatas.forEach(function (metadata) { (metadata.domains || []).forEach(addDomain); }); - (metadata || []).forEach(function (metadata) { + metadatas.forEach(function (metadata) { (metadata.ranges || []).forEach(addRange); }); @@ -126,9 +124,9 @@ define( } $scope.$on("telemetryUpdate", updateRows); - $scope.$watch("telemetry", setupColumns); + $scope.$watch("telemetry.getMetadata()", setupColumns); } return ScrollingListController; } -); \ No newline at end of file +); diff --git a/platform/features/scrolling/src/ScrollingListPopulator.js b/platform/features/scrolling/src/ScrollingListPopulator.js index 466a2ad27d..bbdda2359a 100644 --- a/platform/features/scrolling/src/ScrollingListPopulator.js +++ b/platform/features/scrolling/src/ScrollingListPopulator.js @@ -111,6 +111,25 @@ define( return latest; } + // From a telemetry series, retrieve a single data point + // containing all fields for domains/ranges + function makeDatum(domainObject, series, index) { + var telemetry = domainObject.getCapability('telemetry'), + metadata = telemetry ? telemetry.getMetadata() : {}, + result = {}; + + (metadata.domains || []).forEach(function (domain) { + result[domain.key] = + series.getDomainValue(index, domain.key); + }); + + (metadata.ranges || []).forEach(function (range) { + result[range.key] = + series.getRangeValue(index, range.key); + }); + + return result; + } return { /** @@ -141,11 +160,16 @@ define( // some value in each column (rendering by the // column object itself) return values.map(function (value) { + var datum = makeDatum( + objects[value.objectIndex], + datas[value.objectIndex], + value.pointIndex + ); + return columns.map(function (column) { return column.getValue( objects[value.objectIndex], - datas[value.objectIndex], - value.pointIndex + datum ); }); }); @@ -156,4 +180,4 @@ define( return ScrollingListPopulator; } -); \ No newline at end of file +);