@namespace Oqtane.Modules.Admin.Logs
@inherits ModuleBase
@inject ILogService LogService
@if (_logs == null)
{
Loading...
}
else
{
|
|
|
@if (_logs.Any())
{
|
Date |
Level |
Feature |
Function |
|
@context.LogDate |
@context.Level |
@context.Feature |
@context.Function |
}
else
{
No Logs Match The Criteria Specified
}
}
@code {
private string _level = "-";
private string _function = "-";
private string _rows = "10";
private List _logs;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
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 == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
}
private string GetClass(string function)
{
string classname = string.Empty;
switch (function)
{
case "Create":
classname = "table-success";
break;
case "Read":
classname = "table-primary";
break;
case "Update":
classname = "table-warning";
break;
case "Delete":
classname = "table-danger";
break;
case "Security":
classname = "table-secondary";
break;
default:
classname = string.Empty;
break;
}
return classname;
}
}