|
1 | 1 | @page "/swaps" |
2 | 2 | @using System.Security.Claims |
3 | 3 | @using Humanizer |
| 4 | +@using Blazorise |
4 | 5 | @attribute [Authorize(Roles = "Superadmin,NodeManager,FinanceManager")] |
5 | 6 |
|
6 | 7 | <Row> |
|
9 | 10 | <DataGrid TItem="SwapOut" |
10 | 11 | @ref="_swapsDatagrid" |
11 | 12 | Data="@_swapRequests" |
| 13 | + ReadData="@OnReadData" |
| 14 | + TotalItems="@_totalItems" |
12 | 15 | Filterable="true" |
13 | 16 | FilterMethod="DataGridFilterMethod.Contains" |
14 | 17 | Editable="true" |
|
47 | 50 | </DataGridColumn> |
48 | 51 | <DataGridColumn TItem="SwapOut" Editable="false" Field="@nameof(SwapOut.UserRequestor)" Caption="Requestor" Sortable="true" Displayable="@IsColumnVisible(SwapsColumnName.Requestor)"> |
49 | 52 | <DisplayTemplate> |
50 | | - @(context.UserRequestor?.UserName ?? "Unknown") |
| 53 | + @(context.IsManual ? (context.UserRequestor?.UserName ?? "Unknown") : "Autoswap") |
51 | 54 | </DisplayTemplate> |
52 | 55 | </DataGridColumn> |
53 | 56 | <DataGridColumn TItem="SwapOut" Editable="false" Field="@nameof(SwapOut.Amount)" Caption="Amount (BTC)" Sortable="false" Displayable="@IsColumnVisible(SwapsColumnName.Amount)"> |
|
129 | 132 | private bool _columnsLoaded; |
130 | 133 | private ColumnLayout<SwapsColumnName> _swapsColumnLayout = new(); |
131 | 134 | public required NewSwapModal _newSwapModal; |
| 135 | + private int _totalItems; |
| 136 | + private int _currentPage = 1; |
| 137 | + private int _pageSize = 10; |
132 | 138 |
|
133 | 139 | public abstract class SwapsColumnName |
134 | 140 | { |
|
151 | 157 | ToastService.ShowError("Bitcoin price in USD could not be retrieved."); |
152 | 158 | } |
153 | 159 | _availableNodes = await NodeRepository.GetAllManagedByUser(LoggedUser.Id); |
154 | | - _swapRequests = await SwapOutRepository.GetAll(); |
| 160 | + } |
| 161 | + |
| 162 | + private async Task OnReadData(DataGridReadDataEventArgs<SwapOut> e) |
| 163 | + { |
| 164 | + if (!e.CancellationToken.IsCancellationRequested) |
| 165 | + { |
| 166 | + var (swaps, totalCount) = await SwapOutRepository.GetPaginatedAsync(e.Page, e.PageSize); |
| 167 | + |
| 168 | + _swapRequests = swaps; |
| 169 | + _totalItems = totalCount; |
| 170 | + } |
155 | 171 | } |
156 | 172 |
|
157 | 173 | protected override async Task OnAfterRenderAsync(bool firstRender) |
|
201 | 217 |
|
202 | 218 | private async Task OnSwapCreated() |
203 | 219 | { |
204 | | - _swapRequests = await SwapOutRepository.GetAll(); |
205 | | - StateHasChanged(); |
| 220 | + await _swapsDatagrid.Reload(); |
206 | 221 | } |
207 | 222 | } |
208 | 223 |
|
|
0 commit comments