Naming fixes

This commit is contained in:
Pavel Vesely 2020-03-14 09:54:48 +01:00
parent a06ad38432
commit e5fde5a436
6 changed files with 61 additions and 59 deletions

View File

@ -36,7 +36,7 @@
<label class="control-label">Permissions: </label> <label class="control-label">Permissions: </label>
</td> </td>
<td> <td>
<PermissionGrid EntityName="Folder" PermissionNames="Browse,View,Edit" Permissions="@_permissions" @ref="permissiongrid" /> <PermissionGrid EntityName="Folder" PermissionNames="Browse,View,Edit" Permissions="@_permissions" @ref="_permissionGrid" />
</td> </td>
</tr> </tr>
</table> </table>
@ -65,14 +65,16 @@
int _folderId = -1; int _folderId = -1;
string _name; string _name;
int _parentId = -1; int _parentId = -1;
bool _isSystem = false; bool _isSystem;
string _permissions = ""; string _permissions = "";
string _createdBy; string _createdBy;
DateTime _createdOn; DateTime _createdOn;
string _modifiedBy; string _modifiedBy;
DateTime _modifiedOn; DateTime _modifiedOn;
#pragma warning disable 649
PermissionGrid _permissionGrid; PermissionGrid _permissionGrid;
#pragma warning restore 649
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

View File

@ -17,7 +17,7 @@
<label class="control-label">Permissions: </label> <label class="control-label">Permissions: </label>
</td> </td>
<td> <td>
<PermissionGrid EntityName="ModuleDefinition" PermissionNames="Utilize" Permissions="@_permissions" @ref="_permissiongrid" /> <PermissionGrid EntityName="ModuleDefinition" PermissionNames="Utilize" Permissions="@_permissions" @ref="_permissionGrid" />
</td> </td>
</tr> </tr>
</table> </table>
@ -38,7 +38,9 @@
string _modifiedby; string _modifiedby;
DateTime _modifiedon; DateTime _modifiedon;
PermissionGrid _permissiongrid; #pragma warning disable 649
PermissionGrid _permissionGrid;
#pragma warning restore 649
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -68,7 +70,7 @@
try try
{ {
ModuleDefinition moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); ModuleDefinition moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
moduledefinition.Permissions = _permissiongrid.GetPermissions(); moduledefinition.Permissions = _permissionGrid.GetPermissions();
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());

View File

@ -34,7 +34,7 @@
<label for="Name" class="control-label">Permissions: </label> <label for="Name" class="control-label">Permissions: </label>
</td> </td>
<td> <td>
<PermissionGrid EntityName="Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="permissiongrid" /> <PermissionGrid EntityName="Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="_permissionGrid" />
</td> </td>
</tr> </tr>
<tr> <tr>
@ -70,7 +70,7 @@
string _permissions; string _permissions;
string _pageId; string _pageId;
PermissionGrid _permissiongrid; PermissionGrid _permissionGrid;
RenderFragment DynamicComponent { get; set; } RenderFragment DynamicComponent { get; set; }
object _settings; object _settings;
@ -99,7 +99,7 @@
private async Task SaveModule() private async Task SaveModule()
{ {
Module module = ModuleState; Module module = ModuleState;
module.Permissions = _permissiongrid.GetPermissions(); module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module); await ModuleService.UpdateModuleAsync(module);
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
@ -112,7 +112,7 @@
Type moduleType = Type.GetType(ModuleState.ModuleType); Type moduleType = Type.GetType(ModuleState.ModuleType);
if (moduleType != null) if (moduleType != null)
{ {
moduleType.GetMethod("UpdateSettings").Invoke(_settings, null); // method must be public in settings component moduleType.GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component
} }
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());

View File

