mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 04:14:32 +00:00
[Tables] #733 Made code style changes for conformance with style guide
This commit is contained in:
parent
c5de90a951
commit
fc08df4f6f
@ -47,7 +47,7 @@ define(
|
||||
* @param metadata Metadata describing the domains and ranges available
|
||||
* @returns {TableConfiguration} This object
|
||||
*/
|
||||
TableConfiguration.prototype.buildColumns = function(metadata) {
|
||||
TableConfiguration.prototype.buildColumns = function (metadata) {
|
||||
var self = this;
|
||||
|
||||
this.columns = [];
|
||||
@ -57,10 +57,12 @@ define(
|
||||
metadata.forEach(function (metadatum) {
|
||||
//Push domains first
|
||||
(metadatum.domains || []).forEach(function (domainMetadata) {
|
||||
self.addColumn(new DomainColumn(domainMetadata, self.telemetryFormatter));
|
||||
self.addColumn(new DomainColumn(domainMetadata,
|
||||
self.telemetryFormatter));
|
||||
});
|
||||
(metadatum.ranges || []).forEach(function (rangeMetadata) {
|
||||
self.addColumn(new RangeColumn(rangeMetadata, self.telemetryFormatter));
|
||||
self.addColumn(new RangeColumn(rangeMetadata,
|
||||
self.telemetryFormatter));
|
||||
});
|
||||
});
|
||||
|
||||
@ -98,7 +100,7 @@ define(
|
||||
* Get a simple list of column titles
|
||||
* @returns {Array} The titles of the columns
|
||||
*/
|
||||
TableConfiguration.prototype.getHeaders = function() {
|
||||
TableConfiguration.prototype.getHeaders = function () {
|
||||
var self = this;
|
||||
return this.columns.map(function (column, i){
|
||||
return self.getColumnTitle(column) || 'Column ' + (i + 1);
|
||||
@ -113,9 +115,9 @@ define(
|
||||
* @returns {Object} Key value pairs where the key is the column
|
||||
* title, and the value is the formatted value from the provided datum.
|
||||
*/
|
||||
TableConfiguration.prototype.getRowValues = function(telemetryObject, datum) {
|
||||
TableConfiguration.prototype.getRowValues = function (telemetryObject, datum) {
|
||||
var self = this;
|
||||
return this.columns.reduce(function(rowObject, column, i){
|
||||
return this.columns.reduce(function (rowObject, column, i){
|
||||
var columnTitle = self.getColumnTitle(column) || 'Column ' + (i + 1),
|
||||
columnValue = column.getValue(telemetryObject, datum);
|
||||
|
||||
@ -125,7 +127,9 @@ define(
|
||||
// Don't replace something with nothing.
|
||||
// This occurs when there are multiple columns with the
|
||||
// column title
|
||||
if (rowObject[columnTitle] === undefined || rowObject[columnTitle].text === undefined || rowObject[columnTitle].text.length === 0) {
|
||||
if (rowObject[columnTitle] === undefined ||
|
||||
rowObject[columnTitle].text === undefined ||
|
||||
rowObject[columnTitle].text.length === 0) {
|
||||
rowObject[columnTitle] = columnValue;
|
||||
}
|
||||
return rowObject;
|
||||
@ -136,7 +140,8 @@ define(
|
||||
* @private
|
||||
*/
|
||||
TableConfiguration.prototype.defaultColumnConfiguration = function () {
|
||||
return ((this.domainObject.getModel().configuration || {}).table || {}).columns || {};
|
||||
return ((this.domainObject.getModel().configuration || {}).table ||
|
||||
{}).columns || {};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -158,7 +163,7 @@ define(
|
||||
* pairs where the key is the column title, and the value is a
|
||||
* boolean indicating whether the column should be shown.
|
||||
*/
|
||||
TableConfiguration.prototype.getColumnConfiguration = function() {
|
||||
TableConfiguration.prototype.getColumnConfiguration = function () {
|
||||
var configuration = {},
|
||||
//Use existing persisted config, or default it
|
||||
defaultConfig = this.defaultColumnConfiguration();
|
||||
@ -168,8 +173,10 @@ define(
|
||||
* specifying whether the column is visible or not. Default to
|
||||
* existing (persisted) configuration if available
|
||||
*/
|
||||
this.getHeaders().forEach(function(columnTitle) {
|
||||
configuration[columnTitle] = typeof defaultConfig[columnTitle] === 'undefined' ? true : defaultConfig[columnTitle];
|
||||
this.getHeaders().forEach(function (columnTitle) {
|
||||
configuration[columnTitle] =
|
||||
typeof defaultConfig[columnTitle] === 'undefined' ? true :
|
||||
defaultConfig[columnTitle];
|
||||
});
|
||||
|
||||
return configuration;
|
||||
|
@ -81,13 +81,13 @@ define(
|
||||
* bottom of the page
|
||||
* @private
|
||||
*/
|
||||
MCTTableController.prototype.scrollToBottom = function() {
|
||||
MCTTableController.prototype.scrollToBottom = function () {
|
||||
var self = this;
|
||||
|
||||
//Use timeout to defer execution until next digest when any
|
||||
// pending UI changes have completed, eg. a new row in the table.
|
||||
if (this.$scope.autoScroll) {
|
||||
this.$timeout(function(){
|
||||
this.$timeout(function (){
|
||||
self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight;
|
||||
});
|
||||
}
|
||||
@ -115,8 +115,9 @@ define(
|
||||
MCTTableController.prototype.onScroll = function (event) {
|
||||
//If user scrolls away from bottom, disable auto-scroll.
|
||||
// Auto-scroll will be re-enabled if user scrolls to bottom again.
|
||||
if (this.scrollable[0].scrollTop < (this.scrollable[0].scrollHeight - this.scrollable[0].offsetHeight)) {
|
||||
this.$scope.autoScroll = false;
|
||||
if (this.scrollable[0].scrollTop <
|
||||
(this.scrollable[0].scrollHeight - this.scrollable[0].offsetHeight)) {
|
||||
this.$scope.autoScroll = false;
|
||||
} else {
|
||||
this.$scope.autoScroll = true;
|
||||
}
|
||||
@ -144,7 +145,8 @@ define(
|
||||
if (this.$scope.displayRows.length < this.maxDisplayRows) {
|
||||
//Check whether need to resynchronize visible with display
|
||||
// rows (if data added)
|
||||
if (this.$scope.visibleRows.length != this.$scope.displayRows.length){
|
||||
if (this.$scope.visibleRows.length !=
|
||||
this.$scope.displayRows.length){
|
||||
start = 0;
|
||||
end = this.$scope.displayRows.length;
|
||||
} else {
|
||||
@ -159,11 +161,13 @@ define(
|
||||
firstVisible = 0;
|
||||
} else {
|
||||
firstVisible = Math.floor(
|
||||
(topScroll - this.$scope.headerHeight) / this.$scope.rowHeight
|
||||
(topScroll - this.$scope.headerHeight) /
|
||||
this.$scope.rowHeight
|
||||
);
|
||||
}
|
||||
lastVisible = Math.ceil(
|
||||
(bottomScroll - this.$scope.headerHeight) / this.$scope.rowHeight
|
||||
(bottomScroll - this.$scope.headerHeight) /
|
||||
this.$scope.rowHeight
|
||||
);
|
||||
|
||||
totalVisible = lastVisible - firstVisible;
|
||||
@ -173,12 +177,14 @@ define(
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
end = Math.min(this.maxDisplayRows, this.$scope.displayRows.length);
|
||||
end = Math.min(this.maxDisplayRows,
|
||||
this.$scope.displayRows.length);
|
||||
} else if (end >= this.$scope.displayRows.length) {
|
||||
end = this.$scope.displayRows.length;
|
||||
start = end - this.maxDisplayRows + 1;
|
||||
}
|
||||
if (this.$scope.visibleRows[0] && this.$scope.visibleRows[0].rowIndex === start &&
|
||||
if (this.$scope.visibleRows[0] &&
|
||||
this.$scope.visibleRows[0].rowIndex === start &&
|
||||
this.$scope.visibleRows[this.$scope.visibleRows.length - 1]
|
||||
.rowIndex === end) {
|
||||
|
||||
@ -187,7 +193,7 @@ define(
|
||||
}
|
||||
//Set visible rows from display rows, based on calculated offset.
|
||||
this.$scope.visibleRows = this.$scope.displayRows.slice(start, end)
|
||||
.map(function(row, i) {
|
||||
.map(function (row, i) {
|
||||
return {
|
||||
rowIndex: start + i,
|
||||
offsetY: ((start + i) * self.$scope.rowHeight) +
|
||||
@ -213,9 +219,10 @@ define(
|
||||
}
|
||||
// Reset column sort information unless the new headers
|
||||
// contain the column currently sorted on.
|
||||
if (this.$scope.enableSort && newHeaders.indexOf(this.$scope.sortColumn) === -1) {
|
||||
this.$scope.sortColumn = undefined;
|
||||
this.$scope.sortDirection = undefined;
|
||||
if (this.$scope.enableSort &&
|
||||
newHeaders.indexOf(this.$scope.sortColumn) === -1) {
|
||||
this.$scope.sortColumn = undefined;
|
||||
this.$scope.sortDirection = undefined;
|
||||
}
|
||||
this.updateRows(this.$scope.rows);
|
||||
};
|
||||
@ -234,7 +241,8 @@ define(
|
||||
rowHeight = 20,
|
||||
columnWidth,
|
||||
tableWidth = 0,
|
||||
overallHeight = headerHeight + (rowHeight * (this.$scope.displayRows ? this.$scope.displayRows.length - 1 : 0));
|
||||
overallHeight = headerHeight + (rowHeight *
|
||||
(this.$scope.displayRows ? this.$scope.displayRows.length - 1 : 0));
|
||||
|
||||
this.$scope.columnWidths = [];
|
||||
|
||||
@ -248,18 +256,20 @@ define(
|
||||
this.$scope.rowHeight = rowHeight;
|
||||
this.$scope.totalHeight = overallHeight;
|
||||
this.setVisibleRows();
|
||||
this.$scope.overrideRowPositioning = true;
|
||||
|
||||
if (tableWidth > 0) {
|
||||
this.$scope.totalWidth = tableWidth + 'px';
|
||||
} else {
|
||||
this.$scope.totalWidth = 'none';
|
||||
}
|
||||
|
||||
this.$scope.overrideRowPositioning = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
MCTTableController.prototype.insertSorted = function(array, element) {
|
||||
MCTTableController.prototype.insertSorted = function (array, element) {
|
||||
var index = -1,
|
||||
self = this,
|
||||
sortKey = this.$scope.sortColumn;
|
||||
@ -272,16 +282,22 @@ define(
|
||||
return min; // Element is not in array, min gives direction
|
||||
}
|
||||
|
||||
valA = isNaN(searchElement[sortKey].text) ? searchElement[sortKey].text : parseFloat(searchElement[sortKey].text);
|
||||
valB = isNaN(searchArray[sampleAt][sortKey].text) ? searchArray[sampleAt][sortKey].text : searchArray[sampleAt][sortKey].text;
|
||||
valA = isNaN(searchElement[sortKey].text) ?
|
||||
searchElement[sortKey].text :
|
||||
parseFloat(searchElement[sortKey].text);
|
||||
valB = isNaN(searchArray[sampleAt][sortKey].text) ?
|
||||
searchArray[sampleAt][sortKey].text :
|
||||
searchArray[sampleAt][sortKey].text;
|
||||
|
||||
switch(self.sortComparator(valA, valB)) {
|
||||
case -1:
|
||||
return binarySearch(searchArray, searchElement, min, sampleAt - 1);
|
||||
return binarySearch(searchArray, searchElement, min,
|
||||
sampleAt - 1);
|
||||
case 0 :
|
||||
return sampleAt;
|
||||
case 1 :
|
||||
return binarySearch(searchArray, searchElement, sampleAt + 1, max);
|
||||
return binarySearch(searchArray, searchElement,
|
||||
sampleAt + 1, max);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +325,7 @@ define(
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
MCTTableController.prototype.sortComparator = function(a, b) {
|
||||
MCTTableController.prototype.sortComparator = function (a, b) {
|
||||
var result = 0,
|
||||
sortDirectionMultiplier;
|
||||
|
||||
@ -340,7 +356,7 @@ define(
|
||||
*
|
||||
* Does not modify the array that was passed in.
|
||||
*/
|
||||
MCTTableController.prototype.sortRows = function(rowsToSort) {
|
||||
MCTTableController.prototype.sortRows = function (rowsToSort) {
|
||||
var self = this,
|
||||
sortKey = this.$scope.sortColumn;
|
||||
|
||||
@ -348,12 +364,14 @@ define(
|
||||
return rowsToSort;
|
||||
}
|
||||
|
||||
return rowsToSort.sort(function(a, b) {
|
||||
return rowsToSort.sort(function (a, b) {
|
||||
//If the values to compare can be compared as
|
||||
// numbers, do so. String comparison of number
|
||||
// values can cause inconsistencies
|
||||
var valA = isNaN(a[sortKey].text) ? a[sortKey].text : parseFloat(a[sortKey].text),
|
||||
valB = isNaN(b[sortKey].text) ? b[sortKey].text : parseFloat(b[sortKey].text);
|
||||
var valA = isNaN(a[sortKey].text) ? a[sortKey].text :
|
||||
parseFloat(a[sortKey].text),
|
||||
valB = isNaN(b[sortKey].text) ? b[sortKey].text :
|
||||
parseFloat(b[sortKey].text);
|
||||
|
||||
return self.sortComparator(valA, valB);
|
||||
});
|
||||
@ -365,7 +383,7 @@ define(
|
||||
* pre-calculate optimal column sizes without having to render
|
||||
* every row.
|
||||
*/
|
||||
MCTTableController.prototype.findLargestRow = function(rows) {
|
||||
MCTTableController.prototype.findLargestRow = function (rows) {
|
||||
var largestRow = rows.reduce(function (largestRow, row) {
|
||||
Object.keys(row).forEach(function (key) {
|
||||
var currentColumn = row[key].text,
|
||||
@ -390,7 +408,7 @@ define(
|
||||
|
||||
// Pad with characters to accomodate variable-width fonts,
|
||||
// and remove characters that would allow word-wrapping.
|
||||
Object.keys(largestRow).forEach(function(key) {
|
||||
Object.keys(largestRow).forEach(function (key) {
|
||||
var padCharacters,
|
||||
i;
|
||||
|
||||
@ -424,7 +442,7 @@ define(
|
||||
|
||||
//Wait a timeout to allow digest of previous change to visible
|
||||
// rows to happen.
|
||||
this.$timeout(function() {
|
||||
this.$timeout(function () {
|
||||
//Remove temporary padding row used for setting column widths
|
||||
self.$scope.visibleRows = [];
|
||||
self.setElementSizes();
|
||||
@ -434,7 +452,7 @@ define(
|
||||
/**
|
||||
* @priate
|
||||
*/
|
||||
MCTTableController.prototype.filterAndSort = function(rows) {
|
||||
MCTTableController.prototype.filterAndSort = function (rows) {
|
||||
var displayRows = rows;
|
||||
if (this.$scope.enableFilter) {
|
||||
displayRows = this.filterRows(displayRows);
|
||||
@ -471,7 +489,7 @@ define(
|
||||
* @param rowsToFilter {Object[]} The rows to apply filters to
|
||||
* @returns {Object[]} A filtered copy of the supplied rows
|
||||
*/
|
||||
MCTTableController.prototype.filterRows = function(rowsToFilter) {
|
||||
MCTTableController.prototype.filterRows = function (rowsToFilter) {
|
||||
var filters = {},
|
||||
self = this;
|
||||
|
||||
@ -479,7 +497,7 @@ define(
|
||||
* Returns true if row matches all filters.
|
||||
*/
|
||||
function matchRow(filters, row) {
|
||||
return Object.keys(filters).every(function(key) {
|
||||
return Object.keys(filters).every(function (key) {
|
||||
if (!row[key]) {
|
||||
return false;
|
||||
}
|
||||
@ -492,7 +510,7 @@ define(
|
||||
return rowsToFilter;
|
||||
}
|
||||
|
||||
Object.keys(this.$scope.filters).forEach(function(key) {
|
||||
Object.keys(this.$scope.filters).forEach(function (key) {
|
||||
if (!self.$scope.filters[key]) {
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ define(
|
||||
return range.format === 'string';
|
||||
});
|
||||
}
|
||||
$scope.$watch('domainObject', function(domainObject) {
|
||||
$scope.$watch('domainObject', function (domainObject) {
|
||||
//When a domain object becomes available, check whether the
|
||||
// view should auto-scroll to the bottom.
|
||||
if (domainObject && hasStringTelemetry(domainObject)){
|
||||
@ -71,10 +71,10 @@ define(
|
||||
Override the subscribe function defined on the parent controller in
|
||||
order to handle realtime telemetry instead of historical.
|
||||
*/
|
||||
RTTelemetryTableController.prototype.subscribe = function() {
|
||||
RTTelemetryTableController.prototype.subscribe = function () {
|
||||
var self = this;
|
||||
self.$scope.rows = undefined;
|
||||
(this.subscriptions || []).forEach(function(unsubscribe){
|
||||
(this.subscriptions || []).forEach(function (unsubscribe){
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
@ -85,7 +85,7 @@ define(
|
||||
function updateData(){
|
||||
var datum,
|
||||
row;
|
||||
self.handle.getTelemetryObjects().forEach(function(telemetryObject){
|
||||
self.handle.getTelemetryObjects().forEach(function (telemetryObject){
|
||||
datum = self.handle.getDatum(telemetryObject);
|
||||
if (datum) {
|
||||
row = self.table.getRowValues(telemetryObject, datum);
|
||||
@ -94,7 +94,8 @@ define(
|
||||
self.$scope.rows = [row];
|
||||
} else {
|
||||
self.$scope.rows.push(row);
|
||||
self.$scope.$broadcast('add:row', self.$scope.rows.length - 1);
|
||||
self.$scope.$broadcast('add:row',
|
||||
self.$scope.rows.length - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -58,9 +58,9 @@ define(
|
||||
self.populateForm(model);
|
||||
});
|
||||
|
||||
$scope.$watchCollection('configuration.table.columns', function(columns){
|
||||
$scope.$watchCollection('configuration.table.columns', function (columns){
|
||||
if (columns){
|
||||
self.domainObject.useCapability('mutation', function(model) {
|
||||
self.domainObject.useCapability('mutation', function (model) {
|
||||
model.configuration.table.columns = columns;
|
||||
});
|
||||
self.domainObject.getCapability('persistence').persist();
|
||||
|
@ -54,7 +54,8 @@ define(
|
||||
this.handle = undefined;
|
||||
//this.pending = false;
|
||||
this.telemetryHandler = telemetryHandler;
|
||||
this.table = new TableConfiguration($scope.domainObject, telemetryFormatter);
|
||||
this.table = new TableConfiguration($scope.domainObject,
|
||||
telemetryFormatter);
|
||||
this.changeListeners = [];
|
||||
|
||||
$scope.rows = undefined;
|
||||
@ -77,17 +78,19 @@ define(
|
||||
* available in order to avoid race conditions
|
||||
* @private
|
||||
*/
|
||||
TelemetryTableController.prototype.registerChangeListeners = function() {
|
||||
TelemetryTableController.prototype.registerChangeListeners = function () {
|
||||
this.changeListeners.forEach(function (listener) {
|
||||
return listener && listener();
|
||||
});
|
||||
this.changeListeners = [];
|
||||
// When composition changes, re-subscribe to the various
|
||||
// telemetry subscriptions
|
||||
this.changeListeners.push(this.$scope.$watchCollection('domainObject.getModel().composition', this.subscribe.bind(this)));
|
||||
this.changeListeners.push(this.$scope.$watchCollection(
|
||||
'domainObject.getModel().composition', this.subscribe.bind(this)));
|
||||
|
||||
//Change of bounds in time conductor
|
||||
this.changeListeners.push(this.$scope.$on('telemetry:display:bounds', this.subscribe.bind(this)));
|
||||
this.changeListeners.push(this.$scope.$on('telemetry:display:bounds',
|
||||
this.subscribe.bind(this)));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -105,7 +108,7 @@ define(
|
||||
change default behaviour (which is to retrieve historical telemetry
|
||||
only).
|
||||
*/
|
||||
TelemetryTableController.prototype.subscribe = function() {
|
||||
TelemetryTableController.prototype.subscribe = function () {
|
||||
var self = this;
|
||||
|
||||
if (this.handle) {
|
||||
@ -131,17 +134,18 @@ define(
|
||||
* Populates historical data on scope when it becomes available
|
||||
* @private
|
||||
*/
|
||||
TelemetryTableController.prototype.addHistoricalData = function() {
|
||||
TelemetryTableController.prototype.addHistoricalData = function () {
|
||||
var rowData = [],
|
||||
self = this;
|
||||
|
||||
this.handle.getTelemetryObjects().forEach(function(telemetryObject){
|
||||
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
|
||||
var series = self.handle.getSeries(telemetryObject) || {},
|
||||
pointCount = series.getPointCount ? series.getPointCount() : 0,
|
||||
i = 0;
|
||||
|
||||
for (; i < pointCount; i++) {
|
||||
rowData.push(self.table.getRowValues(telemetryObject, self.handle.makeDatum(telemetryObject, series, i)));
|
||||
rowData.push(self.table.getRowValues(telemetryObject,
|
||||
self.handle.makeDatum(telemetryObject, series, i)));
|
||||
}
|
||||
});
|
||||
|
||||
@ -151,13 +155,13 @@ define(
|
||||
/**
|
||||
* Setup table columns based on domain object metadata
|
||||
*/
|
||||
TelemetryTableController.prototype.setup = function() {
|
||||
TelemetryTableController.prototype.setup = function () {
|
||||
var handle = this.handle,
|
||||
table = this.table,
|
||||
self = this;
|
||||
|
||||
if (handle) {
|
||||
handle.promiseTelemetryObjects().then(function (objects) {
|
||||
handle.promiseTelemetryObjects().then(function () {
|
||||
table.buildColumns(handle.getMetadata());
|
||||
|
||||
self.filterColumns();
|
||||
@ -193,7 +197,7 @@ define(
|
||||
this.table.saveColumnConfiguration(columnConfig);
|
||||
}
|
||||
//Populate headers with visible columns (determined by configuration)
|
||||
this.$scope.headers = Object.keys(columnConfig).filter(function(column) {
|
||||
this.$scope.headers = Object.keys(columnConfig).filter(function (column) {
|
||||
return columnConfig[column];
|
||||
});
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ define(
|
||||
function (TableController) {
|
||||
"use strict";
|
||||
|
||||
describe('The real-time table controller', function() {
|
||||
describe('The real-time table controller', function () {
|
||||
var mockScope,
|
||||
mockTelemetryHandler,
|
||||
mockTelemetryHandle,
|
||||
@ -48,7 +48,7 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
watches = {};
|
||||
mockTableRow = {'col1': 'val1', 'col2': 'row2'};
|
||||
|
||||
@ -58,13 +58,13 @@ define(
|
||||
'$watchCollection',
|
||||
'$broadcast'
|
||||
]);
|
||||
mockScope.$on.andCallFake(function(expression, callback){
|
||||
mockScope.$on.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
mockScope.$watch.andCallFake(function(expression, callback){
|
||||
mockScope.$watch.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
mockScope.$watchCollection.andCallFake(function(expression, callback){
|
||||
mockScope.$watchCollection.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ define(
|
||||
mockDomainObject.getModel.andReturn({});
|
||||
mockDomainObject.getCapability.andReturn(
|
||||
{
|
||||
getMetadata: function(){
|
||||
getMetadata: function (){
|
||||
return {ranges: [{format: 'string'}]};
|
||||
}
|
||||
});
|
||||
@ -124,18 +124,18 @@ define(
|
||||
controller.handle = mockTelemetryHandle;
|
||||
});
|
||||
|
||||
it('registers for streaming telemetry', function() {
|
||||
it('registers for streaming telemetry', function () {
|
||||
controller.subscribe();
|
||||
expect(mockTelemetryHandler.handle).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Function), true);
|
||||
});
|
||||
|
||||
it('updates table with new streaming telemetry', function() {
|
||||
it('updates table with new streaming telemetry', function () {
|
||||
controller.subscribe();
|
||||
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
||||
expect(mockScope.$broadcast).toHaveBeenCalledWith('add:row', 0);
|
||||
});
|
||||
|
||||
it('enables autoscroll for event telemetry', function() {
|
||||
it('enables autoscroll for event telemetry', function () {
|
||||
controller.subscribe();
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockScope.autoScroll).toBe(true);
|
||||
|
@ -28,7 +28,7 @@ define(
|
||||
function (TableController) {
|
||||
"use strict";
|
||||
|
||||
describe('The Table Controller', function() {
|
||||
describe('The Table Controller', function () {
|
||||
var mockScope,
|
||||
mockTelemetryHandler,
|
||||
mockTelemetryHandle,
|
||||
@ -47,7 +47,7 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
watches = {};
|
||||
mockScope = jasmine.createSpyObj('scope', [
|
||||
'$on',
|
||||
@ -55,13 +55,13 @@ define(
|
||||
'$watchCollection'
|
||||
]);
|
||||
|
||||
mockScope.$on.andCallFake(function(expression, callback){
|
||||
mockScope.$on.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
mockScope.$watch.andCallFake(function(expression, callback){
|
||||
mockScope.$watch.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
mockScope.$watchCollection.andCallFake(function(expression, callback){
|
||||
mockScope.$watchCollection.andCallFake(function (expression, callback){
|
||||
watches[expression] = callback;
|
||||
});
|
||||
|
||||
@ -114,28 +114,28 @@ define(
|
||||
controller.handle = mockTelemetryHandle;
|
||||
});
|
||||
|
||||
it('subscribes to telemetry handler for telemetry updates', function() {
|
||||
it('subscribes to telemetry handler for telemetry updates', function () {
|
||||
controller.subscribe();
|
||||
expect(mockTelemetryHandler.handle).toHaveBeenCalled();
|
||||
expect(mockTelemetryHandle.request).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('Unsubscribes from telemetry when scope is destroyed',function() {
|
||||
it('Unsubscribes from telemetry when scope is destroyed',function () {
|
||||
controller.handle = mockTelemetryHandle;
|
||||
watches.$destroy();
|
||||
expect(mockTelemetryHandle.unsubscribe).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('the controller makes use of the table', function() {
|
||||
describe('the controller makes use of the table', function () {
|
||||
|
||||
it('to create column definitions from telemetry' +
|
||||
' metadata', function() {
|
||||
' metadata', function () {
|
||||
controller.setup();
|
||||
expect(mockTable.buildColumns).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('to create column configuration, which is written to the' +
|
||||
' object model', function() {
|
||||
' object model', function () {
|
||||
var mockModel = {};
|
||||
|
||||
controller.setup();
|
||||
@ -144,22 +144,22 @@ define(
|
||||
});
|
||||
});
|
||||
|
||||
it('updates the rows on scope when historical telemetry is received', function(){
|
||||
it('updates the rows on scope when historical telemetry is received', function (){
|
||||
var mockSeries = {
|
||||
getPointCount: function() {
|
||||
getPointCount: function () {
|
||||
return 5;
|
||||
},
|
||||
getDomainValue: function() {
|
||||
getDomainValue: function () {
|
||||
return 'Domain Value';
|
||||
},
|
||||
getRangeValue: function() {
|
||||
getRangeValue: function () {
|
||||
return 'Range Value';
|
||||
}
|
||||
},
|
||||
mockRow = {'domain': 'Domain Value', 'range': 'Range' +
|
||||
' Value'};
|
||||
|
||||
mockTelemetryHandle.makeDatum.andCallFake(function(){
|
||||
mockTelemetryHandle.makeDatum.andCallFake(function (){
|
||||
return mockRow;
|
||||
});
|
||||
mockTable.getRowValues.andReturn(mockRow);
|
||||
@ -172,7 +172,7 @@ define(
|
||||
expect(controller.$scope.rows[0]).toBe(mockRow);
|
||||
});
|
||||
|
||||
it('filters the visible columns based on configuration', function(){
|
||||
it('filters the visible columns based on configuration', function (){
|
||||
controller.filterColumns();
|
||||
expect(controller.$scope.headers.length).toBe(3);
|
||||
expect(controller.$scope.headers[2]).toEqual('domain1');
|
||||
@ -183,14 +183,14 @@ define(
|
||||
expect(controller.$scope.headers[2]).toBeUndefined();
|
||||
});
|
||||
|
||||
describe('creates event listeners', function(){
|
||||
beforeEach(function() {
|
||||
describe('creates event listeners', function (){
|
||||
beforeEach(function () {
|
||||
spyOn(controller,'subscribe');
|
||||
spyOn(controller, 'filterColumns');
|
||||
});
|
||||
|
||||
it('triggers telemetry subscription update when domain' +
|
||||
' object changes', function() {
|
||||
' object changes', function () {
|
||||
controller.registerChangeListeners();
|
||||
//'watches' object is populated by fake scope watch and
|
||||
// watchCollection functions defined above
|
||||
@ -200,7 +200,7 @@ define(
|
||||
});
|
||||
|
||||
it('triggers telemetry subscription update when domain' +
|
||||
' object composition changes', function() {
|
||||
' object composition changes', function () {
|
||||
controller.registerChangeListeners();
|
||||
expect(watches['domainObject.getModel().composition']).toBeDefined();
|
||||
watches['domainObject.getModel().composition']();
|
||||
@ -208,7 +208,7 @@ define(
|
||||
});
|
||||
|
||||
it('triggers telemetry subscription update when time' +
|
||||
' conductor bounds change', function() {
|
||||
' conductor bounds change', function () {
|
||||
controller.registerChangeListeners();
|
||||
expect(watches['telemetry:display:bounds']).toBeDefined();
|
||||
watches['telemetry:display:bounds']();
|
||||
@ -216,7 +216,7 @@ define(
|
||||
});
|
||||
|
||||
it('triggers refiltering of the columns when configuration' +
|
||||
' changes', function() {
|
||||
' changes', function () {
|
||||
controller.setup();
|
||||
expect(watches['domainObject.getModel().configuration.table.columns']).toBeDefined();
|
||||
watches['domainObject.getModel().configuration.table.columns']();
|
||||
|
Loading…
x
Reference in New Issue
Block a user