[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,53 +69,40 @@ 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 () {
var datum,
row,
self = this;
function updateData(){ this.handle.getTelemetryObjects().forEach(function (telemetryObject){
var datum, datum = self.handle.getDatum(telemetryObject);
row; if (datum) {
self.handle.getTelemetryObjects().forEach(function (telemetryObject){ row = self.table.getRowValues(telemetryObject, datum);
datum = self.handle.getDatum(telemetryObject); if (!self.$scope.rows){
if (datum) { self.$scope.rows = [row];
row = self.table.getRowValues(telemetryObject, datum); self.$scope.$digest();
if (!self.$scope.rows){ } else {
self.$scope.rows = [row]; self.$scope.rows.push(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;

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,18 +173,16 @@ 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();
// When table column configuration changes, (due to being // When table column configuration changes, (due to being
// selected or deselected), filter columns appropriately. // selected or deselected), filter columns appropriately.
self.changeListeners.push(self.$scope.$watchCollection( self.changeListeners.push(self.$scope.$watchCollection(
'domainObject.getModel().configuration.table.columns', 'domainObject.getModel().configuration.table.columns',
self.filterColumns.bind(self) self.filterColumns.bind(self)
)); ));
});
} }
}; };