@ -209,7 +209,7 @@
themes = ThemeService.GetThemeTypes(Themes); themes = ThemeService.GetThemeTypes(Themes);
PageId = Int32.Parse(PageState.QueryString["id"]); PageId = Int32.Parse(PageState.QueryString["id"]);
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault(); Page page = PageState.Pages.FirstOrDefault(item => item.PageId == PageId);
if (page != null) if (page != null)
{ {
name = page.Name; name = page.Name;
@ -310,7 +310,7 @@
if (name != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype))) if (name != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)))
{ {
page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault(); page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
string currentpath = page.Path; string currentPath = page.Path;
page.Name = name; page.Name = name;
if (path == "" && name.ToLower() != "home") if (path == "" && name.ToLower() != "home")
@ -329,7 +329,7 @@
else else
{ {
page.ParentId = Int32.Parse(parentid); page.ParentId = Int32.Parse(parentid);
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault(); Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == "") if (parent.Path == "")
{ {
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path); page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(path);
@ -348,12 +348,12 @@
page.Order = 0; page.Order = 0;
break; break;
case "<": case "<":
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault(); child = PageState.Pages.FirstOrDefault(item => item.PageId == childid);
page.Order = child.Order - 1; if (child != null) page.Order = child.Order - 1;
break; break;
case ">": case ">":
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault(); child = PageState.Pages.FirstOrDefault(item => item.PageId == childid);
page.Order = child.Order + 1; if (child != null) page.Order = child.Order + 1;
break; break;
case ">>": case ">>":
page.Order = int.MaxValue; page.Order = int.MaxValue;
@ -363,8 +363,8 @@
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation)); page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
page.EditMode = (mode == "edit" ? true : false); page.EditMode = (mode == "edit" ? true : false);
page.ThemeType = themetype; page.ThemeType = themetype;
page.LayoutType = (layouttype == null ? "" : layouttype); page.LayoutType = layouttype ?? "";
page.Icon = (icon == null ? "" : icon); page.Icon = icon ?? "";
page.Permissions = permissiongrid.GetPermissions(); page.Permissions = permissiongrid.GetPermissions();
if (page.ThemeType == PageState.Site.DefaultThemeType) if (page.ThemeType == PageState.Site.DefaultThemeType)
@ -375,7 +375,7 @@
{ {
page.LayoutType = ""; page.LayoutType = "";
} }
page.IsPersonalizable = (ispersonalizable == null ? false : Boolean.Parse(ispersonalizable)); page.IsPersonalizable = (ispersonalizable != null && Boolean.Parse(ispersonalizable));
page.UserId = null; page.UserId = null;
page = await PageService.UpdatePageAsync(page); page = await PageService.UpdatePageAsync(page);
@ -392,9 +392,9 @@
// update child paths // update child paths
if (parentid != currentparentid) if (parentid != currentparentid)
{ {
foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentpath))) foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath)))
{ {
p.Path = p.Path.Replace(currentpath, page.Path); p.Path = p.Path.Replace(currentPath, page.Path);
await PageService.UpdatePageAsync(p); await PageService.UpdatePageAsync(p);
} }
} }

View File

