1
0
mirror of synced 2024-11-24 06:50:15 +01:00

Merge pull request #1 from asesidaa/options-page

This commit is contained in:
asesidaa 2022-09-06 17:12:13 +08:00 committed by GitHub
commit 6814715ddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 178 additions and 111 deletions

View File

@ -19,4 +19,8 @@ public class UserSetting
public PlaySetting PlaySetting { get; set; } = new(); public PlaySetting PlaySetting { get; set; } = new();
public int NotesPosition { get; set; } public int NotesPosition { get; set; }
public string MyDonName { get; set; } = String.Empty;
public string Title { get; set; } = String.Empty;
} }

View File

@ -35,7 +35,9 @@ public class UserSettingsController : BaseController<UserSettingsController>
IsSkipOn = user.IsSkipOn, IsSkipOn = user.IsSkipOn,
NotesPosition = user.NotesPosition, NotesPosition = user.NotesPosition,
PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting), PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting),
ToneId = user.SelectedToneId ToneId = user.SelectedToneId,
MyDonName = user.MyDonName,
Title = user.Title
}; };
return Ok(response); return Ok(response);
} }
@ -58,6 +60,8 @@ public class UserSettingsController : BaseController<UserSettingsController>
user.SelectedToneId = userSetting.ToneId; user.SelectedToneId = userSetting.ToneId;
user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty; user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty;
user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting); user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting);
user.MyDonName = userSetting.MyDonName;
user.Title = userSetting.Title;
context.Update(user); context.Update(user);
await context.SaveChangesAsync(); await context.SaveChangesAsync();

View File

