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 MudAdmin.Utils
|
||||
@using SharedProject.enums
|
||||
@inject HttpClient Client
|
||||
|
||||
<PageTitle>User</PageTitle>
|
||||
|
||||
@ -143,9 +144,9 @@ else
|
||||
|
||||
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 =
|
||||
{
|
||||
@ -159,18 +160,15 @@ else
|
||||
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)
|
||||
{
|
||||
feverTranceShow = userDetail.PlayOption.FeverTrance;
|
||||
fastSlowIndicator = userDetail.PlayOption.FastSlowIndicator;
|
||||
}
|
||||
songPlayDataList = MockDataRepo.GetMockDataRepo().SongPlayDataList;
|
||||
await base.OnInitializedAsync();
|
||||
userDetail = await Client.GetFromJsonAsync<UserDetail>($"api/UserDetail/{CardId}") ?? new();
|
||||
songPlayDataList = userDetail.SongPlayDataList ?? new List<SongPlayData>();
|
||||
feverTranceShow = userDetail.PlayOption.FeverTrance;
|
||||
fastSlowIndicator = userDetail.PlayOption.FastSlowIndicator;
|
||||
}
|
||||
|
||||
|
||||
private void OnShowDetailsClick(SongPlayData data)
|
||||
{
|
||||
data.ShowDetails = !data.ShowDetails;
|
||||
|
@ -1,8 +1,7 @@
|
||||
@page "/users"
|
||||
@using models = SharedProject.models
|
||||
@using GenFu
|
||||
@using MudAdmin.Utils
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject HttpClient Client
|
||||
|
||||
<PageTitle>Users</PageTitle>
|
||||
|
||||
@ -30,11 +29,12 @@
|
||||
|
||||
@code {
|
||||
private List<models.User> users = new();
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
base.OnInitialized();
|
||||
users = MockDataRepo.GetMockDataRepo().Users;
|
||||
await base.OnInitializedAsync();
|
||||
users = await Client.GetFromJsonAsync<List<models.User>>("api/Users") ?? new List<models.User>();
|
||||
}
|
||||
|
||||
private void OnClick(models.User user)
|
||||
|
@ -7,7 +7,10 @@ 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.AddScoped(sp => new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(builder.Configuration.GetValue<string>("BaseUrl"))
|
||||
});
|
||||
builder.Services.AddMudServices();
|
||||
|
||||
await builder.Build().RunAsync();
|
@ -48,7 +48,7 @@ public class MockDataRepo
|
||||
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…
Reference in New Issue
Block a user