1
0
mirror of synced 2024-12-21 02:45:54 +01:00
TaikoLocalServer/TaikoWebUI/Components/Song/SongLeaderboardCard.razor

115 lines
5.5 KiB
Plaintext
Raw Normal View History

2024-06-03 01:55:44 +02:00
@inject HttpClient Client;
2024-06-03 03:00:54 +02:00
@inject Blazored.LocalStorage.ILocalStorageService LocalStorage;
@inject NavigationManager NavigationManager
@inject AuthService AuthService
@using Microsoft.Extensions.Options;
@using TaikoWebUI.Settings;
2024-06-03 01:55:44 +02:00
@using TaikoWebUI.Utilities;
2024-06-03 01:29:33 +02:00
2024-06-03 01:55:44 +02:00
<MudCard Outlined="true" Elevation="0">
<MudCardHeader>
2024-06-03 17:03:09 +02:00
<MudGrid Spacing="2" Class="align-center pb-2">
2024-06-03 17:27:18 +02:00
<MudItem xs="6">
2024-06-03 01:55:44 +02:00
<MudText Typo="Typo.h6">@Localizer["Leaderboard"]</MudText>
</MudItem>
2024-06-03 03:00:54 +02:00
<MudItem xs="6">
<MudStack Justify="Justify.FlexEnd" Row="true">
<MudToggleGroup T="string" Label="@Localizer["Difficulty"]" Dense="true" ValueChanged="(value) => OnDifficultyChange(value)" Value="SelectedDifficulty" Style="width:300px">
@foreach (var difficulty in Enum.GetValues(typeof(Difficulty)))
2024-06-03 17:27:18 +02:00
{
2024-06-03 17:38:52 +02:00
if ((Difficulty)difficulty == Difficulty.None)
{
continue;
}
2024-06-03 17:27:18 +02:00
2024-06-03 17:38:52 +02:00
<MudToggleItem Value="@difficulty.ToString()">
<div class="d-flex align-center">
<img src="@($"/images/difficulty_{difficulty}.webp")" alt="@difficulty.ToString()" title="@difficulty.ToString()" style="@Constants.ICON_STYLE" />
2024-06-03 17:38:52 +02:00
</div>
</MudToggleItem>
2024-06-03 17:27:18 +02:00
}
</MudToggleGroup>
</MudStack>
2024-06-03 03:00:54 +02:00
</MudItem>
2024-06-03 01:55:44 +02:00
</MudGrid>
</MudCardHeader>
<MudCardContent Class="pa-0">
@if (response == null || response.LeaderboardData.Count == 0)
2024-06-03 17:03:09 +02:00
{
<MudGrid>
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-16">
2024-06-05 15:59:33 +02:00
@Localizer["No Data"]
2024-06-03 17:03:09 +02:00
</MudText>
</MudItem>
</MudGrid>
}
2024-06-03 03:00:54 +02:00
else
{
2024-10-31 15:39:45 +01:00
<MudTable RowClassFunc="@GetActiveRowClass" Loading="isLoading" Items="@LeaderboardScores" Class="leaderboard-table" Elevation="0" Outlined="false" Dense="true" Striped="false" Breakpoint=Breakpoint.None>
2024-06-03 03:00:54 +02:00
<HeaderContent>
<MudTh>@Localizer["Rank"]</MudTh>
<MudTh>@Localizer["Player"]</MudTh>
<MudTh>@Localizer["Score"]</MudTh>
<MudTh>@Localizer["Crown"]</MudTh>
<MudTh>@Localizer["Rank"]</MudTh>
</HeaderContent>
<RowTemplate>
@if (@context.Rank > 0 && @context.BestScore > 0)
{
<MudTd>@context.Rank</MudTd>
<MudTd>
@if (AuthService.IsAdmin)
{
<MudStack Row="true" Class="pointer" onclick="@{
() => UserChanged(context)
}" AlignItems="AlignItems.Baseline">
<MudText Typo="Typo.body1">@context.UserName</MudText>
<MudText Typo="Typo.caption" Style="color: #9E9E9E">(@Localizer["ID"]: @context.Baid)</MudText>
</MudStack>
}
else
{
<MudStack Row="true" AlignItems="AlignItems.Baseline">
<MudText Typo="Typo.body1">@context.UserName</MudText>
<MudText Typo="Typo.caption" Style="color: #9E9E9E">(@Localizer["ID"]: @context.Baid)</MudText>
</MudStack>
}
</MudTd>
<MudTd>@context.BestScore</MudTd>
<MudTd>
<img src="@($"/images/crown_{context.BestCrown}.webp")" alt="@(ScoreUtils.GetCrownText(context.BestCrown))" title="@(ScoreUtils.GetCrownText(context.BestCrown))" style="@Constants.ICON_STYLE" />
</MudTd>
<MudTd>
@if (context.BestScoreRank is not ScoreRank.None)
{
<img src="@($"/images/rank_{context.BestScoreRank}.webp")" alt="@(ScoreUtils.GetRankText(context.BestScoreRank))" title="@(ScoreUtils.GetRankText(context.BestScoreRank))" style="@Constants.ICON_STYLE" />
}
else
{
<MudText Typo="Typo.body1">—</MudText>
}
</MudTd>
}
else
{
<MudTd colspan="6">
<MudText Align="Align.Center" Class="my-1">
...
</MudText>
</MudTd>
}
</RowTemplate>
2024-06-03 03:00:54 +02:00
</MudTable>
@if (TotalPages > 1 && isPaginationEnabled)
{
<div class="d-flex flex-column align-center">
<MudPagination Class="pa-4" Rectangular="true" DisableElevation="true" Count="@TotalPages" Selected="currentPage" SelectedChanged="(page) => OnPageChange(page)" BoundaryCount="1" MiddleCount="3" />
</div>
}
2024-06-03 03:00:54 +02:00
}
</MudCardContent>
2024-06-03 01:55:44 +02:00
</MudCard>