mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(data source observerable): started work on handling data source observerable
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user