grafana/public/app/angular/panel/query_ctrl.ts
Torkel Ödegaard c4ce7a40af
AngularPanels: Move angular panel infra & components to angular/app folder (#40373)
* AngularPanels: Move to app/angular folder

* Fixing issues
2021-10-13 16:59:47 +02:00

25 lines
724 B
TypeScript

import { indexOf } from 'lodash';
import { auto } from 'angular';
export class QueryCtrl<T = any> {
target!: T;
datasource!: any;
panelCtrl!: any;
panel: any;
hasRawMode!: boolean;
error?: string | null;
isLastQuery: boolean;
constructor(public $scope: any, public $injector: auto.IInjectorService) {
this.panelCtrl = this.panelCtrl ?? $scope.ctrl.panelCtrl;
this.target = this.target ?? $scope.ctrl.target;
this.datasource = this.datasource ?? $scope.ctrl.datasource;
this.panel = this.panelCtrl?.panel ?? $scope.ctrl.panelCtrl.panel;
this.isLastQuery = indexOf(this.panel.targets, this.target) === this.panel.targets.length - 1;
}
refresh() {
this.panelCtrl.refresh();
}
}