Merge pull request #1171 from sbwalker/dev

Fix Pager component issue which manifested itself in Event Log. This reverts a fix from #1160 and addresses the root problem.
This commit is contained in:
Shaun Walker 2021-03-11 11:19:58 -05:00 committed by GitHub
commit 32eaa90e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 26 deletions

View File

@ -12,8 +12,8 @@ else
<table class="table table-borderless">
<tr>
<td>
<label>@Localizer["Level:"] </label>
<select class="form-control" @onchange="(e => LevelChanged(e))">
<Label For="level" HelpText="Select the log level for event log items" ResourceKey="Level">Level: </Label><br /><br />
<select id="level" class="form-control" @onchange="(e => LevelChanged(e))">
<option value="-">&lt;@Localizer["All Levels"]&gt;</option>
<option value="Trace">@Localizer["Trace"]</option>
<option value="Debug">@Localizer["Debug"]</option>
@ -24,8 +24,8 @@ else
</select>
</td>
<td>
<label>@Localizer["Function:"] </label>
<select class="form-control" @onchange="(e => FunctionChanged(e))">
<Label For="function" HelpText="Select the function for event log items" ResourceKey="Function">Function: </Label><br /><br />
<select id="function" class="form-control" @onchange="(e => FunctionChanged(e))">
<option value="-">&lt;@Localizer["All Functions"]&gt;</option>
<option value="Create">@Localizer["Create"]</option>
<option value="Read">@Localizer["Read"]</option>
@ -36,8 +36,8 @@ else
</select>
</td>
<td>
<label>@Localizer["Maximum Records:"] </label>
<select class="form-control" @onchange="(e => RowsChanged(e))">
<Label For="rows" HelpText="Select the maximum number of event log items to review. Please note that if you choose more than 10 items the information will be split into pages." ResourceKey="Rows">Maximum Items: </Label><br /><br />
<select id="rows" class="form-control" @onchange="(e => RowsChanged(e))">
<option value="10">10</option>
<option value="50">50</option>
<option value="100">100</option>
@ -48,7 +48,7 @@ else
@if (_logs.Any())
{
<Pager TableItem="Log" Items="@_logs">
<Pager Items="@_logs">
<Header>
<th style="width: 1px;">&nbsp;</th>
<th>@Localizer["Date"]</th>
@ -141,10 +141,6 @@ else
private async Task GetLogs()
{
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
await InvokeAsync(() =>
{
base.StateHasChanged();
});
}
private string GetClass(string function)

View File

@ -1,4 +1,4 @@
@namespace Oqtane.Modules.Controls
@namespace Oqtane.Modules.Controls
@inherits ModuleControlBase
@typeparam TableItem
@ -114,10 +114,10 @@
@code {
private int _pages = 0;
private int _page = 1;
private int _maxItems;
private int _maxPages;
private int _startPage;
private int _endPage;
private int _maxItems = 10;
private int _maxPages = 5;
private int _startPage = 0;
private int _endPage = 0;
[Parameter]
public string Format { get; set; }
@ -172,24 +172,20 @@
}
}
if (string.IsNullOrEmpty(PageSize))
{
_maxItems = 10;
}
else
if (!string.IsNullOrEmpty(PageSize))
{
_maxItems = int.Parse(PageSize);
}
if (string.IsNullOrEmpty(DisplayPages))
{
_maxPages = 5;
}
else
if (!string.IsNullOrEmpty(DisplayPages))
{
_maxPages = int.Parse(DisplayPages);
}
_page = 1;
_startPage = 0;
_endPage = 0;
if (Items != null)
{
ItemList = Items.Skip((_page - 1) * _maxItems).Take(_maxItems);