@implements IDisposable @inject IJSRuntime JsRuntime @inject IUserSession Session @inject IMenuService MenuService @* * dbMango * * Copyright 2025 Deutsche Bank AG * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @code { protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) return; //this is the first opportunity i have to set the title as JS has been initialised await JsRuntime.InvokeVoidAsync("DashboardUtils.SetDocumentTitle", Header + " " + AppName); await JsRuntime.InvokeVoidAsync("DashboardUtils.SetFavicon", FavIcon); } private static string Env => Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Development; private static string FavIcon => GetFavIcon(); public static string GetFavIcon() => (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Development) switch { "Development" => @"images\favicon-dev.svg", "UAT" => @"images\favicon.svg", "PROD" => @"images\favicon-prod.svg", _ => @"images\favicon.svg" }; public static string GetMango() => (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Development) switch { "Development" => @"images\mango-dev.svg", "UAT" => @"images\mango.svg", "PROD" => @"images\mango-prod.svg", _ => @"images\mango.svg" }; private string Header => string.IsNullOrWhiteSpace(Session?.Database) ? Env : Session.Database; private string AppName => "dbMango"; protected override void OnInitialized() { Session.DatabaseChanged += OnDatabaseChangeHandler; } public void Dispose() { Session.DatabaseChanged -= OnDatabaseChangeHandler; } private void OnDatabaseChangeHandler() { _ = InvokeAsync(StateHasChanged); } }