1
0
mirror of synced 2024-11-28 00:20:53 +01:00

Remove spaces from access codes

This commit is contained in:
shiibe 2024-03-08 11:44:16 -05:00
parent 0123283fda
commit 8b4e37d187
2 changed files with 52 additions and 18 deletions

View File

@ -25,7 +25,7 @@
{
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
Please log in by clicking on "Users" tab first.
You are not authorized to see this page. Please log in by clicking on "Users" tab first.
</MudText>
</MudItem>
}
@ -69,18 +69,21 @@
<MudItem xs="12">
<div Style="border-bottom:1px solid #eee; padding: 5px 0;">
<MudGrid Spacing="2" Class="d-flex align-center">
<MudItem xs="12" md="8">
<MudText>
@String.Format("{0:0000 0000 0000 0000 0000}", (Int64.Parse(accessCode)))
</MudText>
</MudItem>
<MudItem xs="12" md="4" Class="d-flex justify-end">
<MudButton OnClick="@(_ => DeleteAccessCode(accessCode))"
Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Delete"
Color="Color.Error">
Remove
</MudButton>
</MudItem>
<MudItem xs="12" md="8" Class="d-flex align-center">
<pre class="mb-0" style="font-size:16px">
@foreach (var digitGroup in SplitIntoGroups(accessCode, 4))
{
<span class="mr-2">@digitGroup</span>
}
</pre>
</MudItem>
<MudItem xs="12" md="4" Class="d-flex justify-end">
<MudButton OnClick="@(_ => DeleteAccessCode(accessCode))"
Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Delete"
Color="Color.Error">
@Localizer["Delete"]
</MudButton>
</MudItem>
</MudGrid>
</div>
</MudItem>
@ -90,4 +93,16 @@
</MudCard>
}
}
</div>
</div>
@code {
List<string> SplitIntoGroups(string str, int groupSize)
{
List<string> groups = new List<string>();
for (int i = 0; i < str.Length; i += groupSize)
{
groups.Add(str.Substring(i, Math.Min(groupSize, str.Length - i)));
}
return groups;
}
}

View File

@ -87,11 +87,14 @@
<MudCardContent>
<MudText Style="font-weight:bold">Access Code</MudText>
<MudText Style="font-family:monospace;overflow:hidden;overflow-x:scroll">
@String.Format("{0:0000 0000 0000 0000 0000}", (Int64.Parse(user.AccessCodes[0])))
@foreach (var digitGroup in SplitIntoGroups(user.AccessCodes[0], 4))
{
<span class="mr-2">@digitGroup</span>
}
</MudText>
@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 Typo="Typo.caption">... and @(user.AccessCodes.Count - 1) other access code(s)</MudText>
}
</MudCardContent>
<MudCardActions>
@ -199,11 +202,15 @@
<MudCardContent>
<MudText Style="font-weight:bold">Access Code</MudText>
<MudText>
@String.Format("{0:0000 0000 0000 0000 0000}", (Int64.Parse(user.AccessCodes[0])))
@foreach (var digitGroup in SplitIntoGroups(user.AccessCodes[0], 4))
{
<span class="mr-2">@digitGroup</span>
}
</MudText>
<MudText Typo="Typo.caption">... and @(user.AccessCodes.Count - 1) other access code(s)</MudText>
@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 Typo="Typo.caption">... and @(user.AccessCodes.Count - 1) other access code(s)</MudText>
}
</MudCardContent>
<MudCardActions>
@ -242,3 +249,15 @@
</MudItem>
}
</MudGrid>
@code {
List<string> SplitIntoGroups(string str, int groupSize)
{
List<string> groups = new List<string>();
for (int i = 0; i < str.Length; i += groupSize)
{
groups.Add(str.Substring(i, Math.Min(groupSize, str.Length - i)));
}
return groups;
}
}