135 lines
3.9 KiB
Plaintext
135 lines
3.9 KiB
Plaintext
@namespace Oqtane.Modules.Admin.Logs
|
|
@inherits ModuleBase
|
|
@inject ILogService LogService
|
|
|
|
@if (Logs == null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<div class="form-group">
|
|
<label>Level: </label>
|
|
<select class="form-control" @onchange="(e => LevelChanged(e))">
|
|
<option value="-"><All Levels></option>
|
|
<option value="Trace">Trace</option>
|
|
<option value="Debug">Debug</option>
|
|
<option value="Information">Information</option>
|
|
<option value="Warning">Warning</option>
|
|
<option value="Error">Error</option>
|
|
<option value="Critical">Critical</option>
|
|
</select>
|
|
<label>Function: </label>
|
|
<select class="form-control" @onchange="(e => FunctionChanged(e))">
|
|
<option value="-"><All Functions></option>
|
|
<option value="Create">Create</option>
|
|
<option value="Read">Read</option>
|
|
<option value="Update">Update</option>
|
|
<option value="Delete">Delete</option>
|
|
<option value="Security">Security</option>
|
|
<option value="Other">Other</option>
|
|
</select>
|
|
<label>Rows: </label>
|
|
<select class="form-control" @onchange="(e => RowsChanged(e))">
|
|
<option value="10">10</option>
|
|
<option value="50">50</option>
|
|
<option value="100">100</option>
|
|
</select>
|
|
</div>
|
|
@if(Logs.Any())
|
|
{
|
|
<Pager Items="@Logs">
|
|
<Header>
|
|
<th> </th>
|
|
<th>Date</th>
|
|
<th>Level</th>
|
|
<th>Feature</th>
|
|
<th>Function</th>
|
|
</Header>
|
|
<Row>
|
|
<td><ActionLink Action="Detail" Parameters="@($"id=" + context.LogId.ToString())" /></td>
|
|
<td>@context.LogDate</td>
|
|
<td>@context.Level</td>
|
|
<td>@context.Feature</td>
|
|
<td>@context.Function</td>
|
|
</Row>
|
|
</Pager>
|
|
}
|
|
else
|
|
{
|
|
<p><em>No Logs Match The Criteria Specified</em></p>
|
|
}
|
|
}
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
|
|
|
string level = "-";
|
|
string function = "-";
|
|
string rows = "10";
|
|
List<Log> Logs;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
await GetLogs();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
AddModuleMessage("Error Loading Logs", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async void LevelChanged(ChangeEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
level = (string)e.Value;
|
|
await GetLogs();
|
|
StateHasChanged();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
AddModuleMessage("Error Loading Logs", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async void FunctionChanged(ChangeEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
function = (string)e.Value;
|
|
await GetLogs();
|
|
StateHasChanged();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
AddModuleMessage("Error Loading Logs", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
|
|
private async void RowsChanged(ChangeEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
rows = (string)e.Value;
|
|
await GetLogs();
|
|
StateHasChanged();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await logger.LogError(ex, "Error Loading Logs {Error}", ex.Message);
|
|
AddModuleMessage("Error Loading Logs", MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async Task GetLogs()
|
|
{
|
|
Logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((level == "-") ? "" : level), ((function == "-") ? "" : function), int.Parse(rows));
|
|
}
|
|
} |