mirror of
https://github.com/nasa/openmct.git
synced 2025-05-03 01:02:52 +00:00
[Code Style] Use prototypes for Events bundle
WTD-1482
This commit is contained in:
parent
7911909c5f
commit
d701567b70
@ -35,6 +35,7 @@ define(
|
|||||||
*
|
*
|
||||||
* @memberof platform/features/events
|
* @memberof platform/features/events
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @implements {platform/features/events.EventsColumn}
|
||||||
* @param domainMetadata an object with the machine- and human-
|
* @param domainMetadata an object with the machine- and human-
|
||||||
* readable names for this domain (in `key` and `name`
|
* readable names for this domain (in `key` and `name`
|
||||||
* fields, respectively.)
|
* fields, respectively.)
|
||||||
@ -42,28 +43,20 @@ define(
|
|||||||
* formatting service, for making values human-readable.
|
* formatting service, for making values human-readable.
|
||||||
*/
|
*/
|
||||||
function DomainColumn(domainMetadata, telemetryFormatter) {
|
function DomainColumn(domainMetadata, telemetryFormatter) {
|
||||||
return {
|
this.domainMetadata = domainMetadata;
|
||||||
/**
|
this.telemetryFormatter = telemetryFormatter;
|
||||||
* Get the title to display in this column's header.
|
|
||||||
* @returns {string} the title to display
|
|
||||||
* @memberof platform/features/events.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/events.DomainColumn#
|
|
||||||
*/
|
|
||||||
getValue: function (domainObject, data, index) {
|
|
||||||
return telemetryFormatter.formatDomainValue(
|
|
||||||
data.getDomainValue(index, domainMetadata.key)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DomainColumn.prototype.getTitle = function () {
|
||||||
|
return this.domainMetadata.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
DomainColumn.prototype.getValue = function (domainObject, data, index) {
|
||||||
|
var domainKey = this.domainMetadata.key;
|
||||||
|
return this.telemetryFormatter.formatDomainValue(
|
||||||
|
data.getDomainValue(index, domainKey)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return DomainColumn;
|
return DomainColumn;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,30 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return EventListController;
|
return EventListController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A description of how to display a certain column of data in an
|
||||||
|
* Events view.
|
||||||
|
* @interface platform/features/events.EventColumn
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get the title to display in this column's header.
|
||||||
|
* @returns {string} the title to display
|
||||||
|
* @method platform/features/events.EventColumn#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/events.EventColumn#getValue
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@ define(
|
|||||||
* @param {Column[]} columns the columns to be populated
|
* @param {Column[]} columns the columns to be populated
|
||||||
*/
|
*/
|
||||||
function EventListPopulator(columns) {
|
function EventListPopulator(columns) {
|
||||||
|
this.columns = columns;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up the most recent values from a set of data objects.
|
* Look up the most recent values from a set of data objects.
|
||||||
* Returns an array of objects in the order in which data
|
* Returns an array of objects in the order in which data
|
||||||
@ -112,19 +115,18 @@ define(
|
|||||||
return latest;
|
return latest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
/**
|
/**
|
||||||
* Get the text which should appear in headers for the
|
* Get the text which should appear in headers for the
|
||||||
* provided columns.
|
* provided columns.
|
||||||
* @memberof platform/features/events.EventListPopulator
|
* @memberof platform/features/events.EventListPopulator
|
||||||
* @returns {string[]} column headers
|
* @returns {string[]} column headers
|
||||||
*/
|
*/
|
||||||
getHeaders: function () {
|
EventListPopulator.prototype.getHeaders = function () {
|
||||||
return columns.map(function (column) {
|
return this.columns.map(function (column) {
|
||||||
return column.getTitle();
|
return column.getTitle();
|
||||||
});
|
});
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the contents of rows for the event list view.
|
* Get the contents of rows for the event list view.
|
||||||
* @param {TelemetrySeries[]} datas the data sets
|
* @param {TelemetrySeries[]} datas the data sets
|
||||||
@ -137,8 +139,9 @@ define(
|
|||||||
* is an array of values which should appear
|
* is an array of values which should appear
|
||||||
* in that row
|
* in that row
|
||||||
*/
|
*/
|
||||||
getRows: function (datas, objects, count) {
|
EventListPopulator.prototype.getRows = function (datas, objects, count) {
|
||||||
var values = getLatestDataValues(datas, count);
|
var values = getLatestDataValues(datas, count),
|
||||||
|
columns = this.columns;
|
||||||
|
|
||||||
// Each value will become a row, which will contain
|
// Each value will become a row, which will contain
|
||||||
// some value in each column (rendering by the
|
// some value in each column (rendering by the
|
||||||
@ -154,9 +157,7 @@ define(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}).reverse();
|
}).reverse();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return EventListPopulator;
|
return EventListPopulator;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ define(
|
|||||||
*
|
*
|
||||||
* @memberof platform/features/events
|
* @memberof platform/features/events
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @implements {platform/features/events.EventsColumn}
|
||||||
* @param rangeMetadata an object with the machine- and human-
|
* @param rangeMetadata an object with the machine- and human-
|
||||||
* readable names for this range (in `key` and `name`
|
* readable names for this range (in `key` and `name`
|
||||||
* fields, respectively.)
|
* fields, respectively.)
|
||||||
@ -42,28 +43,19 @@ define(
|
|||||||
* formatting service, for making values human-readable.
|
* formatting service, for making values human-readable.
|
||||||
*/
|
*/
|
||||||
function RangeColumn(rangeMetadata, telemetryFormatter) {
|
function RangeColumn(rangeMetadata, telemetryFormatter) {
|
||||||
return {
|
this.rangeMetadata = rangeMetadata;
|
||||||
/**
|
this.telemetryFormatter = telemetryFormatter;
|
||||||
* Get the title to display in this column's header.
|
|
||||||
* @returns {string} the title to display
|
|
||||||
* @memberof platform/features/events.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/events.RangeColumn#
|
|
||||||
*/
|
|
||||||
getValue: function (domainObject, data, index) {
|
|
||||||
return telemetryFormatter.formatRangeValue(
|
|
||||||
data.getRangeValue(index, rangeMetadata.key)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RangeColumn.prototype.getTitle = function () {
|
||||||
|
return this.rangeMetadata.name;
|
||||||
|
};
|
||||||
|
RangeColumn.prototype.getValue = function (domainObject, data, index) {
|
||||||
|
var rangeKey = this.rangeMetadata.key;
|
||||||
|
return this.telemetryFormatter.formatRangeValue(
|
||||||
|
data.getRangeValue(index, rangeKey)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return RangeColumn;
|
return RangeColumn;
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,9 @@ define(
|
|||||||
* Policy controlling when the Messages view should be avaliable.
|
* Policy controlling when the Messages view should be avaliable.
|
||||||
* @memberof platform/features/events
|
* @memberof platform/features/events
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @implements {Policy.<View, DomainObject>}
|
||||||
*/
|
*/
|
||||||
function MessagesViewPolicy() {
|
function MessagesViewPolicy() {}
|
||||||
|
|
||||||
function hasStringTelemetry(domainObject) {
|
function hasStringTelemetry(domainObject) {
|
||||||
var telemetry = domainObject &&
|
var telemetry = domainObject &&
|
||||||
@ -46,16 +47,8 @@ define(
|
|||||||
return range.format === 'string';
|
return range.format === 'string';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
/**
|
MessagesViewPolicy.prototype.allow = function (view, domainObject) {
|
||||||
* Check whether or not a given action is allowed by this
|
|
||||||
* policy.
|
|
||||||
* @param {Action} action the action
|
|
||||||
* @param domainObject the domain object which will be viewed
|
|
||||||
* @returns {boolean} true if not disallowed
|
|
||||||
* @memberof platform/features/events.MessagesViewPolicy#
|
|
||||||
*/
|
|
||||||
allow: function (view, domainObject) {
|
|
||||||
// This policy only applies for the Messages view
|
// This policy only applies for the Messages view
|
||||||
if (view.key === 'messages') {
|
if (view.key === 'messages') {
|
||||||
// The Messages view is allowed only if the domain
|
// The Messages view is allowed only if the domain
|
||||||
@ -67,9 +60,7 @@ define(
|
|||||||
|
|
||||||
// Like all policies, allow by default.
|
// Like all policies, allow by default.
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return MessagesViewPolicy;
|
return MessagesViewPolicy;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user