From 39a7f43cd005d761d66157ae6072ef76826de120 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Wed, 7 Mar 2018 13:49:11 -0800 Subject: [PATCH] Fixes Issue #1938 - Fixed Positon should display enumerated value (#1939) * Fixes #1938 Fixed usage of Telemetry API, use hints to get valueMetadata, use valueMetadata to get formatter * dont circumvent chooseTelemetryKeyToDisplay, which was causing a regression when imagery is added to fp * fix broken tests * pass valueMetaData to limitEvaluator.evaluate, rename #chooseTelemetryKeyToDisplay to getValueMetadata, to reflect what is returned. update tests * change getValueMetadata to chooseValueMetadataToDisplay --- .../features/layout/src/FixedController.js | 23 +++++++++---------- .../layout/test/FixedControllerSpec.js | 8 +++---- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index 210bc945e2..cb8b568b38 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -373,10 +373,10 @@ define( */ FixedController.prototype.updateView = function (telemetryObject, datum) { var metadata = this.openmct.telemetry.getMetadata(telemetryObject); - var telemetryKeyToDisplay = this.chooseTelemetryKeyToDisplay(metadata); - var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(telemetryKeyToDisplay, datum, metadata); + var valueMetadata = this.chooseValueMetadataToDisplay(metadata); + var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(valueMetadata, datum); var limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject); - var alarm = limitEvaluator && limitEvaluator.evaluate(datum, telemetryKeyToDisplay); + var alarm = limitEvaluator && limitEvaluator.evaluate(datum, valueMetadata); this.setDisplayedValue( telemetryObject, @@ -389,29 +389,28 @@ define( /** * @private */ - FixedController.prototype.getFormattedTelemetryValueForKey = function (telemetryKeyToDisplay, datum, metadata) { - var valueMetadata = metadata.value(telemetryKeyToDisplay); + FixedController.prototype.getFormattedTelemetryValueForKey = function (valueMetadata, datum) { var formatter = this.openmct.telemetry.getValueFormatter(valueMetadata); - return formatter.format(datum[valueMetadata.key]); + return formatter.format(datum); }; /** * @private */ - FixedController.prototype.chooseTelemetryKeyToDisplay = function (metadata) { + FixedController.prototype.chooseValueMetadataToDisplay = function (metadata) { // If there is a range value, show that preferentially - var telemetryKeyToDisplay = metadata.valuesForHints(['range'])[0]; + var valueMetadata = metadata.valuesForHints(['range'])[0]; // If no range is defined, default to the highest priority non time-domain data. - if (telemetryKeyToDisplay === undefined) { + if (valueMetadata === undefined) { var valuesOrderedByPriority = metadata.values(); - telemetryKeyToDisplay = valuesOrderedByPriority.filter(function (valueMetadata) { - return !(valueMetadata.hints.domain); + valueMetadata = valuesOrderedByPriority.filter(function (values) { + return !(values.hints.domain); })[0]; } - return telemetryKeyToDisplay.source; + return valueMetadata; }; /** diff --git a/platform/features/layout/test/FixedControllerSpec.js b/platform/features/layout/test/FixedControllerSpec.js index e63a193513..7e0c3ef21b 100644 --- a/platform/features/layout/test/FixedControllerSpec.js +++ b/platform/features/layout/test/FixedControllerSpec.js @@ -106,8 +106,8 @@ define( 'telemetryFormatter', ['format'] ); - mockFormatter.format.andCallFake(function (value) { - return "Formatted " + value; + mockFormatter.format.andCallFake(function (valueMetadata) { + return "Formatted " + valueMetadata.value; }); mockDomainObject = jasmine.createSpyObj( @@ -697,7 +697,7 @@ define( source: 'range' } ]); - var key = controller.chooseTelemetryKeyToDisplay(mockMetadata); + var key = controller.chooseValueMetadataToDisplay(mockMetadata).source; expect(key).toEqual('range'); }); @@ -719,7 +719,7 @@ define( } } ]); - var key = controller.chooseTelemetryKeyToDisplay(mockMetadata); + var key = controller.chooseValueMetadataToDisplay(mockMetadata).source; expect(key).toEqual('image'); });