Skip to content

Commit c0b44be

Browse files
authored
Merge pull request #1 from BobbyMcBobFace/main
Add WebUI via Blazor and MudBlazor
2 parents a5dfab5 + eff31f2 commit c0b44be

File tree

126 files changed

+120500
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+120500
-0
lines changed

.github/workflows/dotnet.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This workflow will run tests for a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: .NET Tests
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
test:
14+
15+
runs-on: windows-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: 8.0.x
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
- name: Run Tests
26+
run: dotnet test --no-build --verbosity normal

BastionWebUI/App.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>

BastionWebUI/BastionWebUI.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
12+
<PackageReference Include="MudBlazor" Version="8.6.0" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@inherits LayoutComponentBase
2+
3+
<MudThemeProvider />
4+
5+
<MudLayout>
6+
<!-- App Bar -->
7+
<MudAppBar Color="Color.Primary" Fixed="true" Dense="@_dense" Elevation="@_elevation">
8+
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@ToggleDrawer" />
9+
<MudText Typo="Typo.h5" Class="ml-3">Bastion Web UI</MudText>
10+
<MudSpacer />
11+
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit" Href="https://github.com/MudBlazor/MudBlazor" Target="_blank" />
12+
</MudAppBar>
13+
14+
<!-- Drawer -->
15+
<MudDrawer @bind-Open="@_drawerOpen" Elevation="1" Variant="DrawerVariant.Responsive">
16+
<MudDrawerHeader>
17+
<MudText Typo="Typo.h6">My App</MudText>
18+
</MudDrawerHeader>
19+
<MudNavMenu>
20+
<MudNavLink Match="NavLinkMatch.All" Href="/home">Home</MudNavLink>
21+
<MudNavLink Match="NavLinkMatch.All" Href="/login">Store</MudNavLink>
22+
<MudNavLink Match="NavLinkMatch.All" Href="/dashboard">Library</MudNavLink>
23+
</MudNavMenu>
24+
</MudDrawer>
25+
26+
<!-- Main Content -->
27+
<MudMainContent Class="pt-16 px-16">
28+
@Body
29+
</MudMainContent>
30+
</MudLayout>
31+
32+
@code {
33+
private bool _drawerOpen = false;
34+
private bool _dense = false;
35+
private int _elevation = 4;
36+
37+
private void ToggleDrawer()
38+
{
39+
_drawerOpen = !_drawerOpen;
40+
}
41+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}

BastionWebUI/Pages/Dashboard.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/dashboard"
2+
3+
<MudPaper Elevation="4" Square="true">
4+
<MudText Typo="Typo.h4">Dashboard</MudText>
5+
<MudDivider />
6+
<MudText Typo="Typo.body1">Overview of your servers and users will go here.</MudText>
7+
</MudPaper>

BastionWebUI/Pages/Home.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/home"
2+
3+
<MudPaper Elevation="4" Square="true">
4+
<MudText Typo="Typo.h4">Home</MudText>
5+
<MudDivider />
6+
<MudText Typo="Typo.body1">Welcome to the Bastion Control Panel.</MudText>
7+
</MudPaper>

BastionWebUI/Pages/Login.razor

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@page "/login"
2+
@using MudBlazor
3+
4+
<MudContainer MaxWidth="MaxWidth.Medium">
5+
<MudCard>
6+
<MudCardContent>
7+
<MudTextField Label="Username" @bind-Value="username" Variant="Variant.Filled" FullWidth />
8+
<MudTextField Label="Password" @bind-Value="password" Variant="Variant.Filled" FullWidth InputType="InputType.Password" />
9+
<MudButton OnClick="HandleLogin" Color="Color.Primary" Variant="Variant.Filled">Login</MudButton>
10+
</MudCardContent>
11+
</MudCard>
12+
</MudContainer>
13+
14+
@code {
15+
private string username;
16+
private string password;
17+
18+
private async Task HandleLogin()
19+
{
20+
// Authentication logic here
21+
Console.WriteLine($"Attempting to log in as {username}");
22+
}
23+
}

BastionWebUI/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using MudBlazor.Services;
2+
using Microsoft.AspNetCore.Components.Web;
3+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
4+
using BastionWebUI;
5+
6+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
7+
builder.RootComponents.Add<App>("#app");
8+
builder.RootComponents.Add<HeadOutlet>("head::after");
9+
10+
// Add MudBlazor services to DI container
11+
builder.Services.AddMudServices();
12+
13+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:1234/") });
14+
15+
await builder.Build().RunAsync();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
9+
"applicationUrl": "http://localhost:5056",
10+
"environmentVariables": {
11+
"ASPNETCORE_ENVIRONMENT": "Development"
12+
}
13+
},
14+
"https": {
15+
"commandName": "Project",
16+
"dotnetRunMessages": true,
17+
"launchBrowser": true,
18+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
19+
"applicationUrl": "https://localhost:7211;http://localhost:5056",
20+
"environmentVariables": {
21+
"ASPNETCORE_ENVIRONMENT": "Development"
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)