|
2 | 2 | @using CleanArchitecture.Blazor.Application.Features.AuditTrails.DTOs |
3 | 3 | @using CleanArchitecture.Blazor.Application.Features.AuditTrails.Queries.PaginationQuery |
4 | 4 | @using CleanArchitecture.Blazor.Application.Features.AuditTrails.Caching |
5 | | -@using CleanArchitecture.Blazor.Application.Constants.Permission |
6 | | -@using CleanArchitecture.Blazor.Domain.Enums |
7 | | - |
8 | 5 |
|
9 | 6 | @attribute [Authorize(Policy = Permissions.AuditTrails.View)] |
10 | 7 | @inject IStringLocalizer<AuditTrails> L |
|
31 | 28 | <MudIcon Icon="@Icons.Material.Filled.ReceiptLong" Size="Size.Large" /> |
32 | 29 | <div class="d-flex flex-column"> |
33 | 30 | <MudText Typo="Typo.caption">@L[Title]</MudText> |
34 | | - <MudEnumSelect Style="min-width:220px" TEnum="AuditTrailListView" ValueChanged="OnChangedListView" Value="_query.ListView" Dense="true" Label="List View"> |
| 31 | + <MudEnumSelect Style="min-width:220px" TEnum="AuditTrailListView" ValueChanged="OnChangedListView" Value="Query.ListView" Dense="true" Label="List View"> |
35 | 32 | </MudEnumSelect> |
36 | 33 | </div> |
37 | 34 | </div> |
|
47 | 44 | </div> |
48 | 45 |
|
49 | 46 | <MudStack Row="true" AlignItems="AlignItems.Stretch"> |
50 | | - <MudEnumSelect TEnum="AuditType?" Placeholder="Search for audit type" Value="@_query.AuditType" Clearable="true" ValueChanged="@(s=>OnSearch(s))" Style="width:160px" FullWidth="true"> </MudEnumSelect> |
51 | | - <MudTextField T="string" ValueChanged="@(s=>OnSearch(s))" Value="@_query.Keyword" Placeholder="Search" Adornment="Adornment.End" Style="width:260px" FullWidth="true" |
| 47 | + <MudEnumSelect TEnum="AuditType?" Placeholder="Search for audit type" Value="@Query.AuditType" Clearable="true" ValueChanged="@(s=>OnSearch(s))" Style="width:160px" FullWidth="true"> </MudEnumSelect> |
| 48 | + <MudTextField T="string" ValueChanged="@(s=>OnSearch(s))" Value="@Query.Keyword" Placeholder="Search" Adornment="Adornment.End" Style="width:260px" FullWidth="true" |
52 | 49 | AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Small"></MudTextField> |
53 | 50 | </MudStack> |
54 | 51 |
|
|
108 | 105 | <CustomError Exception="context"></CustomError> |
109 | 106 | </ErrorContent> |
110 | 107 | </ErrorBoundary> |
111 | | - @code { |
| 108 | +@code { |
112 | 109 | public string Title { get; private set; } = "Audit Trails"; |
113 | 110 | private MudDataGrid<AuditTrailDto> _table = null!; |
114 | 111 | private bool _loading; |
115 | 112 | private int _defaultPageSize = 15; |
116 | 113 | [Inject] |
117 | 114 | private IMediator Mediator { get; set; } = default!; |
118 | 115 | private readonly AuditTrailDto _currentDto = new(); |
119 | | - private readonly AuditTrailsWithPaginationQuery _query = new(); |
| 116 | + private AuditTrailsWithPaginationQuery Query { get; set; } = new(); |
120 | 117 |
|
121 | 118 | [CascadingParameter] |
122 | 119 | private Task<AuthenticationState> AuthState { get; set; } = default!; |
|
131 | 128 | try |
132 | 129 | { |
133 | 130 | _loading = true; |
134 | | - _query.Sort = state.SortDefinitions.FirstOrDefault()?.SortBy ?? "Id"; |
135 | | - _query.SortBy = (state.SortDefinitions.FirstOrDefault()?.Descending == false ? AutoFilterer.Enums.Sorting.Ascending : AutoFilterer.Enums.Sorting.Descending); |
136 | | - _query.Page = state.Page + 1; |
137 | | - _query.PerPage = state.PageSize; |
| 131 | + Query.Sort = state.SortDefinitions.FirstOrDefault()?.SortBy ?? "Id"; |
| 132 | + Query.SortBy = (state.SortDefinitions.FirstOrDefault()?.Descending == false ? AutoFilterer.Enums.Sorting.Ascending : AutoFilterer.Enums.Sorting.Descending); |
| 133 | + Query.Page = state.Page + 1; |
| 134 | + Query.PerPage = state.PageSize; |
138 | 135 |
|
139 | | - var result = await Mediator.Send(_query).ConfigureAwait(false); |
| 136 | + var result = await Mediator.Send(Query).ConfigureAwait(false); |
140 | 137 | return new GridData<AuditTrailDto>() { TotalItems = result.TotalItems, Items = result.Items }; |
141 | 138 | } |
142 | 139 | finally |
|
146 | 143 | } |
147 | 144 | private async Task OnChangedListView(AuditTrailListView listview) |
148 | 145 | { |
149 | | - _query.ListView = listview; |
| 146 | + Query.ListView = listview; |
150 | 147 | await _table.ReloadServerData(); |
151 | 148 | } |
152 | 149 | private async Task OnSearch(string text) |
153 | 150 | { |
154 | | - _query.Keyword = text; |
| 151 | + Query.Keyword = text; |
155 | 152 | await _table.ReloadServerData(); |
156 | 153 | } |
157 | 154 | private async Task OnSearch(AuditType? val) |
158 | 155 | { |
159 | | - _query.AuditType = val; |
| 156 | + Query.AuditType = val; |
160 | 157 | await _table.ReloadServerData(); |
161 | 158 | } |
162 | 159 | private async Task OnRefresh() |
163 | 160 | { |
164 | 161 | AuditTrailsCacheKey.Refresh(); |
165 | | - _query.Keyword = string.Empty; |
| 162 | + Query.Keyword = string.Empty; |
166 | 163 | await _table.ReloadServerData(); |
167 | 164 | } |
168 | 165 | private Task OnShowDetail(AuditTrailDto dto) |
|
0 commit comments