Refactor host user security model, support static assets in modules and themes, module definition permissions and categories, paging control, remove SiteUsers, move seed data from script to site template for installation
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inherits ThemeControlBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@ -40,11 +40,21 @@
|
||||
<td>
|
||||
@if (moduledefinitions != null)
|
||||
{
|
||||
<select class="form-control" @onchange="(e => CategoryChanged(e))">
|
||||
<option value="-"><Common Modules></option>
|
||||
@foreach (var category in categories)
|
||||
{
|
||||
<option value="@category">@category</option>
|
||||
}
|
||||
</select>
|
||||
<select class="form-control" @bind="@moduledefinitionname">
|
||||
<option value=""><Select Module></option>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
{
|
||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||
if (moduledefinition.Permissions == "[]" || UserSecurity.IsAuthorized(PageState.User, "Utilize", moduledefinition.Permissions))
|
||||
{
|
||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
}
|
||||
@ -115,9 +125,11 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
List<string> categories = new List<string>();
|
||||
List<ModuleDefinition> moduledefinitions;
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
int pagemanagementmoduleid = -1;
|
||||
string category = "";
|
||||
string moduledefinitionname = "";
|
||||
string pane = "";
|
||||
string title = "";
|
||||
@ -127,7 +139,20 @@
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions;
|
||||
foreach(ModuleDefinition moduledefinition in PageState.ModuleDefinitions)
|
||||
{
|
||||
if (moduledefinition.Categories != "")
|
||||
{
|
||||
foreach(string category in moduledefinition.Categories.Split(','))
|
||||
{
|
||||
if (!categories.Contains(category))
|
||||
{
|
||||
categories.Add(category);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
moduledefinitions = PageState.ModuleDefinitions.Where(item => item.Categories == "").ToList();
|
||||
containers = ThemeService.GetContainerTypes(PageState.Themes);
|
||||
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, Constants.PageManagementModule);
|
||||
if (modules.Count > 0)
|
||||
@ -137,6 +162,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void CategoryChanged(ChangeEventArgs e)
|
||||
{
|
||||
string category = (string)e.Value;
|
||||
if (category == "-")
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions.Where(item => item.Categories == "").ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions.Where(item => item.Categories.Contains(e.Value.ToString())).ToList();
|
||||
}
|
||||
moduledefinitionname = "";
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task AddModule()
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
@ -145,14 +185,11 @@
|
||||
module.SiteId = PageState.Site.SiteId;
|
||||
module.ModuleDefinitionName = moduledefinitionname;
|
||||
module.Permissions = PageState.Page.Permissions;
|
||||
await ModuleService.AddModuleAsync(module);
|
||||
|
||||
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, moduledefinitionname);
|
||||
int ModuleId = modules.LastOrDefault().ModuleId;
|
||||
module = await ModuleService.AddModuleAsync(module);
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
pagemodule.PageId = PageState.Page.PageId;
|
||||
pagemodule.ModuleId = ModuleId;
|
||||
pagemodule.ModuleId = module.ModuleId;
|
||||
if (title == "")
|
||||
{
|
||||
title = moduledefinitions.Where(item => item.ModuleDefinitionName == moduledefinitionname).FirstOrDefault().Name;
|
||||
|
@ -6,7 +6,7 @@
|
||||
@using Oqtane.Shared
|
||||
@using Microsoft.JSInterop
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inherits ThemeControlBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IUserService UserService
|
||||
@inject IJSRuntime jsRuntime
|
||||
@ -33,7 +33,7 @@
|
||||
{
|
||||
returnurl += "/" + PageState.Page.Path;
|
||||
}
|
||||
NavigationManager.NavigateTo("login?returnurl=" + returnurl);
|
||||
NavigationManager.NavigateTo(NavigateUrl("login", "returnurl=" + returnurl));
|
||||
}
|
||||
|
||||
private async Task LogoutUser()
|
||||
|
@ -1,7 +1,7 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Themes
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inherits ThemeControlBase
|
||||
|
||||
@((MarkupString)logo)
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
@using Oqtane.Models;
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inherits ThemeControlBase
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (menu != "")
|
||||
@ -37,7 +37,7 @@
|
||||
}
|
||||
if (p.Icon != "")
|
||||
{
|
||||
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>";
|
||||
menu += "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span>";
|
||||
}
|
||||
menu += p.Name;
|
||||
menu += "</a>\n";
|
||||
|
@ -2,7 +2,7 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Themes
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeObjectBase
|
||||
@inherits ThemeControlBase
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<AuthorizeView>
|
||||
|
Reference in New Issue
Block a user