From c427901252cdf27c89a076de75011b0d25f35799 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Wed, 30 Sep 2020 14:34:27 +0000 Subject: [PATCH] mgr/dashboard: Enable Angular's debug tools when using dev mode Enabling this will allows us to run `ng.profiler.timeChangeDetection();` in the browser. Fixes: https://tracker.ceph.com/issues/47699 Signed-off-by: Tiago Melo --- src/pybind/mgr/dashboard/frontend/src/main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/main.ts b/src/pybind/mgr/dashboard/frontend/src/main.ts index 741c9eb862fed..f399daf9b6378 100644 --- a/src/pybind/mgr/dashboard/frontend/src/main.ts +++ b/src/pybind/mgr/dashboard/frontend/src/main.ts @@ -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)); -- 2.47.3