[Tables] #793 Added fix for tables not appearing on refresh

Fixed failing tests
This commit is contained in:
Henry
2016-03-28 11:21:05 -07:00
parent 012a38cccd
commit a4b79cdb5b
4 changed files with 33 additions and 22 deletions

View File

@ -82,12 +82,12 @@ define(
var datum, var datum,
row, row,
self = this; self = this;
if (this.handle) {
this.handle.getTelemetryObjects().forEach(function (telemetryObject){ this.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){ if (!self.$scope.rows) {
self.$scope.rows = [row]; self.$scope.rows = [row];
self.$scope.$digest(); self.$scope.$digest();
} else { } else {
@ -103,6 +103,7 @@ define(
} }
} }
}); });
}
}; };
return RTTelemetryTableController; return RTTelemetryTableController;

View File

@ -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;
} }
}; };

View File

@ -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', [

View File

@ -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();
}); });