Merge pull request #37499 from tspmelo/wip-ng-profiler

mgr/dashboard: Enable Angular's debug tools when using dev mode

Reviewed-by: Alfonso Martínez <almartin@redhat.com>
Reviewed-by: Ernesto Puerta <epuertat@redhat.com>
Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
Lenz Grimmer 2020-10-01 16:38:32 +02:00 committed by GitHub
commit 48825c5eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { enableProdMode } from '@angular/core';
import { ApplicationRef, enableProdMode, isDevMode } from '@angular/core';
import { enableDebugTools } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
@ -10,4 +11,13 @@ if (environment.production) {
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then((moduleRef) => {
if (isDevMode()) {
// source: https://medium.com/@dmitrymogilko/profiling-angular-change-detection-c00605862b9f
const applicationRef = moduleRef.injector.get(ApplicationRef);
const componentRef = applicationRef.components[0];
// allows to run `ng.profiler.timeChangeDetection();`
enableDebugTools(componentRef);
}
})
.catch((err) => console.log(err));