Merge pull request #1496 from sbwalker/dev

fix Localizer class specification
This commit is contained in:
Shaun Walker 2021-06-18 16:41:47 -04:00 committed by GitHub
commit 19f3095483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 269 additions and 269 deletions

View File

@ -6,7 +6,7 @@
@inject IPageService PageService @inject IPageService PageService
@inject IPageModuleService PageModuleService @inject IPageModuleService PageModuleService
@inject IUserService UserService @inject IUserService UserService
@inject IStringLocalizer<Index> Localizer @inject IStringLocalizer<Detail> Localizer
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>

View File

@ -5,7 +5,7 @@
@inject IModuleDefinitionService ModuleDefinitionService @inject IModuleDefinitionService ModuleDefinitionService
@inject IModuleService ModuleService @inject IModuleService ModuleService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer @inject IStringLocalizer<Create> Localizer
@if (_templates != null) @if (_templates != null)
{ {

View File

@ -6,7 +6,7 @@
@inject IModuleService ModuleService @inject IModuleService ModuleService
@inject IPageModuleService PageModuleService @inject IPageModuleService PageModuleService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer @inject IStringLocalizer<Create> Localizer
@if (_templates != null) @if (_templates != null)
{ {

View File

@ -1,73 +1,73 @@
@namespace Oqtane.Modules.Admin.UserProfile @namespace Oqtane.Modules.Admin.UserProfile
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject IUserService UserService @inject IUserService UserService
@inject INotificationService NotificationService @inject INotificationService NotificationService
@inject IStringLocalizer<Add> Localizer @inject IStringLocalizer<Add> Localizer
@if (PageState.User != null) @if (PageState.User != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<Label For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label> <Label For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label>
</td> </td>
<td> <td>
<input id="to" class="form-control" @bind="@username" /> <input id="to" class="form-control" @bind="@username" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label> <Label For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label>
</td> </td>
<td> <td>
<input id="subject" class="form-control" @bind="@subject" /> <input id="subject" class="form-control" @bind="@subject" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<Label For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label> <Label For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label>
</td> </td>
<td> <td>
<textarea id="message" class="form-control" @bind="@body" rows="5" /> <textarea id="message" class="form-control" @bind="@body" rows="5" />
</td> </td>
</tr> </tr>
</table> </table>
<button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button> <button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
} }
@code { @code {
private string username = ""; private string username = "";
private string subject = ""; private string subject = "";
private string body = ""; private string body = "";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
public override string Title => "Send Notification"; public override string Title => "Send Notification";
private async Task Send() private async Task Send()
{ {
try try
{ {
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null); var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null);
notification = await NotificationService.AddNotificationAsync(notification); notification = await NotificationService.AddNotificationAsync(notification);
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }
else else
{ {
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
} }
} }
} }

View File

@ -1,201 +1,201 @@
@namespace Oqtane.Modules.Admin.UserProfile @namespace Oqtane.Modules.Admin.UserProfile
@inherits ModuleBase @inherits ModuleBase
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject IUserService UserService @inject IUserService UserService
@inject INotificationService NotificationService @inject INotificationService NotificationService
@inject IStringLocalizer<View> Localizer @inject IStringLocalizer<View> Localizer
@if (PageState.User != null) @if (PageState.User != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<label class="control-label">@Localizer["Title"] </label> <label class="control-label">@Localizer["Title"] </label>
</td> </td>
@if (title == "From") @if (title == "From")
{ {
<td> <td>
<input class="form-control" @bind="@username" readonly /> <input class="form-control" @bind="@username" readonly />
</td> </td>
} }
@if (title == "To") @if (title == "To")
{ {
<td> <td>
<input class="form-control" @bind="@username" /> <input class="form-control" @bind="@username" />
</td> </td>
} }
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">@Localizer["Subject"] </label> <label class="control-label">@Localizer["Subject"] </label>
</td> </td>
@if (title == "From") @if (title == "From")
{ {
<td> <td>
<input class="form-control" @bind="@subject" readonly /> <input class="form-control" @bind="@subject" readonly />
</td> </td>
} }
@if (title == "To") @if (title == "To")
{ {
<td> <td>
<input class="form-control" @bind="@subject" /> <input class="form-control" @bind="@subject" />
</td> </td>
} }
</tr> </tr>
@if (title == "From") @if (title == "From")
{ {
<tr> <tr>
<td> <td>
<label class="control-label">@Localizer["Date"] </label> <label class="control-label">@Localizer["Date"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@createdon" readonly /> <input class="form-control" @bind="@createdon" readonly />
</td> </td>
</tr> </tr>
} }
@if (title == "From") @if (title == "From")
{ {
<tr> <tr>
<td> <td>
<label class="control-label">@Localizer["Message"] </label> <label class="control-label">@Localizer["Message"] </label>
</td> </td>
<td> <td>
<textarea class="form-control" @bind="@body" rows="5" readonly /> <textarea class="form-control" @bind="@body" rows="5" readonly />
</td> </td>
</tr> </tr>
} }
@if (title == "To") @if (title == "To")
{ {
<tr> <tr>
<td> <td>
<label class="control-label">@Localizer["Message"] </label> <label class="control-label">@Localizer["Message"] </label>
</td> </td>
<td> <td>
<textarea class="form-control" @bind="@body" rows="5" /> <textarea class="form-control" @bind="@body" rows="5" />
</td> </td>
</tr> </tr>
} }
</table> </table>
@if (reply != string.Empty) @if (reply != string.Empty)
{ {
<button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button> <button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button>
} }
else else
{ {
if (title == "From") if (title == "From")
{ {
<button type="button" class="btn btn-primary" @onclick="Reply">@Localizer["Reply"]</button> <button type="button" class="btn btn-primary" @onclick="Reply">@Localizer["Reply"]</button>
} }
} }
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<br /> <br />
<br /> <br />
@if (title == "To") @if (title == "To")
{ {
<div class="control-group"> <div class="control-group">
<label class="control-label">@Localizer["OriginalMessage"] </label> <label class="control-label">@Localizer["OriginalMessage"] </label>
<textarea class="form-control" @bind="@reply" rows="5" readonly /> <textarea class="form-control" @bind="@reply" rows="5" readonly />
</div> </div>
} }
} }
@code { @code {
private int notificationid; private int notificationid;
private string title = string.Empty; private string title = string.Empty;
private string username = ""; private string username = "";
private string subject = string.Empty; private string subject = string.Empty;
private string createdon = string.Empty; private string createdon = string.Empty;
private string body = string.Empty; private string body = string.Empty;
private string reply = string.Empty; private string reply = string.Empty;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
public override string Title => "View Notification"; public override string Title => "View Notification";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
notificationid = Int32.Parse(PageState.QueryString["id"]); notificationid = Int32.Parse(PageState.QueryString["id"]);
Notification notification = await NotificationService.GetNotificationAsync(notificationid); Notification notification = await NotificationService.GetNotificationAsync(notificationid);
if (notification != null) if (notification != null)
{ {
int userid = -1; int userid = -1;
if (notification.ToUserId == PageState.User.UserId) if (notification.ToUserId == PageState.User.UserId)
{ {
title = "From"; title = "From";
if (notification.FromUserId != null) if (notification.FromUserId != null)
{ {
userid = notification.FromUserId.Value; userid = notification.FromUserId.Value;
} }
} }
else else
{ {
title = "To"; title = "To";
if (notification.ToUserId != null) if (notification.ToUserId != null)
{ {
userid = notification.ToUserId.Value; userid = notification.ToUserId.Value;
} }
} }
if (userid != -1) if (userid != -1)
{ {
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
username = user.Username; username = user.Username;
} }
} }
if (username == "") if (username == "")
{ {
username = "System"; username = "System";
} }
subject = notification.Subject; subject = notification.Subject;
createdon = notification.CreatedOn.ToString(); createdon = notification.CreatedOn.ToString();
body = notification.Body; body = notification.Body;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
await logger.LogError(ex, "Error Loading Users {Error}", ex.Message); await logger.LogError(ex, "Error Loading Users {Error}", ex.Message);
AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error); AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error);
} }
} }
private void Reply() private void Reply()
{ {
title = "To"; title = "To";
if (!subject.Contains("RE:")) if (!subject.Contains("RE:"))
{ {
subject = "RE: " + subject; subject = "RE: " + subject;
} }
reply = body; reply = body;
body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body; body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body;
StateHasChanged(); StateHasChanged();
} }
private async Task Send() private async Task Send()
{ {
try try
{ {
var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); var user = await UserService.GetUserAsync(username, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid); var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid);
notification = await NotificationService.AddNotificationAsync(notification); notification = await NotificationService.AddNotificationAsync(notification);
await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }
else else
{ {
AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message);
AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error);
} }
} }
} }