additional changes for #2228

This commit is contained in:
Shaun Walker 2022-06-13 09:10:01 -04:00
parent 7d9188b659
commit 6d3a556d34
2 changed files with 21 additions and 22 deletions

View File

@ -1,15 +1,12 @@
@namespace Oqtane.Modules.Admin.Logs @namespace Oqtane.Modules.Admin.Logs
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager
@inject ILogService LogService @inject ILogService LogService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer @inject IStringLocalizer<Index> Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer @inject IStringLocalizer<SharedResources> SharedLocalizer
@if (_id > 0) @if (_logs == null)
{
<Detail/>
}
else if (_logs == null)
{ {
<p><em>@SharedLocalizer["Loading"]</em></p> <p><em>@SharedLocalizer["Loading"]</em></p>
} }
@ -95,24 +92,23 @@ else
} }
@code { @code {
private int _id = 0; private string _level = "-";
private string _level = "-"; private string _function = "-";
private string _function = "-"; private string _rows = "10";
private string _rows = "10";
private int _page = 1; private int _page = 1;
private List<Log> _logs; private List<Log> _logs;
private string _retention = ""; private string _retention = "";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
if (PageState.QueryString.ContainsKey("id") && int.TryParse(PageState.QueryString["id"], out int id)) if (PageState.QueryString.ContainsKey("id") && int.TryParse(PageState.QueryString["id"], out int id))
{ {
_id = id; NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, ModuleState.ModuleId, "Detail", $"id={id}"));
} }
if (PageState.QueryString.ContainsKey("level")) if (PageState.QueryString.ContainsKey("level"))
{ {
_level = PageState.QueryString["level"]; _level = PageState.QueryString["level"];

View File

@ -203,12 +203,15 @@ namespace Oqtane.Infrastructure
} }
if (Enum.Parse<LogLevel>(log.Level) >= notifylevel) if (Enum.Parse<LogLevel>(log.Level) >= notifylevel)
{ {
var alias = _tenantManager.GetAlias();
foreach (var userrole in _userRoles.GetUserRoles(log.SiteId.Value)) foreach (var userrole in _userRoles.GetUserRoles(log.SiteId.Value))
{ {
if (userrole.Role.Name == RoleNames.Host) if (userrole.Role.Name == RoleNames.Host)
{ {
var url = $"{_accessor.HttpContext.Request.Scheme}://{_tenantManager.GetAlias().Name}/admin/log?id={log.LogId}"; var subject = $"{alias.Name} Site {log.Level} Notification";
var notification = new Notification(log.SiteId.Value, userrole.User, "Site " + log.Level + " Notification", "Please visit " + url + " for more information"); var url = $"{_accessor.HttpContext.Request.Scheme}://{alias.Name}/admin/log?id={log.LogId}";
string body = $"Log Message: {log.Message}\n\nPlease visit {url} for more information";
var notification = new Notification(log.SiteId.Value, userrole.User, subject, body);
_notifications.AddNotification(notification); _notifications.AddNotification(notification);
} }
} }