User management sort
Added Sorting to User management component.
This commit is contained in:
parent
4e82212956
commit
4820a27016
|
@ -35,9 +35,9 @@ else
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Username"]</th>
|
<th class="app-sort-th" @onclick="@(() => SortTable("Username"))">@Localizer["Username"]<i class="@(SetSortIcon("Username"))"></i></th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th class="app-sort-th" @onclick="@(() => SortTable("DisplayName"))">@Localizer["Name"]<i class="@(SetSortIcon("DisplayName"))"></i></th>
|
||||||
<th>@Localizer["LastLoginOn"]</th>
|
<th class="app-sort-th" @onclick="@(() => SortTable("LastLoginOn"))">@Localizer["LastLoginOn"]<i class="@(SetSortIcon("LastLoginOn"))"></i></th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td>
|
<td>
|
||||||
|
@ -413,6 +413,9 @@ else
|
||||||
private string _lifetime;
|
private string _lifetime;
|
||||||
private string _token;
|
private string _token;
|
||||||
|
|
||||||
|
private bool isSortedAscending;
|
||||||
|
private string activeSortColumn;
|
||||||
|
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
@ -654,4 +657,43 @@ else
|
||||||
_togglesecret = SharedLocalizer["ShowPassword"];
|
_togglesecret = SharedLocalizer["ShowPassword"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SortTable(string columnName)
|
||||||
|
{
|
||||||
|
if (columnName != activeSortColumn)
|
||||||
|
{
|
||||||
|
users = users.OrderBy(x => x.User.GetType().GetProperty(columnName)?.GetValue(x.User)).ToList();
|
||||||
|
isSortedAscending = true;
|
||||||
|
activeSortColumn = columnName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isSortedAscending)
|
||||||
|
{
|
||||||
|
users = users.OrderByDescending(x => x.User.GetType().GetProperty(columnName)?.GetValue(x.User)).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
users = users.OrderBy(x => x.User.GetType().GetProperty(columnName)?.GetValue(x.User)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
isSortedAscending = !isSortedAscending;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SetSortIcon(string columnName)
|
||||||
|
{
|
||||||
|
if (activeSortColumn != columnName)
|
||||||
|
{
|
||||||
|
return "app-fas pe-3 ";
|
||||||
|
}
|
||||||
|
if (isSortedAscending)
|
||||||
|
{
|
||||||
|
return "app-fas oi oi-sort-ascending";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "app-fas oi oi-sort-descending";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,3 +220,11 @@ app {
|
||||||
.app-pager-pointer {
|
.app-pager-pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-sort-th {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-fas {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user