@ -6,15 +6,15 @@
<div class="container"> <div class="container">
<div class="form-group"> <div class="form-group">
<label for="Username" class="control-label">Username: </label> <label for="Username" class="control-label">Username: </label>
<input type="text" class="form-control" placeholder="Username" @bind="@Username" readonly /> <input type="text" class="form-control" placeholder="Username" @bind="@_username" readonly id="Username"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="Password" class="control-label">Password: </label> <label for="Password" class="control-label">Password: </label>
<input type="password" class="form-control" placeholder="Password" @bind="@Password" /> <input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="Password" class="control-label">Confirm Password: </label> <label for="Confirm" class="control-label">Confirm Password: </label>
<input type="password" class="form-control" placeholder="Password" @bind="@Confirm" /> <input type="password" class="form-control" placeholder="Password" @bind="@_confirm" id="Confirm"/>
</div> </div>
<button type="button" class="btn btn-primary" @onclick="Reset">Reset Password</button> <button type="button" class="btn btn-primary" @onclick="Reset">Reset Password</button>
<button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button> <button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button>
@ -23,15 +23,15 @@
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
string Username = ""; string _username = "";
string Password = ""; string _password = "";
string Confirm = ""; string _confirm = "";
protected override void OnInitialized() protected override void OnInitialized()
{ {
if (PageState.QueryString.ContainsKey("name") && PageState.QueryString.ContainsKey("token")) if (PageState.QueryString.ContainsKey("name") && PageState.QueryString.ContainsKey("token"))
{ {
Username = PageState.QueryString["name"]; _username = PageState.QueryString["name"];
} }
else else
{ {
@ -43,24 +43,26 @@
{ {
try try
{ {
if (Username != "" && Password != "" && Confirm != "") if (_username != "" && _password != "" && _confirm != "")
{ {
if (Password == Confirm) if (_password == _confirm)
{ {
User user = new User(); User user = new User
user.SiteId = PageState.Site.SiteId; {
user.Username = Username; SiteId = PageState.Site.SiteId,
user.Password = Password; Username = _username,
Password = _password
};
user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]); user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]);
if (user != null) if (user != null)
{ {
await logger.LogInformation("User Password Reset {Username}", Username); await logger.LogInformation("User Password Reset {Username}", _username);
NavigationManager.NavigateTo(NavigateUrl("login")); NavigationManager.NavigateTo(NavigateUrl("login"));
} }
else else
{ {
await logger.LogError("Error Resetting User Password {Username}", Username); await logger.LogError("Error Resetting User Password {Username}", _username);
AddModuleMessage("Error Resetting User Password. Please Ensure Password Meets Complexity Requirements.", MessageType.Error); AddModuleMessage("Error Resetting User Password. Please Ensure Password Meets Complexity Requirements.", MessageType.Error);
} }
} }
@ -76,7 +78,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", Username, ex.Message); await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message);
AddModuleMessage("Error Resetting User Password", MessageType.Error); AddModuleMessage("Error Resetting User Password", MessageType.Error);
} }
} }

View File

@ -1,20 +1,19 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Oqtane.Services;
using Oqtane.Modules.HtmlText.Models; using Oqtane.Modules.HtmlText.Models;
using Oqtane.Services;
using Oqtane.Shared; using Oqtane.Shared;
using Oqtane.Models;
namespace Oqtane.Modules.HtmlText.Services namespace Oqtane.Modules.HtmlText.Services
{ {
public class HtmlTextService : ServiceBase, IHtmlTextService public class HtmlTextService : ServiceBase, IHtmlTextService
{ {
private readonly HttpClient _http; private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager; private readonly NavigationManager _navigationManager;
private readonly SiteState _siteState;
public HtmlTextService(HttpClient http, SiteState siteState, NavigationManager navigationManager) public HtmlTextService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
{ {
@ -23,42 +22,39 @@ namespace Oqtane.Modules.HtmlText.Services
_navigationManager = navigationManager; _navigationManager = navigationManager;
} }
private string apiurl private string ApiUrl => CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "HtmlText");
{
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "HtmlText"); }
}
public async Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId) public async Task<HtmlTextInfo> GetHtmlTextAsync(int moduleId)
{ {
HtmlTextInfo htmltext; HtmlTextInfo htmlText;
try try
{ {
//because GetJsonAsync() returns an error if no content exists for the ModuleId ( https://github.com/aspnet/AspNetCore/issues/14041 ) //because GetJsonAsync() returns an error if no content exists for the ModuleId ( https://github.com/aspnet/AspNetCore/issues/14041 )
//null value is transfered as empty list //null value is transfered as empty list
var htmltextList = await _http.GetJsonAsync<List<HtmlTextInfo>>(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString()); var htmlTextList = await _http.GetJsonAsync<List<HtmlTextInfo>>(ApiUrl + "/" + moduleId + "?entityid=" + moduleId);
htmltext = htmltextList.FirstOrDefault(); htmlText = htmlTextList.FirstOrDefault();
} }
catch catch
{ {
htmltext = null; htmlText = null;
} }
return htmltext;
return htmlText;
} }
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext) public async Task AddHtmlTextAsync(HtmlTextInfo htmlText)
{ {
await _http.PostJsonAsync(apiurl + "?entityid=" + htmltext.ModuleId.ToString(), htmltext); await _http.PostJsonAsync(ApiUrl + "?entityid=" + htmlText.ModuleId, htmlText);
} }
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmltext) public async Task UpdateHtmlTextAsync(HtmlTextInfo htmlText)
{ {
await _http.PutJsonAsync(apiurl + "/" + htmltext.HtmlTextId.ToString() + "?entityid=" + htmltext.ModuleId.ToString(), htmltext); await _http.PutJsonAsync(ApiUrl + "/" + htmlText.HtmlTextId + "?entityid=" + htmlText.ModuleId, htmlText);
} }
public async Task DeleteHtmlTextAsync(int ModuleId) public async Task DeleteHtmlTextAsync(int moduleId)
{ {
await _http.DeleteAsync(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString()); await _http.DeleteAsync(ApiUrl + "/" + moduleId + "?entityid=" + moduleId);
} }
} }
} }