Skip to content

Commit 3625899

Browse files
committed
latest changes
1 parent 39abd23 commit 3625899

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
119119
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />
120120
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
121+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.8" />
121122
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
122123
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.36" />
123124

LearningHub.Nhs.WebUI/Program.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Diagnostics;
44
using LearningHub.Nhs.WebUI;
5+
using LearningHub.Nhs.WebUI.BlazorComponentHosting;
56
using LearningHub.Nhs.WebUI.Interfaces;
67
using LearningHub.Nhs.WebUI.JsDetection;
78
using LearningHub.Nhs.WebUI.Middleware;
@@ -34,16 +35,22 @@
3435
builder.Logging.ClearProviders();
3536
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
3637
builder.Host.UseNLog();
38+
builder.Services.AddControllersWithViews();
3739

3840
builder.Services.AddHostedService<TimedHostedService>();
3941
builder.Services.ConfigureServices(builder.Configuration, builder.Environment);
4042

43+
// Add Razor components
44+
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
4145
var app = builder.Build();
4246

4347
var appLifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();
4448
var jsDetectionLogger = app.Services.GetRequiredService<IJsDetectionLogger>();
4549
appLifetime.ApplicationStopping.Register(async () => await jsDetectionLogger.FlushCounters());
4650

51+
app.UseBlazorFrameworkFiles("/blazor");
52+
app.UseStaticFiles();
53+
4754
if (app.Environment.IsDevelopment())
4855
{
4956
app.UseDeveloperExceptionPage();
@@ -84,7 +91,6 @@
8491
app.UseAuthorization();
8592

8693
app.UseMiddleware<NLogMiddleware>();
87-
app.UseStaticFiles();
8894

8995
app.Map(TimezoneInfoMiddleware.TimezoneInfoUrl, b => b.UseMiddleware<TimezoneInfoMiddleware>());
9096

@@ -108,6 +114,11 @@
108114
};
109115
});
110116

117+
// Map Razor components (needed for interactivity)
118+
app.MapRazorComponents<App>() // App is your root component
119+
.AddInteractiveServerRenderMode()
120+
.AddAdditionalAssemblies(typeof(TELBlazor.Components._Imports).Assembly);
121+
111122
app.Run();
112123
}
113124
catch (Exception ex)

LearningHub.Nhs.WebUI/Views/Search/Index.cshtml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@
99
}
1010

1111
<div class="search-page">
12-
<div class="nhsuk-width-container app-width-container">
12+
<div class="nhsuk-width-container app-width-container">
13+
14+
<h2>Search (Blazor WASM mounted)</h2>
15+
16+
<div id="tel-auto-suggest">
17+
Loading auto-suggest...
18+
</div>
19+
20+
@* <h2>Fruit Search (Blazor Server Component)</h2>
21+
22+
<component type="typeof(TELAutoSuggestTextbox)"
23+
render-mode="Server"
24+
param-ApiUrl=@("/api/search/GetResult1")
25+
param-Placeholder="@("Type a fruit...")"/> *@
26+
1327
@if (Model.DidYouMeanEnabled)
1428
{
1529
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6 nhsuk-body-l">

LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!DOCTYPE html>
66
<html lang="en">
77
<head>
8+
<base href="/" />
89
<meta charset="utf-8" />
910
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
1011
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
@@ -160,6 +161,19 @@
160161
<partial name="~/Views/Shared/_SessionManagerScriptPartial.cshtml" />
161162
<partial name="~/Views/Shared/_JavascriptDetectorPartial.cshtml" />
162163
<partial name="~/Views/Shared/_SupportUrlsScriptPartial.cshtml" />
164+
165+
@* <script>
166+
window.__BlazorRuntimeBase = "/blazor/_framework/";
167+
</script> *@
168+
<script src="~/blazorcomponents/_framework/blazor.webassembly.js"></script>
169+
@* <script>
170+
Blazor.start({
171+
environmentBaseUrl: '/blazor/_framework/',
172+
onStart: () => console.log('Blazor started OK'),
173+
onError: err => console.error('Blazor startup error:', err)
174+
});
175+
</script> *@
176+
163177
@RenderSection("Scripts", required: false)
164178

165179
<script type="text/javascript" src="~/js/mkplayer-ui-custom.js" asp-append-version="true"></script>

0 commit comments

Comments
 (0)