diff --git a/example/imagery/plugin.js b/example/imagery/plugin.js index 4c4f41d75b..9866514dbd 100644 --- a/example/imagery/plugin.js +++ b/example/imagery/plugin.js @@ -61,7 +61,7 @@ define([ values: [ { name: 'Time', - key: 'time', + key: 'utc', format: 'utc', hints: { domain: 1 @@ -71,7 +71,9 @@ define([ name: 'Image', key: 'url', format: 'image', - hints: {} + hints: { + image: 1 + } } ] } @@ -92,7 +94,7 @@ define([ index = 0; } callback({ - time: Date.now(), + utc: Date.now(), url: IMAGE_SAMPLES[index] }); index += 1; diff --git a/platform/features/imagery/bundle.js b/platform/features/imagery/bundle.js index 107de8ed6a..85aba508ff 100644 --- a/platform/features/imagery/bundle.js +++ b/platform/features/imagery/bundle.js @@ -53,7 +53,10 @@ define([ "policies": [ { "category": "view", - "implementation": ImageryViewPolicy + "implementation": ImageryViewPolicy, + "depends": [ + "openmct" + ] } ], "controllers": [ @@ -62,7 +65,7 @@ define([ "implementation": ImageryController, "depends": [ "$scope", - "telemetryHandler" + "openmct" ] } ], diff --git a/platform/features/imagery/res/templates/imagery.html b/platform/features/imagery/res/templates/imagery.html index 542ef66e56..1b2b1c3e53 100644 --- a/platform/features/imagery/res/templates/imagery.html +++ b/platform/features/imagery/res/templates/imagery.html @@ -34,10 +34,8 @@
- {{imagery.getZone()}} + ng-click="showThumbsBubble = (showThumbsBubble) ? false:true"> {{imagery.getTime()}} - {{imagery.getDate()}}
0 && state !== this.isPaused) { this.isPaused = state; - // Switch to latest image - this.updateValues(); + this.updateValues(this.nextValue); + delete this.nextValue; } return this.isPaused; }; diff --git a/platform/features/imagery/src/policies/ImageryViewPolicy.js b/platform/features/imagery/src/policies/ImageryViewPolicy.js index ecc1505f36..75e43a0015 100644 --- a/platform/features/imagery/src/policies/ImageryViewPolicy.js +++ b/platform/features/imagery/src/policies/ImageryViewPolicy.js @@ -20,8 +20,11 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define( - function () { +define([ + '../../../../../src/api/objects/object-utils' +], function ( + objectUtils +) { /** * Policy preventing the Imagery view from being made available for @@ -29,24 +32,24 @@ define( * @implements {Policy.} * @constructor */ - function ImageryViewPolicy() { + function ImageryViewPolicy(openmct) { + this.openmct = openmct; } - function hasImageTelemetry(domainObject) { - var telemetry = domainObject && - domainObject.getCapability('telemetry'), - metadata = telemetry ? telemetry.getMetadata() : {}, - ranges = metadata.ranges || []; + ImageryViewPolicy.prototype.hasImageTelemetry = function (domainObject) { + var newDO = objectUtils.toNewFormat( + domainObject.getModel(), + domainObject.getId() + ); - return ranges.some(function (range) { - return range.format === 'imageUrl' || - range.format === 'image'; - }); - } + var metadata = this.openmct.telemetry.getMetadata(newDO); + var values = metadata.valuesForHints(['image']); + return values.length >= 1; + }; ImageryViewPolicy.prototype.allow = function (view, domainObject) { if (view.key === 'imagery') { - return hasImageTelemetry(domainObject); + return this.hasImageTelemetry(domainObject); } return true; diff --git a/platform/features/imagery/test/controllers/ImageryControllerSpec.js b/platform/features/imagery/test/controllers/ImageryControllerSpec.js index 3d3c3c00b1..d81becec51 100644 --- a/platform/features/imagery/test/controllers/ImageryControllerSpec.js +++ b/platform/features/imagery/test/controllers/ImageryControllerSpec.js @@ -25,48 +25,45 @@ define( function (ImageryController) { describe("The Imagery controller", function () { - var mockScope, - mockTelemetryHandler, - mockHandle, - mockDomainObject, + var $scope, + openmct, + oldDomainObject, + newDomainObject, + unsubscribe, + callback, controller; - function invokeWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { - if (call.args[0] === expr) { - call.args[1](value); - } - }); - } - beforeEach(function () { - mockScope = jasmine.createSpyObj('$scope', ['$on', '$watch']); - mockTelemetryHandler = jasmine.createSpyObj( - 'telemetryHandler', - ['handle'] - ); - mockHandle = jasmine.createSpyObj( - 'handle', - [ - 'getDomainValue', - 'getRangeValue', - 'getTelemetryObjects', - 'unsubscribe' - ] - ); - mockDomainObject = jasmine.createSpyObj( + $scope = jasmine.createSpyObj('$scope', ['$on', '$watch']); + oldDomainObject = jasmine.createSpyObj( 'domainObject', - ['getId', 'getModel', 'getCapability'] + ['getId'] ); - mockTelemetryHandler.handle.andReturn(mockHandle); - mockHandle.getTelemetryObjects.andReturn([mockDomainObject]); + oldDomainObject.getId.andReturn('testID'); + openmct = { + objects: jasmine.createSpyObj('objectAPI', [ + 'get' + ]), + time: jasmine.createSpyObj('timeAPI', [ + 'timeSystem' + ]), + telemetry: jasmine.createSpyObj('telemetryAPI', [ + 'subscribe' + ]); + }; + unsubscribe = jasmine.createSpy('unsubscribe'); + openmct.telemetry.subscribe.andReturn(unsubcribe); + openmct.time.timeSystem.andReturn({ + key: 'testKey' + }); + openmct.objects.get.andReturn(Promise.resolve(newDomainObject)); controller = new ImageryController( - mockScope, - mockTelemetryHandler + $scope, + openmct ); - invokeWatch('domainObject', mockDomainObject); + }); it("unsubscribes when scope is destroyed", function () {