Merge pull request #2852 from sbwalker/dev
optimize pane rendering, preserve querystring parameters in edit mode , relocate anchor tags to ensure they are always injected, add ability to determine if navigation is internal
This commit is contained in:
commit
b56daae321
@ -5,9 +5,7 @@
|
|||||||
@inject SiteState SiteState
|
@inject SiteState SiteState
|
||||||
|
|
||||||
<span class="app-moduletitle">
|
<span class="app-moduletitle">
|
||||||
<a id="@ModuleState.PageModuleId.ToString()">
|
@((MarkupString)title)
|
||||||
@((MarkupString)title)
|
|
||||||
</a>
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
@ -224,262 +224,266 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
private bool _canViewAdminDashboard = false;
|
private bool _canViewAdminDashboard = false;
|
||||||
private bool _showEditMode = false;
|
private bool _showEditMode = false;
|
||||||
private bool _deleteConfirmation = false;
|
private bool _deleteConfirmation = false;
|
||||||
private List<string> _categories = new List<string>();
|
private List<string> _categories = new List<string>();
|
||||||
private List<ModuleDefinition> _allModuleDefinitions;
|
private List<ModuleDefinition> _allModuleDefinitions;
|
||||||
private List<ModuleDefinition> _moduleDefinitions;
|
private List<ModuleDefinition> _moduleDefinitions;
|
||||||
private List<Page> _pages = new List<Page>();
|
private List<Page> _pages = new List<Page>();
|
||||||
private List<Module> _modules = new List<Module>();
|
private List<Module> _modules = new List<Module>();
|
||||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||||
private string _category = "Common";
|
private string _category = "Common";
|
||||||
|
|
||||||
protected string PageId { get; private set; } = "-";
|
protected string PageId { get; private set; } = "-";
|
||||||
protected string ModuleId { get; private set; } = "-";
|
protected string ModuleId { get; private set; } = "-";
|
||||||
protected string ModuleType { get; private set; } = "new";
|
protected string ModuleType { get; private set; } = "new";
|
||||||
protected string ModuleDefinitionName { get; private set; } = "-";
|
protected string ModuleDefinitionName { get; private set; } = "-";
|
||||||
|
|
||||||
protected string Category
|
protected string Category
|
||||||
{
|
{
|
||||||
get => _category;
|
get => _category;
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
if (_category != value)
|
if (_category != value)
|
||||||
{
|
{
|
||||||
_category = value;
|
_category = value;
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
||||||
ModuleDefinitionName = "-";
|
ModuleDefinitionName = "-";
|
||||||
Message = "";
|
Message = "";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
_ = UpdateSettingsAsync();
|
_ = UpdateSettingsAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string Pane
|
protected string Pane
|
||||||
{
|
{
|
||||||
get => _pane;
|
get => _pane;
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
if (_pane != value)
|
if (_pane != value)
|
||||||
{
|
{
|
||||||
_pane = value;
|
_pane = value;
|
||||||
_ = UpdateSettingsAsync();
|
_ = UpdateSettingsAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string Title { get; private set; } = "";
|
protected string Title { get; private set; } = "";
|
||||||
protected string ContainerType { get; private set; } = "";
|
protected string ContainerType { get; private set; } = "";
|
||||||
protected string Visibility { get; private set; } = "view";
|
protected string Visibility { get; private set; } = "view";
|
||||||
protected string Message { get; private set; } = "";
|
protected string Message { get; private set; } = "";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string ContainerClass { get; set; } = "offcanvas offcanvas-end";
|
public string ContainerClass { get; set; } = "offcanvas offcanvas-end";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string HeaderClass { get; set; } = "offcanvas-header";
|
public string HeaderClass { get; set; } = "offcanvas-header";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string BodyClass { get; set; } = "offcanvas-body overflow-auto";
|
public string BodyClass { get; set; } = "offcanvas-body overflow-auto";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool ShowLanguageSwitcher { get; set; } = true;
|
public bool ShowLanguageSwitcher { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
_canViewAdminDashboard = CanViewAdminDashboard();
|
_canViewAdminDashboard = CanViewAdminDashboard();
|
||||||
_showEditMode = false;
|
_showEditMode = false;
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList))
|
||||||
{
|
{
|
||||||
_showEditMode = true;
|
_showEditMode = true;
|
||||||
_pages?.Clear();
|
_pages?.Clear();
|
||||||
|
|
||||||
foreach (Page p in PageState.Pages)
|
foreach (Page p in PageState.Pages)
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
|
||||||
{
|
{
|
||||||
_pages.Add(p);
|
_pages.Add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await LoadSettingsAsync();
|
await LoadSettingsAsync();
|
||||||
|
|
||||||
var themes = await ThemeService.GetThemesAsync();
|
var themes = await ThemeService.GetThemesAsync();
|
||||||
_containers = ThemeService.GetContainerControls(themes, PageState.Page.ThemeType);
|
_containers = ThemeService.GetContainerControls(themes, PageState.Page.ThemeType);
|
||||||
ContainerType = PageState.Site.DefaultContainerType;
|
ContainerType = PageState.Site.DefaultContainerType;
|
||||||
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
||||||
_categories = _allModuleDefinitions.SelectMany(m => m.Categories.Split(',')).Distinct().ToList();
|
_categories = _allModuleDefinitions.SelectMany(m => m.Categories.Split(',')).Distinct().ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
|
foreach (var module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.PermissionList))
|
||||||
{
|
{
|
||||||
_showEditMode = true;
|
_showEditMode = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanViewAdminDashboard()
|
private bool CanViewAdminDashboard()
|
||||||
{
|
{
|
||||||
var admin = PageState.Pages.FirstOrDefault(item => item.Path == "admin");
|
var admin = PageState.Pages.FirstOrDefault(item => item.Path == "admin");
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
foreach (var page in PageState.Pages.Where(item => item.ParentId == admin?.PageId))
|
foreach (var page in PageState.Pages.Where(item => item.ParentId == admin?.PageId))
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, page.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, page.PermissionList))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CategoryChanged(ChangeEventArgs e)
|
private void CategoryChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
Category = (string)e.Value;
|
Category = (string)e.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModuleChanged(ChangeEventArgs e)
|
private void ModuleChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
ModuleDefinitionName = (string)e.Value;
|
ModuleDefinitionName = (string)e.Value;
|
||||||
if (ModuleDefinitionName != "-")
|
if (ModuleDefinitionName != "-")
|
||||||
{
|
{
|
||||||
var moduleDefinition = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName);
|
var moduleDefinition = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName);
|
||||||
Message = "<div class=\"alert alert-info mt-2 text-center\" role=\"alert\">" + moduleDefinition.Description + "</div>";
|
Message = "<div class=\"alert alert-info mt-2 text-center\" role=\"alert\">" + moduleDefinition.Description + "</div>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message = "";
|
Message = "";
|
||||||
}
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PageChanged(ChangeEventArgs e)
|
private void PageChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
PageId = (string)e.Value;
|
PageId = (string)e.Value;
|
||||||
if (PageId != "-")
|
if (PageId != "-")
|
||||||
{
|
{
|
||||||
_modules = PageState.Modules
|
_modules = PageState.Modules
|
||||||
.Where(module => module.PageId == int.Parse(PageId) &&
|
.Where(module => module.PageId == int.Parse(PageId) &&
|
||||||
UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
ModuleId = "-";
|
ModuleId = "-";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddModule()
|
private async Task AddModule()
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList))
|
||||||
{
|
{
|
||||||
if ((ModuleType == "new" && ModuleDefinitionName != "-") || (ModuleType != "new" && ModuleId != "-"))
|
if ((ModuleType == "new" && ModuleDefinitionName != "-") || (ModuleType != "new" && ModuleId != "-"))
|
||||||
{
|
{
|
||||||
if (ModuleType == "new")
|
if (ModuleType == "new")
|
||||||
{
|
{
|
||||||
Module module = new Module();
|
Module module = new Module();
|
||||||
module.SiteId = PageState.Site.SiteId;
|
module.SiteId = PageState.Site.SiteId;
|
||||||
module.PageId = PageState.Page.PageId;
|
module.PageId = PageState.Page.PageId;
|
||||||
module.ModuleDefinitionName = ModuleDefinitionName;
|
module.ModuleDefinitionName = ModuleDefinitionName;
|
||||||
module.AllPages = false;
|
module.AllPages = false;
|
||||||
|
|
||||||
var permissions = new List<Permission>();
|
var permissions = new List<Permission>();
|
||||||
if (Visibility == "view")
|
if (Visibility == "view")
|
||||||
{
|
{
|
||||||
// set module view permissions to page view permissions
|
// set module view permissions to page view permissions
|
||||||
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.View, PermissionNames.View);
|
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.View, PermissionNames.View);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set module view permissions to page edit permissions
|
// set module view permissions to page edit permissions
|
||||||
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.View, PermissionNames.Edit);
|
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.View, PermissionNames.Edit);
|
||||||
}
|
}
|
||||||
// set module edit permissions to page edit permissions
|
// set module edit permissions to page edit permissions
|
||||||
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.Edit, PermissionNames.Edit);
|
permissions = SetPermissions(permissions, module.SiteId, PermissionNames.Edit, PermissionNames.Edit);
|
||||||
module.PermissionList = permissions;
|
module.PermissionList = permissions;
|
||||||
|
|
||||||
module = await ModuleService.AddModuleAsync(module);
|
module = await ModuleService.AddModuleAsync(module);
|
||||||
ModuleId = module.ModuleId.ToString();
|
ModuleId = module.ModuleId.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
var pageModule = new PageModule
|
var pageModule = new PageModule
|
||||||
{
|
{
|
||||||
PageId = PageState.Page.PageId,
|
PageId = PageState.Page.PageId,
|
||||||
ModuleId = int.Parse(ModuleId),
|
ModuleId = int.Parse(ModuleId),
|
||||||
Title = Title
|
Title = Title
|
||||||
};
|
};
|
||||||
if (pageModule.Title == "")
|
if (pageModule.Title == "")
|
||||||
{
|
{
|
||||||
if (ModuleType == "new")
|
if (ModuleType == "new")
|
||||||
{
|
{
|
||||||
pageModule.Title = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName)?.Name;
|
pageModule.Title = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName)?.Name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(ModuleId))?.Title;
|
pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(ModuleId))?.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pageModule.Pane = Pane;
|
pageModule.Pane = Pane;
|
||||||
pageModule.Order = int.MaxValue;
|
pageModule.Order = int.MaxValue;
|
||||||
pageModule.ContainerType = ContainerType;
|
pageModule.ContainerType = ContainerType;
|
||||||
|
|
||||||
if (pageModule.ContainerType == PageState.Site.DefaultContainerType)
|
if (pageModule.ContainerType == PageState.Site.DefaultContainerType)
|
||||||
{
|
{
|
||||||
pageModule.ContainerType = "";
|
pageModule.ContainerType = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
await PageModuleService.AddPageModuleAsync(pageModule);
|
await PageModuleService.AddPageModuleAsync(pageModule);
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pageModule.PageId, pageModule.Pane);
|
await PageModuleService.UpdatePageModuleOrderAsync(pageModule.PageId, pageModule.Pane);
|
||||||
|
|
||||||
Message = $"<div class=\"alert alert-success mt-2 text-center\" role=\"alert\">{Localizer["Success.Page.ModuleAdd"]}</div>";
|
Message = $"<div class=\"alert alert-success mt-2 text-center\" role=\"alert\">{Localizer["Success.Page.ModuleAdd"]}</div>";
|
||||||
Title = "";
|
Title = "";
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message = $"<div class=\"alert alert-warning mt-2 text-center\" role=\"alert\">{Localizer["Message.Require.ModuleSelect"]}</div>";
|
Message = $"<div class=\"alert alert-warning mt-2 text-center\" role=\"alert\">{Localizer["Message.Require.ModuleSelect"]}</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message = $"<div class=\"alert alert-error mt-2 text-center\" role=\"alert\">{Localizer["Error.Authorize.No"]}</div>";
|
Message = $"<div class=\"alert alert-error mt-2 text-center\" role=\"alert\">{Localizer["Error.Authorize.No"]}</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Permission> SetPermissions(List<Permission> permissions, int siteId, string modulePermission, string pagePermission)
|
private List<Permission> SetPermissions(List<Permission> permissions, int siteId, string modulePermission, string pagePermission)
|
||||||
{
|
{
|
||||||
foreach (var permission in PageState.Page.PermissionList.Where(item => item.PermissionName == pagePermission))
|
foreach (var permission in PageState.Page.PermissionList.Where(item => item.PermissionName == pagePermission))
|
||||||
{
|
{
|
||||||
permissions.Add(new Permission { SiteId = siteId, EntityName = EntityNames.Module, PermissionName = modulePermission, RoleId = permission.RoleId, UserId = permission.UserId, IsAuthorized = permission.IsAuthorized });
|
permissions.Add(new Permission { SiteId = siteId, EntityName = EntityNames.Module, PermissionName = modulePermission, RoleId = permission.RoleId, UserId = permission.UserId, IsAuthorized = permission.IsAuthorized });
|
||||||
}
|
}
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ToggleEditMode(bool EditMode)
|
private async Task ToggleEditMode(bool EditMode)
|
||||||
{
|
{
|
||||||
if (_showEditMode)
|
if (_showEditMode)
|
||||||
{
|
{
|
||||||
if (EditMode)
|
if (EditMode)
|
||||||
{
|
{
|
||||||
PageState.EditMode = false;
|
PageState.EditMode = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PageState.EditMode = true;
|
PageState.EditMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + ((PageState.EditMode) ? "true" : "false")));
|
// preserve other querystring parameters
|
||||||
|
if (PageState.QueryString.ContainsKey("edit")) PageState.QueryString.Remove("edit");
|
||||||
|
PageState.QueryString.Add("edit", PageState.EditMode.ToString().ToLower());
|
||||||
|
var url = PageState.Route.AbsolutePath + Utilities.CreateQueryString(PageState.QueryString);
|
||||||
|
NavigationManager.NavigateTo(url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
@if (_visible)
|
@if (_visible)
|
||||||
{
|
{
|
||||||
<CascadingValue Value="@ModuleState">
|
<a id="@ModuleState.PageModuleId.ToString()"></a>
|
||||||
|
<CascadingValue Value="@ModuleState">
|
||||||
@if (_useadminborder)
|
@if (_useadminborder)
|
||||||
{
|
{
|
||||||
<div class="app-pane-admin-border">
|
<div class="app-pane-admin-border">
|
||||||
@ -16,6 +17,7 @@
|
|||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
}
|
}
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@ -38,7 +40,7 @@
|
|||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
string container = ModuleState.ContainerType;
|
string container = ModuleState.ContainerType;
|
||||||
if (PageState.ModuleId != -1 && ModuleState.UseAdminContainer)
|
if (PageState.ModuleId != -1 && PageState.Route.Action != "" && ModuleState.UseAdminContainer)
|
||||||
{
|
{
|
||||||
container = (!string.IsNullOrEmpty(PageState.Site.AdminContainerType)) ? PageState.Site.AdminContainerType : Constants.DefaultAdminContainer;
|
container = (!string.IsNullOrEmpty(PageState.Site.AdminContainerType)) ? PageState.Site.AdminContainerType : Constants.DefaultAdminContainer;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ namespace Oqtane.UI
|
|||||||
public int VisitorId { get; set; }
|
public int VisitorId { get; set; }
|
||||||
public string RemoteIPAddress { get; set; }
|
public string RemoteIPAddress { get; set; }
|
||||||
public string ReturnUrl { get; set; }
|
public string ReturnUrl { get; set; }
|
||||||
|
public bool IsInternalNavigation { get; set; }
|
||||||
|
|
||||||
public List<Page> Pages
|
public List<Page> Pages
|
||||||
{
|
{
|
||||||
|
@ -17,61 +17,59 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool _useadminborder = false;
|
private bool _useadminborder = false;
|
||||||
private string _panetitle = "";
|
private string _panetitle = "";
|
||||||
|
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected PageState PageState { get; set; }
|
protected PageState PageState { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList) && PageState.Action == Constants.DefaultAction)
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList) && PageState.Action == Constants.DefaultAction)
|
||||||
{
|
{
|
||||||
_useadminborder = true;
|
_useadminborder = true;
|
||||||
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_useadminborder = false;
|
_useadminborder = false;
|
||||||
_panetitle = "";
|
_panetitle = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
|
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
|
||||||
{
|
{
|
||||||
// action route needs to inject module control into specific pane
|
var pane = module.Pane;
|
||||||
string pane = "";
|
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
||||||
if (PageState.Page.Panes.FindIndex(item => item.Equals(PaneNames.Default, StringComparison.OrdinalIgnoreCase)) != -1)
|
{
|
||||||
{
|
if (PageState.Page.Panes.FindIndex(item => item.Equals(PaneNames.Default, StringComparison.OrdinalIgnoreCase)) != -1)
|
||||||
pane = PaneNames.Default;
|
{
|
||||||
}
|
pane = PaneNames.Default;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
pane = PaneNames.Admin;
|
{
|
||||||
|
pane = PaneNames.Admin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// pane matches current pane
|
||||||
if (Name.ToLower() == pane.ToLower())
|
if (Name.ToLower() == pane.ToLower())
|
||||||
{
|
{
|
||||||
Module module = PageState.Modules.FirstOrDefault(item => item.PageId == PageState.Page.PageId && item.ModuleId == PageState.ModuleId);
|
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
||||||
if (module == null)
|
{
|
||||||
{
|
var moduleType = Type.GetType(module.ModuleType);
|
||||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
if (moduleType != null)
|
||||||
}
|
{
|
||||||
if (module != null)
|
bool authorized = false;
|
||||||
{
|
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
||||||
var moduleType = Type.GetType(module.ModuleType);
|
{
|
||||||
if (moduleType != null)
|
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList);
|
||||||
{
|
|
||||||
bool authorized = false;
|
|
||||||
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
|
||||||
{
|
|
||||||
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -100,43 +98,20 @@ else
|
|||||||
CreateComponent(builder, module);
|
CreateComponent(builder, module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// module type does not exist
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (PageState.ModuleId != -1)
|
|
||||||
{
|
|
||||||
Module module = PageState.Modules.FirstOrDefault(item => item.PageId == PageState.Page.PageId && item.ModuleId == PageState.ModuleId);
|
|
||||||
if (module == null)
|
|
||||||
{
|
|
||||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
|
||||||
}
|
|
||||||
if (module != null && module.Pane.ToLower() == Name.ToLower())
|
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
if (PageState.ModuleId == -1 || PageState.ModuleId == module.ModuleId)
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
|
||||||
{
|
{
|
||||||
CreateComponent(builder, module);
|
// check if user is authorized to view module
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
||||||
|
{
|
||||||
|
CreateComponent(builder, module);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower()))
|
|
||||||
{
|
|
||||||
// check if user is authorized to view module
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList))
|
|
||||||
{
|
|
||||||
CreateComponent(builder, module);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _absoluteUri;
|
private string _absoluteUri;
|
||||||
|
private bool _isInternalNavigation = false;
|
||||||
private bool _navigationInterceptionEnabled;
|
private bool _navigationInterceptionEnabled;
|
||||||
private PageState _pagestate;
|
private PageState _pagestate;
|
||||||
private string _error = "";
|
private string _error = "";
|
||||||
@ -72,6 +73,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void LocationChanged(object sender, LocationChangedEventArgs args)
|
||||||
|
{
|
||||||
|
_absoluteUri = args.Location;
|
||||||
|
_isInternalNavigation = true;
|
||||||
|
await Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
Task IHandleAfterRender.OnAfterRenderAsync()
|
||||||
|
{
|
||||||
|
if (!_navigationInterceptionEnabled)
|
||||||
|
{
|
||||||
|
_navigationInterceptionEnabled = true;
|
||||||
|
return NavigationInterception.EnableNavigationInterceptionAsync();
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
{
|
{
|
||||||
@ -87,7 +105,7 @@
|
|||||||
Route route = new Route(_absoluteUri, SiteState.Alias.Path);
|
Route route = new Route(_absoluteUri, SiteState.Alias.Path);
|
||||||
int moduleid = (int.TryParse(route.ModuleId, out moduleid)) ? moduleid : -1;
|
int moduleid = (int.TryParse(route.ModuleId, out moduleid)) ? moduleid : -1;
|
||||||
var action = (!string.IsNullOrEmpty(route.Action)) ? route.Action : Constants.DefaultAction;
|
var action = (!string.IsNullOrEmpty(route.Action)) ? route.Action : Constants.DefaultAction;
|
||||||
var querystring = ParseQueryString(route.Query);
|
var querystring = Utilities.ParseQueryString(route.Query);
|
||||||
var returnurl = "";
|
var returnurl = "";
|
||||||
if (querystring.ContainsKey("returnurl"))
|
if (querystring.ContainsKey("returnurl"))
|
||||||
{
|
{
|
||||||
@ -233,7 +251,8 @@
|
|||||||
Runtime = runtime,
|
Runtime = runtime,
|
||||||
VisitorId = VisitorId,
|
VisitorId = VisitorId,
|
||||||
RemoteIPAddress = SiteState.RemoteIPAddress,
|
RemoteIPAddress = SiteState.RemoteIPAddress,
|
||||||
ReturnUrl = returnurl
|
ReturnUrl = returnurl,
|
||||||
|
IsInternalNavigation = _isInternalNavigation
|
||||||
};
|
};
|
||||||
|
|
||||||
OnStateChange?.Invoke(_pagestate);
|
OnStateChange?.Invoke(_pagestate);
|
||||||
@ -278,56 +297,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void LocationChanged(object sender, LocationChangedEventArgs args)
|
|
||||||
{
|
|
||||||
_absoluteUri = args.Location;
|
|
||||||
await Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
Task IHandleAfterRender.OnAfterRenderAsync()
|
|
||||||
{
|
|
||||||
if (!_navigationInterceptionEnabled)
|
|
||||||
{
|
|
||||||
_navigationInterceptionEnabled = true;
|
|
||||||
return NavigationInterception.EnableNavigationInterceptionAsync();
|
|
||||||
}
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<string, string> ParseQueryString(string query)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> querystring = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // case insensistive keys
|
|
||||||
if (!string.IsNullOrEmpty(query))
|
|
||||||
{
|
|
||||||
if (query.StartsWith("?"))
|
|
||||||
{
|
|
||||||
query = query.Substring(1); // ignore "?"
|
|
||||||
}
|
|
||||||
foreach (string kvp in query.Split('&', StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
|
||||||
if (kvp != "")
|
|
||||||
{
|
|
||||||
if (kvp.Contains("="))
|
|
||||||
{
|
|
||||||
string[] pair = kvp.Split('=');
|
|
||||||
if (!querystring.ContainsKey(pair[0]))
|
|
||||||
{
|
|
||||||
querystring.Add(pair[0], pair[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!querystring.ContainsKey(kvp))
|
|
||||||
{
|
|
||||||
querystring.Add(kvp, "true"); // default parameter when no value is provided
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return querystring;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<Page> ProcessPage(Page page, Site site, User user, Alias alias)
|
private async Task<Page> ProcessPage(Page page, Site site, User user, Alias alias)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -411,11 +380,16 @@
|
|||||||
if ((module.PageId == page.PageId || module.ModuleId == moduleid))
|
if ((module.PageId == page.PageId || module.ModuleId == moduleid))
|
||||||
{
|
{
|
||||||
var typename = Constants.ErrorModule;
|
var typename = Constants.ErrorModule;
|
||||||
|
|
||||||
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(Runtime)))
|
if (module.ModuleDefinition != null && (module.ModuleDefinition.Runtimes == "" || module.ModuleDefinition.Runtimes.Contains(Runtime)))
|
||||||
{
|
{
|
||||||
typename = module.ModuleDefinition.ControlTypeTemplate;
|
typename = module.ModuleDefinition.ControlTypeTemplate;
|
||||||
|
|
||||||
// handle default action
|
// handle default action
|
||||||
|
if (moduleid != module.ModuleId)
|
||||||
|
{
|
||||||
|
action = Constants.DefaultAction;
|
||||||
|
}
|
||||||
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
|
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
|
||||||
{
|
{
|
||||||
action = module.ModuleDefinition.DefaultAction;
|
action = module.ModuleDefinition.DefaultAction;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -438,28 +439,50 @@ namespace Oqtane.Shared
|
|||||||
|
|
||||||
public static Dictionary<string, string> ParseQueryString(string query)
|
public static Dictionary<string, string> ParseQueryString(string query)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
Dictionary<string, string> querystring = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // case insensistive keys
|
||||||
if (!string.IsNullOrEmpty(query))
|
if (!string.IsNullOrEmpty(query))
|
||||||
{
|
{
|
||||||
query = query.Substring(1);
|
if (query.StartsWith("?"))
|
||||||
string str = query;
|
|
||||||
char[] separator = new char[1] { '&' };
|
|
||||||
foreach (string key in str.Split(separator, StringSplitOptions.RemoveEmptyEntries))
|
|
||||||
{
|
{
|
||||||
if (key != "")
|
query = query.Substring(1); // ignore "?"
|
||||||
|
}
|
||||||
|
foreach (string kvp in query.Split('&', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (kvp != "")
|
||||||
{
|
{
|
||||||
if (key.Contains("="))
|
if (kvp.Contains("="))
|
||||||
{
|
{
|
||||||
string[] strArray = key.Split('=', StringSplitOptions.None);
|
string[] pair = kvp.Split('=');
|
||||||
dictionary.Add(strArray[0], strArray[1]);
|
if (!querystring.ContainsKey(pair[0]))
|
||||||
|
{
|
||||||
|
querystring.Add(pair[0], pair[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dictionary.Add(key, "true");
|
{
|
||||||
|
if (!querystring.ContainsKey(kvp))
|
||||||
|
{
|
||||||
|
querystring.Add(kvp, "true"); // default parameter when no value is provided
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return querystring;
|
||||||
|
}
|
||||||
|
|
||||||
return dictionary;
|
public static string CreateQueryString(Dictionary<string, string> parameters)
|
||||||
|
{
|
||||||
|
var querystring = "";
|
||||||
|
if (parameters.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var kvp in parameters)
|
||||||
|
{
|
||||||
|
querystring += (querystring == "") ? "?" : "&";
|
||||||
|
querystring += kvp.Key + "=" + kvp.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return querystring;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string LogMessage(object @class, string message)
|
public static string LogMessage(object @class, string message)
|
||||||
|
Reference in New Issue
Block a user