2022-09-04 19:19:42 +02:00
|
|
|
@using SharedProject.Models.Responses
|
2022-09-06 16:32:36 +02:00
|
|
|
@using TaikoWebUI.Pages.Dialogs
|
|
|
|
@using SharedProject.Models
|
2022-09-04 19:19:42 +02:00
|
|
|
@inject HttpClient Client
|
2022-09-05 06:52:29 +02:00
|
|
|
@inject NavigationManager UriHelper
|
2022-09-06 16:32:36 +02:00
|
|
|
@inject IDialogService DialogService
|
2022-09-04 19:19:42 +02:00
|
|
|
|
2022-09-07 03:59:06 +02:00
|
|
|
@page "/"
|
2022-09-05 23:42:13 +02:00
|
|
|
|
|
|
|
<h1>Dashboard</h1>
|
|
|
|
|
2022-09-06 03:52:13 +02:00
|
|
|
<MudGrid Class="my-8">
|
2022-09-06 16:32:36 +02:00
|
|
|
@if (response is null)
|
|
|
|
{
|
|
|
|
@for (uint i = 0; i < 3; i++)
|
2022-09-07 03:59:06 +02:00
|
|
|
{
|
|
|
|
<MudItem xs="12" md="6" lg="4">
|
|
|
|
<MudCard Outlined="true">
|
|
|
|
<MudCardContent>
|
|
|
|
<MudSkeleton Width="30%" Height="42px;" Class="mb-5"/>
|
|
|
|
<MudSkeleton Width="80%"/>
|
|
|
|
<MudSkeleton Width="100%"/>
|
|
|
|
</MudCardContent>
|
|
|
|
<MudCardActions>
|
|
|
|
<MudStack Row="true" Style="width:100%" Spacing="4" Justify="Justify.FlexEnd">
|
|
|
|
<MudSkeleton Width="64px" Height="40px"/>
|
|
|
|
<MudSkeleton Width="64px" Height="40px"/>
|
|
|
|
</MudStack>
|
|
|
|
</MudCardActions>
|
|
|
|
</MudCard>
|
|
|
|
</MudItem>
|
2022-09-06 16:32:36 +02:00
|
|
|
}
|
2022-09-07 03:59:06 +02:00
|
|
|
}
|
|
|
|
else if (response.Users.Count != 0)
|
2022-09-06 16:32:36 +02:00
|
|
|
{
|
|
|
|
@foreach (var user in response.Users)
|
|
|
|
{
|
2022-09-07 03:59:06 +02:00
|
|
|
<MudItem xs="12" md="6" lg="4">
|
|
|
|
<MudCard Outlined="true">
|
|
|
|
<MudCardHeader>
|
|
|
|
<CardHeaderContent>
|
|
|
|
<MudText Typo="Typo.h6" Style="font-weight:bold">@user.Baid</MudText>
|
|
|
|
</CardHeaderContent>
|
|
|
|
</MudCardHeader>
|
|
|
|
<MudCardContent>
|
|
|
|
<MudText Style="font-weight:bold">Access Code</MudText>
|
|
|
|
<MudText Style="font-family:monospace">@user.AccessCode</MudText>
|
|
|
|
</MudCardContent>
|
|
|
|
<MudCardActions>
|
|
|
|
<MudStack Row="true" Style="width:100%" Spacing="4" Justify="Justify.FlexEnd">
|
|
|
|
<MudButton Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Delete"
|
2022-09-06 16:32:36 +02:00
|
|
|
Color="Color.Error"
|
|
|
|
OnClick="_ => DeleteCard(user)">
|
2022-09-07 03:59:06 +02:00
|
|
|
Delete
|
|
|
|
</MudButton>
|
|
|
|
<MudButton OnClick="() => NavigateToProfile(user.Baid)"
|
2022-09-06 16:32:36 +02:00
|
|
|
Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Edit"
|
|
|
|
Color="Color.Primary">
|
2022-09-07 03:59:06 +02:00
|
|
|
Edit
|
|
|
|
</MudButton>
|
|
|
|
</MudStack>
|
|
|
|
</MudCardActions>
|
|
|
|
</MudCard>
|
|
|
|
</MudItem>
|
2022-09-06 16:32:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-07 03:59:06 +02:00
|
|
|
<MudItem xs="12">
|
|
|
|
<MudText Align="Align.Center" Class="my-8">
|
|
|
|
No data.
|
|
|
|
</MudText>
|
|
|
|
</MudItem>
|
2022-09-06 03:52:13 +02:00
|
|
|
}
|
|
|
|
</MudGrid>
|
2022-09-04 19:19:42 +02:00
|
|
|
|
2022-09-06 16:32:36 +02:00
|
|
|
|
2022-09-04 19:19:42 +02:00
|
|
|
@code {
|
|
|
|
private DashboardResponse? response;
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
|
|
|
|
}
|
|
|
|
|
2022-09-05 06:52:29 +02:00
|
|
|
|
2022-09-05 17:01:54 +02:00
|
|
|
private void NavigateToProfile(uint baid)
|
2022-09-05 06:52:29 +02:00
|
|
|
{
|
|
|
|
UriHelper.NavigateTo($"/Card/{baid}");
|
|
|
|
}
|
2022-09-06 16:32:36 +02:00
|
|
|
|
|
|
|
private async Task DeleteCard(User user)
|
|
|
|
{
|
|
|
|
var parameters = new DialogParameters
|
2022-09-07 03:59:06 +02:00
|
|
|
{
|
|
|
|
["user"] = user
|
|
|
|
};
|
2022-09-06 16:32:36 +02:00
|
|
|
|
|
|
|
var dialog = DialogService.Show<CardDeleteConfirmDialog>("Delete Card", parameters);
|
|
|
|
var result = await dialog.Result;
|
|
|
|
|
|
|
|
if (result.Cancelled)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
|
|
|
|
}
|
|
|
|
|
2022-09-04 19:19:42 +02:00
|
|
|
}
|