mirror of
https://github.com/nasa/openmct.git
synced 2025-05-02 08:43:17 +00:00
[Code Style] Use prototypes in Scrolling List bundle
WTD-1482.
This commit is contained in:
parent
820c15d74c
commit
6302eee17e
@ -34,6 +34,7 @@ define(
|
||||
* (typically, timestamps.) Used by the ScrollingListController.
|
||||
*
|
||||
* @memberof platform/features/scrolling
|
||||
* @implements {platform/features/scrolling.ScrollingColumn}
|
||||
* @constructor
|
||||
* @param domainMetadata an object with the machine- and human-
|
||||
* readable names for this domain (in `key` and `name`
|
||||
@ -42,30 +43,21 @@ define(
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function DomainColumn(domainMetadata, telemetryFormatter) {
|
||||
this.domainMetadata = domainMetadata;
|
||||
this.telemetryFormatter = telemetryFormatter;
|
||||
}
|
||||
|
||||
DomainColumn.prototype.getTitle = function () {
|
||||
return this.domainMetadata.name;
|
||||
};
|
||||
|
||||
DomainColumn.prototype.getValue = function (domainObject, datum) {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
* @memberof platform/features/scrolling.DomainColumn#
|
||||
*/
|
||||
getTitle: function () {
|
||||
return domainMetadata.name;
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
* @memberof platform/features/scrolling.DomainColumn#
|
||||
*/
|
||||
getValue: function (domainObject, datum) {
|
||||
return {
|
||||
text: telemetryFormatter.formatDomainValue(
|
||||
datum[domainMetadata.key]
|
||||
text: this.telemetryFormatter.formatDomainValue(
|
||||
datum[this.domainMetadata.key]
|
||||
)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return DomainColumn;
|
||||
}
|
||||
|
@ -34,31 +34,21 @@ define(
|
||||
* which exposed specific telemetry values.
|
||||
*
|
||||
* @memberof platform/features/scrolling
|
||||
* @implements {platform/features/scrolling.ScrollingColumn}
|
||||
* @constructor
|
||||
*/
|
||||
function NameColumn() {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
* @memberof platform/features/scrolling.NameColumn#
|
||||
*/
|
||||
getTitle: function () {
|
||||
}
|
||||
|
||||
NameColumn.prototype.getTitle = function () {
|
||||
return "Name";
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column. This returns the domain object's name.
|
||||
* @returns {string} the text to display
|
||||
* @memberof platform/features/scrolling.NameColumn#
|
||||
*/
|
||||
getValue: function (domainObject) {
|
||||
};
|
||||
|
||||
NameColumn.prototype.getValue = function (domainObject) {
|
||||
return {
|
||||
text: domainObject.getModel().name
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return NameColumn;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ define(
|
||||
* (typically, measurements.) Used by the ScrollingListController.
|
||||
*
|
||||
* @memberof platform/features/scrolling
|
||||
* @implements {platform/features/scrolling.ScrollingColumn}
|
||||
* @constructor
|
||||
* @param rangeMetadata an object with the machine- and human-
|
||||
* readable names for this range (in `key` and `name`
|
||||
@ -42,34 +43,25 @@ define(
|
||||
* formatting service, for making values human-readable.
|
||||
*/
|
||||
function RangeColumn(rangeMetadata, telemetryFormatter) {
|
||||
return {
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
* @memberof platform/features/scrolling.RangeColumn#
|
||||
*/
|
||||
getTitle: function () {
|
||||
return rangeMetadata.name;
|
||||
},
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @returns {string} the text to display
|
||||
* @memberof platform/features/scrolling.RangeColumn#
|
||||
*/
|
||||
getValue: function (domainObject, datum) {
|
||||
var range = rangeMetadata.key,
|
||||
this.rangeMetadata = rangeMetadata;
|
||||
this.telemetryFormatter = telemetryFormatter;
|
||||
}
|
||||
|
||||
RangeColumn.prototype.getTitle = function () {
|
||||
return this.rangeMetadata.name;
|
||||
};
|
||||
|
||||
RangeColumn.prototype.getValue = function (domainObject, datum) {
|
||||
var range = this.rangeMetadata.key,
|
||||
limit = domainObject.getCapability('limit'),
|
||||
value = datum[range],
|
||||
alarm = limit.evaluate(datum, range);
|
||||
|
||||
return {
|
||||
cssClass: alarm && alarm.cssClass,
|
||||
text: telemetryFormatter.formatRangeValue(value)
|
||||
text: this.telemetryFormatter.formatRangeValue(value)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return RangeColumn;
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ define(
|
||||
* @constructor
|
||||
*/
|
||||
function ScrollingListController($scope, formatter) {
|
||||
var populator;
|
||||
|
||||
|
||||
// Get a set of populated, ready-to-display rows for the
|
||||
// latest data values.
|
||||
@ -129,6 +127,31 @@ define(
|
||||
$scope.$watch("telemetry.getMetadata()", setupColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
* A description of how to display a certain column of data in a
|
||||
* Scrolling List view.
|
||||
* @interface platform/features/scrolling.ScrollingColumn
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Get the title to display in this column's header.
|
||||
* @returns {string} the title to display
|
||||
* @method platform/features/scrolling.ScrollingColumn#getTitle
|
||||
*/
|
||||
/**
|
||||
* Get the text to display inside a row under this
|
||||
* column.
|
||||
* @param {DomainObject} domainObject the domain object associated
|
||||
* with this row
|
||||
* @param {TelemetrySeries} series the telemetry data associated
|
||||
* with this row
|
||||
* @param {number} index the index of the telemetry datum associated
|
||||
* with this row
|
||||
* @returns {string} the text to display
|
||||
* @method platform/features/scrolling.ScrollingColumn#getValue
|
||||
*/
|
||||
|
||||
|
||||
return ScrollingListController;
|
||||
}
|
||||
);
|
||||
|
@ -35,6 +35,9 @@ define(
|
||||
* @param {Column[]} columns the columns to be populated
|
||||
*/
|
||||
function ScrollingListPopulator(columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the most recent values from a set of data objects.
|
||||
* Returns an array of objects in the order in which data
|
||||
@ -51,7 +54,8 @@ define(
|
||||
* data objects; expected to be in the same order
|
||||
* as the domain objects provided at constructor
|
||||
* @param {number} count the number of rows to provide
|
||||
* @memberof platform/features/scrolling.ScrollingListPopulator#
|
||||
* @returns {Array} latest data values in display order
|
||||
* @private
|
||||
*/
|
||||
function getLatestDataValues(datas, count) {
|
||||
var latest = [],
|
||||
@ -113,6 +117,32 @@ define(
|
||||
return latest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text which should appear in headers for the
|
||||
* provided columns.
|
||||
* @returns {string[]} column headers
|
||||
*/
|
||||
ScrollingListPopulator.prototype.getHeaders = function () {
|
||||
return this.columns.map(function (column) {
|
||||
return column.getTitle();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the contents of rows for the scrolling list view.
|
||||
* @param {TelemetrySeries[]} datas the data sets
|
||||
* @param {DomainObject[]} objects the domain objects which
|
||||
* provided the data sets; these should match
|
||||
* index-to-index with the `datas` argument
|
||||
* @param {number} count the number of rows to populate
|
||||
* @returns {string[][]} an array of rows, each of which
|
||||
* is an array of values which should appear
|
||||
* in that row
|
||||
*/
|
||||
ScrollingListPopulator.prototype.getRows = function (datas, objects, count) {
|
||||
var values = getLatestDataValues(datas, count),
|
||||
self = this;
|
||||
|
||||
// From a telemetry series, retrieve a single data point
|
||||
// containing all fields for domains/ranges
|
||||
function makeDatum(domainObject, series, index) {
|
||||
@ -133,33 +163,6 @@ define(
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the text which should appear in headers for the
|
||||
* provided columns.
|
||||
* @returns {string[]} column headers
|
||||
* @memberof platform/features/scrolling.ScrollingListPopulator#
|
||||
*/
|
||||
getHeaders: function () {
|
||||
return columns.map(function (column) {
|
||||
return column.getTitle();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Get the contents of rows for the scrolling list view.
|
||||
* @param {TelemetrySeries[]} datas the data sets
|
||||
* @param {DomainObject[]} objects the domain objects which
|
||||
* provided the data sets; these should match
|
||||
* index-to-index with the `datas` argument
|
||||
* @param {number} count the number of rows to populate
|
||||
* @returns {string[][]} an array of rows, each of which
|
||||
* is an array of values which should appear
|
||||
* in that row
|
||||
* @memberof platform/features/scrolling.ScrollingListPopulator#
|
||||
*/
|
||||
getRows: function (datas, objects, count) {
|
||||
var values = getLatestDataValues(datas, count);
|
||||
|
||||
// Each value will become a row, which will contain
|
||||
// some value in each column (rendering by the
|
||||
// column object itself)
|
||||
@ -170,16 +173,14 @@ define(
|
||||
value.pointIndex
|
||||
);
|
||||
|
||||
return columns.map(function (column) {
|
||||
return self.columns.map(function (column) {
|
||||
return column.getValue(
|
||||
objects[value.objectIndex],
|
||||
datum
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return ScrollingListPopulator;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user