2019-07-18 14:03:04 +08:00
|
|
|
import { auto } from 'angular';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { indexOf } from 'lodash';
|
2016-02-01 19:42:10 +08:00
|
|
|
|
2021-05-03 22:49:09 +08:00
|
|
|
export class QueryCtrl<T = any> {
|
|
|
|
|
target!: T;
|
2021-02-22 17:06:07 +08:00
|
|
|
datasource!: any;
|
|
|
|
|
panelCtrl!: any;
|
2016-02-02 16:12:58 +08:00
|
|
|
panel: any;
|
2021-02-22 17:06:07 +08:00
|
|
|
hasRawMode!: boolean;
|
2020-07-08 17:05:20 +08:00
|
|
|
error?: string | null;
|
2017-09-08 17:43:29 +08:00
|
|
|
isLastQuery: boolean;
|
2016-02-02 16:12:58 +08:00
|
|
|
|
2019-07-18 14:03:04 +08:00
|
|
|
constructor(public $scope: any, public $injector: auto.IInjectorService) {
|
2021-03-31 23:03:07 +08:00
|
|
|
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;
|
2021-04-21 15:38:00 +08:00
|
|
|
this.isLastQuery = indexOf(this.panel.targets, this.target) === this.panel.targets.length - 1;
|
2016-02-02 16:12:58 +08:00
|
|
|
}
|
|
|
|
|
|
2016-02-02 19:52:43 +08:00
|
|
|
refresh() {
|
|
|
|
|
this.panelCtrl.refresh();
|
|
|
|
|
}
|
2016-01-14 21:37:04 +08:00
|
|
|
}
|