Change project using mud template, add test user pages

This commit is contained in:
Yuchen Ji
2022-04-24 02:29:55 +08:00
parent b486b5b36a
commit d89065e58a
31 changed files with 411 additions and 35 deletions
+6 -6
View File
@@ -5,9 +5,9 @@ VisualStudioVersion = 16.0.32126.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GC-local-server-rewrite", "GC-local-server-rewrite\GC-local-server-rewrite.csproj", "{D5FFF2E8-6591-4967-8883-A28F453F0524}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GC-local-web-frontend", "GC-local-web-frontend\GC-local-web-frontend.csproj", "{DAA65FBF-4C21-4052-A772-7899A65B3227}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProject\SharedProject.csproj", "{C01D0576-9D4E-4535-8055-C4905433A1EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{C01D0576-9D4E-4535-8055-C4905433A1EB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudAdmin", "MudAdmin\MudAdmin.csproj", "{DC8E30E9-F81E-4E28-A4D2-F4576C77FFBE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,14 +19,14 @@ Global
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Release|Any CPU.Build.0 = Release|Any CPU
{DAA65FBF-4C21-4052-A772-7899A65B3227}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAA65FBF-4C21-4052-A772-7899A65B3227}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAA65FBF-4C21-4052-A772-7899A65B3227}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAA65FBF-4C21-4052-A772-7899A65B3227}.Release|Any CPU.Build.0 = Release|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Release|Any CPU.Build.0 = Release|Any CPU
{DC8E30E9-F81E-4E28-A4D2-F4576C77FFBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC8E30E9-F81E-4E28-A4D2-F4576C77FFBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC8E30E9-F81E-4E28-A4D2-F4576C77FFBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC8E30E9-F81E-4E28-A4D2-F4576C77FFBE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -59,7 +59,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\Common\Common.csproj" />
<ProjectReference Include="..\SharedProject\SharedProject.csproj" />
</ItemGroup>
</Project>
@@ -3,10 +3,9 @@ using EmbedIO.Routing;
using EmbedIO.WebApi;
using GCLocalServerRewrite.common;
using GCLocalServerRewrite.models;
using Shared.enums;
using Shared.models;
using SharedProject.enums;
using SharedProject.models;
using SQLite.Net2;
using Swan.Logging;
namespace GCLocalServerRewrite.controllers;
-1
View File
@@ -1,5 +1,4 @@
using System.Xml.Serialization;
using ChoETL;
using SQLite.Net2;
namespace GCLocalServerRewrite.models;
+3 -1
View File
@@ -9,4 +9,6 @@
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</Router>
<AntContainer/>
@@ -7,12 +7,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AntDesign" Version="0.10.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\SharedProject\SharedProject.csproj" />
</ItemGroup>
</Project>
+24 -16
View File
@@ -1,12 +1,13 @@
@page "/fetchdata"
@using global::Shared.models
@page "/fetchdata"
@using global::SharedProject.models
@using SharedProject.enums
@inject HttpClient Http
<PageTitle>Weather forecast</PageTitle>
<PageTitle>Play Options</PageTitle>
<h1>Weather forecast</h1>
<h1>Play Options</h1>
<p>This component demonstrates fetching data from the server.</p>
<p>Play options of the specified card</p>
@if (playOption == null)
{
@@ -16,26 +17,33 @@
}
else
{
<table>
<table style="width: 551px; height: 119px">
<thead>
<tr>
<th>CardId</th>
<th>Fast/Slow Indicator</th>
<th>Fever/Trance Show</th>
</tr>
<tr>
<th style="text-align: center">CardId</th>
<th style="text-align: center">Fast/Slow Indicator</th>
<th style="text-align: center">Fever/Trance Show</th>
</tr>
</thead>
<tbody>
<tr>
<th>@playOption.CardId</th>
<th>@playOption.FastSlowIndicator</th>
<th>@playOption.FeverTrance</th>
</tr>
<tr>
<th style="text-align: center">@playOption.CardId</th>
<th style="text-align: center">@playOption.FastSlowIndicator</th>
<th style="text-align: center">@playOption.FeverTrance</th>
</tr>
</tbody>
</table>
}
<EnumSelect TEnum="PlayOptions.FastSlowIndicator" OnSelectedItemChanged="handleChange" />
@code {
private PlayOption? playOption;
private void handleChange(PlayOptions.FastSlowIndicator fastSlowIndicator)
{
Console.WriteLine(fastSlowIndicator);
}
protected override async Task OnInitializedAsync()
{
+1 -3
View File
@@ -4,6 +4,4 @@
<h1>Hello, world!</h1>
Welcome to your new app.
<SurveyPrompt Title="How is Blazor working for you?"/>
Welcome to your new app.
+2
View File
@@ -10,5 +10,7 @@ builder.Services.AddScoped(sp => new HttpClient
{
BaseAddress = new Uri("http://localhost")
});
builder.Services.AddAntDesign();
await builder.Build().RunAsync();
+3
View File
@@ -1,4 +1,5 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="en">
<head>
@@ -8,6 +9,7 @@
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet"/>
<link href="GC-local-web-frontend.styles.css" rel="stylesheet" />
</head>
@@ -19,6 +21,7 @@
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_content/AntDesign/js/ant-design-blazor.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
+11
View File
@@ -0,0 +1,11 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
+20
View File
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.4" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="6.0.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedProject\SharedProject.csproj" />
</ItemGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31717.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MudAdmin", "MudAdmin.csproj", "{D6DF8A15-5B8D-4302-90D2-FC71264B18CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6DF8A15-5B8D-4302-90D2-FC71264B18CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6DF8A15-5B8D-4302-90D2-FC71264B18CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6DF8A15-5B8D-4302-90D2-FC71264B18CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6DF8A15-5B8D-4302-90D2-FC71264B18CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {58C61F27-917C-435B-8900-9B3CE8F8DCD4}
EndGlobalSection
EndGlobal
+18
View File
@@ -0,0 +1,18 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Counter</MudText>
<MudText Class="mb-4">Current count: @currentCount</MudText>
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="IncrementCount">Click me</MudButton>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
+62
View File
@@ -0,0 +1,62 @@
@page "/fetchdata"
@inject HttpClient Http
@using MudAdmin.Shared
<PageTitle>Weather forecast</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Weather forecast</MudText>
<MudText Class="mb-8">This component demonstrates fetching data from the server.</MudText>
@if (forecasts == null)
{
<MudProgressCircular Color="Color.Default" Indeterminate="true"/>
}
else
{
<MudTable Items="forecasts" Hover="true" SortLabel="Sort By" Elevation="0">
<HeaderContent>
<MudTh>
<MudTableSortLabel InitialDirection="SortDirection.Ascending" SortBy="new Func<WeatherForecast, object>(x=>x.Date)">Date</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureC)">Temp. (C)</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureF)">Temp. (F)</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.Summary!)">Summary</MudTableSortLabel>
</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Date">@context.Date</MudTd>
<MudTd DataLabel="Temp. (C)">@context.TemperatureC</MudTd>
<MudTd DataLabel="Temp. (F)">@context.TemperatureF</MudTd>
<MudTd DataLabel="Summary">@context.Summary</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager PageSizeOptions="new int[]{50, 100}"/>
</PagerContent>
</MudTable>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
+12
View File
@@ -0,0 +1,12 @@
@page "/"
<PageTitle>Index</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Hello, world!</MudText>
<MudText Class="mb-8">Welcome to your new app, powered by MudBlazor!</MudText>
<MudAlert Severity="Severity.Normal">
You can find documentation and examples on our website here:
<MudLink Href="https://mudblazor.com" Typo="Typo.body2" Color="Color.Inherit">
<b>www.mudblazor.com</b>
</MudLink>
</MudAlert>
+12
View File
@@ -0,0 +1,12 @@
@page "/user/{CardId:long}"
<PageTitle>User</PageTitle>
<MudText>@CardId</MudText>
@code {
[Parameter]
public long CardId { get; set; }
}
+49
View File
@@ -0,0 +1,49 @@
@page "/users"
@using models = SharedProject.models
@inject NavigationManager NavigationManager
<PageTitle>Users</PageTitle>
<MudGrid>
@foreach (var user in users)
{
<MudItem>
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h6">@user.PlayerName</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
<MudText Typo="Typo.h6">Card ID</MudText>
<MudText>@user.CardId</MudText>
</MudCardContent>
<MudCardActions>
<MudButton Variant="Variant.Text" Color="Color.Primary" OnClick="() => OnClick(user)">Test</MudButton>
</MudCardActions>
</MudCard>
</MudItem>
}
</MudGrid>
@code {
private List<models.User> users;
private static readonly Random RANDOM = Random.Shared;
protected override void OnInitialized()
{
base.OnInitialized();
users = new List<models.User>();
for (var i = 0; i < 5; i++)
{
users.Add(new models.User(RANDOM.NextInt64(7000000000000000, 8000000000000000), i.ToString()));
}
}
private void OnClick(models.User user)
{
NavigationManager.NavigateTo($"user/{user.CardId}");
}
}
+13
View File
@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudAdmin;
using MudBlazor.Services;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddMudServices();
await builder.Build().RunAsync();
+30
View File
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:65283",
"sslPort": 44398
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Mudblazor.Template": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
+35
View File
@@ -0,0 +1,35 @@
@inherits LayoutComponentBase
<MudThemeProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
<MudLayout>
<MudAppBar Elevation="0">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())"/>
<MudSpacer/>
<MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Inherit" Link="https://mudblazor.com/" Target="_blank"/>
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit" Link="https://github.com/MudBlazor/MudBlazor/" Target="_blank"/>
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" Elevation="1">
<MudDrawerHeader>
<MudText Typo="Typo.h6">MudAdmin</MudText>
</MudDrawerHeader>
<NavMenu/>
</MudDrawer>
<MudMainContent>
<MudContainer MaxWidth="MaxWidth.Large" Class="my-16 pt-16">
@Body
</MudContainer>
</MudMainContent>
</MudLayout>
@code {
bool _drawerOpen = true;
void DrawerToggle()
{
_drawerOpen = !_drawerOpen;
}
}
+6
View File
@@ -0,0 +1,6 @@
<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
<MudNavLink Href="fetchdata" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Fetch data</MudNavLink>
<MudNavLink Href="users" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Users</MudNavLink>
</MudNavMenu>
+11
View File
@@ -0,0 +1,11 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using MudBlazor
@using MudAdmin
@using MudAdmin.Shared
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>MudAdmin</title>
<base href="/" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
</head>
<body>
<div id="app">Loading...</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
</body>
</html>
+27
View File
@@ -0,0 +1,27 @@
[
{
"date": "2018-05-06",
"temperatureC": 1,
"summary": "Freezing"
},
{
"date": "2018-05-07",
"temperatureC": 14,
"summary": "Bracing"
},
{
"date": "2018-05-08",
"temperatureC": -13,
"summary": "Freezing"
},
{
"date": "2018-05-09",
"temperatureC": -16,
"summary": "Balmy"
},
{
"date": "2018-05-10",
"temperatureC": -2,
"summary": "Chilly"
}
]
@@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SharedProject</RootNamespace>
</PropertyGroup>
</Project>
@@ -1,4 +1,4 @@
namespace Shared.enums;
namespace SharedProject.enums;
public static class PlayOptions
{
@@ -1,6 +1,6 @@
using Shared.enums;
using SharedProject.enums;
namespace Shared.models;
namespace SharedProject.models;
public class PlayOption
{
+3
View File
@@ -0,0 +1,3 @@
namespace SharedProject.models;
public record User(long CardId, string PlayerName);
+3
View File
@@ -0,0 +1,3 @@
namespace SharedProject.models;
public record UserDetail(long CardId, string PlayerName, PlayOption PlayOption);