Commit a738945a by Torkel Ödegaard

feat(data source observerable): started work on handling data source observerable

parent b273cd13
......@@ -26,6 +26,7 @@ class MetricsPanelCtrl extends PanelCtrl {
timeInfo: any;
skipDataOnInit: boolean;
datasources: any[];
dataSubscription: any;
constructor($scope, $injector) {
super($scope, $injector);
......@@ -182,6 +183,12 @@ class MetricsPanelCtrl extends PanelCtrl {
return datasource.query(metricsQuery).then(results => {
this.setTimeQueryEnd();
// check for if data source returns observable
if (results && results.subscribe) {
this.handleObservable(results);
return {data: []};
}
if (this.dashboard.snapshot) {
this.panel.snapshotData = results;
}
......@@ -193,6 +200,20 @@ class MetricsPanelCtrl extends PanelCtrl {
}
}
handleObservable(observable) {
this.dataSubscription = observable.subscribe({
next: (data) => {
console.log('panel: observer got data');
},
error: (error) => {
console.log('panel: observer got error');
},
complete: () => {
console.log('panel: observer got complete');
}
});
}
setDatasource(datasource) {
// switching to mixed
if (datasource.meta.mixed) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment