mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 08:25:31 +00:00
[Tables] Using new composition API to fetch all telemetry objects
This commit is contained in:
parent
b28eb049dc
commit
6d5530ba9c
@ -26,9 +26,11 @@
|
|||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'../TableConfiguration'
|
'../TableConfiguration',
|
||||||
|
'../../../../../src/api/objects/object-utils'
|
||||||
|
|
||||||
],
|
],
|
||||||
function (TableConfiguration) {
|
function (TableConfiguration, objectUtils) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TableController is responsible for getting data onto the page
|
* The TableController is responsible for getting data onto the page
|
||||||
@ -56,6 +58,8 @@ define(
|
|||||||
telemetryFormatter);
|
telemetryFormatter);
|
||||||
this.changeListeners = [];
|
this.changeListeners = [];
|
||||||
this.conductor = openmct.conductor;
|
this.conductor = openmct.conductor;
|
||||||
|
this.openmct = openmct;
|
||||||
|
this.newObject = objectUtils.toNewFormat($scope.domainObject.getModel(), $scope.domainObject.getId());
|
||||||
|
|
||||||
$scope.rows = [];
|
$scope.rows = [];
|
||||||
|
|
||||||
@ -156,11 +160,42 @@ define(
|
|||||||
only).
|
only).
|
||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.subscribe = function () {
|
TelemetryTableController.prototype.subscribe = function () {
|
||||||
|
var telemetryApi = this.openmct.telemetry;
|
||||||
|
|
||||||
if (this.handle) {
|
if (this.handle) {
|
||||||
this.handle.unsubscribe();
|
this.handle.unsubscribe();
|
||||||
}
|
}
|
||||||
this.$scope.loading = true;
|
this.$scope.loading = true;
|
||||||
|
|
||||||
|
function map(func){
|
||||||
|
return function (objects) {
|
||||||
|
return Promise.all(objects.map(func));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add(object){
|
||||||
|
return function (objects) {
|
||||||
|
objects.unshift(object);
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribeTo(object) {
|
||||||
|
return telemetryApi.request(object, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function error() {
|
||||||
|
console.log("Unable to subscribe");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.openmct.composition.get(this.newObject)
|
||||||
|
.load()
|
||||||
|
.then(add(this.newObject))
|
||||||
|
.then(map(subscribeTo))
|
||||||
|
.then(function (telemetry) {
|
||||||
|
console.log(telemetry.length);
|
||||||
|
}).catch(error);
|
||||||
|
|
||||||
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
this.handle = this.$scope.domainObject && this.telemetryHandler.handle(
|
||||||
this.$scope.domainObject,
|
this.$scope.domainObject,
|
||||||
this.addRealtimeData.bind(this),
|
this.addRealtimeData.bind(this),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user