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 { ...@@ -26,6 +26,7 @@ class MetricsPanelCtrl extends PanelCtrl {
timeInfo: any; timeInfo: any;
skipDataOnInit: boolean; skipDataOnInit: boolean;
datasources: any[]; datasources: any[];
dataSubscription: any;
constructor($scope, $injector) { constructor($scope, $injector) {
super($scope, $injector); super($scope, $injector);
...@@ -182,6 +183,12 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -182,6 +183,12 @@ class MetricsPanelCtrl extends PanelCtrl {
return datasource.query(metricsQuery).then(results => { return datasource.query(metricsQuery).then(results => {
this.setTimeQueryEnd(); this.setTimeQueryEnd();
// check for if data source returns observable
if (results && results.subscribe) {
this.handleObservable(results);
return {data: []};
}
if (this.dashboard.snapshot) { if (this.dashboard.snapshot) {
this.panel.snapshotData = results; this.panel.snapshotData = results;
} }
...@@ -193,6 +200,20 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -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) { setDatasource(datasource) {
// switching to mixed // switching to mixed
if (datasource.meta.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