Update to use server data instead of mock data
This commit is contained in:
parent
003f655585
commit
4871c0bf6f
@ -2,6 +2,7 @@
|
|||||||
@using SharedProject.models
|
@using SharedProject.models
|
||||||
@using MudAdmin.Utils
|
@using MudAdmin.Utils
|
||||||
@using SharedProject.enums
|
@using SharedProject.enums
|
||||||
|
@inject HttpClient Client
|
||||||
|
|
||||||
<PageTitle>User</PageTitle>
|
<PageTitle>User</PageTitle>
|
||||||
|
|
||||||
@ -143,9 +144,9 @@ else
|
|||||||
|
|
||||||
private UserDetail? userDetail;
|
private UserDetail? userDetail;
|
||||||
|
|
||||||
private List<SongPlayData> songPlayDataList = null!;
|
private List<SongPlayData> songPlayDataList = new();
|
||||||
|
|
||||||
private bool isSavingOptions = false;
|
private bool isSavingOptions;
|
||||||
|
|
||||||
private static readonly ScoreGradeMap[] GRADES =
|
private static readonly ScoreGradeMap[] GRADES =
|
||||||
{
|
{
|
||||||
@ -159,17 +160,14 @@ else
|
|||||||
new(990000, "S++"),
|
new(990000, "S++"),
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
|
||||||
var details = MockDataRepo.GetMockDataRepo().UserDetails;
|
|
||||||
userDetail = details.First(detail => detail.CardId == CardId);
|
|
||||||
if (userDetail != null)
|
|
||||||
{
|
{
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
userDetail = await Client.GetFromJsonAsync<UserDetail>($"api/UserDetail/{CardId}") ?? new();
|
||||||
|
songPlayDataList = userDetail.SongPlayDataList ?? new List<SongPlayData>();
|
||||||
feverTranceShow = userDetail.PlayOption.FeverTrance;
|
feverTranceShow = userDetail.PlayOption.FeverTrance;
|
||||||
fastSlowIndicator = userDetail.PlayOption.FastSlowIndicator;
|
fastSlowIndicator = userDetail.PlayOption.FastSlowIndicator;
|
||||||
}
|
}
|
||||||
songPlayDataList = MockDataRepo.GetMockDataRepo().SongPlayDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnShowDetailsClick(SongPlayData data)
|
private void OnShowDetailsClick(SongPlayData data)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
@page "/users"
|
@page "/users"
|
||||||
@using models = SharedProject.models
|
@using models = SharedProject.models
|
||||||
@using GenFu
|
|
||||||
@using MudAdmin.Utils
|
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject HttpClient Client
|
||||||
|
|
||||||
<PageTitle>Users</PageTitle>
|
<PageTitle>Users</PageTitle>
|
||||||
|
|
||||||
@ -31,10 +30,11 @@
|
|||||||
@code {
|
@code {
|
||||||
private List<models.User> users = new();
|
private List<models.User> users = new();
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
await base.OnInitializedAsync();
|
||||||
users = MockDataRepo.GetMockDataRepo().Users;
|
users = await Client.GetFromJsonAsync<List<models.User>>("api/Users") ?? new List<models.User>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick(models.User user)
|
private void OnClick(models.User user)
|
||||||
|
@ -7,7 +7,10 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|||||||
builder.RootComponents.Add<App>("#app");
|
builder.RootComponents.Add<App>("#app");
|
||||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||||
|
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
builder.Services.AddScoped(sp => new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri(builder.Configuration.GetValue<string>("BaseUrl"))
|
||||||
|
});
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
|
||||||
await builder.Build().RunAsync();
|
await builder.Build().RunAsync();
|
@ -48,7 +48,7 @@ public class MockDataRepo
|
|||||||
subDataList.Add(subData);
|
subDataList.Add(subData);
|
||||||
}
|
}
|
||||||
|
|
||||||
songPlayData.SongPlaySubDataList = subDataList;
|
songPlayData.SongPlaySubDataList = subDataList.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
10
MudAdmin/wwwroot/appsettings.json
Normal file
10
MudAdmin/wwwroot/appsettings.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug",
|
||||||
|
"System": "Information",
|
||||||
|
"Microsoft": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BaseUrl": "http://127.0.0.1"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user