From 510fb6ce001b9db0d4be11071283fccd82347677 Mon Sep 17 00:00:00 2001 From: shiibe Date: Sat, 10 Sep 2022 00:56:53 -0400 Subject: [PATCH] Refactor url structure, clean up play results --- TaikoWebUI/Pages/Cards.razor | 112 ++++++++++++++++++ TaikoWebUI/Pages/Dashboard.razor | 67 +---------- TaikoWebUI/Pages/PlayResults.razor | 88 ++++++++------ .../Pages/{Card.razor => Profile.razor} | 8 +- TaikoWebUI/Shared/MainLayout.razor | 2 +- TaikoWebUI/Shared/NavMenu.razor | 3 +- 6 files changed, 174 insertions(+), 106 deletions(-) create mode 100644 TaikoWebUI/Pages/Cards.razor rename TaikoWebUI/Pages/{Card.razor => Profile.razor} (96%) diff --git a/TaikoWebUI/Pages/Cards.razor b/TaikoWebUI/Pages/Cards.razor new file mode 100644 index 0000000..5fe71c8 --- /dev/null +++ b/TaikoWebUI/Pages/Cards.razor @@ -0,0 +1,112 @@ +@using SharedProject.Models.Responses +@using TaikoWebUI.Pages.Dialogs +@using SharedProject.Models +@inject HttpClient Client +@inject IDialogService DialogService + +@page "/Cards" + +

Cards

+ + + @if (response is null) + { + @for (uint i = 0; i < 3; i++) + { + + + + + + + + + + + + + + + + } + } + else if (response.Users.Count != 0) + { + @foreach (var user in response.Users) + { + + + + + @user.Baid + + + + + Delete Card + + + + + + Access Code + @user.AccessCode + + + + + View Play Data + + + Edit Profile + + + + + + } + } + else + { + + + No data. + + + } + + + +@code { + private DashboardResponse? response; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + response = await Client.GetFromJsonAsync("api/Dashboard"); + } + + private async Task DeleteCard(User user) + { + var parameters = new DialogParameters + { + ["user"] = user + }; + + var dialog = DialogService.Show("Delete Card", parameters); + var result = await dialog.Result; + + if (result.Cancelled) + { + return; + } + + response = await Client.GetFromJsonAsync("api/Dashboard"); + } + +} \ No newline at end of file diff --git a/TaikoWebUI/Pages/Dashboard.razor b/TaikoWebUI/Pages/Dashboard.razor index 7101945..f503c33 100644 --- a/TaikoWebUI/Pages/Dashboard.razor +++ b/TaikoWebUI/Pages/Dashboard.razor @@ -9,70 +9,9 @@

Dashboard

- - @if (response is null) - { - @for (uint i = 0; i < 3; i++) - { - - - - - - - - - - - - - - - - } - } - else if (response.Users.Count != 0) - { - @foreach (var user in response.Users) - { - - - - - @user.Baid - - - - Access Code - @user.AccessCode - - - - - Delete - - - Edit - - - - - - } - } - else - { - - - No data. - - - } - + + Welcome to TaikoWebUI! + @code { diff --git a/TaikoWebUI/Pages/PlayResults.razor b/TaikoWebUI/Pages/PlayResults.razor index 8a76e13..30a0c30 100644 --- a/TaikoWebUI/Pages/PlayResults.razor +++ b/TaikoWebUI/Pages/PlayResults.razor @@ -5,50 +5,56 @@ @inject IGameDataService GameDataService @inject HttpClient Client -@page "/PlayResults/{baid:int}" -

PlayResults for baid : @Baid

+@page "/Cards/{baid:int}/PlayResults" + + +

Play Data

+Card: @Baid + + @if (response is null) { - No data + + + No data. + + } else { - - - @* Notice here we have to use cell template for custom conversion *@ - @* Field is retrieved using reflection, so it is a string with name equals field name*@ - - - @GameDataService.GetMusicNameBySongId(context.Item.SongId) - - - - - @GameDataService.GetMusicArtistBySongId(context.Item.SongId) - - - - - - - - - - - - - - - - - + + + + + + @GameDataService.GetMusicNameBySongId(context.Item.SongId) + @GameDataService.GetMusicArtistBySongId(context.Item.SongId) + + + + + + + + + + + + + + + + + + } + @code { @@ -58,10 +64,18 @@ else private SongBestResponse? response; + private List breadcrumbs = new() + { + new BreadcrumbItem("Cards", href: "/Cards"), + }; + protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); response = await Client.GetFromJsonAsync($"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) diff --git a/TaikoWebUI/Pages/Card.razor b/TaikoWebUI/Pages/Profile.razor similarity index 96% rename from TaikoWebUI/Pages/Card.razor rename to TaikoWebUI/Pages/Profile.razor index e04e583..a224910 100644 --- a/TaikoWebUI/Pages/Card.razor +++ b/TaikoWebUI/Pages/Profile.razor @@ -1,11 +1,12 @@ -@page "/Card/{baid:int}" +@page "/Cards/{baid:int}/Profile" @using SharedProject.Enums @using SharedProject.Models @inject HttpClient Client -

Card: @Baid

+

Profile

+Card: @Baid @if (response is not null) { @@ -153,7 +154,7 @@ private List breadcrumbs = new() { - new BreadcrumbItem("Dashboard", href: ""), + new BreadcrumbItem("Cards", href: "/Cards"), }; protected override async Task OnInitializedAsync() @@ -163,6 +164,7 @@ response = await Client.GetFromJsonAsync($"api/UserSettings/{Baid}"); breadcrumbs.Add(new BreadcrumbItem($"Card: {Baid}", href: null, disabled: true)); + breadcrumbs.Add(new BreadcrumbItem("Profile", href: $"/Cards/{Baid}/Profile", disabled: false)); } private async Task SaveOptions() diff --git a/TaikoWebUI/Shared/MainLayout.razor b/TaikoWebUI/Shared/MainLayout.razor index bcd814b..c9c4d91 100644 --- a/TaikoWebUI/Shared/MainLayout.razor +++ b/TaikoWebUI/Shared/MainLayout.razor @@ -15,7 +15,7 @@ - + @Body diff --git a/TaikoWebUI/Shared/NavMenu.razor b/TaikoWebUI/Shared/NavMenu.razor index 7c12347..47eff76 100644 --- a/TaikoWebUI/Shared/NavMenu.razor +++ b/TaikoWebUI/Shared/NavMenu.razor @@ -1,3 +1,4 @@  - Dashboard + Dashboard + Cards \ No newline at end of file