Angular: Fixing some annoying depreaction warnings (#36466)

This commit is contained in:
Torkel Ödegaard 2021-07-07 18:39:10 +02:00 committed by GitHub
parent a86ad1190c
commit 96a51561a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -18,10 +18,14 @@ export class AngularLocationWrapper {
this.url = this.wrapInDeprecationWarning(this.url);
}
wrapInDeprecationWarning = (fn: Function, replacement?: string) => {
deprecationWarning('$location', fn.name, replacement || 'locationService');
return fn.bind(this);
};
wrapInDeprecationWarning(fn: Function, replacement?: string) {
let self = this;
return function wrapper() {
deprecationWarning('$location', fn.name, replacement || 'locationService');
return fn.apply(self, arguments);
};
}
absUrl(): string {
return `${window.location.origin}${this.url()}`;

View File

@ -11,6 +11,7 @@ import {
EventBusSrv,
} from '@grafana/data';
import { DashboardModel } from '../dashboard/state';
import { AngularLocationWrapper } from 'app/angular/AngularLocationWrapper';
export class PanelCtrl {
panel: any;
@ -21,7 +22,6 @@ export class PanelCtrl {
editorTabs: any;
$scope: any;
$injector: auto.IInjectorService;
$location: any;
$timeout: any;
editModeInitiated = false;
height: number;
@ -30,15 +30,16 @@ export class PanelCtrl {
events: EventBusExtended;
loading = false;
timing: any;
$location: AngularLocationWrapper;
constructor($scope: any, $injector: auto.IInjectorService) {
this.panel = this.panel ?? $scope.$parent.panel;
this.dashboard = this.dashboard ?? $scope.$parent.dashboard;
this.$injector = $injector;
this.$location = $injector.get('$location');
this.$scope = $scope;
this.$timeout = $injector.get('$timeout');
this.editorTabs = [];
this.$location = new AngularLocationWrapper();
this.events = new EventBusSrv();
this.timing = {}; // not used but here to not break plugins