diff --git a/TaikoLocalServer.sln b/TaikoLocalServer.sln index 353d155..821218b 100644 --- a/TaikoLocalServer.sln +++ b/TaikoLocalServer.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaikoLocalServer", "TaikoLo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProject\SharedProject.csproj", "{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaikoWebUI", "TaikoWebUI\TaikoWebUI.csproj", "{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Debug|Any CPU.Build.0 = Debug|Any CPU {34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Release|Any CPU.ActiveCfg = Release|Any CPU {34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Release|Any CPU.Build.0 = Release|Any CPU + {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TaikoLocalServer/Controllers/Api/DashboardController.cs b/TaikoLocalServer/Controllers/Api/DashboardController.cs index 1dddd88..de56d60 100644 --- a/TaikoLocalServer/Controllers/Api/DashboardController.cs +++ b/TaikoLocalServer/Controllers/Api/DashboardController.cs @@ -19,7 +19,11 @@ public class DashboardController : BaseController public DashboardResponse GetDashboard() { var cards = context.Cards.AsEnumerable(); - var users = cards.Select(card => card.CopyPropertiesToNew()).ToList(); + var users = cards.Select(card => new User + { + AccessCode = card.AccessCode, + Baid = card.Baid + }).ToList(); return new DashboardResponse { Users = users diff --git a/TaikoLocalServer/Program.cs b/TaikoLocalServer/Program.cs index 4116e29..e800843 100644 --- a/TaikoLocalServer/Program.cs +++ b/TaikoLocalServer/Program.cs @@ -34,6 +34,16 @@ builder.Services.AddHttpLogging(options => HttpLoggingFields.ResponseStatusCode; }); builder.Services.AddMemoryCache(); +builder.Services.AddCors(options => +{ + options.AddPolicy("DevCorsPolicy", builder => + { + builder + .AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + }); +}); var app = builder.Build(); @@ -52,6 +62,7 @@ app.UseForwardedHeaders(new ForwardedHeadersOptions app.UseHttpLogging(); app.MapControllers(); +app.UseCors("DevCorsPolicy"); app.UseWhen(context => context.Request.Path.StartsWithSegments("/sys/servlet/PowerOn", StringComparison.InvariantCulture), applicationBuilder => applicationBuilder.UseAllNetRequestMiddleware()); diff --git a/TaikoWebUI/App.razor b/TaikoWebUI/App.razor new file mode 100644 index 0000000..dcdcd36 --- /dev/null +++ b/TaikoWebUI/App.razor @@ -0,0 +1,11 @@ + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
\ No newline at end of file diff --git a/TaikoWebUI/Pages/Counter.razor b/TaikoWebUI/Pages/Counter.razor new file mode 100644 index 0000000..cf7aaff --- /dev/null +++ b/TaikoWebUI/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +Counter +Current count: @currentCount +Click me + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } + +} \ No newline at end of file diff --git a/TaikoWebUI/Pages/Dashboard.razor b/TaikoWebUI/Pages/Dashboard.razor new file mode 100644 index 0000000..02e521a --- /dev/null +++ b/TaikoWebUI/Pages/Dashboard.razor @@ -0,0 +1,43 @@ +@using SharedProject.Models.Responses +@inject HttpClient Client + +@page "/Dashboard" + + @if (response is null) + { + No Data + } + else + { + + @foreach (var user in response.Users) + { + + + + + Baid @user.Baid + + + + Access Code + @user.AccessCode + + + + } + + } + + + +@code { + private DashboardResponse? response; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + response = await Client.GetFromJsonAsync("api/Dashboard"); + } + +} \ No newline at end of file diff --git a/TaikoWebUI/Pages/FetchData.razor b/TaikoWebUI/Pages/FetchData.razor new file mode 100644 index 0000000..e0050a9 --- /dev/null +++ b/TaikoWebUI/Pages/FetchData.razor @@ -0,0 +1,62 @@ +@page "/fetchdata" +@inject HttpClient Http +@using TaikoWebUI.Shared + +Weather forecast + +Weather forecast +This component demonstrates fetching data from the server. +@if (forecasts == null) +{ + +} +else +{ + + + + Date + + + Temp. (C) + + + Temp. (F) + + + Summary + + + + @context.Date + @context.TemperatureC + @context.TemperatureF + @context.Summary + + + + + +} + + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + forecasts = await Http.GetFromJsonAsync("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); + } + +} \ No newline at end of file diff --git a/TaikoWebUI/Pages/Index.razor b/TaikoWebUI/Pages/Index.razor new file mode 100644 index 0000000..62270c4 --- /dev/null +++ b/TaikoWebUI/Pages/Index.razor @@ -0,0 +1,12 @@ +@page "/" + +Index + +Hello, world! +Welcome to your new app, powered by MudBlazor! + + You can find documentation and examples on our website here: + + www.mudblazor.com + + \ No newline at end of file diff --git a/TaikoWebUI/Program.cs b/TaikoWebUI/Program.cs new file mode 100644 index 0000000..8e3eca2 --- /dev/null +++ b/TaikoWebUI/Program.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using TaikoWebUI; +using MudBlazor.Services; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); +builder.RootComponents.Add("#app"); +builder.RootComponents.Add("head::after"); + +builder.Services.AddScoped(sp => new HttpClient +{ + BaseAddress = new Uri(builder.Configuration.GetValue("BaseUrl")) +}); +builder.Services.AddMudServices(); + +await builder.Build().RunAsync(); \ No newline at end of file diff --git a/TaikoWebUI/Properties/launchSettings.json b/TaikoWebUI/Properties/launchSettings.json new file mode 100644 index 0000000..bb34c40 --- /dev/null +++ b/TaikoWebUI/Properties/launchSettings.json @@ -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" + } + } + } +} diff --git a/TaikoWebUI/Shared/MainLayout.razor b/TaikoWebUI/Shared/MainLayout.razor new file mode 100644 index 0000000..efafd95 --- /dev/null +++ b/TaikoWebUI/Shared/MainLayout.razor @@ -0,0 +1,35 @@ +@inherits LayoutComponentBase + + + + + + + + + + + + + + + TaikoWebUI + + + + + + @Body + + + + +@code { + bool _drawerOpen = true; + + void DrawerToggle() + { + _drawerOpen = !_drawerOpen; + } + +} \ No newline at end of file diff --git a/TaikoWebUI/Shared/NavMenu.razor b/TaikoWebUI/Shared/NavMenu.razor new file mode 100644 index 0000000..f3934ee --- /dev/null +++ b/TaikoWebUI/Shared/NavMenu.razor @@ -0,0 +1,6 @@ + + Home + Counter + Fetch data + Dashboard + \ No newline at end of file diff --git a/TaikoWebUI/TaikoWebUI.csproj b/TaikoWebUI/TaikoWebUI.csproj new file mode 100644 index 0000000..8e55718 --- /dev/null +++ b/TaikoWebUI/TaikoWebUI.csproj @@ -0,0 +1,20 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TaikoWebUI/TaikoWebUI.sln b/TaikoWebUI/TaikoWebUI.sln new file mode 100644 index 0000000..db9a9e0 --- /dev/null +++ b/TaikoWebUI/TaikoWebUI.sln @@ -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}") = "TaikoWebUI", "TaikoWebUI.csproj", "{9A018EAA-0916-4719-B866-0AE17E279AD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9A018EAA-0916-4719-B866-0AE17E279AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A018EAA-0916-4719-B866-0AE17E279AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A018EAA-0916-4719-B866-0AE17E279AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A018EAA-0916-4719-B866-0AE17E279AD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8B394E62-3C53-4284-A4FA-21AD0FA9AEB8} + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/TaikoWebUI/_Imports.razor b/TaikoWebUI/_Imports.razor new file mode 100644 index 0000000..6a7c60c --- /dev/null +++ b/TaikoWebUI/_Imports.razor @@ -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 TaikoWebUI +@using TaikoWebUI.Shared \ No newline at end of file diff --git a/TaikoWebUI/wwwroot/appsettings.json b/TaikoWebUI/wwwroot/appsettings.json new file mode 100644 index 0000000..b06bbde --- /dev/null +++ b/TaikoWebUI/wwwroot/appsettings.json @@ -0,0 +1,3 @@ +{ + "BaseUrl": "http://192.168.50.239:5000" +} \ No newline at end of file diff --git a/TaikoWebUI/wwwroot/favicon.ico b/TaikoWebUI/wwwroot/favicon.ico new file mode 100644 index 0000000..1239223 Binary files /dev/null and b/TaikoWebUI/wwwroot/favicon.ico differ diff --git a/TaikoWebUI/wwwroot/index.html b/TaikoWebUI/wwwroot/index.html new file mode 100644 index 0000000..e3ed8a1 --- /dev/null +++ b/TaikoWebUI/wwwroot/index.html @@ -0,0 +1,25 @@ + + + + + + + TaikoWebUI + + + + + + +
Loading...
+ +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + \ No newline at end of file diff --git a/TaikoWebUI/wwwroot/sample-data/weather.json b/TaikoWebUI/wwwroot/sample-data/weather.json new file mode 100644 index 0000000..06463c0 --- /dev/null +++ b/TaikoWebUI/wwwroot/sample-data/weather.json @@ -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" + } +]