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:
@ -9,20 +9,20 @@
|
||||
@inject IPageService PageService
|
||||
@inject IUserService UserService
|
||||
|
||||
<ul class="list-group">
|
||||
<div class="row">
|
||||
@foreach (var p in pages)
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||
{
|
||||
string url = NavigateUrl(p.Path);
|
||||
<li class="list-group-item">
|
||||
<div class="col-md-2 mx-auto text-center">
|
||||
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
|
||||
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
||||
<h2><span class="oi oi-@p.Icon" aria-hidden="true"></span></h2>@p.Name
|
||||
</NavLink>
|
||||
</li>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// display list of pages which are children of current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
||||
// display list of pages which are children of current page
|
||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
91
Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor
Normal file
91
Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor
Normal file
@ -0,0 +1,91 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Modules.Controls
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
||||
@inherits ModuleBase
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="ModuleDefinition" PermissionNames="Utilize" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
string message = "";
|
||||
|
||||
int ModuleDefinitionId;
|
||||
string name;
|
||||
string permissions;
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
DateTime modifiedon;
|
||||
|
||||
PermissionGrid permissiongrid;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
try
|
||||
{
|
||||
ModuleDefinitionId = Int32.Parse(PageState.QueryString["id"]);
|
||||
ModuleDefinition moduledefinition = PageState.ModuleDefinitions.Where(item => item.ModuleDefinitionId == ModuleDefinitionId).FirstOrDefault();
|
||||
if (moduledefinition != null)
|
||||
{
|
||||
name = moduledefinition.Name;
|
||||
permissions = moduledefinition.Permissions;
|
||||
createdby = moduledefinition.CreatedBy;
|
||||
createdon = moduledefinition.CreatedOn;
|
||||
modifiedby = moduledefinition.ModifiedBy;
|
||||
modifiedon = moduledefinition.ModifiedOn;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveModuleDefinition()
|
||||
{
|
||||
try
|
||||
{
|
||||
ModuleDefinition moduledefinition = PageState.ModuleDefinitions.Where(item => item.ModuleDefinitionId == ModuleDefinitionId).FirstOrDefault();
|
||||
moduledefinition.Permissions = permissiongrid.GetPermissions();
|
||||
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
|
||||
NavigationManager.NavigateTo(NavigateUrl(Reload.Site));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,15 +17,19 @@ else
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var moduledefinition in moduledefinitions)
|
||||
{
|
||||
<tr>
|
||||
<td>@moduledefinition.Name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + moduledefinition.ModuleDefinitionId.ToString())" /></td>
|
||||
<td>@moduledefinition.Name</td>
|
||||
<td>@moduledefinition.Version</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@ -38,6 +42,6 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@
|
||||
<label for="Name" class="control-label">Permissions: </label>
|
||||
</td>
|
||||
<td>
|
||||
<PermissionGrid EntityName="Module" Permissions="@permissions" @ref="permissiongrid" />
|
||||
<PermissionGrid EntityName="Module" PermissionNames="@permissionnames" Permissions="@permissions" @ref="permissiongrid" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -76,6 +76,7 @@
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
string title;
|
||||
string containertype;
|
||||
string permissionnames = "";
|
||||
string permissions;
|
||||
string pageid;
|
||||
|
||||
@ -90,6 +91,7 @@
|
||||
containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
|
||||
containertype = ModuleState.ContainerType;
|
||||
permissions = ModuleState.Permissions;
|
||||
permissionnames = PageState.ModuleDefinitions.Find(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).PermissionNames;
|
||||
pageid = ModuleState.PageId.ToString();
|
||||
|
||||
DynamicComponent = builder =>
|
||||
|
@ -37,7 +37,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value=""><Site Root></option>
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||
@ -191,7 +191,7 @@
|
||||
try
|
||||
{
|
||||
parentid = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
if (parentid == "-1")
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ParentChanged(e))">
|
||||
<option value=""><Site Root></option>
|
||||
<option value="-1"><Site Root></option>
|
||||
@foreach (Page page in pages)
|
||||
{
|
||||
if (page.PageId.ToString() == parentid)
|
||||
@ -237,7 +237,7 @@
|
||||
try
|
||||
{
|
||||
parentid = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(parentid))
|
||||
if (parentid == "-1")
|
||||
{
|
||||
children = PageState.Pages.Where(item => item.ParentId == null).ToList();
|
||||
}
|
||||
|
@ -9,27 +9,20 @@
|
||||
|
||||
@if (PageState.Pages != null)
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Page" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (Page page in PageState.Pages)
|
||||
{
|
||||
<tr>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + page.PageId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + page.PageId.ToString())" Class="btn btn-danger" /></td>
|
||||
<td>@(new string('-', page.Level * 2))@(page.Name)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
|
||||
|
||||
<Pager Items="@PageState.Pages" DisplayPages="3" PageSize="3">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" /></td>
|
||||
<td><ActionLink Action="Delete" Parameters="@($"id=" +context.PageId.ToString())" Class="btn btn-danger" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
@ -34,7 +34,6 @@
|
||||
user.Username = Email;
|
||||
user.DisplayName = Email;
|
||||
user.Email = Email;
|
||||
user.IsHost = false;
|
||||
user.Password = Password;
|
||||
await UserService.AddUserAsync(user);
|
||||
NavigationManager.NavigateTo("");
|
||||
|
@ -11,7 +11,7 @@
|
||||
@inject ITenantService TenantService
|
||||
@inject IAliasService AliasService
|
||||
@inject ISiteService SiteService
|
||||
@inject IPageService PageService
|
||||
@inject IThemeService ThemeService
|
||||
|
||||
@if (tenants == null)
|
||||
{
|
||||
@ -58,6 +58,34 @@ else
|
||||
<input class="form-control" @bind="@logo" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Theme: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@themetype">
|
||||
<option value=""><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Default Layout: </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveSite">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
@ -66,15 +94,23 @@ else
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
||||
List<Tenant> tenants;
|
||||
string tenantid = "";
|
||||
string name = "";
|
||||
string url = "";
|
||||
string logo = "";
|
||||
string themetype;
|
||||
string layouttype;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
tenants = await TenantService.GetTenantsAsync();
|
||||
url = PageState.Alias.Name;
|
||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||
}
|
||||
|
||||
private async Task SaveSite()
|
||||
@ -82,9 +118,9 @@ else
|
||||
Site site = new Site();
|
||||
site.Name = name;
|
||||
site.Logo = (logo == null ? "" : logo);
|
||||
await SiteService.AddSiteAsync(site);
|
||||
List<Site> sites = await SiteService.GetSitesAsync();
|
||||
site = sites.Where(item => item.Name == name).FirstOrDefault();
|
||||
site.DefaultThemeType = themetype;
|
||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
||||
site = await SiteService.AddSiteAsync(site);
|
||||
|
||||
Alias alias = new Alias();
|
||||
alias.Name = url;
|
||||
@ -92,28 +128,6 @@ else
|
||||
alias.SiteId = site.SiteId;
|
||||
await AliasService.AddAliasAsync(alias);
|
||||
|
||||
// need to add a home page and admin pages
|
||||
Page p = new Page();
|
||||
p.SiteId = site.SiteId;
|
||||
p.ParentId = null;
|
||||
p.Name = "Home";
|
||||
p.Path = "";
|
||||
p.Order = 1;
|
||||
p.IsNavigation = true;
|
||||
p.ThemeType = PageState.Site.DefaultThemeType;
|
||||
p.LayoutType = "";
|
||||
p.Icon = "";
|
||||
Type type = Type.GetType(p.ThemeType);
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
|
||||
List<PermissionString> permissionstrings = new List<PermissionString>();
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "View", Permissions = Constants.AllUsersRole });
|
||||
permissionstrings.Add(new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole });
|
||||
p.Permissions = UserSecurity.SetPermissionStrings(permissionstrings);
|
||||
|
||||
await PageService.AddPageAsync(p);
|
||||
|
||||
NavigationManager.NavigateTo(url, true);
|
||||
}
|
||||
}
|
||||
|
62
Oqtane.Client/Modules/Admin/Tenants/Add.razor
Normal file
62
Oqtane.Client/Modules/Admin/Tenants/Add.razor
Normal file
@ -0,0 +1,62 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Security
|
||||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
@inject IAliasService AliasService
|
||||
@inject ISiteService SiteService
|
||||
@inject IPageService PageService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Connection String: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@connectionstring" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Schema: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@schema" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveTenant">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
string name = "";
|
||||
string connectionstring = "";
|
||||
string schema = "";
|
||||
|
||||
private async Task SaveTenant()
|
||||
{
|
||||
Tenant tenant = new Tenant();
|
||||
tenant.Name = name;
|
||||
tenant.DBConnectionString = connectionstring;
|
||||
tenant.DBSchema = schema;
|
||||
await TenantService.AddTenantAsync(tenant);
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
43
Oqtane.Client/Modules/Admin/Tenants/Index.razor
Normal file
43
Oqtane.Client/Modules/Admin/Tenants/Index.razor
Normal file
@ -0,0 +1,43 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Modules.Controls
|
||||
@namespace Oqtane.Modules.Admin.Tenants
|
||||
@inherits ModuleBase
|
||||
@inject ITenantService TenantService
|
||||
|
||||
@if (Tenants == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Tenant" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var Tenant in Tenants)
|
||||
{
|
||||
<tr>
|
||||
<td>@Tenant.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Tenant> Tenants;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Tenants = await TenantService.GetTenantsAsync();
|
||||
}
|
||||
}
|
@ -3,12 +3,12 @@
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Modules.Controls
|
||||
@using Oqtane.Shared
|
||||
@namespace Oqtane.Modules.Admin.Users
|
||||
@inherits ModuleBase
|
||||
@inject IUserRoleService UserRoleService
|
||||
|
||||
@inject IUserService UserService
|
||||
|
||||
@if (Users == null)
|
||||
@if (userroles == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
@ -21,10 +21,10 @@ else
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var User in Users)
|
||||
@foreach (UserRole userrole in userroles)
|
||||
{
|
||||
<tr>
|
||||
<td>@User.Username</td>
|
||||
<td>@userrole.User.Username</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@ -34,10 +34,11 @@ else
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
List<User> Users;
|
||||
List<UserRole> userroles;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Users = await UserService.GetUsersAsync(PageState.Site.SiteId);
|
||||
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
|
||||
userroles = userroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList();
|
||||
}
|
||||
}
|
150
Oqtane.Client/Modules/Controls/Pager.razor
Normal file
150
Oqtane.Client/Modules/Controls/Pager.razor
Normal file
@ -0,0 +1,150 @@
|
||||
@using Oqtane.Modules
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@typeparam TableItem
|
||||
|
||||
<p align="center">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>@Header</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ItemList)
|
||||
{
|
||||
<tr>@Row(item)</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination">
|
||||
@if (Page > MaxPages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("back"))><span class="oi oi-media-skip-backward" title="back" aria-hidden="true"></span></button>
|
||||
}
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button>
|
||||
|
||||
@for (int i = StartPage; i <= EndPage; i++)
|
||||
{
|
||||
var pager = i;
|
||||
<button class="btn @((pager == Page) ? "btn-primary" : "btn-link")" @onclick=@(async () => UpdateList(pager))>
|
||||
@pager
|
||||
</button>
|
||||
}
|
||||
|
||||
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("next"))><span class="oi oi-chevron-right" title="next" aria-hidden="true"></span></button>
|
||||
@if (EndPage < Pages)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("forward"))><span class="oi oi-media-skip-forward" title="forward" aria-hidden="true"></span></button>
|
||||
}
|
||||
|
||||
<span class="btn btn-link disabled">Page @Page of @Pages</span>
|
||||
</div>
|
||||
</p>
|
||||
|
||||
@code {
|
||||
int Pages;
|
||||
int Page;
|
||||
int MaxItems;
|
||||
int MaxPages;
|
||||
int StartPage;
|
||||
int EndPage;
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment Header { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment<TableItem> Row { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public IEnumerable<TableItem> Items { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string PageSize { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string DisplayPages { get; set; }
|
||||
|
||||
IEnumerable<TableItem> ItemList { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PageSize))
|
||||
{
|
||||
MaxItems = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxItems = int.Parse(PageSize);
|
||||
}
|
||||
if (string.IsNullOrEmpty(DisplayPages))
|
||||
{
|
||||
MaxPages = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxPages = int.Parse(DisplayPages);
|
||||
}
|
||||
Page = 1;
|
||||
|
||||
ItemList = Items.Skip((Page - 1) * MaxItems).Take(MaxItems);
|
||||
Pages = (int)Math.Ceiling(Items.Count() / (decimal)MaxItems);
|
||||
|
||||
SetPagerSize("forward");
|
||||
}
|
||||
|
||||
public void UpdateList(int CurrentPage)
|
||||
{
|
||||
ItemList = Items.Skip((Page - 1) * MaxItems).Take(MaxItems);
|
||||
Page = CurrentPage;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void SetPagerSize(string direction)
|
||||
{
|
||||
if (direction == "forward")
|
||||
{
|
||||
StartPage = EndPage + 1;
|
||||
if (EndPage + MaxPages < Pages)
|
||||
{
|
||||
EndPage = StartPage + MaxPages - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndPage = Pages;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
else if (direction == "back")
|
||||
{
|
||||
EndPage = StartPage - 1;
|
||||
StartPage = StartPage - MaxPages;
|
||||
}
|
||||
}
|
||||
|
||||
public void NavigateToPage(string direction)
|
||||
{
|
||||
if (direction == "next")
|
||||
{
|
||||
if (Page < Pages)
|
||||
{
|
||||
if (Page == EndPage)
|
||||
{
|
||||
SetPagerSize("forward");
|
||||
}
|
||||
Page += 1;
|
||||
}
|
||||
}
|
||||
else if (direction == "previous")
|
||||
{
|
||||
if (Page > 1)
|
||||
{
|
||||
if (Page == StartPage)
|
||||
{
|
||||
SetPagerSize("back");
|
||||
}
|
||||
Page -= 1;
|
||||
}
|
||||
}
|
||||
UpdateList(Page);
|
||||
}
|
||||
}
|
@ -83,6 +83,9 @@
|
||||
[Parameter]
|
||||
public string EntityName { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string PermissionNames { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Permissions { get; set; }
|
||||
|
||||
@ -95,8 +98,7 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
permissionnames = PageState.ModuleDefinitions.Find(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).Permissions;
|
||||
if (string.IsNullOrEmpty(permissionnames))
|
||||
if (string.IsNullOrEmpty(PermissionNames))
|
||||
{
|
||||
permissionnames = "View,Edit";
|
||||
}
|
||||
|
@ -20,6 +20,11 @@ namespace Oqtane.Modules
|
||||
|
||||
public virtual bool UseAdminContainer { get { return true; } }
|
||||
|
||||
public string ModulePath()
|
||||
{
|
||||
return "Modules/" + this.GetType().Namespace + "/";
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
|
@ -6,7 +6,8 @@ namespace Oqtane.Services
|
||||
{
|
||||
public interface IModuleDefinitionService
|
||||
{
|
||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync();
|
||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId);
|
||||
Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition);
|
||||
Task InstallModulesAsync();
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,7 @@ namespace Oqtane.Services
|
||||
Task<List<Tenant>> GetTenantsAsync();
|
||||
|
||||
Task<Tenant> GetTenantAsync();
|
||||
|
||||
Task<Tenant> AddTenantAsync(Tenant Tenant);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace Oqtane.Services
|
||||
public interface IUserRoleService
|
||||
{
|
||||
Task<List<UserRole>> GetUserRolesAsync();
|
||||
Task<List<UserRole>> GetUserRolesAsync(int UserId);
|
||||
Task<List<UserRole>> GetUserRolesAsync(int SiteId);
|
||||
Task<UserRole> GetUserRoleAsync(int UserRoleId);
|
||||
Task<UserRole> AddUserRoleAsync(UserRole UserRole);
|
||||
Task<UserRole> UpdateUserRoleAsync(UserRole UserRole);
|
||||
|
@ -6,7 +6,7 @@ namespace Oqtane.Services
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
Task<List<User>> GetUsersAsync(int SiteId);
|
||||
Task<List<User>> GetUsersAsync();
|
||||
|
||||
Task<User> GetUserAsync(int UserId, int SiteId);
|
||||
|
||||
|
@ -28,10 +28,10 @@ namespace Oqtane.Services
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "ModuleDefinition"); }
|
||||
}
|
||||
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId)
|
||||
{
|
||||
// get list of modules from the server
|
||||
List<ModuleDefinition> moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl);
|
||||
List<ModuleDefinition> moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
|
||||
// get list of loaded assemblies on the client ( in the client-side hosting module the browser client has its own app domain )
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
@ -64,6 +64,11 @@ namespace Oqtane.Services
|
||||
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition)
|
||||
{
|
||||
await http.PutJsonAsync<Page>(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
||||
}
|
||||
|
||||
public async Task InstallModulesAsync()
|
||||
{
|
||||
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
|
@ -36,5 +36,10 @@ namespace Oqtane.Services
|
||||
{
|
||||
return await http.GetJsonAsync<Tenant>(apiurl);
|
||||
}
|
||||
|
||||
public async Task<Tenant> AddTenantAsync(Tenant Tenant)
|
||||
{
|
||||
return await http.PostJsonAsync<Tenant>(apiurl, Tenant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<List<UserRole>>(apiurl);
|
||||
}
|
||||
|
||||
public async Task<List<UserRole>> GetUserRolesAsync(int UserId)
|
||||
public async Task<List<UserRole>> GetUserRolesAsync(int SiteId)
|
||||
{
|
||||
return await http.GetJsonAsync<List<UserRole>>(apiurl + "?userid=" + UserId.ToString());
|
||||
return await http.GetJsonAsync<List<UserRole>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<UserRole> GetUserRoleAsync(int UserRoleId)
|
||||
|
@ -27,9 +27,9 @@ namespace Oqtane.Services
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "User"); }
|
||||
}
|
||||
|
||||
public async Task<List<User>> GetUsersAsync(int SiteId)
|
||||
public async Task<List<User>> GetUsersAsync()
|
||||
{
|
||||
List<User> users = await http.GetJsonAsync<List<User>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<User> users = await http.GetJsonAsync<List<User>>(apiurl);
|
||||
return users.OrderBy(item => item.DisplayName).ToList();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
@namespace Oqtane.Shared
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IInstallationService InstallationService
|
||||
@inject ISiteService SiteService
|
||||
@inject IAliasService AliasService
|
||||
@inject IUserService UserService
|
||||
|
||||
<div class="container">
|
||||
@ -165,12 +167,18 @@
|
||||
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||
if (response.Success)
|
||||
{
|
||||
Site site = new Site();
|
||||
site.Name = "Site1";
|
||||
site.Logo = "oqtane.png";
|
||||
site.DefaultThemeType = "Oqtane.Themes.Theme2.Theme2, Oqtane.Client";
|
||||
site.DefaultLayoutType = "";
|
||||
site = await SiteService.AddSiteAsync(site);
|
||||
|
||||
User user = new User();
|
||||
user.SiteId = 1;
|
||||
user.SiteId = site.SiteId;
|
||||
user.Username = Email;
|
||||
user.DisplayName = Email;
|
||||
user.Email = Email;
|
||||
user.IsHost = true;
|
||||
user.Password = HostPassword;
|
||||
user = await UserService.AddUserAsync(user);
|
||||
|
||||
|
@ -119,14 +119,12 @@
|
||||
|
||||
if (PageState == null || reload == Reload.Application)
|
||||
{
|
||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||
themes = await ThemeService.GetThemesAsync();
|
||||
aliases = await AliasService.GetAliasesAsync();
|
||||
alias = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions;
|
||||
themes = PageState.Themes;
|
||||
aliases = PageState.Aliases;
|
||||
alias = PageState.Alias;
|
||||
@ -151,10 +149,12 @@
|
||||
{
|
||||
if (PageState == null || reload >= Reload.Site)
|
||||
{
|
||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(site.SiteId);
|
||||
pages = await PageService.GetPagesAsync(site.SiteId);
|
||||
}
|
||||
else
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions;
|
||||
pages = PageState.Pages;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -10,6 +10,11 @@ namespace Oqtane.Themes
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Panes { get; set; }
|
||||
|
||||
public string ThemePath()
|
||||
{
|
||||
return "Themes/" + this.GetType().Namespace + "/";
|
||||
}
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
return NavigateUrl(PageState.Page.Path);
|
||||
@ -40,5 +45,19 @@ namespace Oqtane.Themes
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters, reload);
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action)
|
||||
{
|
||||
return EditUrl(moduleid, action, "");
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action, string parameters)
|
||||
{
|
||||
return EditUrl(PageState.Page.Path, moduleid, action, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(string path, int moduleid, string action, string parameters)
|
||||
{
|
||||
return Utilities.EditUrl(PageState.Alias.Path, path, moduleid, action, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Themes
|
||||
{
|
||||
public class ThemeObjectBase : ComponentBase
|
||||
public class ThemeControlBase : ComponentBase
|
||||
{
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
Reference in New Issue
Block a user