mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 14:32:22 +00:00
Merge remote-tracking branch 'origin/open793'
This commit is contained in:
commit
f49552779a
@ -39,6 +39,7 @@ define(
|
|||||||
function TableConfiguration(domainObject, telemetryFormatter) {
|
function TableConfiguration(domainObject, telemetryFormatter) {
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.columns = [];
|
this.columns = [];
|
||||||
|
this.columnConfiguration = {};
|
||||||
this.telemetryFormatter = telemetryFormatter;
|
this.telemetryFormatter = telemetryFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,16 +145,30 @@ define(
|
|||||||
{}).columns || {};
|
{}).columns || {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function configEqual(obj1, obj2) {
|
||||||
|
var obj1Keys = Object.keys(obj1),
|
||||||
|
obj2Keys = Object.keys(obj2);
|
||||||
|
return (obj1Keys.length === obj2Keys.length) &&
|
||||||
|
obj1Keys.every(function (key) {
|
||||||
|
return obj1[key] === obj2[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the established configuration on the domain object
|
* Set the established configuration on the domain object. Will noop
|
||||||
|
* if configuration is unchanged
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
TableConfiguration.prototype.saveColumnConfiguration = function (columnConfig) {
|
TableConfiguration.prototype.saveColumnConfiguration = function (columnConfig) {
|
||||||
this.domainObject.useCapability('mutation', function (model) {
|
var self = this;
|
||||||
model.configuration = model.configuration || {};
|
if (!configEqual(this.columnConfiguration, columnConfig)) {
|
||||||
model.configuration.table = model.configuration.table || {};
|
this.domainObject.useCapability('mutation', function (model) {
|
||||||
model.configuration.table.columns = columnConfig;
|
model.configuration = model.configuration || {};
|
||||||
});
|
model.configuration.table = model.configuration.table || {};
|
||||||
|
model.configuration.table.columns = columnConfig;
|
||||||
|
self.columnConfiguration = columnConfig;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ define(
|
|||||||
$scope.$watchCollection('filters', function () {
|
$scope.$watchCollection('filters', function () {
|
||||||
self.updateRows($scope.rows);
|
self.updateRows($scope.rows);
|
||||||
});
|
});
|
||||||
$scope.$watch('headers', this.updateHeaders.bind(this));
|
|
||||||
$scope.$watch('rows', this.updateRows.bind(this));
|
$scope.$watch('rows', this.updateRows.bind(this));
|
||||||
|
$scope.$watch('headers', this.updateHeaders.bind(this));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Listen for rows added individually (eg. for real-time tables)
|
* Listen for rows added individually (eg. for real-time tables)
|
||||||
@ -101,13 +101,19 @@ define(
|
|||||||
*/
|
*/
|
||||||
MCTTableController.prototype.newRow = function (event, rowIndex) {
|
MCTTableController.prototype.newRow = function (event, rowIndex) {
|
||||||
var row = this.$scope.rows[rowIndex];
|
var row = this.$scope.rows[rowIndex];
|
||||||
//Add row to the filtered, sorted list of all rows
|
//If rows.length === 1 we need to calculate column widths etc.
|
||||||
if (this.filterRows([row]).length > 0) {
|
// so do the updateRows logic, rather than the 'add row' logic
|
||||||
this.insertSorted(this.$scope.displayRows, row);
|
if (this.$scope.rows.length === 1){
|
||||||
}
|
this.updateRows(this.$scope.rows);
|
||||||
|
} else {
|
||||||
|
//Add row to the filtered, sorted list of all rows
|
||||||
|
if (this.filterRows([row]).length > 0) {
|
||||||
|
this.insertSorted(this.$scope.displayRows, row);
|
||||||
|
}
|
||||||
|
|
||||||
this.$timeout(this.setElementSizes.bind(this))
|
this.$timeout(this.setElementSizes.bind(this))
|
||||||
.then(this.scrollToBottom.bind(this));
|
.then(this.scrollToBottom.bind(this));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,53 +69,36 @@ define(
|
|||||||
RTTelemetryTableController.prototype = Object.create(TableController.prototype);
|
RTTelemetryTableController.prototype = Object.create(TableController.prototype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Override the subscribe function defined on the parent controller in
|
*
|
||||||
order to handle realtime telemetry instead of historical.
|
|
||||||
*/
|
*/
|
||||||
RTTelemetryTableController.prototype.subscribe = function () {
|
RTTelemetryTableController.prototype.addHistoricalData = function () {
|
||||||
var self = this;
|
//Noop for realtime table
|
||||||
self.$scope.rows = undefined;
|
};
|
||||||
(this.subscriptions || []).forEach(function (unsubscribe){
|
|
||||||
unsubscribe();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handling for real-time data
|
||||||
|
*/
|
||||||
|
RTTelemetryTableController.prototype.updateRealtime = function () {
|
||||||
|
var datum,
|
||||||
|
row,
|
||||||
|
self = this;
|
||||||
if (this.handle) {
|
if (this.handle) {
|
||||||
this.handle.unsubscribe();
|
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
|
||||||
}
|
|
||||||
|
|
||||||
function updateData(){
|
|
||||||
var datum,
|
|
||||||
row;
|
|
||||||
self.handle.getTelemetryObjects().forEach(function (telemetryObject){
|
|
||||||
datum = self.handle.getDatum(telemetryObject);
|
datum = self.handle.getDatum(telemetryObject);
|
||||||
if (datum) {
|
if (datum) {
|
||||||
row = self.table.getRowValues(telemetryObject, datum);
|
row = self.table.getRowValues(telemetryObject, datum);
|
||||||
if (!self.$scope.rows){
|
self.$scope.rows.push(row);
|
||||||
self.$scope.rows = [row];
|
|
||||||
self.$scope.$digest();
|
|
||||||
} else {
|
|
||||||
self.$scope.rows.push(row);
|
|
||||||
|
|
||||||
if (self.$scope.rows.length > self.maxRows) {
|
if (self.$scope.rows.length > self.maxRows) {
|
||||||
self.$scope.$broadcast('remove:row', 0);
|
self.$scope.$broadcast('remove:row', 0);
|
||||||
self.$scope.rows.shift();
|
self.$scope.rows.shift();
|
||||||
}
|
|
||||||
|
|
||||||
self.$scope.$broadcast('add:row',
|
|
||||||
self.$scope.rows.length - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.$scope.$broadcast('add:row',
|
||||||
|
self.$scope.rows.length - 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
|
||||||
this.$scope.domainObject,
|
|
||||||
updateData,
|
|
||||||
true // Lossless
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setup();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return RTTelemetryTableController;
|
return RTTelemetryTableController;
|
||||||
|
@ -58,14 +58,14 @@ define(
|
|||||||
telemetryFormatter);
|
telemetryFormatter);
|
||||||
this.changeListeners = [];
|
this.changeListeners = [];
|
||||||
|
|
||||||
$scope.rows = undefined;
|
$scope.rows = [];
|
||||||
|
|
||||||
// Subscribe to telemetry when a domain object becomes available
|
// Subscribe to telemetry when a domain object becomes available
|
||||||
this.$scope.$watch('domainObject', function(domainObject){
|
this.$scope.$watch('domainObject', function(domainObject){
|
||||||
if (!domainObject)
|
if (!domainObject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.subscribe();
|
self.subscribe(domainObject);
|
||||||
self.registerChangeListeners();
|
self.registerChangeListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,14 +79,28 @@ define(
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.registerChangeListeners = function () {
|
TelemetryTableController.prototype.registerChangeListeners = function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.changeListeners.forEach(function (listener) {
|
this.changeListeners.forEach(function (listener) {
|
||||||
return listener && listener();
|
return listener && listener();
|
||||||
});
|
});
|
||||||
this.changeListeners = [];
|
this.changeListeners = [];
|
||||||
// When composition changes, re-subscribe to the various
|
|
||||||
// telemetry subscriptions
|
/**
|
||||||
this.changeListeners.push(this.$scope.$watchCollection(
|
* Listen to all children for model mutation events that might
|
||||||
'domainObject.getModel().composition', this.subscribe.bind(this)));
|
* indicate that metadata is available, or that composition has
|
||||||
|
* changed.
|
||||||
|
*/
|
||||||
|
if (this.$scope.domainObject.hasCapability('composition')) {
|
||||||
|
this.$scope.domainObject.useCapability('composition').then(function (composees) {
|
||||||
|
composees.forEach(function (composee) {
|
||||||
|
self.changeListeners.push(composee.getCapability('mutation').listen(self.setup.bind(self)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//Register mutation listener for the parent itself
|
||||||
|
self.changeListeners.push(self.$scope.domainObject.getCapability('mutation').listen(this.setup.bind(this)));
|
||||||
|
|
||||||
//Change of bounds in time conductor
|
//Change of bounds in time conductor
|
||||||
this.changeListeners.push(this.$scope.$on('telemetry:display:bounds',
|
this.changeListeners.push(this.$scope.$on('telemetry:display:bounds',
|
||||||
@ -110,26 +124,38 @@ define(
|
|||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.subscribe = function () {
|
TelemetryTableController.prototype.subscribe = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
this.$scope.rows = [];
|
||||||
|
|
||||||
if (this.handle) {
|
if (this.handle) {
|
||||||
this.handle.unsubscribe();
|
this.handle.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Noop because not supporting realtime data right now
|
//Noop because not supporting realtime data right now
|
||||||
function noop(){
|
function update(){
|
||||||
|
//Is there anything to show?
|
||||||
|
if (self.table.columns.length > 0){
|
||||||
|
self.updateRealtime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
||||||
this.$scope.domainObject,
|
self.$scope.domainObject,
|
||||||
noop,
|
update,
|
||||||
true // Lossless
|
true // Lossless
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handle.request({}).then(this.addHistoricalData.bind(this));
|
this.handle.request({}).then(this.addHistoricalData.bind(this));
|
||||||
|
|
||||||
|
//Call setup at least once
|
||||||
this.setup();
|
this.setup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this method to define handling for realtime data.
|
||||||
|
*/
|
||||||
|
TelemetryTableController.prototype.updateRealtime = function () {
|
||||||
|
//Noop in an historical table
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates historical data on scope when it becomes available
|
* Populates historical data on scope when it becomes available
|
||||||
* @private
|
* @private
|
||||||
@ -157,33 +183,42 @@ define(
|
|||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.setup = function () {
|
TelemetryTableController.prototype.setup = function () {
|
||||||
var handle = this.handle,
|
var handle = this.handle,
|
||||||
|
domainObject = this.$scope.domainObject,
|
||||||
table = this.table,
|
table = this.table,
|
||||||
self = this;
|
self = this,
|
||||||
|
metadatas = [];
|
||||||
|
|
||||||
if (handle) {
|
function addMetadata(object) {
|
||||||
handle.promiseTelemetryObjects().then(function () {
|
if (object.hasCapability('telemetry') &&
|
||||||
table.buildColumns(handle.getMetadata());
|
object.getCapability('telemetry').getMetadata()){
|
||||||
|
metadatas.push(object.getCapability('telemetry').getMetadata());
|
||||||
self.filterColumns();
|
}
|
||||||
|
|
||||||
// When table column configuration changes, (due to being
|
|
||||||
// selected or deselected), filter columns appropriately.
|
|
||||||
self.changeListeners.push(self.$scope.$watchCollection(
|
|
||||||
'domainObject.getModel().configuration.table.columns',
|
|
||||||
self.filterColumns.bind(self)
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
function buildAndFilterColumns(){
|
||||||
* @private
|
if (metadatas && metadatas.length > 0){
|
||||||
* @param object The object for which data is available (table may
|
self.$scope.rows = [];
|
||||||
* be composed of multiple objects)
|
table.buildColumns(metadatas);
|
||||||
* @param datum The data received from the telemetry source
|
self.filterColumns();
|
||||||
*/
|
}
|
||||||
TelemetryTableController.prototype.updateRows = function (object, datum) {
|
}
|
||||||
this.$scope.rows.push(this.table.getRowValues(object, datum));
|
|
||||||
|
//Add telemetry metadata (if any) for parent object
|
||||||
|
addMetadata(domainObject);
|
||||||
|
|
||||||
|
//If object is composed of multiple objects, also add
|
||||||
|
// telemetry metadata from children
|
||||||
|
if (domainObject.hasCapability('composition')) {
|
||||||
|
domainObject.useCapability('composition').then(function (composition) {
|
||||||
|
composition.forEach(addMetadata);
|
||||||
|
}).then(function () {
|
||||||
|
//Build columns based on available metadata
|
||||||
|
buildAndFilterColumns();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//Build columns based on collected metadata
|
||||||
|
buildAndFilterColumns();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,11 +226,9 @@ define(
|
|||||||
* accordingly.
|
* accordingly.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.filterColumns = function (columnConfig) {
|
TelemetryTableController.prototype.filterColumns = function () {
|
||||||
if (!columnConfig){
|
var columnConfig = this.table.getColumnConfiguration();
|
||||||
columnConfig = this.table.getColumnConfiguration();
|
this.table.saveColumnConfiguration(columnConfig);
|
||||||
this.table.saveColumnConfiguration(columnConfig);
|
|
||||||
}
|
|
||||||
//Populate headers with visible columns (determined by configuration)
|
//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];
|
return columnConfig[column];
|
||||||
|
@ -89,20 +89,24 @@ define(
|
|||||||
|
|
||||||
mockDomainObject= jasmine.createSpyObj('domainObject', [
|
mockDomainObject= jasmine.createSpyObj('domainObject', [
|
||||||
'getCapability',
|
'getCapability',
|
||||||
|
'hasCapability',
|
||||||
'useCapability',
|
'useCapability',
|
||||||
'getModel'
|
'getModel'
|
||||||
]);
|
]);
|
||||||
mockDomainObject.getModel.andReturn({});
|
mockDomainObject.getModel.andReturn({});
|
||||||
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
mockDomainObject.getCapability.andReturn(
|
mockDomainObject.getCapability.andReturn(
|
||||||
{
|
{
|
||||||
getMetadata: function (){
|
getMetadata: function (){
|
||||||
return {ranges: [{format: 'string'}]};
|
return {ranges: [{format: 'string'}]};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mockDomainObject.useCapability.andReturn(promise([]));
|
||||||
|
|
||||||
mockScope.domainObject = mockDomainObject;
|
mockScope.domainObject = mockDomainObject;
|
||||||
|
|
||||||
mockTelemetryHandle = jasmine.createSpyObj('telemetryHandle', [
|
mockTelemetryHandle = jasmine.createSpyObj('telemetryHandle', [
|
||||||
|
'request',
|
||||||
'getMetadata',
|
'getMetadata',
|
||||||
'unsubscribe',
|
'unsubscribe',
|
||||||
'getDatum',
|
'getDatum',
|
||||||
@ -113,6 +117,7 @@ define(
|
|||||||
// used by mocks
|
// used by mocks
|
||||||
mockTelemetryHandle.getTelemetryObjects.andReturn([{}]);
|
mockTelemetryHandle.getTelemetryObjects.andReturn([{}]);
|
||||||
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
||||||
|
mockTelemetryHandle.request.andReturn(promise(undefined));
|
||||||
mockTelemetryHandle.getDatum.andReturn({});
|
mockTelemetryHandle.getDatum.andReturn({});
|
||||||
|
|
||||||
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
||||||
@ -123,6 +128,8 @@ define(
|
|||||||
controller = new TableController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
controller = new TableController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
||||||
controller.table = mockTable;
|
controller.table = mockTable;
|
||||||
controller.handle = mockTelemetryHandle;
|
controller.handle = mockTelemetryHandle;
|
||||||
|
spyOn(controller, 'updateRealtime');
|
||||||
|
controller.updateRealtime.andCallThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('registers for streaming telemetry', function () {
|
it('registers for streaming telemetry', function () {
|
||||||
@ -130,14 +137,16 @@ define(
|
|||||||
expect(mockTelemetryHandler.handle).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Function), true);
|
expect(mockTelemetryHandler.handle).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Function), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('receives new telemetry', function () {
|
describe('when receiving new telemetry', function () {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
controller.subscribe();
|
controller.subscribe();
|
||||||
mockScope.rows = [];
|
mockScope.rows = [];
|
||||||
|
mockTable.columns = ['a', 'b'];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates table with new streaming telemetry', function () {
|
it('updates table with new streaming telemetry', function () {
|
||||||
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
||||||
|
expect(controller.updateRealtime).toHaveBeenCalled();
|
||||||
expect(mockScope.$broadcast).toHaveBeenCalledWith('add:row', 0);
|
expect(mockScope.$broadcast).toHaveBeenCalledWith('add:row', 0);
|
||||||
});
|
});
|
||||||
it('observes the row limit', function () {
|
it('observes the row limit', function () {
|
||||||
|
@ -33,7 +33,13 @@ define(
|
|||||||
mockTelemetryHandler,
|
mockTelemetryHandler,
|
||||||
mockTelemetryHandle,
|
mockTelemetryHandle,
|
||||||
mockTelemetryFormatter,
|
mockTelemetryFormatter,
|
||||||
|
mockTelemetryCapability,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
|
mockChild,
|
||||||
|
mockMutationCapability,
|
||||||
|
mockCompositionCapability,
|
||||||
|
childMutationCapability,
|
||||||
|
capabilities = {},
|
||||||
mockTable,
|
mockTable,
|
||||||
mockConfiguration,
|
mockConfiguration,
|
||||||
watches,
|
watches,
|
||||||
@ -64,6 +70,17 @@ define(
|
|||||||
mockScope.$watchCollection.andCallFake(function (expression, callback){
|
mockScope.$watchCollection.andCallFake(function (expression, callback){
|
||||||
watches[expression] = callback;
|
watches[expression] = callback;
|
||||||
});
|
});
|
||||||
|
mockTelemetryCapability = jasmine.createSpyObj('telemetryCapability',
|
||||||
|
['getMetadata']
|
||||||
|
);
|
||||||
|
mockTelemetryCapability.getMetadata.andReturn({});
|
||||||
|
capabilities.telemetry = mockTelemetryCapability;
|
||||||
|
|
||||||
|
mockCompositionCapability = jasmine.createSpyObj('compositionCapability',
|
||||||
|
['invoke']
|
||||||
|
);
|
||||||
|
mockCompositionCapability.invoke.andReturn(promise([]));
|
||||||
|
capabilities.composition = mockCompositionCapability;
|
||||||
|
|
||||||
mockConfiguration = {
|
mockConfiguration = {
|
||||||
'range1': true,
|
'range1': true,
|
||||||
@ -81,13 +98,36 @@ define(
|
|||||||
);
|
);
|
||||||
mockTable.columns = [];
|
mockTable.columns = [];
|
||||||
mockTable.getColumnConfiguration.andReturn(mockConfiguration);
|
mockTable.getColumnConfiguration.andReturn(mockConfiguration);
|
||||||
|
mockMutationCapability = jasmine.createSpyObj('mutationCapability', [
|
||||||
|
"listen"
|
||||||
|
]);
|
||||||
|
capabilities.mutation = mockMutationCapability;
|
||||||
|
|
||||||
mockDomainObject= jasmine.createSpyObj('domainObject', [
|
mockDomainObject = jasmine.createSpyObj('domainObject', [
|
||||||
'getCapability',
|
'getCapability',
|
||||||
|
'hasCapability',
|
||||||
'useCapability',
|
'useCapability',
|
||||||
'getModel'
|
'getModel'
|
||||||
]);
|
]);
|
||||||
|
mockChild = jasmine.createSpyObj('domainObject', [
|
||||||
|
'getCapability'
|
||||||
|
]);
|
||||||
|
childMutationCapability = jasmine.createSpyObj('childMutationCapability', [
|
||||||
|
"listen"
|
||||||
|
]);
|
||||||
|
mockChild.getCapability.andReturn(childMutationCapability);
|
||||||
|
|
||||||
|
|
||||||
mockDomainObject.getModel.andReturn({});
|
mockDomainObject.getModel.andReturn({});
|
||||||
|
mockDomainObject.hasCapability.andCallFake(function (name){
|
||||||
|
return typeof capabilities[name] !== 'undefined';
|
||||||
|
});
|
||||||
|
mockDomainObject.useCapability.andCallFake(function (capability){
|
||||||
|
return capabilities[capability] && capabilities[capability].invoke && capabilities[capability].invoke();
|
||||||
|
});
|
||||||
|
mockDomainObject.getCapability.andCallFake(function (name){
|
||||||
|
return capabilities[name];
|
||||||
|
});
|
||||||
|
|
||||||
mockScope.domainObject = mockDomainObject;
|
mockScope.domainObject = mockDomainObject;
|
||||||
|
|
||||||
@ -103,6 +143,7 @@ define(
|
|||||||
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
||||||
mockTelemetryHandle.request.andReturn(promise(undefined));
|
mockTelemetryHandle.request.andReturn(promise(undefined));
|
||||||
mockTelemetryHandle.getTelemetryObjects.andReturn([]);
|
mockTelemetryHandle.getTelemetryObjects.andReturn([]);
|
||||||
|
mockTelemetryHandle.getMetadata.andReturn(["a", "b", "c"]);
|
||||||
|
|
||||||
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
||||||
'handle'
|
'handle'
|
||||||
@ -127,7 +168,6 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
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' +
|
it('to create column definitions from telemetry' +
|
||||||
' metadata', function () {
|
' metadata', function () {
|
||||||
controller.setup();
|
controller.setup();
|
||||||
@ -199,14 +239,6 @@ define(
|
|||||||
expect(controller.subscribe).toHaveBeenCalled();
|
expect(controller.subscribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers telemetry subscription update when domain' +
|
|
||||||
' object composition changes', function () {
|
|
||||||
controller.registerChangeListeners();
|
|
||||||
expect(watches['domainObject.getModel().composition']).toBeDefined();
|
|
||||||
watches['domainObject.getModel().composition']();
|
|
||||||
expect(controller.subscribe).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('triggers telemetry subscription update when time' +
|
it('triggers telemetry subscription update when time' +
|
||||||
' conductor bounds change', function () {
|
' conductor bounds change', function () {
|
||||||
controller.registerChangeListeners();
|
controller.registerChangeListeners();
|
||||||
@ -214,12 +246,21 @@ define(
|
|||||||
watches['telemetry:display:bounds']();
|
watches['telemetry:display:bounds']();
|
||||||
expect(controller.subscribe).toHaveBeenCalled();
|
expect(controller.subscribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
it('Listens for changes to object model', function () {
|
||||||
|
controller.registerChangeListeners();
|
||||||
|
expect(mockMutationCapability.listen).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('triggers refiltering of the columns when configuration' +
|
it('Listens for changes to child model', function () {
|
||||||
' changes', function () {
|
mockCompositionCapability.invoke.andReturn(promise([mockChild]));
|
||||||
controller.setup();
|
controller.registerChangeListeners();
|
||||||
expect(watches['domainObject.getModel().configuration.table.columns']).toBeDefined();
|
expect(childMutationCapability.listen).toHaveBeenCalled();
|
||||||
watches['domainObject.getModel().configuration.table.columns']();
|
});
|
||||||
|
|
||||||
|
it('Recalculates columns when model changes occur', function () {
|
||||||
|
controller.registerChangeListeners();
|
||||||
|
expect(mockMutationCapability.listen).toHaveBeenCalled();
|
||||||
|
mockMutationCapability.listen.mostRecentCall.args[0]();
|
||||||
expect(controller.filterColumns).toHaveBeenCalled();
|
expect(controller.filterColumns).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user