Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 9740132

Browse files
committed
feat(frontend-blazor): add blazor web assembly project (#243)
* add cors policy to accept all request * add blazor project * add dockerfile and docker compose support * add mudblazor * update readme
1 parent 813d033 commit 9740132

31 files changed

Lines changed: 534 additions & 8 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| [![Actions Status](https://github.com/OpenCodeFoundation/eSchool/workflows/Enrolling.API/badge.svg)](https://github.com/OpenCodeFoundation/eSchool/actions) | [![Actions Status](https://github.com/OpenCodeFoundation/eSchool/workflows/WebStatus/badge.svg)](https://github.com/OpenCodeFoundation/eSchool/actions) | [![Actions Status](https://github.com/OpenCodeFoundation/eSchool/workflows/ESchool.GraphQL/badge.svg)](https://github.com/OpenCodeFoundation/eSchool/actions) |
99

1010
## System requirements
11+
1112
### Recommended Hardware requirements for Windows
1213

1314
- Windows 10 Pro, Education or Enterprise
@@ -37,6 +38,7 @@ in terminal from project's root folder. The first run can take 30 mins to 1 hour
3738

3839
### Service URLs
3940

41+
- eSchool Frontend (Blazor) - [http://localhost:5200/](http://localhost:5200/)
4042
- eSchool Gateway (GraphQL) - [http://localhost:5101/graphql/](http://localhost:5102/graphql/)
4143
- WebStatus - [http://localhost:5107/](http://localhost:5107/)
4244
- Enrolling.API (REST - Swagger) - [http://localhost:5102/swagger/](http://localhost:5102/swagger/)
@@ -55,6 +57,7 @@ in terminal from project's root folder. The first run can take 30 mins to 1 hour
5557
- RabbitMQ
5658
- API Gateway
5759
- GraphQL
60+
- Blazor
5861

5962
## Contributing
6063

docker-compose.override.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525

2626
webstatus:
2727
environment:
28-
- ASPNETCORE_ENVIRONMENT=Production
28+
- ASPNETCORE_ENVIRONMENT=Development
2929
- ASPNETCORE_URLS=http://0.0.0.0:80
3030
- ConnectionStrings=Server=sql.data;Database=OpenCodeFoundation.WebStatusDb;User Id=sa;Password=Pass@word
3131
- HealthChecksUI__HealthChecks__0__Name=Enrolling HTTP Check
@@ -35,11 +35,18 @@ services:
3535

3636
eschool.graphql:
3737
environment:
38-
- ASPNETCORE_ENVIRONMENT=Production
38+
- ASPNETCORE_ENVIRONMENT=Development
3939
- ASPNETCORE_URLS=http://0.0.0.0:80
4040
ports:
4141
- "5101:80"
4242

43+
frontend.blazor:
44+
environment:
45+
- ASPNETCORE_ENVIRONMENT=Development
46+
- ASPNETCORE_URLS=http://0.0.0.0:80
47+
ports:
48+
- "5200:80"
49+
4350
jaeger:
4451
environment:
4552
- COLLECTOR_ZIPKIN_HTTP_PORT=9411

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ services:
2727
context: .
2828
dockerfile: src/ApiGateways/eSchool.GraphQL/Dockerfile
2929

30+
frontend.blazor:
31+
image: ${REGISTRY:-eschool}/frontend.blazor:${TAG:-latest}
32+
build:
33+
context: .
34+
dockerfile: src/Web/Frontend.Blazor/Frontend.Blazor.Server/Dockerfile
35+
3036
jaeger:
3137
image: jaegertracing/all-in-one

eSchool.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGateways", "ApiGateways"
3333
EndProject
3434
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eSchool.GraphQL", "src\ApiGateways\eSchool.GraphQL\eSchool.GraphQL.csproj", "{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}"
3535
EndProject
36+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend.Blazor", "Frontend.Blazor", "{0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}"
37+
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Blazor.Client", "src\Web\Frontend.Blazor\Frontend.Blazor.Client\Frontend.Blazor.Client.csproj", "{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}"
39+
EndProject
40+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Blazor.Server", "src\Web\Frontend.Blazor\Frontend.Blazor.Server\Frontend.Blazor.Server.csproj", "{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}"
41+
EndProject
3642
Global
3743
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3844
Debug|Any CPU = Debug|Any CPU
@@ -151,6 +157,30 @@ Global
151157
{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}.Release|x64.Build.0 = Release|Any CPU
152158
{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}.Release|x86.ActiveCfg = Release|Any CPU
153159
{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}.Release|x86.Build.0 = Release|Any CPU
160+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
161+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
162+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|x64.ActiveCfg = Debug|Any CPU
163+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|x64.Build.0 = Debug|Any CPU
164+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|x86.ActiveCfg = Debug|Any CPU
165+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Debug|x86.Build.0 = Debug|Any CPU
166+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
167+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|Any CPU.Build.0 = Release|Any CPU
168+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|x64.ActiveCfg = Release|Any CPU
169+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|x64.Build.0 = Release|Any CPU
170+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|x86.ActiveCfg = Release|Any CPU
171+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}.Release|x86.Build.0 = Release|Any CPU
172+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
173+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|Any CPU.Build.0 = Debug|Any CPU
174+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|x64.ActiveCfg = Debug|Any CPU
175+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|x64.Build.0 = Debug|Any CPU
176+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|x86.ActiveCfg = Debug|Any CPU
177+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Debug|x86.Build.0 = Debug|Any CPU
178+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|Any CPU.ActiveCfg = Release|Any CPU
179+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|Any CPU.Build.0 = Release|Any CPU
180+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|x64.ActiveCfg = Release|Any CPU
181+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|x64.Build.0 = Release|Any CPU
182+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|x86.ActiveCfg = Release|Any CPU
183+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}.Release|x86.Build.0 = Release|Any CPU
154184
EndGlobalSection
155185
GlobalSection(SolutionProperties) = preSolution
156186
HideSolutionNode = FALSE
@@ -169,6 +199,9 @@ Global
169199
{7B410F3B-36E0-4853-9B4E-41D0CC2865B5} = {74511F4E-FF9D-42C4-9531-A75C61270B73}
170200
{256317ED-A2C8-48A0-9C6E-D6EB1F7D0BE0} = {6BFF1AB8-C900-43E5-988F-E07C085BD64A}
171201
{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C} = {256317ED-A2C8-48A0-9C6E-D6EB1F7D0BE0}
202+
{0C00A596-0FE3-4FA6-B54B-FE2BE83371EF} = {AA9E7227-03DB-4D04-A7FB-E8FD09D4C719}
203+
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE} = {0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}
204+
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389} = {0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}
172205
EndGlobalSection
173206
GlobalSection(ExtensibilityGlobals) = postSolution
174207
SolutionGuid = {E418719F-3193-403E-AF58-9BE9F94FD8BE}

src/ApiGateways/eSchool.GraphQL/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
22
WORKDIR /app
33
EXPOSE 80
44

5-
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
5+
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
66
WORKDIR /src
77

88
COPY "eSchool.sln" "eSchool.sln"
@@ -19,6 +19,9 @@ COPY "src/Libraries/OpenTelemetry/OpenTelemetry.csproj" "src/Libraries/OpenTelem
1919

2020
COPY "src/Web/WebStatus/WebStatus.csproj" "src/Web/WebStatus/WebStatus.csproj"
2121

22+
COPY "src/Web/Frontend.Blazor/Frontend.Blazor.Server/Frontend.Blazor.Server.csproj" "src/Web/Frontend.Blazor/Frontend.Blazor.Server/Frontend.Blazor.Server.csproj"
23+
COPY "src/Web/Frontend.Blazor/Frontend.Blazor.Client/Frontend.Blazor.Client.csproj" "src/Web/Frontend.Blazor/Frontend.Blazor.Client/Frontend.Blazor.Client.csproj"
24+
2225
COPY "docker-compose.dcproj" "docker-compose.dcproj"
2326

2427
RUN dotnet restore eSchool.sln -nowarn:msb3202,nu1503

src/ApiGateways/eSchool.GraphQL/Startup.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using HotChocolate.Configuration;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
45
using Microsoft.Extensions.DependencyInjection;
@@ -16,6 +17,8 @@ public class Startup
1617
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
1718
public void ConfigureServices(IServiceCollection services)
1819
{
20+
services.AddCors();
21+
1922
services.AddHttpClient(Enrolling, c =>
2023
c.BaseAddress = new Uri("http://enrolling.api/graphql"));
2124

@@ -36,6 +39,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3639

3740
app.UseSerilogRequestLogging();
3841

42+
app.UseCors(o => o
43+
.AllowAnyHeader()
44+
.AllowAnyMethod()
45+
.AllowAnyOrigin());
46+
3947
app.UseRouting();
4048

4149
app.UseEndpoints(endpoints =>

src/Services/Enrolling/Enrolling.API/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
22
WORKDIR /app
33
EXPOSE 80
44

5-
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
5+
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
66
WORKDIR /src
77

88
COPY "eSchool.sln" "eSchool.sln"
@@ -19,6 +19,9 @@ COPY "src/Libraries/OpenTelemetry/OpenTelemetry.csproj" "src/Libraries/OpenTelem
1919

2020
COPY "src/Web/WebStatus/WebStatus.csproj" "src/Web/WebStatus/WebStatus.csproj"
2121

22+
COPY "src/Web/Frontend.Blazor/Frontend.Blazor.Server/Frontend.Blazor.Server.csproj" "src/Web/Frontend.Blazor/Frontend.Blazor.Server/Frontend.Blazor.Server.csproj"
23+
COPY "src/Web/Frontend.Blazor/Frontend.Blazor.Client/Frontend.Blazor.Client.csproj" "src/Web/Frontend.Blazor/Frontend.Blazor.Client/Frontend.Blazor.Client.csproj"
24+
2225
COPY "docker-compose.dcproj" "docker-compose.dcproj"
2326

2427
RUN dotnet restore eSchool.sln -nowarn:msb3202,nu1503
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
6+
7+
<AssemblyName>Frontend.Blazor.Client</AssemblyName>
8+
<RootNamespace>OpenCodeFoundation.ESchool.Web.Frontend.Blazor.Client</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
14+
<PackageReference Include="MudBlazor" Version="1.1.5" />
15+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/counter"
2+
3+
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-16">
4+
<MudText Typo="Typo.h3" GutterBottom="true">Counter</MudText>
5+
<MudText Class="mb-4">Current count: @currentCount</MudText>
6+
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="IncrementCount">Click me</MudButton>
7+
</MudContainer>
8+
9+
@code {
10+
private int currentCount = 0;
11+
12+
private void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}

0 commit comments

Comments
 (0)