mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
[Tables] #793 Added fix for tables not appearing on refresh
Fixed failing tests
This commit is contained in:
@ -82,27 +82,28 @@ define(
|
|||||||
var datum,
|
var datum,
|
||||||
row,
|
row,
|
||||||
self = this;
|
self = this;
|
||||||
|
if (this.handle) {
|
||||||
|
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
|
||||||
|
datum = self.handle.getDatum(telemetryObject);
|
||||||
|
if (datum) {
|
||||||
|
row = self.table.getRowValues(telemetryObject, datum);
|
||||||
|
if (!self.$scope.rows) {
|
||||||
|
self.$scope.rows = [row];
|
||||||
|
self.$scope.$digest();
|
||||||
|
} else {
|
||||||
|
self.$scope.rows.push(row);
|
||||||
|
|
||||||
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
|
if (self.$scope.rows.length > self.maxRows) {
|
||||||
datum = self.handle.getDatum(telemetryObject);
|
self.$scope.$broadcast('remove:row', 0);
|
||||||
if (datum) {
|
self.$scope.rows.shift();
|
||||||
row = self.table.getRowValues(telemetryObject, datum);
|
}
|
||||||
if (!self.$scope.rows){
|
|
||||||
self.$scope.rows = [row];
|
|
||||||
self.$scope.$digest();
|
|
||||||
} else {
|
|
||||||
self.$scope.rows.push(row);
|
|
||||||
|
|
||||||
if (self.$scope.rows.length > self.maxRows) {
|
self.$scope.$broadcast('add:row',
|
||||||
self.$scope.$broadcast('remove:row', 0);
|
self.$scope.rows.length - 1);
|
||||||
self.$scope.rows.shift();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.$scope.$broadcast('add:row',
|
|
||||||
self.$scope.rows.length - 1);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return RTTelemetryTableController;
|
return RTTelemetryTableController;
|
||||||
|
@ -66,7 +66,7 @@ define(
|
|||||||
if (!domainObject)
|
if (!domainObject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.subscribe();
|
self.subscribe(domainObject);
|
||||||
self.registerChangeListeners();
|
self.registerChangeListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -80,6 +80,8 @@ 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();
|
||||||
});
|
});
|
||||||
@ -87,7 +89,11 @@ define(
|
|||||||
// When composition changes, re-subscribe to the various
|
// When composition changes, re-subscribe to the various
|
||||||
// telemetry subscriptions
|
// telemetry subscriptions
|
||||||
this.changeListeners.push(this.$scope.$watchCollection(
|
this.changeListeners.push(this.$scope.$watchCollection(
|
||||||
'domainObject.getModel().composition', this.subscribe.bind(this)));
|
'domainObject.getModel().composition', function(composition, oldComposition) {
|
||||||
|
if (composition!== oldComposition) {
|
||||||
|
self.subscribe();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
//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',
|
||||||
@ -112,6 +118,7 @@ define(
|
|||||||
TelemetryTableController.prototype.subscribe = function () {
|
TelemetryTableController.prototype.subscribe = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
this.$scope.rows = undefined;
|
||||||
|
|
||||||
if (this.handle) {
|
if (this.handle) {
|
||||||
this.handle.unsubscribe();
|
this.handle.unsubscribe();
|
||||||
@ -121,13 +128,12 @@ define(
|
|||||||
function update(){
|
function update(){
|
||||||
if(!self.initialized){
|
if(!self.initialized){
|
||||||
self.setup();
|
self.setup();
|
||||||
self.initialized = true;
|
|
||||||
}
|
}
|
||||||
self.updateRealtime();
|
self.updateRealtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
||||||
this.$scope.domainObject,
|
self.$scope.domainObject,
|
||||||
update,
|
update,
|
||||||
true // Lossless
|
true // Lossless
|
||||||
);
|
);
|
||||||
@ -172,6 +178,7 @@ define(
|
|||||||
table = this.table,
|
table = this.table,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
|
//Is metadata available yet?
|
||||||
if (handle) {
|
if (handle) {
|
||||||
table.buildColumns(handle.getMetadata());
|
table.buildColumns(handle.getMetadata());
|
||||||
|
|
||||||
@ -183,6 +190,7 @@ define(
|
|||||||
'domainObject.getModel().configuration.table.columns',
|
'domainObject.getModel().configuration.table.columns',
|
||||||
self.filterColumns.bind(self)
|
self.filterColumns.bind(self)
|
||||||
));
|
));
|
||||||
|
self.initialized = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ define(
|
|||||||
mockScope.domainObject = mockDomainObject;
|
mockScope.domainObject = mockDomainObject;
|
||||||
|
|
||||||
mockTelemetryHandle = jasmine.createSpyObj('telemetryHandle', [
|
mockTelemetryHandle = jasmine.createSpyObj('telemetryHandle', [
|
||||||
|
'request',
|
||||||
'getMetadata',
|
'getMetadata',
|
||||||
'unsubscribe',
|
'unsubscribe',
|
||||||
'getDatum',
|
'getDatum',
|
||||||
@ -113,6 +114,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', [
|
||||||
|
@ -203,7 +203,7 @@ define(
|
|||||||
' object composition changes', function () {
|
' object composition changes', function () {
|
||||||
controller.registerChangeListeners();
|
controller.registerChangeListeners();
|
||||||
expect(watches['domainObject.getModel().composition']).toBeDefined();
|
expect(watches['domainObject.getModel().composition']).toBeDefined();
|
||||||
watches['domainObject.getModel().composition']();
|
watches['domainObject.getModel().composition'](["one"], ["two"]);
|
||||||
expect(controller.subscribe).toHaveBeenCalled();
|
expect(controller.subscribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user