Skip to content

Commit 48c6fea

Browse files
authored
refactor(channels): replace wallet filter with channel ID search functionality (#487)
- Replace wallet ID filter parameter with channel ID string filter in repository methods - Update UI to swap wallet dropdown with channel ID text input field - Modify query logic to search channels by ChanId instead of wallet associations - Reorder filter columns for better layout organization
1 parent 8ba2200 commit 48c6fea

3 files changed

Lines changed: 30 additions & 40 deletions

File tree

src/Data/Repositories/ChannelRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public async Task<List<Channel>> GetAllManagedByUserNodes(string loggedUserId)
225225
int? statusFilter = null,
226226
int? sourceNodeIdFilter = null,
227227
int? destinationNodeIdFilter = null,
228-
int? walletIdFilter = null,
228+
string? channelIdFilter = null,
229229
DateTimeOffset? fromDate = null,
230230
DateTimeOffset? toDate = null)
231231
{
@@ -268,9 +268,9 @@ public async Task<List<Channel>> GetAllManagedByUserNodes(string loggedUserId)
268268
query = query.Where(x => x.DestinationNodeId == destinationNodeIdFilter.Value);
269269
}
270270

271-
if (walletIdFilter.HasValue)
271+
if (!string.IsNullOrWhiteSpace(channelIdFilter))
272272
{
273-
query = query.Where(x => x.ChannelOperationRequests.Any(r => r.WalletId == walletIdFilter.Value));
273+
query = query.Where(x => x.ChanId.ToString().Contains(channelIdFilter));
274274
}
275275

276276
if (fromDate.HasValue)

src/Data/Repositories/Interfaces/IChannelRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public interface IChannelRepository
6565
int? statusFilter = null,
6666
int? sourceNodeIdFilter = null,
6767
int? destinationNodeIdFilter = null,
68-
int? walletIdFilter = null,
68+
string? channelIdFilter = null,
6969
DateTimeOffset? fromDate = null,
7070
DateTimeOffset? toDate = null);
7171
}

