query_ctrl.ts 724 B

123456789101112131415161718192021222324
  1. import { auto } from 'angular';
  2. import { indexOf } from 'lodash';
  3. export class QueryCtrl<T = any> {
  4. target!: T;
  5. datasource!: any;
  6. panelCtrl!: any;
  7. panel: any;
  8. hasRawMode!: boolean;
  9. error?: string | null;
  10. isLastQuery: boolean;
  11. constructor(public $scope: any, public $injector: auto.IInjectorService) {
  12. this.panelCtrl = this.panelCtrl ?? $scope.ctrl.panelCtrl;
  13. this.target = this.target ?? $scope.ctrl.target;
  14. this.datasource = this.datasource ?? $scope.ctrl.datasource;
  15. this.panel = this.panelCtrl?.panel ?? $scope.ctrl.panelCtrl.panel;
  16. this.isLastQuery = indexOf(this.panel.targets, this.target) === this.panel.targets.length - 1;
  17. }
  18. refresh() {
  19. this.panelCtrl.refresh();
  20. }
  21. }