@ -4,86 +4,110 @@
@using SharedProject.Models @using SharedProject.Models
@inject HttpClient Client @inject HttpClient Client
<MudBreadcrumbs Items="_breadcrumbs" Class="px-0"></MudBreadcrumbs>
<h1>Card: @Baid</h1> <h1>Card: @Baid</h1>
@if (response is not null) @if (response is not null)
{ {
<MudStack> <MudGrid>
<MudSelect @bind-Value="@response.IsDisplayAchievement" <MudItem xs="12" md="8">
Label="Is Display Achievement Panel"> <MudPaper Class="py-8 px-8 my-8" Outlined="true">
<MudSelectItem Value="@true">On</MudSelectItem> <MudStack Spacing="6">
<MudSelectItem Value="@false">Off</MudSelectItem> <h2>Profile Options</h2>
</MudSelect>
<MudSelect @bind-Value="@response.IsSkipOn" <MudTextField @bind-Value="@response.MyDonName" Label="Name" Variant="Variant.Outlined"></MudTextField>
Label="Is Skip On">
<MudSelectItem Value="@true">On</MudSelectItem> <MudTextField @bind-Value="@response.Title" Label="Title" Variant="Variant.Outlined"></MudTextField>
<MudSelectItem Value="@false">Off</MudSelectItem>
</MudSelect> <MudSelect @bind-Value="@response.IsDisplayAchievement"
<MudSelect @bind-Value="@response.IsVoiceOn" Label="Display Achievement Panel">
Label="Is Voice On"> <MudSelectItem Value="@true">On</MudSelectItem>
<MudSelectItem Value="@true">On</MudSelectItem> <MudSelectItem Value="@false">Off</MudSelectItem>
<MudSelectItem Value="@false">Off</MudSelectItem> </MudSelect>
</MudSelect>
<MudSelect @bind-Value="@response.IsDisplayDanOnNamePlate" <MudSelect @bind-Value="@response.IsDisplayDanOnNamePlate"
Label="Should Dan be Displayed On Name Plate"> Label="Display Dan Rank on Name Plate">
<MudSelectItem Value="@true">On</MudSelectItem> <MudSelectItem Value="@true">On</MudSelectItem>
<MudSelectItem Value="@false">Off</MudSelectItem> <MudSelectItem Value="@false">Off</MudSelectItem>
</MudSelect> </MudSelect>
<MudSelect @bind-Value="@response.AchievementDisplayDifficulty" <MudSelect @bind-Value="@response.AchievementDisplayDifficulty"
Label="Difficulty Used on Achievement Panel"> Label="Achievement Panel Difficulty">
@foreach (var item in Enum.GetValues<Difficulty>()) @foreach (var item in Enum.GetValues<Difficulty>())
{ {
<MudSelectItem Value="@item"/> <MudSelectItem Value="@item" />
} }
</MudSelect> </MudSelect>
<MudSelect @bind-Value="@response.NotesPosition" </MudStack>
Label="Notes Position"> </MudPaper>
@for (var i = -5; i <= 5; i++)
{ <MudPaper Class="py-8 px-8 my-8" Outlined="true">
<MudSelectItem Value="@i"/> <MudStack Spacing="6">
} <h2>Song Options</h2>
</MudSelect> <MudGrid>
<MudSelect @bind-Value="@response.PlaySetting.RandomType" <MudItem xs="12" md="4">
Label="Random"> <MudStack Spacing="6">
@foreach (var item in Enum.GetValues<RandomType>()) <MudSwitch @bind-Checked="@response.PlaySetting.IsVanishOn" Label="Vanish" Color="Color.Primary" />
{
<MudSelectItem Value="@item"/> <MudSwitch @bind-Checked="@response.PlaySetting.IsInverseOn" Label="Inverse" Color="Color.Primary" />
}
</MudSelect> <MudSwitch @bind-Checked="@response.IsSkipOn" Label="Give Up" Color="Color.Primary" />
<MudSelect @bind-Value="@response.PlaySetting.Speed"
Label="Speed"> <MudSwitch @bind-Checked="@response.IsVoiceOn" Label="Voice" Color="Color.Primary" />
@for (uint i = 0; i < 15; i++) </MudStack>
{ </MudItem>
var index= i; <MudItem xs="12" md="8">
<MudSelectItem Value="@i">@speedStrings[index]</MudSelectItem> <MudStack Spacing="6">
} <MudSelect @bind-Value="@response.PlaySetting.Speed" Label="Speed">
</MudSelect> @for (uint i = 0; i < 15; i++)
<MudSelect @bind-Value="@response.PlaySetting.IsInverseOn" {
Label="Inverse"> var index = i;
<MudSelectItem Value="@true">On</MudSelectItem> <MudSelectItem Value="@i">@speedStrings[index]</MudSelectItem>
<MudSelectItem Value="@false">Off</MudSelectItem> }
</MudSelect> </MudSelect>
<MudSelect @bind-Value="@response.PlaySetting.IsVanishOn"
Label="Vanish"> <MudSelect @bind-Value="@response.PlaySetting.RandomType"
<MudSelectItem Value="@true">On</MudSelectItem> Label="Random">
<MudSelectItem Value="@false">Off</MudSelectItem> @foreach (var item in Enum.GetValues<RandomType>())
</MudSelect> {
<MudButton Disabled="@isSavingOptions" <MudSelectItem Value="@item" />
OnClick="SaveOptions" }
Variant="Variant.Filled" </MudSelect>
Color="Color.Info">
@if (isSavingOptions) <MudSlider Class="mb-8" @bind-Value="@response.NotesPosition" Size="Size.Medium" Min="-5" Max="5" Step="1" TickMarks="true" TickMarkLabels="@notePositionStrings">
{ <MudText Typo="Typo.caption">Notes Position</MudText>
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/> </MudSlider>
<MudText Class="ms-2">Saving...</MudText> </MudStack>
} </MudItem>
else </MudGrid>
{ </MudStack>
<MudIcon Icon="@Icons.Filled.Save"></MudIcon> </MudPaper>
<MudText>Save</MudText> </MudItem>
} <MudItem md="4" xs="12" Class="py-8 px-8 my-4 pt-8">
</MudButton> <MudStack Spacing="6" Style="top:100px" Class="sticky">
</MudStack> <MudButton Disabled="@isSavingOptions"
OnClick="SaveOptions"
Variant="Variant.Filled"
Color="Color.Primary">
@if (isSavingOptions)
{
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true" />
<MudText Class="ms-2">Saving...</MudText>
}
else
{
<MudIcon Icon="@Icons.Filled.Save" Class="mx-2"></MudIcon>
<MudText>Save</MudText>
}
</MudButton>
</MudStack>
</MudItem>
</MudGrid>
<MudScrollToTop>
<MudFab Color="Color.Secondary" Icon="@Icons.Filled.ArrowCircleUp" />
</MudScrollToTop>
} }
@code { @code {
@ -98,11 +122,20 @@
private readonly string[] speedStrings = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", private readonly string[] speedStrings = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9",
"2.0", "2.5", "3.0", "3.5", "4.0"}; "2.0", "2.5", "3.0", "3.5", "4.0"};
private readonly string[] notePositionStrings = new string[] { "-5", "-4", "-3", "-2", "-1", "0", "+1", "+2", "+3", "+4", "+5"};
private List<BreadcrumbItem> _breadcrumbs = new List<BreadcrumbItem>
{
new BreadcrumbItem("Dashboard", href: "Dashboard"),
};
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
isSavingOptions = false; isSavingOptions = false;
response = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}"); response = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
_breadcrumbs.Add(new BreadcrumbItem($"Card: {Baid}", href: null, disabled: true));
} }
private async Task SaveOptions() private async Task SaveOptions()
@ -111,5 +144,4 @@
await Client.PostAsJsonAsync($"api/UserSettings/{Baid}", response); await Client.PostAsJsonAsync($"api/UserSettings/{Baid}", response);
isSavingOptions = false; isSavingOptions = false;
} }
} }

