diff --git a/platform/features/table/src/controllers/RTTelemetryTableController.js b/platform/features/table/src/controllers/RTTelemetryTableController.js index 8a61d61b5e..f18157d168 100644 --- a/platform/features/table/src/controllers/RTTelemetryTableController.js +++ b/platform/features/table/src/controllers/RTTelemetryTableController.js @@ -69,53 +69,40 @@ define( 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 () { - var self = this; - self.$scope.rows = undefined; - (this.subscriptions || []).forEach(function (unsubscribe){ - unsubscribe(); - }); + RTTelemetryTableController.prototype.addHistoricalData = function () { + //Noop for realtime table + }; - if (this.handle) { - this.handle.unsubscribe(); - } + /** + * Handling for real-time data + */ + RTTelemetryTableController.prototype.updateRealtime = function () { + var datum, + row, + self = this; - function updateData(){ - var datum, - row; - self.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){ + 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); - if (self.$scope.rows.length > self.maxRows) { - self.$scope.$broadcast('remove:row', 0); - self.$scope.rows.shift(); - } - - self.$scope.$broadcast('add:row', - self.$scope.rows.length - 1); + if (self.$scope.rows.length > self.maxRows) { + self.$scope.$broadcast('remove:row', 0); + self.$scope.rows.shift(); } + + 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; diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index e579c5eeb8..c8ecff5f2e 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -57,6 +57,7 @@ define( this.table = new TableConfiguration($scope.domainObject, telemetryFormatter); this.changeListeners = []; + this.initialized = false; $scope.rows = undefined; @@ -110,24 +111,35 @@ define( */ TelemetryTableController.prototype.subscribe = function () { var self = this; + this.initialized = false; if (this.handle) { this.handle.unsubscribe(); } //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.$scope.domainObject, - noop, + update, true // Lossless ); 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; 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 - // selected or deselected), filter columns appropriately. - self.changeListeners.push(self.$scope.$watchCollection( - 'domainObject.getModel().configuration.table.columns', - self.filterColumns.bind(self) - )); - }); + // 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) + )); } };