-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented ListUsers page, refactored Specification classes
- Loading branch information
Showing
49 changed files
with
320 additions
and
200 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
.../Logistics.AdminApp/Utils/AddressUtils.cs → ....AdminApp/Extensions/AddressExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Client/Logistics.AdminApp/Extensions/LoadDataArgsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Radzen; | ||
|
||
namespace Logistics.AdminApp.Extensions; | ||
|
||
public static class LoadDataArgsExtensions | ||
{ | ||
public static int GetPageNumber(this LoadDataArgs loadDataArgs) | ||
{ | ||
var top = loadDataArgs.Top ?? 10; | ||
var skip = loadDataArgs.Skip ?? 0; | ||
var page = (int)Math.Ceiling((skip + 1) / (double)top); | ||
return page; | ||
} | ||
|
||
public static int GetPageSize(this LoadDataArgs loadDataArgs) | ||
{ | ||
return loadDataArgs.Top ?? 10; | ||
} | ||
|
||
public static string GetOrderBy(this LoadDataArgs loadDataArgs) | ||
{ | ||
if (string.IsNullOrEmpty(loadDataArgs.OrderBy)) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
var splitStr = loadDataArgs.OrderBy.Split(' '); | ||
|
||
switch (splitStr.Length) | ||
{ | ||
case 1: | ||
return splitStr[0]; | ||
case 0: | ||
return string.Empty; | ||
default: | ||
{ | ||
var sortProperty = splitStr[0]; | ||
var orderSpecifier = splitStr[1]; | ||
return orderSpecifier == "desc" ? $"-{sortProperty}" : sortProperty; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@page "/users" | ||
@inherits PageBase | ||
|
||
<RadzenText TextStyle="TextStyle.H3">Tenants</RadzenText> | ||
<hr/> | ||
|
||
<RadzenGrid Data="_users" | ||
LoadData="LoadData" | ||
Count="_totalRecords" | ||
AllowPaging="true" | ||
AllowSorting="true" | ||
PageSizeOptions="new[] { 10, 25, 50 }" | ||
PageSize="10"> | ||
<Columns> | ||
<RadzenGridColumn TItem="UserDto" | ||
Property="FirstName" | ||
Title="First Name"> | ||
</RadzenGridColumn> | ||
<RadzenGridColumn TItem="UserDto" | ||
Property="LastName" | ||
Title="Last Name"> | ||
</RadzenGridColumn> | ||
<RadzenGridColumn TItem="UserDto" | ||
Property="Email" | ||
Title="Email"> | ||
</RadzenGridColumn> | ||
<RadzenGridColumn TItem="UserDto" | ||
Property="PhoneNumber" | ||
Title="Phone Number"> | ||
</RadzenGridColumn> | ||
@* <RadzenGridColumn TItem="UserDto" Title="Action"> *@ | ||
@* <Template Context="user"> *@ | ||
@* <RadzenButton Click="@(() => Navigation.NavigateTo($"tenants/{tenant.Id}"))">Edit</RadzenButton> *@ | ||
@* </Template> *@ | ||
@* </RadzenGridColumn> *@ | ||
</Columns> | ||
</RadzenGrid> |
33 changes: 33 additions & 0 deletions
33
src/Client/Logistics.AdminApp/Pages/User/ListUsers.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Logistics.AdminApp.Extensions; | ||
using Logistics.Shared.Models; | ||
using Logistics.Shared; | ||
using Microsoft.AspNetCore.Components; | ||
using Radzen; | ||
|
||
namespace Logistics.AdminApp.Pages.User; | ||
|
||
public partial class ListUsers : PageBase | ||
{ | ||
private IEnumerable<UserDto>? _users; | ||
private int _totalRecords = 10; | ||
|
||
|
||
#region Injectable services | ||
|
||
[Inject] | ||
private NavigationManager Navigation { get; set; } = default!; | ||
|
||
#endregion | ||
|
||
|
||
private async void LoadData(LoadDataArgs e) | ||
{ | ||
var orderBy = e.GetOrderBy(); | ||
var page = e.GetPageNumber(); | ||
var pageSize = e.GetPageSize(); | ||
var pagedData = await CallApiAsync(api => api.GetUsersAsync(new SearchableQuery(null, orderBy, page, pageSize))); | ||
_users = pagedData?.Items; | ||
_totalRecords = pagedData?.TotalItems ?? 0; | ||
StateHasChanged(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.