View File

@ -3,45 +3,75 @@
@inject NavigationManager UriHelper @inject NavigationManager UriHelper
@page "/Dashboard" @page "/Dashboard"
<MudContainer>
@if (response is null) <h1>Dashboard</h1>
{
<MudText>No Data</MudText> <MudGrid Class="my-8">
} @if (response is null)
else {
{ @if (isLoading is true) {
<MudGrid> @for (uint i = 0; i < 3; i++) {
@foreach (var user in response.Users) <MudItem xs="12" md="6" lg="4">
{ <MudCard Outlined="true">
<MudItem>
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h5">Baid @user.Baid</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton OnClick="() => NavigateToProfile(user.Baid)" Icon="@Icons.Material.Filled.Settings" Color="Color.Default" />
</CardHeaderActions>
</MudCardHeader>
<MudCardContent> <MudCardContent>
<MudText Typo="Typo.h6">Access Code</MudText> <MudSkeleton Width="30%" Height="42px;" Class="mb-5" />
<MudText>@user.AccessCode</MudText> <MudSkeleton Width="80%" />
<MudSkeleton Width="100%" />
</MudCardContent> </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> </MudCard>
</MudItem> </MudItem>
} }
</MudGrid> } else {
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
No data.
</MudText>
</MudItem>
} }
}
</MudContainer> else
{
@foreach (var user in response.Users)
{
<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" Color="Color.Error">Delete</MudButton>
<MudButton OnClick="() => NavigateToProfile(user.Baid)" Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Edit" Color="Color.Primary">Edit</MudButton>
</MudStack>
</MudCardActions>
</MudCard>
</MudItem>
}
}
</MudGrid>
@code { @code {
private DashboardResponse? response; private DashboardResponse? response;
private bool isLoading = true;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard"); response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
isLoading = false;
} }

View File

@ -7,9 +7,6 @@
<MudLayout> <MudLayout>
<MudAppBar Elevation="0"> <MudAppBar Elevation="0">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())"/> <MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())"/>
<MudSpacer/>
<MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Inherit" Link="https://mudblazor.com/" Target="_blank"/>
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit" Link="https://github.com/MudBlazor/MudBlazor/" Target="_blank"/>
</MudAppBar> </MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" Elevation="1"> <MudDrawer @bind-Open="_drawerOpen" Elevation="1">
<MudDrawerHeader> <MudDrawerHeader>
@ -18,7 +15,7 @@
<NavMenu/> <NavMenu/>
</MudDrawer> </MudDrawer>
<MudMainContent> <MudMainContent>
<MudContainer MaxWidth="MaxWidth.Large" Class="my-8 pt-8"> <MudContainer MaxWidth="MaxWidth.Large" Class="my-8">
@Body @Body
</MudContainer> </MudContainer>
</MudMainContent> </MudMainContent>

View File

@ -1,6 +1,6 @@
<MudNavMenu> <MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink> @* <MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink> <MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
<MudNavLink Href="fetchdata" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Fetch data</MudNavLink> <MudNavLink Href="fetchdata" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Fetch data</MudNavLink>*@
<MudNavLink Href="Dashboard" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Dashboard">Dashboard</MudNavLink> <MudNavLink Href="Dashboard" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Dashboard">Dashboard</MudNavLink>
</MudNavMenu> </MudNavMenu>