mirror of
https://github.com/nasa/openmct.git
synced 2025-01-20 11:38:56 +00:00
[Code Style] Use prototypes in Imagery bundle
WTD-1482
This commit is contained in:
parent
d701567b70
commit
a9e2d48036
@ -40,40 +40,29 @@ define(
|
|||||||
* @memberof platform/features/imagery
|
* @memberof platform/features/imagery
|
||||||
*/
|
*/
|
||||||
function ImageryController($scope, telemetryHandler) {
|
function ImageryController($scope, telemetryHandler) {
|
||||||
var date = "",
|
var self = this;
|
||||||
time = "",
|
|
||||||
imageUrl = "",
|
|
||||||
paused = false,
|
|
||||||
handle;
|
|
||||||
|
|
||||||
function releaseSubscription() {
|
function releaseSubscription() {
|
||||||
if (handle) {
|
if (self.handle) {
|
||||||
handle.unsubscribe();
|
self.handle.unsubscribe();
|
||||||
handle = undefined;
|
self.handle = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateValues() {
|
function updateValuesCallback() {
|
||||||
var imageObject = handle && handle.getTelemetryObjects()[0],
|
return self.updateValues();
|
||||||
m;
|
|
||||||
if (imageObject && !paused) {
|
|
||||||
m = moment.utc(handle.getDomainValue(imageObject));
|
|
||||||
date = m.format(DATE_FORMAT);
|
|
||||||
time = m.format(TIME_FORMAT);
|
|
||||||
imageUrl = handle.getRangeValue(imageObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new subscription; telemetrySubscriber gets
|
// Create a new subscription; telemetrySubscriber gets
|
||||||
// to do the meaningful work here.
|
// to do the meaningful work here.
|
||||||
function subscribe(domainObject) {
|
function subscribe(domainObject) {
|
||||||
releaseSubscription();
|
releaseSubscription();
|
||||||
date = "";
|
self.date = "";
|
||||||
time = "";
|
self.time = "";
|
||||||
imageUrl = "";
|
self.imageUrl = "";
|
||||||
handle = domainObject && telemetryHandler.handle(
|
self.handle = domainObject && telemetryHandler.handle(
|
||||||
domainObject,
|
domainObject,
|
||||||
updateValues,
|
updateValuesCallback,
|
||||||
true // Lossless
|
true // Lossless
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -83,62 +72,72 @@ define(
|
|||||||
|
|
||||||
// Unsubscribe when the plot is destroyed
|
// Unsubscribe when the plot is destroyed
|
||||||
$scope.$on("$destroy", releaseSubscription);
|
$scope.$on("$destroy", releaseSubscription);
|
||||||
|
|
||||||
return {
|
|
||||||
/**
|
|
||||||
* Get the time portion (hours, minutes, seconds) of the
|
|
||||||
* timestamp associated with the incoming image telemetry.
|
|
||||||
* @returns {string} the time
|
|
||||||
* @memberof platform/features/imagery.ImageryController#
|
|
||||||
*/
|
|
||||||
getTime: function () {
|
|
||||||
return time;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Get the date portion (month, year) of the
|
|
||||||
* timestamp associated with the incoming image telemetry.
|
|
||||||
* @returns {string} the date
|
|
||||||
* @memberof platform/features/imagery.ImageryController#
|
|
||||||
*/
|
|
||||||
getDate: function () {
|
|
||||||
return date;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Get the time zone for the displayed time/date corresponding
|
|
||||||
* to the timestamp associated with the incoming image
|
|
||||||
* telemetry.
|
|
||||||
* @returns {string} the time
|
|
||||||
* @memberof platform/features/imagery.ImageryController#
|
|
||||||
*/
|
|
||||||
getZone: function () {
|
|
||||||
return "UTC";
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Get the URL of the image telemetry to display.
|
|
||||||
* @returns {string} URL for telemetry image
|
|
||||||
* @memberof platform/features/imagery.ImageryController#
|
|
||||||
*/
|
|
||||||
getImageUrl: function () {
|
|
||||||
return imageUrl;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Getter-setter for paused state of the view (true means
|
|
||||||
* paused, false means not.)
|
|
||||||
* @param {boolean} [state] the state to set
|
|
||||||
* @returns {boolean} the current state
|
|
||||||
* @memberof platform/features/imagery.ImageryController#
|
|
||||||
*/
|
|
||||||
paused: function (state) {
|
|
||||||
if (arguments.length > 0 && state !== paused) {
|
|
||||||
paused = state;
|
|
||||||
// Switch to latest image
|
|
||||||
updateValues();
|
|
||||||
}
|
|
||||||
return paused;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update displayable values to reflect latest image telemetry
|
||||||
|
ImageryController.prototype.updateValues = function () {
|
||||||
|
var imageObject =
|
||||||
|
this.handle && this.handle.getTelemetryObjects()[0],
|
||||||
|
m;
|
||||||
|
if (imageObject && !this.isPaused) {
|
||||||
|
m = moment.utc(this.handle.getDomainValue(imageObject));
|
||||||
|
this.date = m.format(DATE_FORMAT);
|
||||||
|
this.time = m.format(TIME_FORMAT);
|
||||||
|
this.imageUrl = this.handle.getRangeValue(imageObject);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time portion (hours, minutes, seconds) of the
|
||||||
|
* timestamp associated with the incoming image telemetry.
|
||||||
|
* @returns {string} the time
|
||||||
|
*/
|
||||||
|
ImageryController.prototype.getTime = function () {
|
||||||
|
return this.time;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the date portion (month, year) of the
|
||||||
|
* timestamp associated with the incoming image telemetry.
|
||||||
|
* @returns {string} the date
|
||||||
|
*/
|
||||||
|
ImageryController.prototype.getDate = function () {
|
||||||
|
return this.date;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time zone for the displayed time/date corresponding
|
||||||
|
* to the timestamp associated with the incoming image
|
||||||
|
* telemetry.
|
||||||
|
* @returns {string} the time
|
||||||
|
*/
|
||||||
|
ImageryController.prototype.getZone = function () {
|
||||||
|
return "UTC";
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL of the image telemetry to display.
|
||||||
|
* @returns {string} URL for telemetry image
|
||||||
|
*/
|
||||||
|
ImageryController.prototype.getImageUrl = function () {
|
||||||
|
return this.imageUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter-setter for paused state of the view (true means
|
||||||
|
* paused, false means not.)
|
||||||
|
* @param {boolean} [state] the state to set
|
||||||
|
* @returns {boolean} the current state
|
||||||
|
*/
|
||||||
|
ImageryController.prototype.paused = function (state) {
|
||||||
|
if (arguments.length > 0 && state !== this.isPaused) {
|
||||||
|
this.isPaused = state;
|
||||||
|
// Switch to latest image
|
||||||
|
this.updateValues();
|
||||||
|
}
|
||||||
|
return this.isPaused;
|
||||||
|
};
|
||||||
|
|
||||||
return ImageryController;
|
return ImageryController;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -28,33 +28,31 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Policy preventing the Imagery view from being made available for
|
* Policy preventing the Imagery view from being made available for
|
||||||
* domain objects which do not have associated image telemetry.
|
* domain objects which do not have associated image telemetry.
|
||||||
* @implements {Policy}
|
* @implements {Policy.<View, DomainObject>}
|
||||||
* @constructor
|
* @constructor
|
||||||
* @memberof platform/features/imagery
|
|
||||||
*/
|
*/
|
||||||
function ImageryViewPolicy() {
|
function ImageryViewPolicy() {
|
||||||
function hasImageTelemetry(domainObject) {
|
}
|
||||||
var telemetry = domainObject &&
|
|
||||||
domainObject.getCapability('telemetry'),
|
|
||||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
|
||||||
ranges = metadata.ranges || [];
|
|
||||||
|
|
||||||
return ranges.some(function (range) {
|
function hasImageTelemetry(domainObject) {
|
||||||
return range.format === 'imageUrl' ||
|
var telemetry = domainObject &&
|
||||||
range.format === 'image';
|
domainObject.getCapability('telemetry'),
|
||||||
});
|
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||||
|
ranges = metadata.ranges || [];
|
||||||
|
|
||||||
|
return ranges.some(function (range) {
|
||||||
|
return range.format === 'imageUrl' ||
|
||||||
|
range.format === 'image';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageryViewPolicy.prototype.allow = function (view, domainObject) {
|
||||||
|
if (view.key === 'imagery') {
|
||||||
|
return hasImageTelemetry(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return true;
|
||||||
allow: function (view, domainObject) {
|
};
|
||||||
if (view.key === 'imagery') {
|
|
||||||
return hasImageTelemetry(domainObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImageryViewPolicy;
|
return ImageryViewPolicy;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user