Update admin pages (not complete)
This commit is contained in:
parent
39c5920dc5
commit
04be44cff1
@ -10,7 +10,7 @@
|
|||||||
<PackageReference Include="GenFu" Version="1.6.0" />
|
<PackageReference Include="GenFu" Version="1.6.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.4" />
|
<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="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.4" PrivateAssets="all" />
|
||||||
<PackageReference Include="MudBlazor" Version="6.0.9" />
|
<PackageReference Include="MudBlazor" Version="6.0.11-dev.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
@using SharedProject.models
|
@using SharedProject.models
|
||||||
@using MudAdmin.Utils
|
@using MudAdmin.Utils
|
||||||
@using SharedProject.enums
|
@using SharedProject.enums
|
||||||
@using GenFu
|
|
||||||
|
|
||||||
<PageTitle>User</PageTitle>
|
<PageTitle>User</PageTitle>
|
||||||
|
|
||||||
@ -42,6 +41,19 @@ else
|
|||||||
<MudSelectItem Value="@item">@item.GetHelpText()</MudSelectItem>
|
<MudSelectItem Value="@item">@item.GetHelpText()</MudSelectItem>
|
||||||
}
|
}
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
|
|
||||||
|
<MudButton Disabled="@isSavingOptions" OnClick="SaveOptions" Variant="Variant.Filled" Color="Color.Info">
|
||||||
|
@if (isSavingOptions)
|
||||||
|
{
|
||||||
|
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
|
||||||
|
<MudText Class="ms-2">Saving...</MudText>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudIcon Icon="@Icons.Filled.Save"></MudIcon>
|
||||||
|
<MudText>Save</MudText>
|
||||||
|
}
|
||||||
|
</MudButton>
|
||||||
</MudExpansionPanel>
|
</MudExpansionPanel>
|
||||||
<MudExpansionPanel Text="SongPlayData">
|
<MudExpansionPanel Text="SongPlayData">
|
||||||
<MudDataGrid T="SongPlayData" Items="@songPlayDataList" Sortable="true">
|
<MudDataGrid T="SongPlayData" Items="@songPlayDataList" Sortable="true">
|
||||||
@ -52,15 +64,27 @@ else
|
|||||||
<Column T="SongPlayData">
|
<Column T="SongPlayData">
|
||||||
<CellTemplate>
|
<CellTemplate>
|
||||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||||
OnClick="@(() => OnClick(context.Item))">
|
OnClick="@(() => OnShowDetailsClick(context.Item))">
|
||||||
@(context.Item.ShowDetails ? "Hide" : "Show") Song Play Details
|
@(context.Item.ShowDetails ? "Hide" : "Show") Song Play Details
|
||||||
</MudButton>
|
</MudButton>
|
||||||
</CellTemplate>
|
</CellTemplate>
|
||||||
</Column>
|
</Column>
|
||||||
|
<Column T="SongPlayData">
|
||||||
|
<CellTemplate>
|
||||||
|
<MudToggleIconButton ToggleChanged="@(() => OnFavoriteToggled(context.Item))"
|
||||||
|
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary" Title="Add to favorite"
|
||||||
|
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary" ToggledTitle="Remove from favorite"/>
|
||||||
|
</CellTemplate>
|
||||||
|
</Column>
|
||||||
<Column T="SongPlayData" Field="Title" Title="Song Title"/>
|
<Column T="SongPlayData" Field="Title" Title="Song Title"/>
|
||||||
<Column T="SongPlayData" Field="Artist" Title="Artist"/>
|
<Column T="SongPlayData" Field="Artist" Title="Artist"/>
|
||||||
<Column T="SongPlayData" Field="LastPlayTime" Title="Last Play Time"/>
|
<Column T="SongPlayData" Title="Total Play Count">
|
||||||
<Column T="SongPlayData" Field="TotalPlayCount" Title="Total Play Count"/>
|
<CellTemplate>
|
||||||
|
<MudText>
|
||||||
|
@CalculateTotalPlayCount(context.Item)
|
||||||
|
</MudText>
|
||||||
|
</CellTemplate>
|
||||||
|
</Column>
|
||||||
</Columns>
|
</Columns>
|
||||||
<ChildRowContent>
|
<ChildRowContent>
|
||||||
@if (context.ShowDetails)
|
@if (context.ShowDetails)
|
||||||
@ -77,16 +101,20 @@ else
|
|||||||
<MudTable Items="@context.SongPlaySubDataList" Context="SongPlayDetail" Elevation="0">
|
<MudTable Items="@context.SongPlaySubDataList" Context="SongPlayDetail" Elevation="0">
|
||||||
<HeaderContent>
|
<HeaderContent>
|
||||||
<MudTh>Difficulty</MudTh>
|
<MudTh>Difficulty</MudTh>
|
||||||
<MudTh>Score</MudTh>
|
|
||||||
<MudTh>Clear State</MudTh>
|
<MudTh>Clear State</MudTh>
|
||||||
<MudTh>Play Count</MudTh>
|
<MudTh>Play Count</MudTh>
|
||||||
|
<MudTh>Rating</MudTh>
|
||||||
|
<MudTh>Score</MudTh>
|
||||||
<MudTh>Max Chain</MudTh>
|
<MudTh>Max Chain</MudTh>
|
||||||
</HeaderContent>
|
</HeaderContent>
|
||||||
<RowTemplate>
|
<RowTemplate>
|
||||||
<MudTd DataLabel="Difficulty">@SongPlayDetail.Difficulty</MudTd>
|
<MudTd DataLabel="Difficulty">@SongPlayDetail.Difficulty</MudTd>
|
||||||
<MudTd DataLabel="Score">@SongPlayDetail.Score</MudTd>
|
<MudTd DataLabel="Clear State">
|
||||||
<MudTd DataLabel="Clear State">@SongPlayDetail.ClearState</MudTd>
|
@(SongPlayDetail.Score != 1000000 ? SongPlayDetail.ClearState : ClearState.Perfect)
|
||||||
|
</MudTd>
|
||||||
<MudTd DataLabel="Play Count">@SongPlayDetail.PlayCount</MudTd>
|
<MudTd DataLabel="Play Count">@SongPlayDetail.PlayCount</MudTd>
|
||||||
|
<MudTd DataLabel="Rating">@CalculateRating(SongPlayDetail.Score)</MudTd>
|
||||||
|
<MudTd DataLabel="Score">@SongPlayDetail.Score</MudTd>
|
||||||
<MudTd DataLabel="Max Chain">@SongPlayDetail.MaxChain</MudTd>
|
<MudTd DataLabel="Max Chain">@SongPlayDetail.MaxChain</MudTd>
|
||||||
</RowTemplate>
|
</RowTemplate>
|
||||||
</MudTable>
|
</MudTable>
|
||||||
@ -117,6 +145,20 @@ else
|
|||||||
|
|
||||||
private List<SongPlayData> songPlayDataList = null!;
|
private List<SongPlayData> songPlayDataList = null!;
|
||||||
|
|
||||||
|
private bool isSavingOptions = false;
|
||||||
|
|
||||||
|
private static readonly ScoreGradeMap[] GRADES =
|
||||||
|
{
|
||||||
|
new(0, "E"),
|
||||||
|
new(300000, "D"),
|
||||||
|
new(500000, "C"),
|
||||||
|
new(700000, "B"),
|
||||||
|
new(800000, "A"),
|
||||||
|
new(900000, "S"),
|
||||||
|
new(950000, "S+"),
|
||||||
|
new(990000, "S++"),
|
||||||
|
};
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
var details = MockDataRepo.GetMockDataRepo().UserDetails;
|
var details = MockDataRepo.GetMockDataRepo().UserDetails;
|
||||||
@ -129,9 +171,40 @@ else
|
|||||||
songPlayDataList = MockDataRepo.GetMockDataRepo().SongPlayDataList;
|
songPlayDataList = MockDataRepo.GetMockDataRepo().SongPlayDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick(SongPlayData data)
|
private void OnShowDetailsClick(SongPlayData data)
|
||||||
{
|
{
|
||||||
data.ShowDetails = !data.ShowDetails;
|
data.ShowDetails = !data.ShowDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SaveOptions()
|
||||||
|
{
|
||||||
|
isSavingOptions = true;
|
||||||
|
await Task.Delay(2000);
|
||||||
|
isSavingOptions = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ScoreGradeMap(int Score, string Grade)
|
||||||
|
{
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{{ Score = {Score}, Grade = {Grade} }}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CalculateRating(int score)
|
||||||
|
{
|
||||||
|
var grade = GRADES.Where(g => g.Score <= score).Select(g => g.Grade).Last();
|
||||||
|
return grade;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFavoriteToggled(SongPlayData data)
|
||||||
|
{
|
||||||
|
data.IsFavorite = !data.IsFavorite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int CalculateTotalPlayCount(SongPlayData data)
|
||||||
|
{
|
||||||
|
return data.SongPlaySubDataList
|
||||||
|
.Sum(detailData => detailData.PlayCount);
|
||||||
|
}
|
||||||
}
|
}
|
@ -33,12 +33,19 @@ public class MockDataRepo
|
|||||||
|
|
||||||
foreach (var difficulty in Enum.GetValues<Difficulty>())
|
foreach (var difficulty in Enum.GetValues<Difficulty>())
|
||||||
{
|
{
|
||||||
if (random.Next() > int.MaxValue / 2)
|
if (random.Next() <= int.MaxValue / 2)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var subData = GenFu.GenFu.New<SongPlayDetailData>();
|
var subData = GenFu.GenFu.New<SongPlayDetailData>();
|
||||||
subData.Difficulty = difficulty;
|
subData.Difficulty = difficulty;
|
||||||
subDataList.Add(subData);
|
|
||||||
|
if (subData.ClearState == ClearState.Perfect)
|
||||||
|
{
|
||||||
|
subData.ClearState = ClearState.FullChain;
|
||||||
}
|
}
|
||||||
|
subDataList.Add(subData);
|
||||||
}
|
}
|
||||||
|
|
||||||
songPlayData.SongPlaySubDataList = subDataList;
|
songPlayData.SongPlaySubDataList = subDataList;
|
||||||
@ -92,7 +99,6 @@ public class MockDataRepo
|
|||||||
GenFu.GenFu.Configure<SongPlayDetailData>()
|
GenFu.GenFu.Configure<SongPlayDetailData>()
|
||||||
.Fill(data => data.Score).WithinRange(0, 1000001);
|
.Fill(data => data.Score).WithinRange(0, 1000001);
|
||||||
GenFu.GenFu.Configure<SongPlayData>()
|
GenFu.GenFu.Configure<SongPlayData>()
|
||||||
.Fill(data => data.LastPlayTime).AsPastDate()
|
|
||||||
.Fill(data => data.ShowDetails, false);
|
.Fill(data => data.ShowDetails, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ public class SongPlayData
|
|||||||
|
|
||||||
public List<SongPlayDetailData> SongPlaySubDataList { get; set; } = new List<SongPlayDetailData>(4);
|
public List<SongPlayDetailData> SongPlaySubDataList { get; set; } = new List<SongPlayDetailData>(4);
|
||||||
|
|
||||||
public DateTime LastPlayTime { get; set; }
|
public bool IsFavorite { get; set; }
|
||||||
|
|
||||||
public int TotalPlayCount { get; set; }
|
|
||||||
|
|
||||||
public bool ShowDetails { get; set; }
|
public bool ShowDetails { get; set; }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user