src/Pages/Channels.razor

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@
1515
<Row>
1616
<Column ColumnSize="ColumnSize.Is12">
1717
<Row Class="mb-3" @key="_filtersResetKey">
18-
<Column ColumnSize="ColumnSize.Is1">
19-
<Field>
20-
<FieldLabel>Status</FieldLabel>
21-
<Autocomplete TItem="string"
22-
TValue="string"
23-
Data="@_statusOptions"
24-
TextField="@(item => item)"
25-
ValueField="@(item => item)"
26-
@bind-SelectedValue="@_statusFilterValue"
27-
@bind-SelectedValue:after="OnFiltersChanged"
28-
Placeholder="All"
29-
FreeTyping="false"
30-
MinLength="0"
31-
Filter="AutocompleteFilter.Contains" />
32-
</Field>
33-
</Column>
3418
<Column ColumnSize="ColumnSize.Is2">
3519
<Field>
3620
<FieldLabel>Source Node</FieldLabel>
@@ -63,22 +47,30 @@
6347
Filter="AutocompleteFilter.Contains" />
6448
</Field>
6549
</Column>
66-
<Column ColumnSize="ColumnSize.Is2">
50+
<Column ColumnSize="ColumnSize.Is1">
6751
<Field>
68-
<FieldLabel>Wallet</FieldLabel>
69-
<Autocomplete TItem="Wallet"
70-
TValue="int?"
71-
Data="@_wallets"
72-
TextField="@(item => item.Name)"
73-
ValueField="@(item => item.Id)"
74-
@bind-SelectedValue="@_walletIdFilterValue"
52+
<FieldLabel>Status</FieldLabel>
53+
<Autocomplete TItem="string"
54+
TValue="string"
55+
Data="@_statusOptions"
56+
TextField="@(item => item)"
57+
ValueField="@(item => item)"
58+
@bind-SelectedValue="@_statusFilterValue"
7559
@bind-SelectedValue:after="OnFiltersChanged"
7660
Placeholder="All"
7761
FreeTyping="false"
7862
MinLength="0"
7963
Filter="AutocompleteFilter.Contains" />
8064
</Field>
8165
</Column>
66+
<Column ColumnSize="ColumnSize.Is2">
67+
<Field>
68+
<FieldLabel>Channel Id</FieldLabel>
69+
<TextEdit @bind-Text="@_channelIdFilterValue"
70+
@bind-Text:after="OnFiltersChanged"
71+
Placeholder="All" />
72+
</Field>
73+
</Column>
8274
<Column ColumnSize="ColumnSize.Is1">
8375
<Field>
8476
<FieldLabel>Availability</FieldLabel>
@@ -193,6 +185,13 @@
193185
</Button>
194186
</DisplayTemplate>
195187
</DataGridColumn>
188+
<DataGridColumn TItem="Channel" Field="@nameof(Channel.ChanId)" Caption="Channel Id" Sortable="false" Displayable="@IsColumnVisible(ChannelsColumnName.CHANNEL_ID)">
189+
<DisplayTemplate>
190+
<a href="@(Constants.AMBOSS_ENDPOINT + "/edge/" + context.ChanId)" target="_blank">
191+
@context.ChanId
192+
</a>
193+
</DisplayTemplate>
194+
</DataGridColumn>
196195
<DataGridNumericColumn TItem="Channel" Field="@nameof(Channel.SatsAmount)" Caption="Capacity (BTC)" Filterable="false" Sortable="true" Displayable="@IsColumnVisible(ChannelsColumnName.CAPACITY)">
197196
<DisplayTemplate>
198197
@{
@@ -246,13 +245,6 @@
246245
</DataGridColumn>
247246
<DataGridColumn TItem="Channel" Field="@nameof(Channel.CreationDatetime)" Caption="@nameof(Channel.CreationDatetime).Humanize(LetterCasing.Sentence)" Sortable="true" Displayable="@IsColumnVisible(ChannelsColumnName.CREATION_DATE)"/>
248247
<DataGridColumn TItem="Channel" Field="@nameof(Channel.UpdateDatetime)" Caption="@nameof(Channel.UpdateDatetime).Humanize(LetterCasing.Sentence)" Sortable="true" Displayable="@IsColumnVisible(ChannelsColumnName.UPDATE_DATE)"/>
249-
<DataGridColumn TItem="Channel" Field="@nameof(Channel.ChanId)" Caption="Channel Id" Sortable="false" Displayable="@IsColumnVisible(ChannelsColumnName.CHANNEL_ID)">
250-
<DisplayTemplate>
251-
<a href="@(Constants.AMBOSS_ENDPOINT + "/edge/" + context.ChanId)" target="_blank">
252-
@context.ChanId
253-
</a>
254-
</DisplayTemplate>
255-
</DataGridColumn>
256248
<DataGridColumn TItem="Channel" Displayable="true">
257249
<FilterTemplate>
258250
<ColumnLayout @ref="_channelsColumnLayout" Columns="@_channelsColumns" ColumnType="ChannelsColumnName" OnUpdate="@OnColumnLayoutUpdate"/>
@@ -463,7 +455,7 @@
463455
private string? _statusFilterValue = "Open";
464456
private int? _sourceNodeIdFilterValue;
465457
private int? _destinationNodeIdFilterValue;
466-
private int? _walletIdFilterValue;
458+
private string? _channelIdFilterValue;
467459
private DateTimeOffset? _fromDateFilter;
468460
private DateTimeOffset? _toDateFilter;
469461

@@ -477,7 +469,6 @@
477469
private List<string> _availabilityOptions = new List<string> { "Active", "Inactive" };
478470

479471
private List<Node> _nodes = new List<Node>();
480-
private List<Wallet> _wallets = new List<Wallet>();
481472
private int _totalItems;
482473

483474
[CascadingParameter]
@@ -521,7 +512,6 @@
521512
if (LoggedUser != null)
522513
{
523514
_nodes = await NodeRepository.GetAll();
524-
_wallets = await WalletRepository.GetAll();
525515
_availableWallets = await WalletRepository.GetAvailableWallets(true);
526516
if (ClaimsPrincipal != null && ClaimsPrincipal.IsInRole(ApplicationUserRole.NodeManager.ToString()))
527517
{
@@ -559,7 +549,7 @@
559549
statusFilter,
560550
_sourceNodeIdFilterValue,
561551
_destinationNodeIdFilterValue,
562-
_walletIdFilterValue,
552+
_channelIdFilterValue,
563553
fromDate,
564554
toDate);
565555

@@ -595,7 +585,7 @@
595585
_statusFilterValue = null;
596586
_sourceNodeIdFilterValue = null;
597587
_destinationNodeIdFilterValue = null;
598-
_walletIdFilterValue = null;
588+
_channelIdFilterValue = null;
599589
_availabilityFilterValue = null;
600590
_fromDateFilter = null;
601591
_toDateFilter = null;

0 commit comments

Comments
 (0)