Merge pull request #25 from AkaiiKitsune/Mobile-UI-Fixes
Fixed dialogs not being displayed on phone and tweaked access code binding
This commit is contained in:
commit
651c2d91f2
@ -67,7 +67,7 @@ public partial class AccessCode
|
|||||||
{
|
{
|
||||||
if (response != null)
|
if (response != null)
|
||||||
{
|
{
|
||||||
var result = await LoginService.BindAccessCode(inputAccessCode, Client);
|
var result = await LoginService.BindAccessCode(inputAccessCode.ToUpper().Trim(), response.Users.First(u => u.Baid == Baid), Client);
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -106,6 +106,13 @@ public partial class AccessCode
|
|||||||
"Access code cannot be empty.<br />Please enter a valid access code.",
|
"Access code cannot be empty.<br />Please enter a valid access code.",
|
||||||
"Ok");
|
"Ok");
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
await DialogService.ShowMessageBox(
|
||||||
|
"Error",
|
||||||
|
(MarkupString)
|
||||||
|
"You can't do that!<br />You need to be an admin to edit someone else's access codes.",
|
||||||
|
"Ok");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,41 +26,42 @@ public partial class Register
|
|||||||
if (response != null)
|
if (response != null)
|
||||||
{
|
{
|
||||||
var result = await LoginService.Register(accessCode, inputDateTime, password, confirmPassword, response, Client);
|
var result = await LoginService.Register(accessCode, inputDateTime, password, confirmPassword, response, Client);
|
||||||
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"Only admin can log in.",
|
"Only admin can log in.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
NavigationManager.NavigateTo("/Users");
|
NavigationManager.NavigateTo("/Users");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Success",
|
"Success",
|
||||||
"Access code registered successfully.",
|
"Access code registered successfully.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
NavigationManager.NavigateTo("/Users");
|
NavigationManager.NavigateTo("/Users");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"Confirm password is not the same as password.",
|
"Confirm password is not the same as password.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
(MarkupString)
|
(MarkupString)
|
||||||
"Access code not found.<br />Please play one game with this access code to register it.",
|
"Access code not found.<br />Please play one game with this access code to register it.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
(MarkupString)
|
(MarkupString)
|
||||||
"Access code is already registered, please use set password to login.",
|
"Access code is already registered, please use set password to login.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
NavigationManager.NavigateTo("/Users");
|
NavigationManager.NavigateTo("/Users");
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
@ -68,7 +69,7 @@ public partial class Register
|
|||||||
"Error",
|
"Error",
|
||||||
(MarkupString)
|
(MarkupString)
|
||||||
"Wrong last play time.<br />If you have forgotten when you last played, please play another game with this access code.",
|
"Wrong last play time.<br />If you have forgotten when you last played, please play another game with this access code.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
<MudItem xs="12" md="6" lg="4">
|
<MudItem xs="12" md="6" lg="4">
|
||||||
<MudCard Outlined="true">
|
<MudCard Outlined="true">
|
||||||
<MudCardContent>
|
<MudCardContent>
|
||||||
<MudSkeleton Width="30%" Height="42px;" Class="mb-5"/>
|
<MudSkeleton Width="30%" Height="42px;" Class="mb-5" />
|
||||||
<MudSkeleton Width="80%"/>
|
<MudSkeleton Width="80%" />
|
||||||
<MudSkeleton Width="100%"/>
|
<MudSkeleton Width="100%" />
|
||||||
</MudCardContent>
|
</MudCardContent>
|
||||||
<MudCardActions>
|
<MudCardActions>
|
||||||
<MudStack Row="true" Style="width:100%" Spacing="4" Justify="Justify.FlexEnd">
|
<MudStack Row="true" Style="width:100%" Spacing="4" Justify="Justify.FlexEnd">
|
||||||
<MudSkeleton Width="64px" Height="40px"/>
|
<MudSkeleton Width="64px" Height="40px" />
|
||||||
<MudSkeleton Width="64px" Height="40px"/>
|
<MudSkeleton Width="64px" Height="40px" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudCardActions>
|
</MudCardActions>
|
||||||
</MudCard>
|
</MudCard>
|
||||||
@ -45,32 +45,35 @@
|
|||||||
TransformOrigin="Origin.TopLeft" Size="Size.Small">
|
TransformOrigin="Origin.TopLeft" Size="Size.Small">
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.QrCode"
|
<MudMenuItem Icon="@Icons.Material.Filled.QrCode"
|
||||||
OnClick="@(_ => ShowQrCode(user))"
|
OnClick="@(_ => ShowQrCode(user))"
|
||||||
|
OnTouch="@(_ => ShowQrCode(user))"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Show QR Code
|
Show QR Code
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.FeaturedPlayList"
|
<MudMenuItem Icon="@Icons.Material.Filled.FeaturedPlayList"
|
||||||
Href="@($"Users/{user.Baid}/AccessCode")"
|
Href="@($"Users/{user.Baid}/AccessCode")"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Manage Access Codes
|
Manage Access Codes
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Lock"
|
<MudMenuItem Icon="@Icons.Material.Filled.Lock"
|
||||||
Href="@($"Users/ChangePassword")"
|
Href="@($"Users/ChangePassword")"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Change Password
|
Change Password
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.LockReset"
|
<MudMenuItem Icon="@Icons.Material.Filled.LockReset"
|
||||||
OnClick="@(_ => ResetPassword(user))"
|
OnClick="@(_ => ResetPassword(user))"
|
||||||
|
OnTouch="@(_ => ResetPassword(user))"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Reset Password
|
Reset Password
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
@if (LoginService.AllowUserDelete)
|
@if (LoginService.AllowUserDelete)
|
||||||
{
|
{
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Delete"
|
<MudMenuItem Icon="@Icons.Material.Filled.Delete"
|
||||||
OnClick="@(_ => DeleteUser(user))"
|
OnClick="@(_ => DeleteUser(user))"
|
||||||
|
OnTouch="@(_ => DeleteUser(user))"
|
||||||
IconColor="@Color.Error">
|
IconColor="@Color.Error">
|
||||||
Delete User
|
Delete User
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
@ -83,7 +86,7 @@
|
|||||||
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">@user.AccessCodes[0]</MudText>
|
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">@user.AccessCodes[0]</MudText>
|
||||||
@if (user.AccessCodes.Count > 1)
|
@if (user.AccessCodes.Count > 1)
|
||||||
{
|
{
|
||||||
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">... and @(user.AccessCodes.Count-1) other access code(s)</MudText>
|
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">... and @(user.AccessCodes.Count - 1) other access code(s)</MudText>
|
||||||
}
|
}
|
||||||
</MudCardContent>
|
</MudCardContent>
|
||||||
<MudCardActions>
|
<MudCardActions>
|
||||||
@ -124,7 +127,7 @@
|
|||||||
<MudText Typo="Typo.h4" Align="Align.Center">Login</MudText>
|
<MudText Typo="Typo.h4" Align="Align.Center">Login</MudText>
|
||||||
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
|
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
|
||||||
FullWidth="true" Required="@true" RequiredError="Access code is required"
|
FullWidth="true" Required="@true" RequiredError="Access code is required"
|
||||||
Label="Access code"/>
|
Label="Access code" />
|
||||||
<MudTextField @bind-Value="inputPassword" InputType="InputType.Password"
|
<MudTextField @bind-Value="inputPassword" InputType="InputType.Password"
|
||||||
T="string" FullWidth="true" Required="@true"
|
T="string" FullWidth="true" Required="@true"
|
||||||
RequiredError="Password is required"
|
RequiredError="Password is required"
|
||||||
@ -159,16 +162,17 @@
|
|||||||
TransformOrigin="Origin.TopLeft" Size="Size.Small">
|
TransformOrigin="Origin.TopLeft" Size="Size.Small">
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.QrCode"
|
<MudMenuItem Icon="@Icons.Material.Filled.QrCode"
|
||||||
OnClick="@(_ => ShowQrCode(user))"
|
OnClick="@(_ => ShowQrCode(user))"
|
||||||
|
OnTouch="@(_ => ShowQrCode(user))"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Show QR Code
|
Show QR Code
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.FeaturedPlayList"
|
<MudMenuItem Icon="@Icons.Material.Filled.FeaturedPlayList"
|
||||||
Href="@($"Users/{user.Baid}/AccessCode")"
|
Href="@($"Users/{user.Baid}/AccessCode")"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
Manage Access Codes
|
Manage Access Codes
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Lock"
|
<MudMenuItem Icon="@Icons.Material.Filled.Lock"
|
||||||
Href="@($"Users/ChangePassword")"
|
Href="@($"Users/ChangePassword")"
|
||||||
IconColor="@Color.Primary">
|
IconColor="@Color.Primary">
|
||||||
@ -176,9 +180,10 @@
|
|||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
@if (LoginService.AllowUserDelete)
|
@if (LoginService.AllowUserDelete)
|
||||||
{
|
{
|
||||||
<MudDivider/>
|
<MudDivider />
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Delete"
|
<MudMenuItem Icon="@Icons.Material.Filled.Delete"
|
||||||
OnClick="@(_ => DeleteUser(user))"
|
OnClick="@(_ => DeleteUser(user))"
|
||||||
|
OnTouch="@(_ => DeleteUser(user))"
|
||||||
IconColor="@Color.Error">
|
IconColor="@Color.Error">
|
||||||
Delete User
|
Delete User
|
||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
@ -191,7 +196,7 @@
|
|||||||
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">@user.AccessCodes[0]</MudText>
|
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">@user.AccessCodes[0]</MudText>
|
||||||
@if (user.AccessCodes.Count > 1)
|
@if (user.AccessCodes.Count > 1)
|
||||||
{
|
{
|
||||||
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">... and @(user.AccessCodes.Count-1) other access code(s)</MudText>
|
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">... and @(user.AccessCodes.Count - 1) other access code(s)</MudText>
|
||||||
}
|
}
|
||||||
</MudCardContent>
|
</MudCardContent>
|
||||||
<MudCardActions>
|
<MudCardActions>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using TaikoWebUI.Pages.Dialogs;
|
using Microsoft.Extensions.Options;
|
||||||
|
using TaikoWebUI.Pages.Dialogs;
|
||||||
|
|
||||||
namespace TaikoWebUI.Pages;
|
namespace TaikoWebUI.Pages;
|
||||||
|
|
||||||
@ -17,12 +18,13 @@ public partial class Users
|
|||||||
|
|
||||||
private async Task DeleteUser(User user)
|
private async Task DeleteUser(User user)
|
||||||
{
|
{
|
||||||
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
||||||
if (!LoginService.AllowUserDelete)
|
if (!LoginService.AllowUserDelete)
|
||||||
{
|
{
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"User deletion is disabled by admin.",
|
"User deletion is disabled by admin.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var parameters = new DialogParameters
|
var parameters = new DialogParameters
|
||||||
@ -30,7 +32,7 @@ public partial class Users
|
|||||||
["user"] = user
|
["user"] = user
|
||||||
};
|
};
|
||||||
|
|
||||||
var dialog = DialogService.Show<UserDeleteConfirmDialog>("Delete User", parameters);
|
var dialog = DialogService.Show<UserDeleteConfirmDialog>("Delete User", parameters, options);
|
||||||
var result = await dialog.Result;
|
var result = await dialog.Result;
|
||||||
|
|
||||||
if (result.Canceled) return;
|
if (result.Canceled) return;
|
||||||
@ -41,12 +43,13 @@ public partial class Users
|
|||||||
|
|
||||||
private async Task ResetPassword(User user)
|
private async Task ResetPassword(User user)
|
||||||
{
|
{
|
||||||
if (!LoginService.IsAdmin)
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
||||||
|
if (LoginService.LoginRequired && !LoginService.IsAdmin)
|
||||||
{
|
{
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"Only admin can reset password.",
|
"Only admin can reset password.",
|
||||||
"Ok");
|
"Ok", null , null, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var parameters = new DialogParameters
|
var parameters = new DialogParameters
|
||||||
@ -54,7 +57,7 @@ public partial class Users
|
|||||||
["user"] = user
|
["user"] = user
|
||||||
};
|
};
|
||||||
|
|
||||||
var dialog = DialogService.Show<ResetPasswordConfirmDialog>("Reset Password", parameters);
|
var dialog = DialogService.Show<ResetPasswordConfirmDialog>("Reset Password", parameters, options);
|
||||||
var result = await dialog.Result;
|
var result = await dialog.Result;
|
||||||
|
|
||||||
if (result.Canceled) return;
|
if (result.Canceled) return;
|
||||||
@ -67,13 +70,14 @@ public partial class Users
|
|||||||
if (response != null)
|
if (response != null)
|
||||||
{
|
{
|
||||||
var result = LoginService.Login(inputAccessCode, inputPassword, response);
|
var result = LoginService.Login(inputAccessCode, inputPassword, response);
|
||||||
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"Only admin can log in.",
|
"Only admin can log in.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
await loginForm.ResetAsync();
|
await loginForm.ResetAsync();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -83,21 +87,21 @@ public partial class Users
|
|||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
"Wrong password!",
|
"Wrong password!",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
(MarkupString)
|
(MarkupString)
|
||||||
"Access code not found.<br />Please play one game with this access code to register it.",
|
"Access code not found.<br />Please play one game with this access code to register it.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
await DialogService.ShowMessageBox(
|
await DialogService.ShowMessageBox(
|
||||||
"Error",
|
"Error",
|
||||||
(MarkupString)
|
(MarkupString)
|
||||||
"Access code not registered.<br />Please use register button to create a password first.",
|
"Access code not registered.<br />Please use register button to create a password first.",
|
||||||
"Ok");
|
"Ok", null, null, options);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +120,8 @@ public partial class Users
|
|||||||
["user"] = user
|
["user"] = user
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogService.Show<UserQrCodeDialog>("QR Code", parameters);
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
||||||
|
DialogService.Show<UserQrCodeDialog>("QR Code", parameters, options);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -153,15 +153,16 @@ public class LoginService
|
|||||||
LoggedInUser = newLoggedInUser;
|
LoggedInUser = newLoggedInUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> BindAccessCode(string inputAccessCode, HttpClient client)
|
public async Task<int> BindAccessCode(string inputAccessCode, User user, HttpClient client)
|
||||||
{
|
{
|
||||||
if (inputAccessCode.Trim() == "") return 4;
|
if (inputAccessCode.Trim() == "") return 4; /*Empty access code*/
|
||||||
if (!IsLoggedIn) return 0;
|
if (!IsLoggedIn && LoginRequired) return 0; /*User not connected and login is required*/
|
||||||
if (LoggedInUser.AccessCodes.Count >= boundAccessCodeUpperLimit) return 2;
|
if (LoginRequired && !IsAdmin && !(user.Baid == GetLoggedInUser().Baid)) return 5; /*User not admin trying to update someone elses Access Codes*/
|
||||||
|
if (user.AccessCodes.Count >= boundAccessCodeUpperLimit) return 2; /*Limit of codes has been reached*/
|
||||||
var request = new BindAccessCodeRequest
|
var request = new BindAccessCodeRequest
|
||||||
{
|
{
|
||||||
AccessCode = inputAccessCode,
|
AccessCode = inputAccessCode,
|
||||||
Baid = LoggedInUser.Baid
|
Baid = user.Baid
|
||||||
};
|
};
|
||||||
var responseMessage = await client.PostAsJsonAsync("api/Cards", request);
|
var responseMessage = await client.PostAsJsonAsync("api/Cards", request);
|
||||||
return responseMessage.IsSuccessStatusCode ? 1 : 3;
|
return responseMessage.IsSuccessStatusCode ? 1 : 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user