From 49e68f854da81a32208bc8c0a81be6a9a9351553 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 17 May 2023 11:36:13 +0200 Subject: [PATCH 1/5] rearrange imports --- .../dashboard-performance-profiling.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts index 836316ac25..d7c0458e9c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts @@ -1,9 +1,9 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; +import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; import { ProfilingResource } from '@umbraco-cms/backoffice/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; -import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; @customElement('umb-dashboard-performance-profiling') export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { From 13e02f654552212a47760bd5c50fba5c2722a4ad Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 17 May 2023 11:36:57 +0200 Subject: [PATCH 2/5] call the server instead of localstorage --- ...dashboard-performance-profiling.element.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts index d7c0458e9c..4bcf74c4fe 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts @@ -10,13 +10,12 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { @state() private _profilingStatus?: boolean; + // TODO: Get this from the management api configuration when available @state() - private _profilingPerformance = false; + private _isDebugMode = true; - constructor() { - super(); + firstUpdated() { this._getProfilingStatus(); - this._profilingPerformance = localStorage.getItem('profilingPerformance') === 'true'; } private async _getProfilingStatus() { @@ -27,9 +26,15 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { } } - private _changeProfilingPerformance() { - this._profilingPerformance = !this._profilingPerformance; - localStorage.setItem('profilingPerformance', this._profilingPerformance.toString()); + private async _changeProfilingStatus() { + const { error } = await tryExecuteAndNotify( + this, + ProfilingResource.putProfilingStatus({ requestBody: { enabled: !this._profilingStatus } }) + ); + + if (!error) { + this._profilingStatus = !this._profilingStatus; + } } private renderProfilingStatus() { From 81c3cc65235d7596c086398553f04b45e5bf561a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 17 May 2023 11:37:05 +0200 Subject: [PATCH 3/5] update texts --- .../dashboard-performance-profiling.element.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts index 4bcf74c4fe..fb976bac77 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.ts @@ -38,7 +38,7 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { } private renderProfilingStatus() { - return this._profilingStatus + return this._isDebugMode ? html`
Umbraco currently runs in debug mode. This means you can use the built-in performance profiler to assess the
@@ -58,14 +58,14 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement {
You should never let a production site run in debug mode. Debug mode is turned off by setting - Umbraco:CMS:Hosting:Debug to false in appsettings.json, appsettings.{Environment}.json or via an environment - variable. + Umbraco:CMS:Hosting:Debug to false in appsettings.json, + appsettings.{Environment}.json or via an environment variable.
` : html` @@ -74,8 +74,8 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { be for a production site.- Debug mode is turned on by setting debug="true" on the <compilation /> element in - web.config. + Debug mode is turned on by by setting Umbraco:CMS:Hosting:Debug to true in + appsettings.json, appsettings.{Environment}.json or via an environment variable.
`; } From 6dd11cadbb5342b590147d25122553d74a030cca Mon Sep 17 00:00:00 2001 From: Mads Rasmussen- Umbraco currently runs in debug mode. This means you can use the built-in performance profiler to assess the - performance when rendering pages. + Umbraco is running in debug mode. This means you can use the built-in performance profiler + to assess performance when rendering pages.
If you want to activate the profiler for a specific page rendering, simply add @@ -70,11 +70,11 @@ export class UmbDashboardPerformanceProfilingElement extends UmbLitElement { ` : html`
- Umbraco currently does not run in debug mode, so you can't use the built-in profiler. This is how it should + Umbraco is not running in debug mode, so you can't use the built-in profiler. This is how it should be for a production site.
- Debug mode is turned on by by setting Umbraco:CMS:Hosting:Debug to true in + Debug mode is turned on by setting Umbraco:CMS:Hosting:Debug to true in appsettings.json, appsettings.{Environment}.json or via an environment variable.
`;