96 lines
3.6 KiB
Plaintext
96 lines
3.6 KiB
Plaintext
@using TaikoWebUI.Services
|
|
@using SharedProject.Models.Responses
|
|
@using SharedProject.Models
|
|
@using SharedProject.Models.Requests
|
|
@inject IGameDataService GameDataService
|
|
@inject HttpClient Client
|
|
|
|
@page "/Cards/{baid:int}/PlayResults"
|
|
|
|
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
|
|
|
|
<h1>Play Data</h1>
|
|
<MudText Typo="Typo.caption">Card: @Baid</MudText>
|
|
|
|
<MudGrid Class="my-8">
|
|
@if (response is null)
|
|
{
|
|
<MudItem xs="12">
|
|
<MudText Align="Align.Center">
|
|
No data.
|
|
</MudText>
|
|
</MudItem>
|
|
}
|
|
else
|
|
{
|
|
<MudItem xs="12">
|
|
<MudDataGrid Items="@response.SongBestData">
|
|
<Columns>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.SongId)" Title="Song">
|
|
<CellTemplate>
|
|
<MudText Typo="Typo.body2" Style="font-weight:bold">@GameDataService.GetMusicNameBySongId(context.Item.SongId)</MudText>
|
|
<MudText Typo="Typo.caption">@GameDataService.GetMusicArtistBySongId(context.Item.SongId)</MudText>
|
|
</CellTemplate>
|
|
</Column>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.Difficulty)" Title="Difficulty"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestScore)" Title="Best Score"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestCrown)" Title="Best Crown"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestScoreRank)" Title="Best Rank" />
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.BestRate)" Title="Best Rate"/>
|
|
<Column T="SongBestData" Field="@nameof(SongBestData.IsFavorite)" Title="Favorite">
|
|
<CellTemplate>
|
|
<MudToggleIconButton Toggled="@context.Item.IsFavorite"
|
|
ToggledChanged="@(async () => await OnFavoriteToggled(context.Item))"
|
|
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
|
|
Title="Add to favorites"
|
|
ToggledIcon="@Icons.Material.Filled.Favorite" ToggledColor="@Color.Secondary"
|
|
ToggledTitle="Remove from favorites"/>
|
|
</CellTemplate>
|
|
</Column>
|
|
</Columns>
|
|
<PagerContent>
|
|
<MudDataGridPager T="SongBestData"/>
|
|
</PagerContent>
|
|
</MudDataGrid>
|
|
</MudItem>
|
|
}
|
|
</MudGrid>
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public int Baid { get; set; }
|
|
|
|
private SongBestResponse? response;
|
|
|
|
private List<BreadcrumbItem> breadcrumbs = new()
|
|
{
|
|
new BreadcrumbItem("Cards", href: "/Cards"),
|
|
};
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
response = await Client.GetFromJsonAsync<SongBestResponse>($"api/PlayData/{Baid}");
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem($"Card: {Baid}", href: null, disabled: true));
|
|
breadcrumbs.Add(new BreadcrumbItem("Play Data", href: $"/Cards/{Baid}/PlayResults", disabled: false));
|
|
}
|
|
|
|
private async Task OnFavoriteToggled(SongBestData data)
|
|
{
|
|
var request = new SetFavoriteRequest
|
|
{
|
|
Baid = (uint)Baid,
|
|
IsFavorite = !data.IsFavorite,
|
|
SongId = data.SongId
|
|
};
|
|
var result = await Client.PostAsJsonAsync("api/FavoriteSongs", request);
|
|
if (result.IsSuccessStatusCode)
|
|
{
|
|
data.IsFavorite = !data.IsFavorite;
|
|
}
|
|
}
|
|
|
|
} |