[Tables] Fix for table columns not being populated

This commit is contained in:
Henry
2016-03-25 11:20:09 -07:00
parent cbea842c8b
commit 012a38cccd
2 changed files with 51 additions and 54 deletions

View File

@ -69,24 +69,21 @@ 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();
});
if (this.handle) { /**
this.handle.unsubscribe(); * Handling for real-time data
} */
RTTelemetryTableController.prototype.updateRealtime = function () {
function updateData(){
var datum, var datum,
row; row,
self.handle.getTelemetryObjects().forEach(function (telemetryObject){ self = this;
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);
@ -106,16 +103,6 @@ define(
} }
} }
}); });
}
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
this.$scope.domainObject,
updateData,
true // Lossless
);
this.setup();
}; };
return RTTelemetryTableController; return RTTelemetryTableController;

View File

@ -57,6 +57,7 @@ define(
this.table = new TableConfiguration($scope.domainObject, this.table = new TableConfiguration($scope.domainObject,
telemetryFormatter); telemetryFormatter);
this.changeListeners = []; this.changeListeners = [];
this.initialized = false;
$scope.rows = undefined; $scope.rows = undefined;
@ -110,24 +111,35 @@ define(
*/ */
TelemetryTableController.prototype.subscribe = function () { TelemetryTableController.prototype.subscribe = function () {
var self = this; var self = this;
this.initialized = false;
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(){
if(!self.initialized){
self.setup();
self.initialized = true;
}
self.updateRealtime();
} }
this.handle = this.$scope.domainObject && this.telemetryHandler.handle( this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
this.$scope.domainObject, this.$scope.domainObject,
noop, update,
true // Lossless true // Lossless
); );
this.handle.request({}).then(this.addHistoricalData.bind(this)); this.handle.request({}).then(this.addHistoricalData.bind(this));
};
this.setup(); /**
* Override this method to define handling for realtime data.
*/
TelemetryTableController.prototype.updateRealtime = function () {
//Noop in an historical table
}; };
/** /**
@ -161,7 +173,6 @@ define(
self = this; self = this;
if (handle) { if (handle) {
handle.promiseTelemetryObjects().then(function () {
table.buildColumns(handle.getMetadata()); table.buildColumns(handle.getMetadata());
self.filterColumns(); self.filterColumns();
@ -172,7 +183,6 @@ define(
'domainObject.getModel().configuration.table.columns', 'domainObject.getModel().configuration.table.columns',
self.filterColumns.bind(self) self.filterColumns.bind(self)
)); ));
});
} }
}; };