|
@@ -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 {
|
|
|
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 {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ 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) {
|