mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
3c6e0e8ef8
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { ILocationService } from 'angular';
|
||
|
||
import { RouteParamsProvider } from '../core/navigation/patch/RouteParamsProvider';
|
||
import { RouteProvider } from '../core/navigation/patch/RouteProvider';
|
||
|
||
import { AngularLocationWrapper } from './AngularLocationWrapper';
|
||
import { coreModule } from './core_module';
|
||
|
||
// Neutralizing Angular’s location tampering
|
||
// https://stackoverflow.com/a/19825756
|
||
const tamperAngularLocation = () => {
|
||
coreModule.config([
|
||
'$provide',
|
||
($provide: any) => {
|
||
$provide.decorator('$browser', [
|
||
'$delegate',
|
||
($delegate: any) => {
|
||
$delegate.onUrlChange = () => {};
|
||
$delegate.url = () => '';
|
||
|
||
return $delegate;
|
||
},
|
||
]);
|
||
},
|
||
]);
|
||
};
|
||
|
||
// Intercepting $location service with implementation based on history
|
||
const interceptAngularLocation = () => {
|
||
coreModule.config([
|
||
'$provide',
|
||
($provide: any) => {
|
||
$provide.decorator('$location', [
|
||
'$delegate',
|
||
($delegate: ILocationService) => {
|
||
$delegate = new AngularLocationWrapper() as unknown as ILocationService;
|
||
return $delegate;
|
||
},
|
||
]);
|
||
},
|
||
]);
|
||
coreModule.provider('$route', RouteProvider);
|
||
coreModule.provider('$routeParams', RouteParamsProvider);
|
||
};
|
||
|
||
export function initAngularRoutingBridge() {
|
||
tamperAngularLocation();
|
||
interceptAngularLocation();
|
||
}
|