commit
ac23b720c4
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,7 +6,9 @@ artifacts/
|
||||||
msbuild.binlog
|
msbuild.binlog
|
||||||
.vscode/
|
.vscode/
|
||||||
*.binlog
|
*.binlog
|
||||||
|
*.nupkg
|
||||||
|
|
||||||
Oqtane.Server/appsettings.json
|
Oqtane.Server/appsettings.json
|
||||||
Oqtane.Server/Data/*.mdf
|
Oqtane.Server/Data/*.mdf
|
||||||
Oqtane.Server/Data/*.ldf
|
Oqtane.Server/Data/*.ldf
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Client.Shared
|
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
|
|
||||||
|
@if (Initialized)
|
||||||
|
{
|
||||||
@if (!Installed)
|
@if (!Installed)
|
||||||
{
|
{
|
||||||
<Installer />
|
<Installer />
|
||||||
|
@ -15,15 +16,18 @@ else
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
</CascadingAuthenticationState>
|
</CascadingAuthenticationState>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private bool Initialized = false;
|
||||||
private bool Installed = false;
|
private bool Installed = false;
|
||||||
private PageState PageState { get; set; }
|
private PageState PageState { get; set; }
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
var response = await InstallationService.IsInstalled();
|
var response = await InstallationService.IsInstalled();
|
||||||
Installed = response.Success;
|
Installed = response.Success;
|
||||||
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeState(PageState pagestate)
|
private void ChangeState(PageState pagestate)
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models;
|
@using Oqtane.Models;
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Admin.Dashboard
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IPageService PageService
|
@inject IPageService PageService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
@foreach (var p in pages)
|
@foreach (var p in pages)
|
||||||
{
|
{
|
||||||
if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions))
|
if (p.IsNavigation && UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||||
{
|
{
|
||||||
string url = NavigateUrl(p.Path);
|
string url = NavigateUrl(p.Path);
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
|
@ -21,12 +22,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
<br /><br />
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
List<Page> pages;
|
List<Page> pages;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
// display list of pages which are children of current page
|
// display list of pages which are children of current page
|
||||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
|
@ -5,6 +5,7 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Providers
|
@using Oqtane.Providers
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Modules.Admin.Login
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IJSRuntime jsRuntime
|
@inject IJSRuntime jsRuntime
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||||
|
|
||||||
public string Message { get; set; } = "";
|
public string Message { get; set; } = "";
|
||||||
public string Username { get; set; } = "";
|
public string Username { get; set; } = "";
|
||||||
|
@ -50,13 +51,6 @@ public string Password { get; set; } = "";
|
||||||
public bool Remember { get; set; } = false;
|
public bool Remember { get; set; } = false;
|
||||||
|
|
||||||
private async Task Login()
|
private async Task Login()
|
||||||
{
|
|
||||||
User user = new User();
|
|
||||||
user.Username = Username;
|
|
||||||
user.Password = Password;
|
|
||||||
user.IsPersistent = Remember;
|
|
||||||
user = await UserService.LoginUserAsync(user);
|
|
||||||
if (user.IsAuthenticated)
|
|
||||||
{
|
{
|
||||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||||
|
|
||||||
|
@ -64,6 +58,14 @@ private async Task Login()
|
||||||
if (authstateprovider == null)
|
if (authstateprovider == null)
|
||||||
{
|
{
|
||||||
// server-side Blazor
|
// server-side Blazor
|
||||||
|
User user = new User();
|
||||||
|
user.SiteId = PageState.Site.SiteId;
|
||||||
|
user.Username = Username;
|
||||||
|
user.Password = Password;
|
||||||
|
user = await UserService.LoginUserAsync(user, false, false);
|
||||||
|
if (user.IsAuthenticated)
|
||||||
|
{
|
||||||
|
// complete the login on the server so that the cookies are set correctly on SignalR
|
||||||
var interop = new Interop(jsRuntime);
|
var interop = new Interop(jsRuntime);
|
||||||
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||||
var fields = new { __RequestVerificationToken = antiforgerytoken, username = Username, password = Password, remember = Remember, returnurl = ReturnUrl };
|
var fields = new { __RequestVerificationToken = antiforgerytoken, username = Username, password = Password, remember = Remember, returnurl = ReturnUrl };
|
||||||
|
@ -71,20 +73,33 @@ private async Task Login()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// client-side Blazor
|
Message = "<div class=\"alert alert-danger\" role=\"alert\">Login Failed. Please Remember That Passwords Are Case Sensitive.</div>";
|
||||||
authstateprovider.NotifyAuthenticationChanged();
|
|
||||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// client-side Blazor
|
||||||
|
User user = new User();
|
||||||
|
user.SiteId = PageState.Site.SiteId;
|
||||||
|
user.Username = Username;
|
||||||
|
user.Password = Password;
|
||||||
|
user = await UserService.LoginUserAsync(user, true, Remember);
|
||||||
|
if (user.IsAuthenticated)
|
||||||
|
{
|
||||||
|
authstateprovider.NotifyAuthenticationChanged();
|
||||||
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Login Failed. Please Remember That Passwords Are Case Sensitive.</div>";
|
Message = "<div class=\"alert alert-danger\" role=\"alert\">Login Failed. Please Remember That Passwords Are Case Sensitive.</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Cancel()
|
private void Cancel()
|
||||||
{
|
{
|
||||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
UriHelper.NavigateTo(ReturnUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
50
Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
Normal file
50
Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@using Oqtane.Services
|
||||||
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject IUriHelper UriHelper
|
||||||
|
@inject IFileService FileService
|
||||||
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Module: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<FileUpload Filter=".nupkg"></FileUpload>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
@if (uploaded)
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-success" @onclick="InstallFile">Install</button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-success" @onclick="UploadFile">Upload</button>
|
||||||
|
}
|
||||||
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
|
bool uploaded = false;
|
||||||
|
|
||||||
|
private async Task UploadFile()
|
||||||
|
{
|
||||||
|
await FileService.UploadFilesAsync("Modules");
|
||||||
|
uploaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InstallFile()
|
||||||
|
{
|
||||||
|
await ModuleDefinitionService.InstallModulesAsync();
|
||||||
|
PageState.Reload = Constants.ReloadApplication;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
|
@namespace Oqtane.Modules.Admin.ModuleDefinitions
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
|
|
||||||
@if (moduledefinitions == null)
|
@if (moduledefinitions == null)
|
||||||
|
@ -12,7 +12,8 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="table">
|
<ActionLink Action="Add" Text="Install Module" />
|
||||||
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
@ -30,11 +31,11 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<ModuleDefinition> moduledefinitions;
|
List<ModuleDefinition> moduledefinitions;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,17 @@
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Security
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
|
@namespace Oqtane.Modules.Admin.ModuleSettings
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject IPageModuleService PageModuleService
|
@inject IPageModuleService PageModuleService
|
||||||
|
|
||||||
<table class="form-group">
|
<table class="table table-borderless">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Title" class="control-label">Title: </label>
|
<label for="Title" class="control-label">Title: </label>
|
||||||
|
@ -19,6 +22,8 @@
|
||||||
<input type="text" name="Title" class="form-control" @bind="@title" />
|
<input type="text" name="Title" class="form-control" @bind="@title" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Container" class="control-label">Container: </label>
|
<label for="Container" class="control-label">Container: </label>
|
||||||
|
@ -35,18 +40,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="ViewPermissions" class="control-label">View Permissions: </label>
|
<label for="Name" class="control-label">Permissions: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="ViewPermissions" class="form-control" @bind="@viewpermissions" />
|
<PermissionGrid EntityName="Module" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="EditPermissions" class="control-label">Edit Permissions: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="EditPermissions" class="form-control" @bind="@editpermissions" />
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -62,48 +59,69 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-success" @onclick="@SaveModule">Save</button>
|
|
||||||
|
@DynamicComponent
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" @onclick="@SaveModule">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
|
||||||
public override string Title { get { return "Module Settings"; } }
|
public override string Title { get { return "Module Settings"; } }
|
||||||
|
|
||||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||||
string title;
|
string title;
|
||||||
string containertype;
|
string containertype;
|
||||||
string viewpermissions;
|
string permissions;
|
||||||
string editpermissions;
|
|
||||||
string pageid;
|
string pageid;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
PermissionGrid permissiongrid;
|
||||||
|
|
||||||
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
object settings;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
title = ModuleState.Title;
|
title = ModuleState.Title;
|
||||||
containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
|
containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync());
|
||||||
containertype = ModuleState.ContainerType;
|
containertype = ModuleState.ContainerType;
|
||||||
viewpermissions = ModuleState.ViewPermissions;
|
permissions = ModuleState.Permissions;
|
||||||
editpermissions = ModuleState.EditPermissions;
|
|
||||||
pageid = ModuleState.PageId.ToString();
|
pageid = ModuleState.PageId.ToString();
|
||||||
|
|
||||||
|
DynamicComponent = builder =>
|
||||||
|
{
|
||||||
|
Type moduleType = Type.GetType(ModuleState.ModuleType);
|
||||||
|
if (moduleType != null)
|
||||||
|
{
|
||||||
|
builder.OpenComponent(0, moduleType);
|
||||||
|
builder.AddComponentReferenceCapture(1, inst => { settings = Convert.ChangeType(inst, moduleType); });
|
||||||
|
builder.CloseComponent();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveModule()
|
private async Task SaveModule()
|
||||||
{
|
{
|
||||||
Module module = ModuleState;
|
Module module = ModuleState;
|
||||||
module.ViewPermissions = viewpermissions;
|
module.Permissions = permissiongrid.GetPermissions();
|
||||||
module.EditPermissions = editpermissions;
|
|
||||||
await ModuleService.UpdateModuleAsync(module);
|
await ModuleService.UpdateModuleAsync(module);
|
||||||
|
|
||||||
PageModule pagemodule = new PageModule();
|
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||||
pagemodule.PageModuleId = ModuleState.PageModuleId;
|
|
||||||
pagemodule.PageId = Int32.Parse(pageid);
|
|
||||||
pagemodule.ModuleId = ModuleState.ModuleId;
|
|
||||||
pagemodule.Title = title;
|
pagemodule.Title = title;
|
||||||
pagemodule.Pane = ModuleState.Pane;
|
|
||||||
pagemodule.Order = ModuleState.Order;
|
|
||||||
pagemodule.ContainerType = containertype;
|
pagemodule.ContainerType = containertype;
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
|
||||||
UriHelper.NavigateTo(NavigateUrl(true));
|
Type moduleType = Type.GetType(ModuleState.ModuleType);
|
||||||
|
if (moduleType != null)
|
||||||
|
{
|
||||||
|
moduleType.GetMethod("UpdateSettings").Invoke(settings, null); // method must be public in settings component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Admin.Pages
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IPageService PageService
|
@inject IPageService PageService
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
|
||||||
<table class="form-group">
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Name: </label>
|
<label for="Name" class="control-label">Name: </label>
|
||||||
|
@ -17,34 +22,44 @@
|
||||||
<input class="form-control" @bind="@name" />
|
<input class="form-control" @bind="@name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="Name" class="control-label">Path: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" @bind="@path" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Parent: </label>
|
<label for="Name" class="control-label">Parent: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@parentid">
|
<select class="form-control" @onchange="@(e => ParentChanged(e))">
|
||||||
<option value=""><Select Parent></option>
|
<option value=""><Site Root></option>
|
||||||
@foreach (Page p in PageState.Pages)
|
@foreach (Page page in pages)
|
||||||
{
|
{
|
||||||
<option value="@p.PageId">@p.Name</option>
|
<option value="@(page.PageId)">@(new string('-',page.Level * 2))@(page.Name)</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Order: </label>
|
<label for="Name" class="control-label">Insert: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@order" />
|
<select class="form-control" @bind="@insert">
|
||||||
|
<option value="<<">At Beginning</option>
|
||||||
|
@if (children != null && children.Count > 0)
|
||||||
|
{
|
||||||
|
<option value="<">Before</option>
|
||||||
|
<option value=">">After</option>
|
||||||
|
}
|
||||||
|
<option value=">>" selected>At End</option>
|
||||||
|
</select>
|
||||||
|
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||||
|
{
|
||||||
|
<select class="form-control" @bind="@childid">
|
||||||
|
<option value="-1"><Select Page></option>
|
||||||
|
@foreach (Page page in children)
|
||||||
|
{
|
||||||
|
<option value="@(page.PageId)">@(page.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -53,8 +68,19 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isnavigation">
|
<select class="form-control" @bind="@isnavigation">
|
||||||
<option value="true">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="false">No</option>
|
<option value="False">No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Edit Mode? </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select class="form-control" @bind="@editmode">
|
||||||
|
<option value="True">Yes</option>
|
||||||
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -96,66 +122,122 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">View Permissions: </label>
|
<label for="Name" class="control-label">Permissions: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@viewpermissions" />
|
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" @bind="@editpermissions" />
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-success" @onclick="@SavePage">Save</button>
|
<button type="button" class="btn btn-success" @onclick="@SavePage">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
|
string message = "";
|
||||||
|
|
||||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
List<Page> pages;
|
||||||
string name;
|
string name;
|
||||||
string path;
|
|
||||||
string parentid;
|
string parentid;
|
||||||
string order = "";
|
string insert;
|
||||||
|
List<Page> children;
|
||||||
|
int childid = -1;
|
||||||
string isnavigation = "True";
|
string isnavigation = "True";
|
||||||
|
string editmode = "False";
|
||||||
string themetype;
|
string themetype;
|
||||||
string layouttype = "";
|
string layouttype = "";
|
||||||
string icon = "";
|
string icon = "";
|
||||||
string viewpermissions = "All Users";
|
string permissions = ""; // need to set default permissions
|
||||||
string editpermissions = "Administrators";
|
|
||||||
|
|
||||||
protected override void OnInit()
|
PermissionGrid permissiongrid;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pages = PageState.Pages.Where(item => item.IsNavigation).ToList();
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
|
||||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||||
|
|
||||||
|
List<PermissionString> permissionstrings = new List<PermissionString>();
|
||||||
|
permissionstrings.Add(new PermissionString { PermissionName = "View", Permissions = Constants.AdminRole });
|
||||||
|
permissionstrings.Add(new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole });
|
||||||
|
permissions = UserSecurity.SetPermissionStrings(permissionstrings);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParentChanged(UIChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parentid = (string)e.Value;
|
||||||
|
if (string.IsNullOrEmpty(parentid))
|
||||||
|
{
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid) && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SavePage()
|
private async Task SavePage()
|
||||||
{
|
{
|
||||||
Page p = new Page();
|
try
|
||||||
p.SiteId = PageState.Page.SiteId;
|
{
|
||||||
|
Page page = new Page();
|
||||||
|
page.SiteId = PageState.Page.SiteId;
|
||||||
|
page.Name = name;
|
||||||
if (string.IsNullOrEmpty(parentid))
|
if (string.IsNullOrEmpty(parentid))
|
||||||
{
|
{
|
||||||
p.ParentId = null;
|
page.ParentId = null;
|
||||||
|
page.Path = page.Name.ToLower();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.ParentId = Int32.Parse(parentid);
|
page.ParentId = Int32.Parse(parentid);
|
||||||
|
Page parent = PageState.Pages.Where(item => item.ParentId == page.ParentId).FirstOrDefault();
|
||||||
|
page.Path = parent.Path + "/" + page.Name.ToLower();
|
||||||
}
|
}
|
||||||
p.Name = name;
|
Page child;
|
||||||
p.Path = path;
|
switch (insert)
|
||||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
{
|
||||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
case "<<":
|
||||||
p.ThemeType = themetype;
|
page.Order = 0;
|
||||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
break;
|
||||||
p.Icon = (icon == null ? "" : icon);
|
case "<":
|
||||||
|
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||||
|
page.Order = child.Order - 1;
|
||||||
|
break;
|
||||||
|
case ">":
|
||||||
|
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||||
|
page.Order = child.Order + 1;
|
||||||
|
break;
|
||||||
|
case ">>":
|
||||||
|
page.Order = int.MaxValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||||
|
page.EditMode = (editmode == null ? true : Boolean.Parse(editmode));
|
||||||
|
page.ThemeType = themetype;
|
||||||
|
page.LayoutType = (layouttype == null ? "" : layouttype);
|
||||||
|
page.Icon = (icon == null ? "" : icon);
|
||||||
Type type;
|
Type type;
|
||||||
if (!string.IsNullOrEmpty(layouttype))
|
if (!string.IsNullOrEmpty(layouttype))
|
||||||
{
|
{
|
||||||
|
@ -166,10 +248,18 @@
|
||||||
type = Type.GetType(themetype);
|
type = Type.GetType(themetype);
|
||||||
}
|
}
|
||||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||||
p.ViewPermissions = viewpermissions;
|
page.Permissions = permissiongrid.GetPermissions();
|
||||||
p.EditPermissions = editpermissions;
|
await PageService.AddPageAsync(page);
|
||||||
await PageService.AddPageAsync(p);
|
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||||
UriHelper.NavigateTo(NavigateUrl(path, true));
|
|
||||||
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Admin.Pages
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IPageService PageService
|
@inject IPageService PageService
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
|
||||||
<table class="form-group">
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Name: </label>
|
<label for="Name" class="control-label">Name: </label>
|
||||||
|
@ -39,22 +44,25 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="Name" class="control-label">Order: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" @bind="@order" readonly />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Navigation? </label>
|
<label for="Name" class="control-label">Navigation? </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isnavigation" readonly>
|
<select class="form-control" @bind="@isnavigation" readonly>
|
||||||
<option value="true">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="false">No</option>
|
<option value="False">No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Edit Mode? </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select class="form-control" @bind="@editmode" readonly>
|
||||||
|
<option value="True">Yes</option>
|
||||||
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -63,7 +71,7 @@
|
||||||
<label for="Name" class="control-label">Theme: </label>
|
<label for="Name" class="control-label">Theme: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@themetype">
|
<select class="form-control" @bind="@themetype" readonly>
|
||||||
<option value=""><Select Theme></option>
|
<option value=""><Select Theme></option>
|
||||||
@foreach (KeyValuePair<string, string> item in themes)
|
@foreach (KeyValuePair<string, string> item in themes)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +85,7 @@
|
||||||
<label for="Name" class="control-label">Layout: </label>
|
<label for="Name" class="control-label">Layout: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@layouttype">
|
<select class="form-control" @bind="@layouttype" readonly>
|
||||||
<option value=""><Select Layout></option>
|
<option value=""><Select Layout></option>
|
||||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
||||||
{
|
{
|
||||||
|
@ -96,26 +104,23 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">View Permissions: </label>
|
<label for="Name" class="control-label">Permissions: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@viewpermissions" readonly />
|
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" @bind="@editpermissions" readonly />
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-danger" @onclick="@DeletePage">Delete</button>
|
<button type="button" class="btn btn-danger" @onclick="@DeletePage">Delete</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
|
string message = "";
|
||||||
|
|
||||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||||
|
@ -124,39 +129,68 @@
|
||||||
string name;
|
string name;
|
||||||
string path;
|
string path;
|
||||||
string parentid;
|
string parentid;
|
||||||
string order;
|
|
||||||
string isnavigation;
|
string isnavigation;
|
||||||
|
string editmode;
|
||||||
string themetype;
|
string themetype;
|
||||||
string layouttype;
|
string layouttype;
|
||||||
string icon;
|
string icon;
|
||||||
string viewpermissions;
|
string permissions;
|
||||||
string editpermissions;
|
string createdby;
|
||||||
|
DateTime createdon;
|
||||||
|
string modifiedby;
|
||||||
|
DateTime modifiedon;
|
||||||
|
|
||||||
protected override void OnInit()
|
PermissionGrid permissiongrid;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||||
|
|
||||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||||
if (p != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
name = p.Name;
|
name = page.Name;
|
||||||
path = p.Path;
|
path = page.Path;
|
||||||
|
isnavigation = page.IsNavigation.ToString();
|
||||||
order = p.Order.ToString();
|
editmode = page.EditMode.ToString();
|
||||||
isnavigation = p.IsNavigation.ToString();
|
themetype = page.ThemeType;
|
||||||
themetype = p.ThemeType;
|
layouttype = page.LayoutType;
|
||||||
layouttype = p.LayoutType;
|
icon = page.Icon;
|
||||||
icon = p.Icon;
|
permissions = page.Permissions;
|
||||||
viewpermissions = p.ViewPermissions;
|
createdby = page.CreatedBy;
|
||||||
editpermissions = p.EditPermissions;
|
createdon = page.CreatedOn;
|
||||||
|
modifiedby = page.ModifiedBy;
|
||||||
|
modifiedon = page.ModifiedOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeletePage()
|
private async Task DeletePage()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
|
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
|
||||||
UriHelper.NavigateTo(NavigateUrl("", true));
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
if (PageState.Page.Name == "Page Management")
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Admin.Pages
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IPageService PageService
|
@inject IPageService PageService
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
|
||||||
<table class="form-group">
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Name: </label>
|
<label for="Name" class="control-label">Name: </label>
|
||||||
|
@ -23,7 +27,7 @@
|
||||||
<label for="Name" class="control-label">Path: </label>
|
<label for="Name" class="control-label">Path: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@path" />
|
<input class="form-control" @bind="@path" readonly />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -31,21 +35,40 @@
|
||||||
<label for="Name" class="control-label">Parent: </label>
|
<label for="Name" class="control-label">Parent: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@parentid">
|
<select class="form-control" @onchange="@(e => ParentChanged(e))">
|
||||||
<option value=""><Select Parent></option>
|
<option value=""><Site Root></option>
|
||||||
@foreach (Page p in PageState.Pages)
|
@foreach (Page page in pages)
|
||||||
{
|
{
|
||||||
<option value="@p.PageId">@p.Name</option>
|
<option value="@(page.PageId)">@(new string('-', page.Level * 2))@(page.Name)</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Order: </label>
|
<label for="Name" class="control-label">Move : </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@order" />
|
<select class="form-control" @bind="@insert">
|
||||||
|
<option value=""><Maintain Current Location></option>
|
||||||
|
<option value="<<">To Beginning</option>
|
||||||
|
@if (children != null && children.Count > 0)
|
||||||
|
{
|
||||||
|
<option value="<">Before</option>
|
||||||
|
<option value=">">After</option>
|
||||||
|
}
|
||||||
|
<option value=">>" selected>To End</option>
|
||||||
|
</select>
|
||||||
|
@if (children != null && children.Count > 0 && (insert == "<" || insert == ">"))
|
||||||
|
{
|
||||||
|
<select class="form-control" @bind="@childid">
|
||||||
|
<option value="-1"><Select Page></option>
|
||||||
|
@foreach (Page page in children)
|
||||||
|
{
|
||||||
|
<option value="@(page.PageId)">@(page.Name)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -54,8 +77,19 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isnavigation">
|
<select class="form-control" @bind="@isnavigation">
|
||||||
<option value="true">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="false">No</option>
|
<option value="False">No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Edit Mode? </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select class="form-control" @bind="@editmode">
|
||||||
|
<option value="True">Yes</option>
|
||||||
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -97,90 +131,156 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">View Permissions: </label>
|
<label for="Name" class="control-label">Permissions: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@viewpermissions" />
|
<PermissionGrid EntityName="Page" Permissions="@permissions" @ref="permissiongrid" @ref:suppressField />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="Name" class="control-label">Edit Permissions: </label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" @bind="@editpermissions" />
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-success" @onclick="@SavePage">Save</button>
|
<button type="button" class="btn btn-success" @onclick="@SavePage">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
|
string message = "";
|
||||||
|
|
||||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
List<Page> pages;
|
||||||
int PageId;
|
int PageId;
|
||||||
string name;
|
string name;
|
||||||
string path;
|
string path;
|
||||||
string parentid;
|
string parentid;
|
||||||
string order;
|
string insert = "";
|
||||||
|
List<Page> children;
|
||||||
|
int childid = -1;
|
||||||
string isnavigation;
|
string isnavigation;
|
||||||
|
string editmode;
|
||||||
string themetype;
|
string themetype;
|
||||||
string layouttype;
|
string layouttype;
|
||||||
string icon;
|
string icon;
|
||||||
string viewpermissions;
|
string permissions;
|
||||||
string editpermissions;
|
string createdby;
|
||||||
|
DateTime createdon;
|
||||||
|
string modifiedby;
|
||||||
|
DateTime modifiedon;
|
||||||
|
|
||||||
protected override void OnInit()
|
PermissionGrid permissiongrid;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pages = PageState.Pages.Where(item => item.IsNavigation).ToList();
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
|
||||||
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
themes = ThemeService.GetThemeTypes(PageState.Themes);
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
|
||||||
|
|
||||||
PageId = Int32.Parse(PageState.QueryString["id"]);
|
PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
|
||||||
if (p != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
name = p.Name;
|
name = page.Name;
|
||||||
path = p.Path;
|
path = page.Path;
|
||||||
if (p.ParentId == null)
|
if (page.ParentId == null)
|
||||||
{
|
{
|
||||||
parentid = "";
|
parentid = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parentid = p.ParentId.ToString();
|
parentid = page.ParentId.ToString();
|
||||||
}
|
}
|
||||||
order = p.Order.ToString();
|
isnavigation = page.IsNavigation.ToString();
|
||||||
isnavigation = p.IsNavigation.ToString();
|
editmode = page.EditMode.ToString();
|
||||||
themetype = p.ThemeType;
|
themetype = page.ThemeType;
|
||||||
layouttype = p.LayoutType;
|
layouttype = page.LayoutType;
|
||||||
icon = p.Icon;
|
icon = page.Icon;
|
||||||
viewpermissions = p.ViewPermissions;
|
permissions = page.Permissions;
|
||||||
editpermissions = p.EditPermissions;
|
createdby = page.CreatedBy;
|
||||||
|
createdon = page.CreatedOn;
|
||||||
|
modifiedby = page.ModifiedBy;
|
||||||
|
modifiedon = page.ModifiedOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParentChanged(UIChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parentid = (string)e.Value;
|
||||||
|
if (string.IsNullOrEmpty(parentid))
|
||||||
|
{
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == null && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
children = PageState.Pages.Where(item => item.ParentId == int.Parse(parentid) && item.IsNavigation).OrderBy(item => item.Order).ToList();
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SavePage()
|
private async Task SavePage()
|
||||||
{
|
{
|
||||||
Page p = PageState.Page;
|
try
|
||||||
p.PageId = Int32.Parse(PageState.QueryString["id"]);
|
{
|
||||||
|
Page page = PageState.Page;
|
||||||
|
int? currentparentid = page.ParentId;
|
||||||
|
page.PageId = Int32.Parse(PageState.QueryString["id"]);
|
||||||
|
page.Name = name;
|
||||||
if (string.IsNullOrEmpty(parentid))
|
if (string.IsNullOrEmpty(parentid))
|
||||||
{
|
{
|
||||||
p.ParentId = null;
|
page.ParentId = null;
|
||||||
|
page.Path = page.Name.ToLower();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.ParentId = Int32.Parse(parentid);
|
page.ParentId = Int32.Parse(parentid);
|
||||||
|
Page parent = PageState.Pages.Where(item => item.ParentId == page.ParentId).FirstOrDefault();
|
||||||
|
page.Path = parent.Path + "/" + page.Name.ToLower();
|
||||||
}
|
}
|
||||||
p.Name = name;
|
if (insert != "")
|
||||||
p.Path = path;
|
{
|
||||||
p.Order = (order == null ? 1 : Int32.Parse(order));
|
Page child;
|
||||||
p.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
switch (insert)
|
||||||
p.ThemeType = themetype;
|
{
|
||||||
p.LayoutType = (layouttype == null ? "" : layouttype);
|
case "<<":
|
||||||
p.Icon = (icon == null ? "" : icon);
|
page.Order = 0;
|
||||||
|
break;
|
||||||
|
case "<":
|
||||||
|
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||||
|
page.Order = child.Order - 1;
|
||||||
|
break;
|
||||||
|
case ">":
|
||||||
|
child = PageState.Pages.Where(item => item.PageId == childid).FirstOrDefault();
|
||||||
|
page.Order = child.Order + 1;
|
||||||
|
break;
|
||||||
|
case ">>":
|
||||||
|
page.Order = int.MaxValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation));
|
||||||
|
page.EditMode = (editmode == null ? true : Boolean.Parse(editmode));
|
||||||
|
page.ThemeType = themetype;
|
||||||
|
page.LayoutType = (layouttype == null ? "" : layouttype);
|
||||||
|
page.Icon = (icon == null ? "" : icon);
|
||||||
Type type;
|
Type type;
|
||||||
if (!string.IsNullOrEmpty(layouttype))
|
if (!string.IsNullOrEmpty(layouttype))
|
||||||
{
|
{
|
||||||
|
@ -191,10 +291,18 @@
|
||||||
type = Type.GetType(themetype);
|
type = Type.GetType(themetype);
|
||||||
}
|
}
|
||||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||||
p.ViewPermissions = viewpermissions;
|
page.Permissions = permissiongrid.GetPermissions();
|
||||||
p.EditPermissions = editpermissions;
|
await PageService.UpdatePageAsync(page);
|
||||||
await PageService.UpdatePageAsync(p);
|
await PageService.UpdatePageOrderAsync(page.SiteId, page.ParentId);
|
||||||
UriHelper.NavigateTo(NavigateUrl(path));
|
await PageService.UpdatePageOrderAsync(page.SiteId, currentparentid);
|
||||||
|
|
||||||
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,36 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Modules.Controls
|
||||||
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Modules.Admin.Pages
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@inject IPageService PageService
|
@if (PageState.Pages != null)
|
||||||
|
|
||||||
@if (PageState.Pages == null)
|
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<ActionLink Action="Add" Text="Add Page" />
|
||||||
}
|
<table class="table table-borderless">
|
||||||
else
|
|
||||||
{
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th>Path</th>
|
<th> </th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var p in PageState.Pages)
|
@foreach (Page page in PageState.Pages)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + p.PageId.ToString())" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + page.PageId.ToString())" /></td>
|
||||||
<td><ActionLink Action="Delete" Parameters="@($"id=" + p.PageId.ToString())" ButtonClass="btn-danger" /></td>
|
<td><ActionLink Action="Delete" Parameters="@($"id=" + page.PageId.ToString())" Class="btn btn-danger" /></td>
|
||||||
<td>@p.Path</td>
|
<td>@(new string('-', page.Level * 2))@(page.Name)</td>
|
||||||
<td>@p.Name</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<ActionLink Action="Add" Text="Add Page" />
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
}
|
}
|
128
Oqtane.Client/Modules/Admin/Profile/Index.razor
Normal file
128
Oqtane.Client/Modules/Admin/Profile/Index.razor
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Services
|
||||||
|
@namespace Oqtane.Modules.Admin.Profile
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject IUriHelper UriHelper
|
||||||
|
@inject IUserService UserService
|
||||||
|
@inject IProfileService ProfileService
|
||||||
|
@inject ISettingService SettingService
|
||||||
|
|
||||||
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
|
@if (PageState.User != null && profiles != null)
|
||||||
|
{
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Name: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="form-control" @bind="@displayname" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label">Email: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="form-control" @bind="@email" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@foreach (Profile profile in profiles)
|
||||||
|
{
|
||||||
|
var p = profile;
|
||||||
|
if (p.Category != category)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" style="text-align: center;">
|
||||||
|
@p.Category
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
category = p.Category;
|
||||||
|
}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="@p.Name" class="control-label">@p.Title: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" placeholder="@p.Description" @onchange="@(e => ProfileChanged(e, p.Name))" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
<button type="button" class="btn btn-primary" @onclick="@SaveUser">Save</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="@Cancel">Cancel</button>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } }
|
||||||
|
|
||||||
|
string message = "";
|
||||||
|
string displayname = "";
|
||||||
|
string email = "";
|
||||||
|
List<Profile> profiles;
|
||||||
|
Dictionary<string, string> settings;
|
||||||
|
string category = "";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PageState.User != null)
|
||||||
|
{
|
||||||
|
displayname = PageState.User.DisplayName;
|
||||||
|
email = PageState.User.Email;
|
||||||
|
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||||
|
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Current User Is Not Logged In";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetProfileValue(string SettingName, string DefaultValue)
|
||||||
|
{
|
||||||
|
return SettingService.GetSetting(settings, SettingName, DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveUser()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = PageState.User;
|
||||||
|
user.DisplayName = displayname;
|
||||||
|
user.Email = email;
|
||||||
|
await UserService.UpdateUserAsync(user);
|
||||||
|
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
|
||||||
|
|
||||||
|
UriHelper.NavigateTo("");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfileChanged(UIChangeEventArgs e, string SettingName)
|
||||||
|
{
|
||||||
|
string value = (string)e.Value;
|
||||||
|
settings = SettingService.SetSetting(settings, SettingName, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
|
@namespace Oqtane.Modules.Admin.Register
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -9,31 +10,37 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Username" class="control-label">Email: </label>
|
<label for="Username" class="control-label">Email: </label>
|
||||||
<input type="text" name="Username" class="form-control" placeholder="Username" @bind="@Username" />
|
<input type="text" name="Username" class="form-control" placeholder="Username" @bind="@Email" />
|
||||||
</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" name="Password" class="form-control" placeholder="Password" @bind="@Password" />
|
<input type="password" name="Password" class="form-control" placeholder="Password" @bind="@Password" />
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
||||||
<NavLink class="btn btn-secondary" href="/">Cancel</NavLink>
|
<button type="button" class="btn btn-secondary" @onclick="@Cancel">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||||
|
|
||||||
public string Username { get; set; } = "";
|
public string Email { get; set; } = "";
|
||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
|
|
||||||
private async Task RegisterUser()
|
private async Task RegisterUser()
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.Username = Username;
|
user.SiteId = PageState.Site.SiteId;
|
||||||
user.DisplayName = Username;
|
user.Username = Email;
|
||||||
user.Roles = "Administrators;";
|
user.DisplayName = Email;
|
||||||
user.IsSuperUser = false;
|
user.Email = Email;
|
||||||
|
user.IsHost = false;
|
||||||
user.Password = Password;
|
user.Password = Password;
|
||||||
await UserService.AddUserAsync(user);
|
await UserService.AddUserAsync(user);
|
||||||
UriHelper.NavigateTo("");
|
UriHelper.NavigateTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl("")); // navigate to home
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
41
Oqtane.Client/Modules/Admin/Roles/Index.razor
Normal file
41
Oqtane.Client/Modules/Admin/Roles/Index.razor
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
@using Oqtane.Services
|
||||||
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@using Oqtane.Modules.Controls
|
||||||
|
@namespace Oqtane.Modules.Admin.Roles
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject IRoleService RoleService
|
||||||
|
|
||||||
|
@if (Roles == null)
|
||||||
|
{
|
||||||
|
<p><em>Loading...</em></p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var Role in Roles)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Role.Name</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
|
List<Role> Roles;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,9 @@
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Admin.Sites
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject ITenantService TenantService
|
@inject ITenantService TenantService
|
||||||
|
@ -15,7 +18,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="form-group">
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Name" class="control-label">Tenant: </label>
|
<label for="Name" class="control-label">Tenant: </label>
|
||||||
|
@ -55,12 +58,12 @@ else
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-success" @onclick="@SaveSite">Save</button>
|
<button type="button" class="btn btn-success" @onclick="@SaveSite">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<Tenant> tenants;
|
List<Tenant> tenants;
|
||||||
string tenantid;
|
string tenantid;
|
||||||
|
@ -68,7 +71,7 @@ else
|
||||||
string url;
|
string url;
|
||||||
string logo;
|
string logo;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
tenants = await TenantService.GetTenantsAsync();
|
tenants = await TenantService.GetTenantsAsync();
|
||||||
}
|
}
|
||||||
|
@ -96,14 +99,18 @@ else
|
||||||
p.Path = "";
|
p.Path = "";
|
||||||
p.Order = 1;
|
p.Order = 1;
|
||||||
p.IsNavigation = true;
|
p.IsNavigation = true;
|
||||||
p.ThemeType = "Oqtane.Client.Themes.Theme1.Theme1, Oqtane.Client";
|
p.ThemeType = PageState.Site.DefaultThemeType;
|
||||||
p.LayoutType = "";
|
p.LayoutType = "";
|
||||||
p.Icon = "";
|
p.Icon = "";
|
||||||
Type type = Type.GetType(p.ThemeType);
|
Type type = Type.GetType(p.ThemeType);
|
||||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||||
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
p.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||||
p.ViewPermissions = "All Users";
|
|
||||||
p.EditPermissions = "Administrators";
|
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);
|
await PageService.AddPageAsync(p);
|
||||||
|
|
||||||
UriHelper.NavigateTo(url, true);
|
UriHelper.NavigateTo(url, true);
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
|
@namespace Oqtane.Modules.Admin.Sites
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="table">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
@ -31,11 +32,11 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<Site> sites;
|
List<Site> sites;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
sites = await SiteService.GetSitesAsync();
|
sites = await SiteService.GetSitesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Modules.Admin.Themes
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="table">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
@ -29,11 +30,11 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
List<Theme> Themes;
|
List<Theme> Themes;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Themes = await ThemeService.GetThemesAsync();
|
Themes = await ThemeService.GetThemesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
|
@namespace Oqtane.Modules.Admin.Users
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -30,12 +31,12 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
List<User> Users;
|
List<User> Users;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Users = await UserService.GetUsersAsync();
|
Users = await UserService.GetUsersAsync(PageState.Site.SiteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,34 +2,40 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
@if (authorized)
|
@if (authorized)
|
||||||
{
|
{
|
||||||
<NavLink class="@buttonClass" href="@url">@text</NavLink>
|
<NavLink class="@classname" href="@url" style="@style">@text</NavLink>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private string Action { get; set; }
|
public string Action { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private string Text { get; set; } // optional
|
public string Text { get; set; } // optional
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private string Parameters { get; set; } // optional
|
public string Parameters { get; set; } // optional
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private string ButtonClass { get; set; } // optional
|
public string Class { get; set; } // optional
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Style { get; set; } // optional
|
||||||
|
|
||||||
string text = "";
|
string text = "";
|
||||||
string url = "";
|
string url = "";
|
||||||
string parameters = "";
|
string parameters = "";
|
||||||
string buttonClass = "btn btn-primary";
|
string classname = "btn btn-primary";
|
||||||
|
string style = "";
|
||||||
bool authorized = false;
|
bool authorized = false;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
text = Action;
|
text = Action;
|
||||||
if (!String.IsNullOrEmpty(Text))
|
if (!String.IsNullOrEmpty(Text))
|
||||||
|
@ -42,37 +48,45 @@
|
||||||
parameters = Parameters;
|
parameters = Parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ButtonClass))
|
if (!string.IsNullOrEmpty(Class))
|
||||||
{
|
{
|
||||||
buttonClass = "btn " + ButtonClass;
|
classname = Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Style))
|
||||||
|
{
|
||||||
|
style = Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = EditUrl(Action, parameters);
|
url = EditUrl(Action, parameters);
|
||||||
|
|
||||||
|
if (PageState.EditMode)
|
||||||
|
{
|
||||||
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameClass(ModuleState.ModuleType) + ",", Action + ",");
|
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameClass(ModuleState.ModuleType) + ",", Action + ",");
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduleType);
|
var moduleobject = Activator.CreateInstance(moduleType);
|
||||||
SecurityAccessLevelEnum SecurityAccessLevel = (SecurityAccessLevelEnum)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
SecurityAccessLevel SecurityAccessLevel = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||||
switch (SecurityAccessLevel)
|
switch (SecurityAccessLevel)
|
||||||
{
|
{
|
||||||
case SecurityAccessLevelEnum.Anonymous:
|
case SecurityAccessLevel.Anonymous:
|
||||||
authorized = true;
|
authorized = true;
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.View:
|
case SecurityAccessLevel.View:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.ViewPermissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, "View", ModuleState.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Edit:
|
case SecurityAccessLevel.Edit:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.EditPermissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Admin:
|
case SecurityAccessLevel.Admin:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, Constants.AdminRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Host:
|
case SecurityAccessLevel.Host:
|
||||||
authorized = PageState.User.IsSuperUser;
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
59
Oqtane.Client/Modules/Controls/AuditInfo.razor
Normal file
59
Oqtane.Client/Modules/Controls/AuditInfo.razor
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inherits ModuleBase
|
||||||
|
|
||||||
|
@if (text != "")
|
||||||
|
{
|
||||||
|
@((MarkupString)@text)
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string CreatedBy { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public DateTime CreatedOn { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string ModifiedBy { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public DateTime ModifiedOn { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Style { get; set; }
|
||||||
|
|
||||||
|
string text = "";
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
text = "";
|
||||||
|
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
|
||||||
|
{
|
||||||
|
text += "<p style=\"" + Style + "\">Created ";
|
||||||
|
if (!String.IsNullOrEmpty(CreatedBy))
|
||||||
|
{
|
||||||
|
text += " by <b>" + CreatedBy + "</b>";
|
||||||
|
}
|
||||||
|
if (CreatedOn != null)
|
||||||
|
{
|
||||||
|
text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||||
|
}
|
||||||
|
text += "</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
|
||||||
|
{
|
||||||
|
text += "<p style=\"" + Style + "\">Last modified ";
|
||||||
|
if (!String.IsNullOrEmpty(ModifiedBy))
|
||||||
|
{
|
||||||
|
text += " by <b>" + ModifiedBy + "</b>";
|
||||||
|
}
|
||||||
|
if (ModifiedOn != null)
|
||||||
|
{
|
||||||
|
text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||||
|
}
|
||||||
|
text += "</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
Oqtane.Client/Modules/Controls/FileUpload.razor
Normal file
45
Oqtane.Client/Modules/Controls/FileUpload.razor
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
|
||||||
|
@if (multiple)
|
||||||
|
{
|
||||||
|
<input type="file" id="@fileid" name="file" accept="@filter" multiple />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="file" id="@fileid" name="file" accept="@filter" />
|
||||||
|
}
|
||||||
|
<span id="@progressinfoid"></span> <progress id="@progressbarid" style="visibility: hidden;"></progress>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string Name { get; set; } // optional - can be used for managing multiple file upload controls on a page
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Filter { get; set; } // optional - for restricting types of files that can be selected
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Multiple { get; set; } // optional - enable multiple file uploads
|
||||||
|
|
||||||
|
string fileid = "";
|
||||||
|
string progressinfoid = "";
|
||||||
|
string progressbarid = "";
|
||||||
|
string filter = "*";
|
||||||
|
bool multiple = false;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
fileid = Name + "FileInput";
|
||||||
|
progressinfoid = Name + "ProgressInfo";
|
||||||
|
progressbarid = Name + "ProgressBar";
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Filter))
|
||||||
|
{
|
||||||
|
filter = Filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Multiple))
|
||||||
|
{
|
||||||
|
multiple = bool.Parse(Multiple);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
Oqtane.Client/Modules/Controls/ModuleMessage.razor
Normal file
39
Oqtane.Client/Modules/Controls/ModuleMessage.razor
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inherits ModuleBase
|
||||||
|
|
||||||
|
@if (Message != "")
|
||||||
|
{
|
||||||
|
<div class="@type">@Message</div>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public MessageType Type { get; set; }
|
||||||
|
|
||||||
|
string type = "alert alert-danger";
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case MessageType.Success:
|
||||||
|
type = "alert alert-success";
|
||||||
|
break;
|
||||||
|
case MessageType.Info:
|
||||||
|
type = "alert alert-info";
|
||||||
|
break;
|
||||||
|
case MessageType.Warning:
|
||||||
|
type = "alert alert-warning";
|
||||||
|
break;
|
||||||
|
case MessageType.Error:
|
||||||
|
type = "alert alert-danger";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
213
Oqtane.Client/Modules/Controls/PermissionGrid.razor
Normal file
213
Oqtane.Client/Modules/Controls/PermissionGrid.razor
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
@using Oqtane.Services
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Security
|
||||||
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject IRoleService RoleService
|
||||||
|
@inject IUserService UserService
|
||||||
|
|
||||||
|
@if (roles != null)
|
||||||
|
{
|
||||||
|
<br />
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Role</th>
|
||||||
|
@foreach (PermissionString permission in permissions)
|
||||||
|
{
|
||||||
|
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
@foreach (Role role in roles)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@role.Name</td>
|
||||||
|
@foreach (PermissionString permission in permissions)
|
||||||
|
{
|
||||||
|
var p = permission;
|
||||||
|
<td style="text-align: center;">
|
||||||
|
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, role.Name) Disabled=@GetPermissionDisabled(role.Name) OnChange="@(e => PermissionChanged(e, p.PermissionName, role.Name))" />
|
||||||
|
</td>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@if (@users.Count != 0)
|
||||||
|
{
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
@foreach (PermissionString permission in permissions)
|
||||||
|
{
|
||||||
|
<th style="text-align: center;">@permission.PermissionName @EntityName</th>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (User user in users)
|
||||||
|
{
|
||||||
|
string userid = "[" + user.UserId.ToString() + "]";
|
||||||
|
<tr>
|
||||||
|
<td>@user.DisplayName</td>
|
||||||
|
@foreach (PermissionString permission in permissions)
|
||||||
|
{
|
||||||
|
var p = permission;
|
||||||
|
<td style="text-align: center;">
|
||||||
|
<TriStateCheckBox Value=@GetPermissionValue(p.Permissions, userid) Disabled=@GetPermissionDisabled(userid) OnChange="@(e => PermissionChanged(e, p.PermissionName, userid))" />
|
||||||
|
</td>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: right;"><label for="Username" class="control-label">User: </label></td>
|
||||||
|
<td><input type="text" name="Username" class="form-control" placeholder="Enter Username" @bind="@username" /></td>
|
||||||
|
<td style="text-align: left;"><button type="button" class="btn btn-primary" @onclick="@AddUser">Add</button></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<ModuleMessage Type="MessageType.Error" Message="@message" />
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string EntityName { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Permissions { get; set; }
|
||||||
|
|
||||||
|
string permissionnames = "";
|
||||||
|
List<Role> roles;
|
||||||
|
List<PermissionString> permissions = new List<PermissionString>();
|
||||||
|
List<User> users = new List<User>();
|
||||||
|
string username = "";
|
||||||
|
string message = "";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
permissionnames = PageState.ModuleDefinitions.Find(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).Permissions;
|
||||||
|
if (string.IsNullOrEmpty(permissionnames))
|
||||||
|
{
|
||||||
|
permissionnames = "View,Edit";
|
||||||
|
}
|
||||||
|
roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||||
|
roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||||
|
|
||||||
|
foreach (string permissionname in permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = "" });
|
||||||
|
}
|
||||||
|
foreach (PermissionString permissionstring in UserSecurity.GetPermissionStrings(Permissions))
|
||||||
|
{
|
||||||
|
if (permissions.Find(item => item.PermissionName == permissionstring.PermissionName) != null)
|
||||||
|
{
|
||||||
|
permissions[permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
|
||||||
|
}
|
||||||
|
if (permissionstring.Permissions.Contains("["))
|
||||||
|
{
|
||||||
|
foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (user.Contains("]"))
|
||||||
|
{
|
||||||
|
int userid = int.Parse(user.Substring(0, user.IndexOf("]")));
|
||||||
|
if (users.Where(item => item.UserId == userid).FirstOrDefault() == null)
|
||||||
|
{
|
||||||
|
users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool? GetPermissionValue(string Permissions, string SecurityKey)
|
||||||
|
{
|
||||||
|
if ((";" + Permissions + ";").Contains(";" + "!" + SecurityKey + ";"))
|
||||||
|
{
|
||||||
|
return false; // deny permission
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((";" + Permissions + ";").Contains(";" + SecurityKey + ";"))
|
||||||
|
{
|
||||||
|
return true; // grant permission
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null; // not specified
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool GetPermissionDisabled(string RoleName)
|
||||||
|
{
|
||||||
|
if (RoleName == Constants.AdminRole)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddUser()
|
||||||
|
{
|
||||||
|
if (users.Where(item => item.Username == username).FirstOrDefault() == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = await UserService.GetUserAsync(username, ModuleState.SiteId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
users.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
message = "Username Does Not Exist";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
username = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PermissionChanged(bool? Value, string PermissionName, string SecurityId)
|
||||||
|
{
|
||||||
|
bool? selected = Value;
|
||||||
|
PermissionString permission = permissions.Find(item => item.PermissionName == PermissionName);
|
||||||
|
if (permission != null)
|
||||||
|
{
|
||||||
|
List<string> ids = permission.Permissions.Split(';').ToList();
|
||||||
|
|
||||||
|
ids.Remove(SecurityId); // remove grant permission
|
||||||
|
ids.Remove("!" + SecurityId); // remove deny permission
|
||||||
|
|
||||||
|
switch (selected)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
ids.Add(SecurityId); // add grant permission
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
ids.Add("!" + SecurityId); // add deny permission
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
break; // permission not specified
|
||||||
|
}
|
||||||
|
permissions[permissions.FindIndex(item => item.PermissionName == PermissionName)].Permissions = string.Join(";", ids.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetPermissions()
|
||||||
|
{
|
||||||
|
return UserSecurity.SetPermissionStrings(permissions);
|
||||||
|
}
|
||||||
|
}
|
62
Oqtane.Client/Modules/Controls/TriStateCheckBox.razor
Normal file
62
Oqtane.Client/Modules/Controls/TriStateCheckBox.razor
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
|
||||||
|
<img src="@src" title="@title" disabled=@Disabled @onclick="SetValue" />
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bool? Value { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool Disabled { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public Action<bool?> OnChange { get; set; }
|
||||||
|
|
||||||
|
bool? value = null;
|
||||||
|
string title;
|
||||||
|
string src = "";
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
value = Value;
|
||||||
|
SetImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetValue()
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
value = false;
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
value = null;
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
value = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SetImage();
|
||||||
|
OnChange(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetImage()
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
src = "images/checked.png";
|
||||||
|
title = "Permission Granted";
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
src = "images/unchecked.png";
|
||||||
|
title = "Permission Denied";
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
src = "images/null.png";
|
||||||
|
title = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Modules.Counter
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
Current count: @currentCount
|
Current count: @currentCount
|
||||||
<br />
|
<br />
|
||||||
<button class="btn btn-primary" @onclick="@IncrementCount">Click me</button>
|
<button type="button" class="btn btn-primary" @onclick="@IncrementCount">Click me</button>
|
||||||
<br /><br />
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
int currentCount = 0;
|
int currentCount = 0;
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.Counter
|
namespace Oqtane.Modules.Counter
|
||||||
{
|
{
|
||||||
public class Module : IModule
|
public class Module : IModule
|
||||||
{
|
{
|
||||||
public string Name { get { return "Counter"; } }
|
public Dictionary<string, string> Properties
|
||||||
public string Description { get { return "Increments a counter"; } }
|
{
|
||||||
public string Version { get { return "1.0.0"; } }
|
get
|
||||||
public string Owner { get { return ""; } }
|
{
|
||||||
public string Url { get { return ""; } }
|
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||||
public string Contact { get { return ""; } }
|
{
|
||||||
public string License { get { return ""; } }
|
{ "Name", "Counter" },
|
||||||
public string Dependencies { get { return ""; } }
|
{ "Description", "Increments a counter" },
|
||||||
|
{ "Version", "1.0.0" }
|
||||||
|
};
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.HtmlText.Services
|
@using Oqtane.Modules.Controls
|
||||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
@using Oqtane.Modules.HtmlText.Services
|
||||||
|
@using Oqtane.Modules.HtmlText.Models
|
||||||
@using System.Net.Http;
|
@using System.Net.Http;
|
||||||
@using Oqtane.Shared;
|
@using Oqtane.Shared;
|
||||||
|
@namespace Oqtane.Modules.HtmlText
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject HttpClient http
|
@inject HttpClient http
|
||||||
@inject SiteState sitestate
|
@inject SiteState sitestate
|
||||||
|
|
||||||
<form>
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
<table class="form-group">
|
<table class="form-group">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
@ -20,31 +23,50 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn btn-success" @onclick="@SaveContent">Save</button>
|
<button type="button" class="btn btn-success" @onclick="@SaveContent">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
</form>
|
<br />
|
||||||
|
<br />
|
||||||
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
|
||||||
public override string Title { get { return "Edit Html/Text"; } }
|
public override string Title { get { return "Edit Html/Text"; } }
|
||||||
|
|
||||||
HtmlTextInfo htmltext;
|
string message = "";
|
||||||
string content;
|
string content;
|
||||||
|
string createdby;
|
||||||
|
DateTime createdon;
|
||||||
|
string modifiedby;
|
||||||
|
DateTime modifiedon;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
||||||
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||||
if (htmltextlist != null)
|
if (htmltext != null)
|
||||||
{
|
{
|
||||||
htmltext = htmltextlist.FirstOrDefault();
|
|
||||||
content = htmltext.Content;
|
content = htmltext.Content;
|
||||||
|
createdby = htmltext.CreatedBy;
|
||||||
|
createdon = htmltext.CreatedOn;
|
||||||
|
modifiedby = htmltext.ModifiedBy;
|
||||||
|
modifiedon = htmltext.ModifiedOn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveContent()
|
private async Task SaveContent()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
||||||
|
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||||
if (htmltext != null)
|
if (htmltext != null)
|
||||||
{
|
{
|
||||||
htmltext.Content = content;
|
htmltext.Content = content;
|
||||||
|
@ -57,6 +79,12 @@
|
||||||
htmltext.Content = content;
|
htmltext.Content = content;
|
||||||
await htmltextservice.AddHtmlTextAsync(htmltext);
|
await htmltextservice.AddHtmlTextAsync(htmltext);
|
||||||
}
|
}
|
||||||
UriHelper.NavigateTo(NavigateUrl(), true);
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,42 @@
|
||||||
@using Oqtane.Client.Modules.HtmlText.Services
|
@using Oqtane.Modules.HtmlText.Services
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
@using Oqtane.Modules.HtmlText.Models
|
||||||
@using System.Net.Http;
|
@using System.Net.Http;
|
||||||
@using Oqtane.Client.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
@using Oqtane.Shared;
|
@using Oqtane.Shared;
|
||||||
|
@namespace Oqtane.Modules.HtmlText
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject HttpClient http
|
@inject HttpClient http
|
||||||
@inject SiteState sitestate
|
@inject SiteState sitestate
|
||||||
|
|
||||||
|
<ModuleMessage Message="@message" />
|
||||||
|
|
||||||
@((MarkupString)content)
|
@((MarkupString)content)
|
||||||
|
|
||||||
<br /><ActionLink Action="Edit" /><br /><br />
|
<br />
|
||||||
|
<ActionLink Action="Edit" />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
string message = "";
|
||||||
string content;
|
string content;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
||||||
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||||
if (htmltext != null)
|
if (htmltext != null)
|
||||||
{
|
{
|
||||||
content = htmltext.FirstOrDefault().Content;
|
content = htmltext.Content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,22 @@
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.HtmlText
|
namespace Oqtane.Modules.HtmlText
|
||||||
{
|
{
|
||||||
public class Module : IModule
|
public class Module : IModule
|
||||||
{
|
{
|
||||||
public string Name { get { return "HtmlText"; } }
|
public Dictionary<string, string> Properties
|
||||||
public string Description { get { return "Renders HTML or Text"; } }
|
{
|
||||||
public string Version { get { return "1.0.0"; } }
|
get
|
||||||
public string Owner { get { return ""; } }
|
{
|
||||||
public string Url { get { return ""; } }
|
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||||
public string Contact { get { return ""; } }
|
{
|
||||||
public string License { get { return ""; } }
|
{ "Name", "HtmlText" },
|
||||||
public string Dependencies { get { return ""; } }
|
{ "Description", "Renders HTML or Text" },
|
||||||
|
{ "Version", "1.0.0" }
|
||||||
|
};
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ using System.Threading.Tasks;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
using Oqtane.Modules.HtmlText.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
namespace Oqtane.Modules.HtmlText.Services
|
||||||
{
|
{
|
||||||
public class HtmlTextService : ServiceBase, IHtmlTextService
|
public class HtmlTextService : ServiceBase, IHtmlTextService
|
||||||
{
|
{
|
||||||
|
@ -27,28 +27,24 @@ namespace Oqtane.Client.Modules.HtmlText.Services
|
||||||
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "HtmlText"); }
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "HtmlText"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId)
|
public async Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId)
|
||||||
{
|
{
|
||||||
List<HtmlTextInfo> htmltext = await http.GetJsonAsync<List<HtmlTextInfo>>(apiurl);
|
return await http.GetJsonAsync<HtmlTextInfo>(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
|
||||||
htmltext = htmltext
|
|
||||||
.Where(item => item.ModuleId == ModuleId)
|
|
||||||
.ToList();
|
|
||||||
return htmltext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext)
|
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, htmltext);
|
await http.PostJsonAsync(apiurl + "?entityid=" + htmltext.ModuleId.ToString(), htmltext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmltext)
|
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmltext)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + htmltext.HtmlTextId.ToString(), htmltext);
|
await http.PutJsonAsync(apiurl + "/" + htmltext.HtmlTextId.ToString() + "?entityid=" + htmltext.ModuleId.ToString(), htmltext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteHtmlTextAsync(int HtmlTextId)
|
public async Task DeleteHtmlTextAsync(int ModuleId)
|
||||||
{
|
{
|
||||||
await http.DeleteAsync(apiurl + "/" + HtmlTextId.ToString());
|
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
using Oqtane.Modules.HtmlText.Models;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
namespace Oqtane.Modules.HtmlText.Services
|
||||||
{
|
{
|
||||||
public interface IHtmlTextService
|
public interface IHtmlTextService
|
||||||
{
|
{
|
||||||
Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId);
|
Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId);
|
||||||
|
|
||||||
Task AddHtmlTextAsync(HtmlTextInfo htmltext);
|
Task AddHtmlTextAsync(HtmlTextInfo htmltext);
|
||||||
|
|
||||||
Task UpdateHtmlTextAsync(HtmlTextInfo htmltext);
|
Task UpdateHtmlTextAsync(HtmlTextInfo htmltext);
|
||||||
|
|
||||||
Task DeleteHtmlTextAsync(int HtmlTextId);
|
Task DeleteHtmlTextAsync(int ModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
namespace Oqtane.Modules
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Oqtane.Modules
|
||||||
{
|
{
|
||||||
public interface IModule
|
public interface IModule
|
||||||
{
|
{
|
||||||
string Name { get; }
|
Dictionary<string, string> Properties { get; }
|
||||||
string Description { get; }
|
|
||||||
string Version { get; }
|
|
||||||
string Owner { get; }
|
|
||||||
string Url { get; }
|
|
||||||
string Contact { get; }
|
|
||||||
string License { get; }
|
|
||||||
string Dependencies { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
{
|
{
|
||||||
public interface IModuleControl
|
public interface IModuleControl
|
||||||
{
|
{
|
||||||
string Title { get; }
|
SecurityAccessLevel SecurityAccessLevel { get; } // defines the security access level for this control - defaults to View
|
||||||
SecurityAccessLevelEnum SecurityAccessLevel { get; }
|
string Title { get; } // title to display for this control - defaults to module title
|
||||||
string Actions { get; } // can be specified as a comma delimited set of values
|
string Actions { get; } // allows for routing by configuration rather than by convention ( comma delimited ) - defaults to using component file name
|
||||||
|
bool UseAdminContainer { get; } // container for embedding module control - defaults to true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
Oqtane.Client/Modules/MessageType.cs
Normal file
10
Oqtane.Client/Modules/MessageType.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace Oqtane.Modules
|
||||||
|
{
|
||||||
|
public enum MessageType
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
Info,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,40 +12,52 @@ namespace Oqtane.Modules
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected Module ModuleState { get; set; }
|
protected Module ModuleState { get; set; }
|
||||||
|
|
||||||
public virtual string Title { get { return ""; } }
|
public virtual SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } set { } } // default security
|
||||||
|
|
||||||
public virtual SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.View; } set { } } // default security
|
public virtual string Title { get { return ""; } }
|
||||||
|
|
||||||
public virtual string Actions { get { return ""; } }
|
public virtual string Actions { get { return ""; } }
|
||||||
|
|
||||||
|
public virtual bool UseAdminContainer { get { return true; } }
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string path)
|
public string NavigateUrl(string path)
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState, path);
|
return NavigateUrl(path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string path, bool reload)
|
public string NavigateUrl(string path, string parameters)
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState, path, reload);
|
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action)
|
public string EditUrl(string action)
|
||||||
{
|
{
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, "");
|
return EditUrl(ModuleState.ModuleId, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action, string parameters)
|
public string EditUrl(string action, string parameters)
|
||||||
{
|
{
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, parameters);
|
return EditUrl(ModuleState.ModuleId, action, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Client.Modules.Weather.Services
|
@using Oqtane.Modules.Weather.Services
|
||||||
|
@namespace Oqtane.Modules.Weather
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
|
|
||||||
@if (forecasts == null)
|
@if (forecasts == null)
|
||||||
|
@ -34,7 +35,7 @@ else
|
||||||
@code {
|
@code {
|
||||||
WeatherForecast[] forecasts;
|
WeatherForecast[] forecasts;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
WeatherForecastService forecastservice = new WeatherForecastService();
|
WeatherForecastService forecastservice = new WeatherForecastService();
|
||||||
forecasts = await forecastservice.GetForecastAsync(DateTime.Now);
|
forecasts = await forecastservice.GetForecastAsync(DateTime.Now);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.Weather
|
namespace Oqtane.Modules.Weather
|
||||||
{
|
{
|
||||||
public class WeatherForecast
|
public class WeatherForecast
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.Weather
|
namespace Oqtane.Modules.Weather
|
||||||
{
|
{
|
||||||
public class Module : IModule
|
public class Module : IModule
|
||||||
{
|
{
|
||||||
public string Name { get { return "Weather"; } }
|
public Dictionary<string, string> Properties
|
||||||
public string Description { get { return "Displays random weather using a service"; } }
|
{
|
||||||
public string Version { get { return "1.0.0"; } }
|
get
|
||||||
public string Owner { get { return ""; } }
|
{
|
||||||
public string Url { get { return ""; } }
|
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||||
public string Contact { get { return ""; } }
|
{
|
||||||
public string License { get { return ""; } }
|
{ "Name", "Weather" },
|
||||||
public string Dependencies { get { return ""; } }
|
{ "Description", "Displays random weather using a service" },
|
||||||
|
{ "Version", "1.0.0" }
|
||||||
|
};
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.Weather.Services
|
namespace Oqtane.Modules.Weather.Services
|
||||||
{
|
{
|
||||||
public interface IWeatherForecastService
|
public interface IWeatherForecastService
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Oqtane.Client.Modules.Weather.Services
|
namespace Oqtane.Modules.Weather.Services
|
||||||
{
|
{
|
||||||
public class WeatherForecastService : IWeatherForecastService
|
public class WeatherForecastService : IWeatherForecastService
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"applicationUrl": "http://localhost:14246/"
|
"applicationUrl": "http://localhost:44358/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,29 +4,40 @@ using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Services;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
namespace Oqtane.Providers
|
namespace Oqtane.Providers
|
||||||
{
|
{
|
||||||
public class IdentityAuthenticationStateProvider : AuthenticationStateProvider
|
public class IdentityAuthenticationStateProvider : AuthenticationStateProvider
|
||||||
{
|
{
|
||||||
private readonly IUriHelper urihelper;
|
private readonly IUriHelper urihelper;
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
|
||||||
public IdentityAuthenticationStateProvider(IUriHelper urihelper)
|
public IdentityAuthenticationStateProvider(IUriHelper urihelper, SiteState sitestate)
|
||||||
{
|
{
|
||||||
this.urihelper = urihelper;
|
this.urihelper = urihelper;
|
||||||
|
this.sitestate = sitestate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||||
{
|
{
|
||||||
// hack: create a new HttpClient rather than relying on the registered service as the AuthenticationStateProvider is initialized prior to IUriHelper ( https://github.com/aspnet/AspNetCore/issues/11867 )
|
// hack: create a new HttpClient rather than relying on the registered service as the AuthenticationStateProvider is initialized prior to IUriHelper ( https://github.com/aspnet/AspNetCore/issues/11867 )
|
||||||
HttpClient http = new HttpClient();
|
HttpClient http = new HttpClient();
|
||||||
Uri uri = new Uri(urihelper.GetAbsoluteUri());
|
string apiurl = ServiceBase.CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "User") + "/authenticate";
|
||||||
string apiurl = uri.Scheme + "://" + uri.Authority + "/~/api/User/authenticate";
|
|
||||||
User user = await http.GetJsonAsync<User>(apiurl);
|
User user = await http.GetJsonAsync<User>(apiurl);
|
||||||
|
|
||||||
var identity = user.IsAuthenticated
|
ClaimsIdentity identity = new ClaimsIdentity();
|
||||||
? new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.Username) }, "Identity.Application")
|
if (user.IsAuthenticated)
|
||||||
: new ClaimsIdentity();
|
{
|
||||||
|
identity = new ClaimsIdentity("Identity.Application");
|
||||||
|
identity.AddClaim(new Claim(ClaimTypes.Name, user.Username));
|
||||||
|
identity.AddClaim(new Claim(ClaimTypes.PrimarySid, user.UserId.ToString()));
|
||||||
|
foreach (string role in user.Roles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
identity.AddClaim(new Claim(ClaimTypes.Role, role));
|
||||||
|
}
|
||||||
|
}
|
||||||
return new AuthenticationState(new ClaimsPrincipal(identity));
|
return new AuthenticationState(new ClaimsPrincipal(identity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@ namespace Oqtane.Services
|
||||||
return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAliasAsync(Alias alias)
|
public async Task<Alias> AddAliasAsync(Alias alias)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, alias);
|
return await http.PostJsonAsync<Alias>(apiurl, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAliasAsync(Alias alias)
|
public async Task<Alias> UpdateAliasAsync(Alias alias)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + alias.AliasId.ToString(), alias);
|
return await http.PutJsonAsync<Alias>(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||||
}
|
}
|
||||||
public async Task DeleteAliasAsync(int AliasId)
|
public async Task DeleteAliasAsync(int AliasId)
|
||||||
{
|
{
|
||||||
|
|
37
Oqtane.Client/Services/FileService.cs
Normal file
37
Oqtane.Client/Services/FileService.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.JSInterop;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class FileService : ServiceBase, IFileService
|
||||||
|
{
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
private readonly IUriHelper urihelper;
|
||||||
|
private readonly IJSRuntime jsRuntime;
|
||||||
|
|
||||||
|
public FileService(SiteState sitestate, IUriHelper urihelper, IJSRuntime jsRuntime)
|
||||||
|
{
|
||||||
|
this.sitestate = sitestate;
|
||||||
|
this.urihelper = urihelper;
|
||||||
|
this.jsRuntime = jsRuntime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string apiurl
|
||||||
|
{
|
||||||
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "File"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UploadFilesAsync(string Folder)
|
||||||
|
{
|
||||||
|
await UploadFilesAsync(Folder, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UploadFilesAsync(string Folder, string FileUploadName)
|
||||||
|
{
|
||||||
|
var interop = new Interop(jsRuntime);
|
||||||
|
await interop.UploadFiles(apiurl + "/upload", Folder, FileUploadName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
using Oqtane.Models;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Oqtane.Services
|
|
||||||
{
|
|
||||||
public interface IUserService
|
|
||||||
{
|
|
||||||
Task<List<User>> GetUsersAsync();
|
|
||||||
|
|
||||||
Task<User> GetUserAsync(int UserId);
|
|
||||||
|
|
||||||
Task<User> GetUserAsync(string Username);
|
|
||||||
|
|
||||||
Task AddUserAsync(User user);
|
|
||||||
|
|
||||||
Task UpdateUserAsync(User user);
|
|
||||||
|
|
||||||
Task DeleteUserAsync(int UserId);
|
|
||||||
|
|
||||||
Task<User> GetCurrentUserAsync();
|
|
||||||
|
|
||||||
Task<User> LoginUserAsync(User user);
|
|
||||||
|
|
||||||
Task LogoutUserAsync();
|
|
||||||
|
|
||||||
bool IsAuthorized(User user, string accesscontrollist);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,9 +10,9 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
Task<Alias> GetAliasAsync(int AliasId);
|
Task<Alias> GetAliasAsync(int AliasId);
|
||||||
|
|
||||||
Task AddAliasAsync(Alias alias);
|
Task<Alias> AddAliasAsync(Alias Alias);
|
||||||
|
|
||||||
Task UpdateAliasAsync(Alias alias);
|
Task<Alias> UpdateAliasAsync(Alias Alias);
|
||||||
|
|
||||||
Task DeleteAliasAsync(int AliasId);
|
Task DeleteAliasAsync(int AliasId);
|
||||||
}
|
}
|
12
Oqtane.Client/Services/Interfaces/IFileService.cs
Normal file
12
Oqtane.Client/Services/Interfaces/IFileService.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IFileService
|
||||||
|
{
|
||||||
|
Task UploadFilesAsync(string Folder);
|
||||||
|
Task UploadFilesAsync(string Folder, string FileUploadName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,5 +7,6 @@ namespace Oqtane.Services
|
||||||
public interface IModuleDefinitionService
|
public interface IModuleDefinitionService
|
||||||
{
|
{
|
||||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync();
|
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync();
|
||||||
|
Task InstallModulesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,8 +9,8 @@ namespace Oqtane.Services
|
||||||
Task<List<Module>> GetModulesAsync(int PageId);
|
Task<List<Module>> GetModulesAsync(int PageId);
|
||||||
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
|
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
|
||||||
Task<Module> GetModuleAsync(int ModuleId);
|
Task<Module> GetModuleAsync(int ModuleId);
|
||||||
Task AddModuleAsync(Module module);
|
Task<Module> AddModuleAsync(Module Module);
|
||||||
Task UpdateModuleAsync(Module module);
|
Task<Module> UpdateModuleAsync(Module Module);
|
||||||
Task DeleteModuleAsync(int ModuleId);
|
Task DeleteModuleAsync(int ModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,8 +7,10 @@ namespace Oqtane.Services
|
||||||
public interface IPageModuleService
|
public interface IPageModuleService
|
||||||
{
|
{
|
||||||
Task<List<PageModule>> GetPageModulesAsync();
|
Task<List<PageModule>> GetPageModulesAsync();
|
||||||
Task AddPageModuleAsync(PageModule pagemodule);
|
Task<PageModule> GetPageModuleAsync(int PageModuleId);
|
||||||
Task UpdatePageModuleAsync(PageModule pagemodule);
|
Task<PageModule> AddPageModuleAsync(PageModule PageModule);
|
||||||
|
Task<PageModule> UpdatePageModuleAsync(PageModule PageModule);
|
||||||
|
Task UpdatePageModuleOrderAsync(int PageId, string Pane);
|
||||||
Task DeletePageModuleAsync(int PageModuleId);
|
Task DeletePageModuleAsync(int PageModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,8 +8,9 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||||
Task<Page> GetPageAsync(int PageId);
|
Task<Page> GetPageAsync(int PageId);
|
||||||
Task AddPageAsync(Page page);
|
Task<Page> AddPageAsync(Page Page);
|
||||||
Task UpdatePageAsync(Page page);
|
Task<Page> UpdatePageAsync(Page Page);
|
||||||
|
Task UpdatePageOrderAsync(int SiteId, int? ParentId);
|
||||||
Task DeletePageAsync(int PageId);
|
Task DeletePageAsync(int PageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
21
Oqtane.Client/Services/Interfaces/IProfileService.cs
Normal file
21
Oqtane.Client/Services/Interfaces/IProfileService.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IProfileService
|
||||||
|
{
|
||||||
|
Task<List<Profile>> GetProfilesAsync();
|
||||||
|
|
||||||
|
Task<List<Profile>> GetProfilesAsync(int SiteId);
|
||||||
|
|
||||||
|
Task<Profile> GetProfileAsync(int ProfileId);
|
||||||
|
|
||||||
|
Task<Profile> AddProfileAsync(Profile Profile);
|
||||||
|
|
||||||
|
Task<Profile> UpdateProfileAsync(Profile Profile);
|
||||||
|
|
||||||
|
Task DeleteProfileAsync(int ProfileId);
|
||||||
|
}
|
||||||
|
}
|
21
Oqtane.Client/Services/Interfaces/IRoleService.cs
Normal file
21
Oqtane.Client/Services/Interfaces/IRoleService.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IRoleService
|
||||||
|
{
|
||||||
|
Task<List<Role>> GetRolesAsync();
|
||||||
|
|
||||||
|
Task<List<Role>> GetRolesAsync(int SiteId);
|
||||||
|
|
||||||
|
Task<Role> GetRoleAsync(int RoleId);
|
||||||
|
|
||||||
|
Task<Role> AddRoleAsync(Role Role);
|
||||||
|
|
||||||
|
Task<Role> UpdateRoleAsync(Role Role);
|
||||||
|
|
||||||
|
Task DeleteRoleAsync(int RoleId);
|
||||||
|
}
|
||||||
|
}
|
51
Oqtane.Client/Services/Interfaces/ISettingService.cs
Normal file
51
Oqtane.Client/Services/Interfaces/ISettingService.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface ISettingService
|
||||||
|
{
|
||||||
|
Task<Dictionary<string, string>> GetHostSettingsAsync();
|
||||||
|
|
||||||
|
Task UpdateHostSettingsAsync(Dictionary<string, string> HostSettings);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetSiteSettingsAsync(int SiteId);
|
||||||
|
|
||||||
|
Task UpdateSiteSettingsAsync(Dictionary<string, string> SiteSettings, int SiteId);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetPageSettingsAsync(int PageId);
|
||||||
|
|
||||||
|
Task UpdatePageSettingsAsync(Dictionary<string, string> PageSettings, int PageId);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int PageModuleId);
|
||||||
|
|
||||||
|
Task UpdatePageModuleSettingsAsync(Dictionary<string, string> PageModuleSettings, int PageModuleId);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetModuleSettingsAsync(int ModuleId);
|
||||||
|
|
||||||
|
Task UpdateModuleSettingsAsync(Dictionary<string, string> ModuleSettings, int ModuleId);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetUserSettingsAsync(int UserId);
|
||||||
|
|
||||||
|
Task UpdateUserSettingsAsync(Dictionary<string, string> UserSettings, int UserId);
|
||||||
|
|
||||||
|
Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId);
|
||||||
|
|
||||||
|
Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId);
|
||||||
|
|
||||||
|
|
||||||
|
Task<Setting> GetSettingAsync(int SettingId);
|
||||||
|
|
||||||
|
Task<Setting> AddSettingAsync(Setting Setting);
|
||||||
|
|
||||||
|
Task<Setting> UpdateSettingAsync(Setting Setting);
|
||||||
|
|
||||||
|
Task DeleteSettingAsync(int SettingId);
|
||||||
|
|
||||||
|
|
||||||
|
string GetSetting(Dictionary<string, string> Settings, string SettingName, string DefaultValue);
|
||||||
|
|
||||||
|
Dictionary<string, string> SetSetting(Dictionary<string, string> Settings, string SettingName, string SettingValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,9 +10,9 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
Task<Site> GetSiteAsync(int SiteId);
|
Task<Site> GetSiteAsync(int SiteId);
|
||||||
|
|
||||||
Task AddSiteAsync(Site site);
|
Task<Site> AddSiteAsync(Site Site);
|
||||||
|
|
||||||
Task UpdateSiteAsync(Site site);
|
Task<Site> UpdateSiteAsync(Site Site);
|
||||||
|
|
||||||
Task DeleteSiteAsync(int SiteId);
|
Task DeleteSiteAsync(int SiteId);
|
||||||
}
|
}
|
16
Oqtane.Client/Services/Interfaces/IUserRoleService.cs
Normal file
16
Oqtane.Client/Services/Interfaces/IUserRoleService.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IUserRoleService
|
||||||
|
{
|
||||||
|
Task<List<UserRole>> GetUserRolesAsync();
|
||||||
|
Task<List<UserRole>> GetUserRolesAsync(int UserId);
|
||||||
|
Task<UserRole> GetUserRoleAsync(int UserRoleId);
|
||||||
|
Task<UserRole> AddUserRoleAsync(UserRole UserRole);
|
||||||
|
Task<UserRole> UpdateUserRoleAsync(UserRole UserRole);
|
||||||
|
Task DeleteUserRoleAsync(int UserRoleId);
|
||||||
|
}
|
||||||
|
}
|
25
Oqtane.Client/Services/Interfaces/IUserService.cs
Normal file
25
Oqtane.Client/Services/Interfaces/IUserService.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public interface IUserService
|
||||||
|
{
|
||||||
|
Task<List<User>> GetUsersAsync(int SiteId);
|
||||||
|
|
||||||
|
Task<User> GetUserAsync(int UserId, int SiteId);
|
||||||
|
|
||||||
|
Task<User> GetUserAsync(string Username, int SiteId);
|
||||||
|
|
||||||
|
Task<User> AddUserAsync(User User);
|
||||||
|
|
||||||
|
Task<User> UpdateUserAsync(User User);
|
||||||
|
|
||||||
|
Task DeleteUserAsync(int UserId);
|
||||||
|
|
||||||
|
Task<User> LoginUserAsync(User User, bool SetCookie, bool IsPersistent);
|
||||||
|
|
||||||
|
Task LogoutUserAsync();
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,13 +30,15 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()
|
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()
|
||||||
{
|
{
|
||||||
|
// 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);
|
||||||
|
|
||||||
// get list of loaded assemblies
|
// 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();
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
|
||||||
foreach (ModuleDefinition moduledefinition in moduledefinitions)
|
foreach (ModuleDefinition moduledefinition in moduledefinitions)
|
||||||
{
|
{
|
||||||
|
// if a module has dependencies, check if they are loaded
|
||||||
if (moduledefinition.Dependencies != "")
|
if (moduledefinition.Dependencies != "")
|
||||||
{
|
{
|
||||||
foreach (string dependency in moduledefinition.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string dependency in moduledefinition.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
@ -50,6 +52,7 @@ namespace Oqtane.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// check if the module assembly is loaded
|
||||||
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
// download assembly from server and load
|
// download assembly from server and load
|
||||||
|
@ -60,5 +63,10 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task InstallModulesAsync()
|
||||||
|
{
|
||||||
|
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,14 @@ namespace Oqtane.Services
|
||||||
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddModuleAsync(Module module)
|
public async Task<Module> AddModuleAsync(Module Module)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, module);
|
return await http.PostJsonAsync<Module>(apiurl, Module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateModuleAsync(Module module)
|
public async Task<Module> UpdateModuleAsync(Module Module)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + module.ModuleId.ToString(), module);
|
return await http.PutJsonAsync<Module>(apiurl + "/" + Module.ModuleId.ToString(), Module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteModuleAsync(int ModuleId)
|
public async Task DeleteModuleAsync(int ModuleId)
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
private string apiurl
|
private string apiurl
|
||||||
{
|
{
|
||||||
get { return CreateApiUrl(sitestate.Alias, "PageModule", urihelper.GetAbsoluteUri()); }
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "PageModule"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<PageModule>> GetPageModulesAsync()
|
public async Task<List<PageModule>> GetPageModulesAsync()
|
||||||
|
@ -31,14 +31,24 @@ namespace Oqtane.Services
|
||||||
return await http.GetJsonAsync<List<PageModule>>(apiurl);
|
return await http.GetJsonAsync<List<PageModule>>(apiurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddPageModuleAsync(PageModule pagemodule)
|
public async Task<PageModule> GetPageModuleAsync(int PageModuleId)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, pagemodule);
|
return await http.GetJsonAsync<PageModule>(apiurl + "/" + PageModuleId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdatePageModuleAsync(PageModule pagemodule)
|
public async Task<PageModule> AddPageModuleAsync(PageModule PageModule)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + pagemodule.PageModuleId.ToString(), pagemodule);
|
return await http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PageModule> UpdatePageModuleAsync(PageModule PageModule)
|
||||||
|
{
|
||||||
|
return await http.PutJsonAsync<PageModule>(apiurl + "/" + PageModule.PageModuleId.ToString(), PageModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePageModuleOrderAsync(int PageId, string Pane)
|
||||||
|
{
|
||||||
|
await http.PutJsonAsync(apiurl + "/?pageid=" + PageId.ToString() + "&pane=" + Pane, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeletePageModuleAsync(int PageModuleId)
|
public async Task DeletePageModuleAsync(int PageModuleId)
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Oqtane.Services
|
namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
|
@ -29,7 +30,8 @@ namespace Oqtane.Services
|
||||||
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
||||||
{
|
{
|
||||||
List<Page> pages = await http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
List<Page> pages = await http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||||
return pages.OrderBy(item => item.Order).ToList();
|
pages = GetPagesHierarchy(pages);
|
||||||
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Page> GetPageAsync(int PageId)
|
public async Task<Page> GetPageAsync(int PageId)
|
||||||
|
@ -37,18 +39,55 @@ namespace Oqtane.Services
|
||||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddPageAsync(Page page)
|
public async Task<Page> AddPageAsync(Page Page)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, page);
|
return await http.PostJsonAsync<Page>(apiurl, Page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdatePageAsync(Page page)
|
public async Task<Page> UpdatePageAsync(Page Page)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + page.PageId.ToString(), page);
|
return await http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePageOrderAsync(int SiteId, int? ParentId)
|
||||||
|
{
|
||||||
|
await http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task DeletePageAsync(int PageId)
|
public async Task DeletePageAsync(int PageId)
|
||||||
{
|
{
|
||||||
await http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
await http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<Page> GetPagesHierarchy(List<Page> Pages)
|
||||||
|
{
|
||||||
|
List<Page> hierarchy = new List<Page>();
|
||||||
|
Action<List<Page>, Page> GetPath = null;
|
||||||
|
GetPath = (List<Page> pages, Page page) =>
|
||||||
|
{
|
||||||
|
IEnumerable<Page> children;
|
||||||
|
int level;
|
||||||
|
if (page == null)
|
||||||
|
{
|
||||||
|
level = -1;
|
||||||
|
children = Pages.Where(item => item.ParentId == null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
level = page.Level;
|
||||||
|
children = Pages.Where(item => item.ParentId == page.PageId);
|
||||||
|
}
|
||||||
|
foreach (Page child in children)
|
||||||
|
{
|
||||||
|
child.Level = level + 1;
|
||||||
|
child.HasChildren = Pages.Where(item => item.ParentId == child.PageId).Any();
|
||||||
|
hierarchy.Add(child);
|
||||||
|
GetPath(pages, child);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Pages = Pages.OrderBy(item => item.Order).ToList();
|
||||||
|
GetPath(Pages, null);
|
||||||
|
return hierarchy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
59
Oqtane.Client/Services/ProfileService.cs
Normal file
59
Oqtane.Client/Services/ProfileService.cs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class ProfileService : ServiceBase, IProfileService
|
||||||
|
{
|
||||||
|
private readonly HttpClient http;
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
private readonly IUriHelper urihelper;
|
||||||
|
|
||||||
|
public ProfileService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
|
||||||
|
{
|
||||||
|
this.http = http;
|
||||||
|
this.sitestate = sitestate;
|
||||||
|
this.urihelper = urihelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string apiurl
|
||||||
|
{
|
||||||
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Profile"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Profile>> GetProfilesAsync()
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<List<Profile>>(apiurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Profile>> GetProfilesAsync(int SiteId)
|
||||||
|
{
|
||||||
|
List<Profile> Profiles = await http.GetJsonAsync<List<Profile>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||||
|
return Profiles.OrderBy(item => item.ViewOrder).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Profile> GetProfileAsync(int ProfileId)
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<Profile>(apiurl + "/" + ProfileId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Profile> AddProfileAsync(Profile Profile)
|
||||||
|
{
|
||||||
|
return await http.PostJsonAsync<Profile>(apiurl, Profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Profile> UpdateProfileAsync(Profile Profile)
|
||||||
|
{
|
||||||
|
return await http.PutJsonAsync<Profile>(apiurl + "/" + Profile.SiteId.ToString(), Profile);
|
||||||
|
}
|
||||||
|
public async Task DeleteProfileAsync(int ProfileId)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + ProfileId.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Oqtane.Client/Services/RoleService.cs
Normal file
60
Oqtane.Client/Services/RoleService.cs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class RoleService : ServiceBase, IRoleService
|
||||||
|
{
|
||||||
|
private readonly HttpClient http;
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
private readonly IUriHelper urihelper;
|
||||||
|
|
||||||
|
public RoleService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
|
||||||
|
{
|
||||||
|
this.http = http;
|
||||||
|
this.sitestate = sitestate;
|
||||||
|
this.urihelper = urihelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string apiurl
|
||||||
|
{
|
||||||
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Role"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Role>> GetRolesAsync()
|
||||||
|
{
|
||||||
|
List<Role> Roles = await http.GetJsonAsync<List<Role>>(apiurl);
|
||||||
|
return Roles.OrderBy(item => item.Name).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Role>> GetRolesAsync(int SiteId)
|
||||||
|
{
|
||||||
|
List<Role> Roles = await http.GetJsonAsync<List<Role>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||||
|
return Roles.OrderBy(item => item.Name).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Role> GetRoleAsync(int RoleId)
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<Role>(apiurl + "/" + RoleId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Role> AddRoleAsync(Role Role)
|
||||||
|
{
|
||||||
|
return await http.PostJsonAsync<Role>(apiurl, Role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Role> UpdateRoleAsync(Role Role)
|
||||||
|
{
|
||||||
|
return await http.PutJsonAsync<Role>(apiurl + "/" + Role.SiteId.ToString(), Role);
|
||||||
|
}
|
||||||
|
public async Task DeleteRoleAsync(int RoleId)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + RoleId.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ namespace Oqtane.Services
|
||||||
public class ServiceBase
|
public class ServiceBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public string CreateApiUrl(Alias alias, string absoluteUri, string serviceName)
|
public static string CreateApiUrl(Alias alias, string absoluteUri, string serviceName)
|
||||||
{
|
{
|
||||||
string apiurl = "";
|
string apiurl = "";
|
||||||
if (alias != null)
|
if (alias != null)
|
||||||
|
|
168
Oqtane.Client/Services/SettingService.cs
Normal file
168
Oqtane.Client/Services/SettingService.cs
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class SettingService : ServiceBase, ISettingService
|
||||||
|
{
|
||||||
|
private readonly HttpClient http;
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
private readonly IUriHelper urihelper;
|
||||||
|
|
||||||
|
public SettingService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
|
||||||
|
{
|
||||||
|
this.http = http;
|
||||||
|
this.sitestate = sitestate;
|
||||||
|
this.urihelper = urihelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string apiurl
|
||||||
|
{
|
||||||
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "Setting"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetHostSettingsAsync()
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("Host", -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateHostSettingsAsync(Dictionary<string, string> HostSettings)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(HostSettings, "Host", -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetSiteSettingsAsync(int SiteId)
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("Site", SiteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateSiteSettingsAsync(Dictionary<string, string> SiteSettings, int SiteId)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(SiteSettings, "Site", SiteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetPageSettingsAsync(int PageId)
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("Page", PageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePageSettingsAsync(Dictionary<string, string> PageSettings, int PageId)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(PageSettings, "Page", PageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetPageModuleSettingsAsync(int PageModuleId)
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("PageModule", PageModuleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePageModuleSettingsAsync(Dictionary<string, string> PageModuleSettings, int PageModuleId)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(PageModuleSettings, "PageModule", PageModuleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetModuleSettingsAsync(int ModuleId)
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("Module", ModuleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateModuleSettingsAsync(Dictionary<string, string> ModuleSettings, int ModuleId)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(ModuleSettings, "Module", ModuleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetUserSettingsAsync(int UserId)
|
||||||
|
{
|
||||||
|
return await GetSettingsAsync("User", UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateUserSettingsAsync(Dictionary<string, string> UserSettings, int UserId)
|
||||||
|
{
|
||||||
|
await UpdateSettingsAsync(UserSettings, "User", UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||||
|
List<Setting> Settings = await http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||||
|
foreach(Setting setting in Settings.OrderBy(item => item.SettingName).ToList())
|
||||||
|
{
|
||||||
|
dictionary.Add(setting.SettingName, setting.SettingValue);
|
||||||
|
}
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId)
|
||||||
|
{
|
||||||
|
List<Setting> settings = await http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||||
|
foreach (KeyValuePair<string, string> kvp in Settings)
|
||||||
|
{
|
||||||
|
Setting setting = settings.Where(item => item.SettingName == kvp.Key).FirstOrDefault();
|
||||||
|
if (setting == null)
|
||||||
|
{
|
||||||
|
setting = new Setting();
|
||||||
|
setting.EntityName = EntityName;
|
||||||
|
setting.EntityId = EntityId;
|
||||||
|
setting.SettingName = kvp.Key;
|
||||||
|
setting.SettingValue = kvp.Value;
|
||||||
|
setting = await AddSettingAsync(setting);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setting.SettingValue = kvp.Value;
|
||||||
|
setting = await UpdateSettingAsync(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<Setting> GetSettingAsync(int SettingId)
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<Setting>(apiurl + "/" + SettingId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Setting> AddSettingAsync(Setting Setting)
|
||||||
|
{
|
||||||
|
return await http.PostJsonAsync<Setting>(apiurl, Setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Setting> UpdateSettingAsync(Setting Setting)
|
||||||
|
{
|
||||||
|
return await http.PutJsonAsync<Setting>(apiurl + "/" + Setting.SettingId.ToString(), Setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteSettingAsync(int SettingId)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + SettingId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetSetting(Dictionary<string, string> Settings, string SettingName, string DefaultValue)
|
||||||
|
{
|
||||||
|
string value = DefaultValue;
|
||||||
|
if (Settings.ContainsKey(SettingName))
|
||||||
|
{
|
||||||
|
value = Settings[SettingName];
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> SetSetting(Dictionary<string, string> Settings, string SettingName, string SettingValue)
|
||||||
|
{
|
||||||
|
if (Settings.ContainsKey(SettingName))
|
||||||
|
{
|
||||||
|
Settings[SettingName] = SettingValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Settings.Add(SettingName, SettingValue);
|
||||||
|
}
|
||||||
|
return Settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,14 +37,14 @@ namespace Oqtane.Services
|
||||||
return await http.GetJsonAsync<Site>(apiurl + "/" + SiteId.ToString());
|
return await http.GetJsonAsync<Site>(apiurl + "/" + SiteId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddSiteAsync(Site site)
|
public async Task<Site> AddSiteAsync(Site Site)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, site);
|
return await http.PostJsonAsync<Site>(apiurl, Site);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateSiteAsync(Site site)
|
public async Task<Site> UpdateSiteAsync(Site Site)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + site.SiteId.ToString(), site);
|
return await http.PutJsonAsync<Site>(apiurl + "/" + Site.SiteId.ToString(), Site);
|
||||||
}
|
}
|
||||||
public async Task DeleteSiteAsync(int SiteId)
|
public async Task DeleteSiteAsync(int SiteId)
|
||||||
{
|
{
|
||||||
|
|
59
Oqtane.Client/Services/UserRoleService.cs
Normal file
59
Oqtane.Client/Services/UserRoleService.cs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
public class UserRoleService : ServiceBase, IUserRoleService
|
||||||
|
{
|
||||||
|
private readonly HttpClient http;
|
||||||
|
private readonly SiteState sitestate;
|
||||||
|
private readonly IUriHelper urihelper;
|
||||||
|
|
||||||
|
public UserRoleService(HttpClient http, SiteState sitestate, IUriHelper urihelper)
|
||||||
|
{
|
||||||
|
this.http = http;
|
||||||
|
this.sitestate = sitestate;
|
||||||
|
this.urihelper = urihelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string apiurl
|
||||||
|
{
|
||||||
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "UserRole"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<UserRole>> GetUserRolesAsync()
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<List<UserRole>>(apiurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<UserRole>> GetUserRolesAsync(int UserId)
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<List<UserRole>>(apiurl + "?userid=" + UserId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserRole> GetUserRoleAsync(int UserRoleId)
|
||||||
|
{
|
||||||
|
return await http.GetJsonAsync<UserRole>(apiurl + "/" + UserRoleId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserRole> AddUserRoleAsync(UserRole UserRole)
|
||||||
|
{
|
||||||
|
return await http.PostJsonAsync<UserRole>(apiurl, UserRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserRole> UpdateUserRoleAsync(UserRole UserRole)
|
||||||
|
{
|
||||||
|
return await http.PutJsonAsync<UserRole>(apiurl + "/" + UserRole.UserRoleId.ToString(), UserRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteUserRoleAsync(int UserRoleId)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + UserRoleId.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,44 +27,39 @@ namespace Oqtane.Services
|
||||||
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "User"); }
|
get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "User"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<User>> GetUsersAsync()
|
public async Task<List<User>> GetUsersAsync(int SiteId)
|
||||||
{
|
{
|
||||||
List<User> users = await http.GetJsonAsync<List<User>>(apiurl);
|
List<User> users = await http.GetJsonAsync<List<User>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||||
return users.OrderBy(item => item.DisplayName).ToList();
|
return users.OrderBy(item => item.DisplayName).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User> GetUserAsync(int UserId)
|
public async Task<User> GetUserAsync(int UserId, int SiteId)
|
||||||
{
|
{
|
||||||
return await http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString());
|
return await http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString() + "?siteid=" + SiteId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User> GetUserAsync(string Username)
|
public async Task<User> GetUserAsync(string Username, int SiteId)
|
||||||
{
|
{
|
||||||
return await http.GetJsonAsync<User>(apiurl + "/name/" + Username);
|
return await http.GetJsonAsync<User>(apiurl + "/name/" + Username + "?siteid=" + SiteId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddUserAsync(User user)
|
public async Task<User> AddUserAsync(User User)
|
||||||
{
|
{
|
||||||
await http.PostJsonAsync(apiurl, user);
|
return await http.PostJsonAsync<User>(apiurl, User);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateUserAsync(User user)
|
public async Task<User> UpdateUserAsync(User User)
|
||||||
{
|
{
|
||||||
await http.PutJsonAsync(apiurl + "/" + user.UserId.ToString(), user);
|
return await http.PutJsonAsync<User>(apiurl + "/" + User.UserId.ToString(), User);
|
||||||
}
|
}
|
||||||
public async Task DeleteUserAsync(int UserId)
|
public async Task DeleteUserAsync(int UserId)
|
||||||
{
|
{
|
||||||
await http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
await http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User> GetCurrentUserAsync()
|
public async Task<User> LoginUserAsync(User User, bool SetCookie, bool IsPersistent)
|
||||||
{
|
{
|
||||||
return await http.GetJsonAsync<User>(apiurl + "/current");
|
return await http.PostJsonAsync<User>(apiurl + "/login?setcookie=" + SetCookie.ToString() + "&persistent =" + IsPersistent.ToString(), User);
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<User> LoginUserAsync(User user)
|
|
||||||
{
|
|
||||||
return await http.PostJsonAsync<User>(apiurl + "/login", user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LogoutUserAsync()
|
public async Task LogoutUserAsync()
|
||||||
|
@ -72,78 +67,5 @@ namespace Oqtane.Services
|
||||||
// best practices recommend post is preferrable to get for logout
|
// best practices recommend post is preferrable to get for logout
|
||||||
await http.PostJsonAsync(apiurl + "/logout", null);
|
await http.PostJsonAsync(apiurl + "/logout", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLs are stored in the format "!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]" where "!" designates Deny permissions
|
|
||||||
public bool IsAuthorized(User user, string accesscontrollist)
|
|
||||||
{
|
|
||||||
bool isAllowed = false;
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
//super user always has full access
|
|
||||||
isAllowed = user.IsSuperUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAllowed)
|
|
||||||
{
|
|
||||||
if (accesscontrollist != null)
|
|
||||||
{
|
|
||||||
foreach (string permission in accesscontrollist.Split(new[] { ';' }))
|
|
||||||
{
|
|
||||||
bool? allowed = VerifyPermission(user, permission);
|
|
||||||
if (allowed.HasValue)
|
|
||||||
{
|
|
||||||
isAllowed = allowed.Value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool? VerifyPermission(User user, string permission)
|
|
||||||
{
|
|
||||||
bool? allowed = null;
|
|
||||||
//permissions strings are encoded with deny permissions at the beginning and grant permissions at the end for optimal performance
|
|
||||||
if (!String.IsNullOrEmpty(permission))
|
|
||||||
{
|
|
||||||
// deny permission
|
|
||||||
if (permission.StartsWith("!"))
|
|
||||||
{
|
|
||||||
string denyRole = permission.Replace("!", "");
|
|
||||||
if (denyRole == Constants.AllUsersRole || IsAllowed(user, denyRole))
|
|
||||||
{
|
|
||||||
allowed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // grant permission
|
|
||||||
{
|
|
||||||
if (permission == Constants.AllUsersRole || IsAllowed(user, permission))
|
|
||||||
{
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsAllowed(User user, string permission)
|
|
||||||
{
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
if ("[" + user.UserId + "]" == permission)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var roles = user.Roles;
|
|
||||||
if (roles != null)
|
|
||||||
{
|
|
||||||
return roles.IndexOf(";" + permission + ";") != -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
namespace Oqtane.Shared
|
|
||||||
{
|
|
||||||
public class Constants
|
|
||||||
{
|
|
||||||
public const string DefaultPage = "Oqtane.Client.Shared.Theme, Oqtane.Client";
|
|
||||||
public const string DefaultContainer = "Oqtane.Client.Shared.Container, Oqtane.Client";
|
|
||||||
public const string DefaultAdminContainer = "Oqtane.Client.Themes.AdminContainer, Oqtane.Client";
|
|
||||||
public const string DefaultSettingsControl = "Oqtane.Client.Modules.Admin.ModuleSettings.Index, Oqtane.Client";
|
|
||||||
public const string PageManagementModule = "Oqtane.Client.Modules.Admin.Pages, Oqtane.Client";
|
|
||||||
public const string DefaultControl = "Index";
|
|
||||||
|
|
||||||
public const string AdminPane = "Admin";
|
|
||||||
|
|
||||||
public const string AllUsersRole = "All Users";
|
|
||||||
public const string AdminRole = "Administrators";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Shared
|
||||||
|
|
||||||
<CascadingValue Value="@ModuleState">
|
<CascadingValue Value="@ModuleState">
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
@ -10,15 +12,21 @@
|
||||||
protected PageState PageState { get; set; }
|
protected PageState PageState { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private Module Module { get; set; }
|
public Module Module { get; set; }
|
||||||
|
|
||||||
Module ModuleState;
|
|
||||||
string container;
|
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
protected override void OnInit()
|
Module ModuleState;
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
|
ModuleState = Module; // passed in from Pane component
|
||||||
|
string container = ModuleState.ContainerType;
|
||||||
|
if (PageState.ModuleId != -1 && PageState.Control != "" && ModuleState.UseAdminContainer)
|
||||||
|
{
|
||||||
|
container = Constants.DefaultAdminContainer;
|
||||||
|
}
|
||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
Type containerType = Type.GetType(container);
|
Type containerType = Type.GetType(container);
|
||||||
|
@ -30,18 +38,10 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// container does not exist with type specified
|
// container does not exist with type specified
|
||||||
|
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
|
||||||
|
builder.AddAttribute(1, "Message", "Error Loading Module Container " + container);
|
||||||
|
builder.CloseComponent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
ModuleState = Module; // passed in from Pane component
|
|
||||||
container = ModuleState.ContainerType;
|
|
||||||
if (PageState.ModuleId != -1 && PageState.Control != "")
|
|
||||||
{
|
|
||||||
container = Constants.DefaultAdminContainer;
|
|
||||||
}
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Shared
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -82,10 +84,10 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Title" class="control-label" style="font-weight: bold">Username: </label>
|
<label for="Title" class="control-label" style="font-weight: bold">Email: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" id="Email" class="form-control" @bind="@HostUsername" />
|
<input type="text" id="Email" class="form-control" @bind="@Email" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -102,7 +104,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="mx-auto text-center">
|
<div class="mx-auto text-center">
|
||||||
<button class="btn btn-success" @onclick="@Install">Install Now</button><br /><br />
|
<button type="button" class="btn btn-success" @onclick="@Install">Install Now</button><br /><br />
|
||||||
@((MarkupString)@Message)
|
@((MarkupString)@Message)
|
||||||
</div>
|
</div>
|
||||||
<div class="loading" style="@LoadingDisplay"></div>
|
<div class="loading" style="@LoadingDisplay"></div>
|
||||||
|
@ -110,14 +112,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
private string DatabaseType = "LocalDB";
|
private string DatabaseType = "LocalDB";
|
||||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||||
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||||
private bool IntegratedSecurity = true;
|
|
||||||
private string Username = "";
|
private string Username = "";
|
||||||
private string Password = "";
|
private string Password = "";
|
||||||
private string HostUsername = "host";
|
private string Email = "";
|
||||||
private string HostPassword = "";
|
private string HostPassword = "";
|
||||||
private string Message = "";
|
private string Message = "";
|
||||||
|
|
||||||
|
@ -165,12 +165,14 @@ private async Task Install()
|
||||||
if (response.Success)
|
if (response.Success)
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.Username = HostUsername;
|
user.SiteId = 1;
|
||||||
user.DisplayName = HostUsername;
|
user.Username = Email;
|
||||||
|
user.DisplayName = Email;
|
||||||
|
user.Email = Email;
|
||||||
|
user.IsHost = true;
|
||||||
user.Password = HostPassword;
|
user.Password = HostPassword;
|
||||||
user.IsSuperUser = true;
|
user = await UserService.AddUserAsync(user);
|
||||||
user.Roles = "";
|
|
||||||
await UserService.AddUserAsync(user);
|
|
||||||
UriHelper.NavigateTo("", true);
|
UriHelper.NavigateTo("", true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -85,5 +85,20 @@ namespace Oqtane.Shared
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task UploadFiles(string posturl, string folder, string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsRuntime.InvokeAsync<string>(
|
||||||
|
"interop.uploadFiles",
|
||||||
|
posturl, folder, name);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Shared
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
|
@ -21,7 +23,11 @@
|
||||||
{
|
{
|
||||||
typename = Constants.DefaultSettingsControl;
|
typename = Constants.DefaultSettingsControl;
|
||||||
}
|
}
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = null;
|
||||||
|
if (typename != null)
|
||||||
|
{
|
||||||
|
moduleType = Type.GetType(typename);
|
||||||
|
}
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, moduleType);
|
builder.OpenComponent(0, moduleType);
|
||||||
|
@ -29,7 +35,10 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// module control does not exist with typename specified
|
// module does not exist with typename specified
|
||||||
|
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
|
||||||
|
builder.AddAttribute(1, "Message", "Error Loading Component For Module " + ModuleState.ModuleDefinitionName);
|
||||||
|
builder.CloseComponent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,8 @@ namespace Oqtane.Shared
|
||||||
public Dictionary<string, string> QueryString { get; set; }
|
public Dictionary<string, string> QueryString { get; set; }
|
||||||
public int ModuleId { get; set; }
|
public int ModuleId { get; set; }
|
||||||
public string Control { get; set; }
|
public string Control { get; set; }
|
||||||
|
public bool EditMode { get; set; }
|
||||||
|
public bool DesignMode { get; set; }
|
||||||
|
public int Reload { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,18 @@
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
@using System.Linq
|
@using System.Linq
|
||||||
|
@namespace Oqtane.Shared
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
|
|
||||||
<div class="@paneadminborder">
|
<div class="@paneadminborder">
|
||||||
|
@if (panetitle != "")
|
||||||
|
{
|
||||||
@((MarkupString)panetitle)
|
@((MarkupString)panetitle)
|
||||||
|
}
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -18,20 +23,25 @@
|
||||||
protected PageState PageState { get; set; }
|
protected PageState PageState { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
private string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
string paneadminborder = "";
|
string paneadminborder = "";
|
||||||
string panetitle = "";
|
string panetitle = "";
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
if (UserService.IsAuthorized(PageState.User, PageState.Page.EditPermissions) && Name != Constants.AdminPane)
|
if (PageState.DesignMode && UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||||
{
|
{
|
||||||
paneadminborder = "pane-admin-border";
|
paneadminborder = "pane-admin-border";
|
||||||
panetitle = "<div class=\"pane-admin-title\">" + Name + " Pane</div>";
|
panetitle = "<div class=\"pane-admin-title\">" + Name + " Pane</div>";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paneadminborder = "";
|
||||||
|
panetitle = "";
|
||||||
|
}
|
||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
|
@ -50,38 +60,38 @@
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduleType);
|
|
||||||
// verify security access level for this module control
|
|
||||||
SecurityAccessLevelEnum SecurityAccessLevel = (SecurityAccessLevelEnum)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
|
||||||
bool authorized = false;
|
bool authorized = false;
|
||||||
switch (SecurityAccessLevel)
|
if (PageState.Control == "Settings")
|
||||||
{
|
{
|
||||||
case SecurityAccessLevelEnum.Anonymous:
|
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// verify security access level for this module control
|
||||||
|
switch (module.SecurityAccessLevel)
|
||||||
|
{
|
||||||
|
case SecurityAccessLevel.Anonymous:
|
||||||
authorized = true;
|
authorized = true;
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.View:
|
case SecurityAccessLevel.View:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, module.ViewPermissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Edit:
|
case SecurityAccessLevel.Edit:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, module.EditPermissions);
|
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", module.Permissions);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Admin:
|
case SecurityAccessLevel.Admin:
|
||||||
authorized = UserService.IsAuthorized(PageState.User, Constants.AdminRole);
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||||
break;
|
break;
|
||||||
case SecurityAccessLevelEnum.Host:
|
case SecurityAccessLevel.Host:
|
||||||
authorized = PageState.User.IsSuperUser;
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (authorized)
|
if (authorized)
|
||||||
{
|
{
|
||||||
if (PageState.Control != "Settings")
|
if (PageState.Control != "Settings" && module.ControlTitle != "")
|
||||||
{
|
{
|
||||||
// get module control title
|
module.Title = module.ControlTitle;
|
||||||
string title = (string)moduleType.GetProperty("Title").GetValue(moduleobject);
|
|
||||||
if (title != "")
|
|
||||||
{
|
|
||||||
module.Title = title;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||||
builder.AddAttribute(1, "Module", module);
|
builder.AddAttribute(1, "Module", module);
|
||||||
|
@ -103,7 +113,7 @@
|
||||||
if (module != null && module.Pane == Name)
|
if (module != null && module.Pane == Name)
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
// check if user is authorized to view module
|
||||||
if (UserService.IsAuthorized(PageState.User, module.ViewPermissions))
|
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||||
builder.AddAttribute(1, "Module", module);
|
builder.AddAttribute(1, "Module", module);
|
||||||
|
@ -116,10 +126,11 @@
|
||||||
foreach (Module module in PageState.Modules.Where(item => item.Pane == Name).OrderBy(x => x.Order).ToArray())
|
foreach (Module module in PageState.Modules.Where(item => item.Pane == Name).OrderBy(x => x.Order).ToArray())
|
||||||
{
|
{
|
||||||
// check if user is authorized to view module
|
// check if user is authorized to view module
|
||||||
if (UserService.IsAuthorized(PageState.User, module.ViewPermissions))
|
if (UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions))
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||||
builder.AddAttribute(1, "Module", module);
|
builder.AddAttribute(1, "Module", module);
|
||||||
|
builder.SetKey(module.PageModuleId);
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@using System
|
@using System
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Shared
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
@using System
|
@using System
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Modules
|
||||||
@using System.Linq
|
@using System.Linq
|
||||||
@using System.Collections.Generic
|
@using System.Collections.Generic
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Microsoft.JSInterop
|
@using Oqtane.Security
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@namespace Oqtane.Shared
|
||||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||||
@inject SiteState SiteState
|
@inject SiteState SiteState
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject INavigationInterception NavigationInterception
|
@inject INavigationInterception NavigationInterception
|
||||||
@inject IComponentContext ComponentContext
|
@inject IComponentContext ComponentContext
|
||||||
@inject IJSRuntime jsRuntime
|
|
||||||
@inject IAliasService AliasService
|
@inject IAliasService AliasService
|
||||||
@inject ITenantService TenantService
|
@inject ITenantService TenantService
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
|
@ -26,9 +27,11 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[CascadingParameter] PageState PageState { get; set; }
|
[CascadingParameter]
|
||||||
|
PageState PageState { get; set; }
|
||||||
|
|
||||||
[Parameter] Action<PageState> OnStateChange { get; set; }
|
[Parameter]
|
||||||
|
public Action<PageState> OnStateChange { get; set; }
|
||||||
|
|
||||||
PageState pagestate;
|
PageState pagestate;
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
@ -36,14 +39,14 @@ RenderFragment DynamicComponent { get; set; }
|
||||||
string _absoluteUri;
|
string _absoluteUri;
|
||||||
bool _navigationInterceptionEnabled;
|
bool _navigationInterceptionEnabled;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
_absoluteUri = UriHelper.GetAbsoluteUri();
|
_absoluteUri = UriHelper.GetAbsoluteUri();
|
||||||
UriHelper.OnLocationChanged += OnLocationChanged;
|
UriHelper.OnLocationChanged += OnLocationChanged;
|
||||||
|
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
if (pagestate != null)
|
if (PageState != null)
|
||||||
{
|
{
|
||||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultPage));
|
builder.OpenComponent(0, Type.GetType(Constants.DefaultPage));
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
|
@ -59,9 +62,17 @@ public void Dispose()
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
if (PageState == null)
|
if (PageState == null)
|
||||||
|
{
|
||||||
|
// misconfigured api calls should not be processed through the router
|
||||||
|
if (!_absoluteUri.Contains("~/api/"))
|
||||||
{
|
{
|
||||||
await Refresh();
|
await Refresh();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine(this.GetType().FullName + ": Error: API call to " + _absoluteUri + " is not mapped to a Controller");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
|
@ -75,67 +86,52 @@ private async Task Refresh()
|
||||||
Page page;
|
Page page;
|
||||||
User user;
|
User user;
|
||||||
List<Module> modules;
|
List<Module> modules;
|
||||||
|
int moduleid = -1;
|
||||||
|
string control = "";
|
||||||
|
bool editmode = false;
|
||||||
|
bool designmode = false;
|
||||||
|
int reload = 0;
|
||||||
|
|
||||||
bool reload = false;
|
if (PageState != null)
|
||||||
if (PageState == null)
|
|
||||||
{
|
{
|
||||||
|
reload = PageState.Reload;
|
||||||
|
editmode = PageState.EditMode;
|
||||||
|
designmode = PageState.DesignMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PageState == null || reload == Constants.ReloadApplication)
|
||||||
|
{
|
||||||
|
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
||||||
|
themes = await ThemeService.GetThemesAsync();
|
||||||
aliases = await AliasService.GetAliasesAsync();
|
aliases = await AliasService.GetAliasesAsync();
|
||||||
alias = null;
|
alias = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
moduledefinitions = PageState.ModuleDefinitions;
|
||||||
|
themes = PageState.Themes;
|
||||||
aliases = PageState.Aliases;
|
aliases = PageState.Aliases;
|
||||||
alias = PageState.Alias;
|
alias = PageState.Alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if site has changed
|
||||||
if (alias == null || GetAlias(_absoluteUri, aliases).Name != alias.Name)
|
if (alias == null || GetAlias(_absoluteUri, aliases).Name != alias.Name)
|
||||||
{
|
{
|
||||||
alias = GetAlias(_absoluteUri, aliases);
|
alias = GetAlias(_absoluteUri, aliases);
|
||||||
SiteState.Alias = alias; // set state for services
|
SiteState.Alias = alias; // set state for services
|
||||||
reload = true;
|
reload = Constants.ReloadSite;
|
||||||
}
|
}
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload <= Constants.ReloadSite)
|
||||||
{
|
{
|
||||||
moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync();
|
|
||||||
themes = await ThemeService.GetThemesAsync();
|
|
||||||
site = await SiteService.GetSiteAsync(alias.SiteId);
|
site = await SiteService.GetSiteAsync(alias.SiteId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moduledefinitions = PageState.ModuleDefinitions;
|
|
||||||
themes = PageState.Themes;
|
|
||||||
site = PageState.Site;
|
site = PageState.Site;
|
||||||
}
|
}
|
||||||
if (site != null || reload == true)
|
if (site != null)
|
||||||
{
|
{
|
||||||
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
if (PageState == null || reload >= Constants.ReloadSite)
|
||||||
if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
||||||
if (alias.Path != "")
|
|
||||||
{
|
|
||||||
path = path.Replace(alias.Path, "");
|
|
||||||
if (path.StartsWith("/")) { path = path.Substring(1); }
|
|
||||||
}
|
|
||||||
Dictionary<string, string> querystring = ParseQueryString(path);
|
|
||||||
|
|
||||||
if (querystring.ContainsKey("reload"))
|
|
||||||
{
|
|
||||||
reload = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
user = null;
|
|
||||||
if (PageState == null || reload == true)
|
|
||||||
{
|
|
||||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
||||||
if (authState.User.Identity.IsAuthenticated)
|
|
||||||
{
|
|
||||||
user = await UserService.GetUserAsync(authState.User.Identity.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user = PageState.User;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
|
||||||
{
|
{
|
||||||
pages = await PageService.GetPagesAsync(site.SiteId);
|
pages = await PageService.GetPagesAsync(site.SiteId);
|
||||||
}
|
}
|
||||||
|
@ -144,12 +140,48 @@ private async Task Refresh()
|
||||||
pages = PageState.Pages;
|
pages = PageState.Pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get Url path and querystring
|
||||||
|
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
||||||
|
|
||||||
|
// parse querystring and remove
|
||||||
|
Dictionary<string, string> querystring = new Dictionary<string, string>();
|
||||||
if (path.IndexOf("?") != -1)
|
if (path.IndexOf("?") != -1)
|
||||||
{
|
{
|
||||||
|
querystring = ParseQueryString(path);
|
||||||
path = path.Substring(0, path.IndexOf("?"));
|
path = path.Substring(0, path.IndexOf("?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
// format path and remove alias
|
||||||
|
path = path.Replace("//", "/");
|
||||||
|
if (!path.EndsWith("/")) { path += "/"; }
|
||||||
|
if (alias.Path != "")
|
||||||
|
{
|
||||||
|
path = path.Replace(alias.Path + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract admin route elements from path
|
||||||
|
string[] segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
int result;
|
||||||
|
if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
|
||||||
|
{
|
||||||
|
// path has moduleid and control specification ie. page/moduleid/control/
|
||||||
|
control = segments[segments.Length - 1];
|
||||||
|
moduleid = result;
|
||||||
|
path = path.Replace(moduleid.ToString() + "/" + control + "/", "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
|
||||||
|
{
|
||||||
|
// path has only moduleid specification ie. page/moduleid/
|
||||||
|
moduleid = result;
|
||||||
|
path = path.Replace(moduleid.ToString() + "/", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove trailing slash so it can be used as a key for Pages
|
||||||
|
if (path.EndsWith("/")) path = path.Substring(0, path.Length - 1);
|
||||||
|
|
||||||
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
{
|
{
|
||||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
@ -157,16 +189,33 @@ private async Task Refresh()
|
||||||
{
|
{
|
||||||
page = PageState.Page;
|
page = PageState.Page;
|
||||||
}
|
}
|
||||||
|
// check if page has changed
|
||||||
if (page.Path != path)
|
if (page.Path != path)
|
||||||
{
|
{
|
||||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||||
reload = true;
|
reload = Constants.ReloadPage;
|
||||||
|
editmode = page.EditMode;
|
||||||
|
designmode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
user = null;
|
||||||
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
|
{
|
||||||
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||||
|
if (authState.User.Identity.IsAuthenticated)
|
||||||
|
{
|
||||||
|
user = await UserService.GetUserAsync(authState.User.Identity.Name, site.SiteId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user = PageState.User;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
// check if user is authorized to view page
|
// check if user is authorized to view page
|
||||||
if (UserService.IsAuthorized(user, page.ViewPermissions))
|
if (UserSecurity.IsAuthorized(user, "View", page.Permissions))
|
||||||
{
|
{
|
||||||
pagestate = new PageState();
|
pagestate = new PageState();
|
||||||
pagestate.ModuleDefinitions = moduledefinitions;
|
pagestate.ModuleDefinitions = moduledefinitions;
|
||||||
|
@ -179,23 +228,15 @@ private async Task Refresh()
|
||||||
pagestate.User = user;
|
pagestate.User = user;
|
||||||
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
|
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
|
||||||
pagestate.QueryString = querystring;
|
pagestate.QueryString = querystring;
|
||||||
pagestate.ModuleId = -1;
|
pagestate.ModuleId = moduleid;
|
||||||
pagestate.Control = "";
|
pagestate.Control = control;
|
||||||
|
|
||||||
if (querystring.ContainsKey("mid"))
|
|
||||||
{
|
|
||||||
pagestate.ModuleId = int.Parse(querystring["mid"]);
|
|
||||||
}
|
|
||||||
if (querystring.ContainsKey("ctl"))
|
|
||||||
{
|
|
||||||
pagestate.Control = querystring["ctl"];
|
|
||||||
}
|
|
||||||
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
||||||
{
|
{
|
||||||
reload = true;
|
reload = Constants.ReloadPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload >= Constants.ReloadPage)
|
||||||
{
|
{
|
||||||
modules = await ModuleService.GetModulesAsync(page.PageId);
|
modules = await ModuleService.GetModulesAsync(page.PageId);
|
||||||
modules = ProcessModules(modules, moduledefinitions, pagestate.Control, page.Panes);
|
modules = ProcessModules(modules, moduledefinitions, pagestate.Control, page.Panes);
|
||||||
|
@ -205,6 +246,9 @@ private async Task Refresh()
|
||||||
modules = PageState.Modules;
|
modules = PageState.Modules;
|
||||||
}
|
}
|
||||||
pagestate.Modules = modules;
|
pagestate.Modules = modules;
|
||||||
|
pagestate.EditMode = editmode;
|
||||||
|
pagestate.DesignMode = designmode;
|
||||||
|
pagestate.Reload = Constants.ReloadReset;
|
||||||
|
|
||||||
OnStateChange?.Invoke(pagestate);
|
OnStateChange?.Invoke(pagestate);
|
||||||
}
|
}
|
||||||
|
@ -245,7 +289,7 @@ private Dictionary<string, string> ParseQueryString(string path)
|
||||||
Dictionary<string, string> querystring = new Dictionary<string, string>();
|
Dictionary<string, string> querystring = new Dictionary<string, string>();
|
||||||
if (path.IndexOf("?") != -1)
|
if (path.IndexOf("?") != -1)
|
||||||
{
|
{
|
||||||
foreach (string kvp in path.Substring(path.IndexOf("?") + 1).Split('&'))
|
foreach (string kvp in path.Substring(path.IndexOf("?") + 1).Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (kvp != "")
|
if (kvp != "")
|
||||||
{
|
{
|
||||||
|
@ -283,7 +327,7 @@ private List<Module> ProcessModules(List<Module> modules, List<ModuleDefinition>
|
||||||
string typename = moduledefinition.ControlTypeTemplate;
|
string typename = moduledefinition.ControlTypeTemplate;
|
||||||
if (moduledefinition.ControlTypeRoutes != "")
|
if (moduledefinition.ControlTypeRoutes != "")
|
||||||
{
|
{
|
||||||
foreach (string route in moduledefinition.ControlTypeRoutes.Split(';'))
|
foreach (string route in moduledefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (route.StartsWith(control + "="))
|
if (route.StartsWith(control + "="))
|
||||||
{
|
{
|
||||||
|
@ -292,6 +336,22 @@ private List<Module> ProcessModules(List<Module> modules, List<ModuleDefinition>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.ModuleType = typename.Replace("{Control}", control);
|
module.ModuleType = typename.Replace("{Control}", control);
|
||||||
|
|
||||||
|
// get IModuleControl properties
|
||||||
|
typename = module.ModuleType;
|
||||||
|
if (control == "Settings")
|
||||||
|
{
|
||||||
|
typename = Constants.DefaultSettingsControl;
|
||||||
|
}
|
||||||
|
Type moduletype = Type.GetType(typename);
|
||||||
|
if (moduletype != null)
|
||||||
|
{
|
||||||
|
var moduleobject = Activator.CreateInstance(moduletype);
|
||||||
|
module.SecurityAccessLevel = (SecurityAccessLevel)moduletype.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||||
|
module.ControlTitle = (string)moduletype.GetProperty("Title").GetValue(moduleobject);
|
||||||
|
module.Actions = (string)moduletype.GetProperty("Actions").GetValue(moduleobject);
|
||||||
|
module.UseAdminContainer = (bool)moduletype.GetProperty("UseAdminContainer").GetValue(moduleobject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Modules
|
||||||
|
@namespace Oqtane.Shared
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
DynamicComponent = builder =>
|
DynamicComponent = builder =>
|
||||||
{
|
{
|
||||||
|
@ -20,6 +22,9 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// theme does not exist with type specified
|
// theme does not exist with type specified
|
||||||
|
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
|
||||||
|
builder.AddAttribute(1, "Message", "Error Loading Page Theme " + PageState.Page.ThemeType);
|
||||||
|
builder.CloseComponent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -1,57 +1,58 @@
|
||||||
using System;
|
using Oqtane.Models;
|
||||||
using Oqtane.Models;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Oqtane.Shared
|
namespace Oqtane.Shared
|
||||||
{
|
{
|
||||||
public class Utilities
|
public class Utilities
|
||||||
{
|
{
|
||||||
public static string NavigateUrl(PageState pagestate)
|
|
||||||
{
|
|
||||||
return NavigateUrl(pagestate, pagestate.Page.Path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string NavigateUrl(PageState pagestate, bool reload)
|
public static string NavigateUrl(string alias, string path, string parameters)
|
||||||
{
|
{
|
||||||
return NavigateUrl(pagestate, pagestate.Page.Path, reload);
|
string url = "";
|
||||||
|
if (alias != "")
|
||||||
|
{
|
||||||
|
url += alias + "/";
|
||||||
}
|
}
|
||||||
|
if (path != "" && path != "/")
|
||||||
public static string NavigateUrl(PageState pagestate, string path)
|
|
||||||
{
|
{
|
||||||
return NavigateUrl(pagestate, path, false);
|
url += path + "/";
|
||||||
}
|
}
|
||||||
|
if (url.EndsWith("/"))
|
||||||
public static string NavigateUrl(PageState pagestate, string path, bool reload)
|
|
||||||
{
|
{
|
||||||
string url = pagestate.Alias.Path + "/" + path;
|
url = url.Substring(0, url.Length - 1);
|
||||||
if (reload)
|
|
||||||
{
|
|
||||||
if (url.Contains("?"))
|
|
||||||
{
|
|
||||||
url += "&reload=true";
|
|
||||||
}
|
}
|
||||||
else
|
if (!string.IsNullOrEmpty(parameters))
|
||||||
{
|
{
|
||||||
url += "?reload=true";
|
url += "?" + parameters;
|
||||||
}
|
}
|
||||||
|
if (!url.StartsWith("/"))
|
||||||
|
{
|
||||||
|
url = "/" + url;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EditUrl(PageState pagestate, Module modulestate, string action)
|
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
||||||
{
|
{
|
||||||
return EditUrl(pagestate, modulestate, action, "");
|
string url = NavigateUrl(alias, path, "");
|
||||||
|
if (url == "/") url = "";
|
||||||
|
if (moduleid != -1)
|
||||||
|
{
|
||||||
|
url += "/" + moduleid.ToString();
|
||||||
}
|
}
|
||||||
|
if (moduleid != -1 && action != "")
|
||||||
public static string EditUrl(PageState pagestate, Module modulestate, string action, string parameters)
|
|
||||||
{
|
{
|
||||||
string url = pagestate.Alias.Path + "/" + pagestate.Page.Path + "?mid=" + modulestate.ModuleId.ToString();
|
url += "/" + action;
|
||||||
if (action != "")
|
|
||||||
{
|
|
||||||
url += "&ctl=" + action;
|
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(parameters))
|
if (!string.IsNullOrEmpty(parameters))
|
||||||
{
|
{
|
||||||
url += "&" + parameters;
|
url += "?" + parameters;
|
||||||
|
}
|
||||||
|
if (!url.StartsWith("/"))
|
||||||
|
{
|
||||||
|
url = "/" + url;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ namespace Oqtane.Client
|
||||||
services.AddScoped<IModuleService, ModuleService>();
|
services.AddScoped<IModuleService, ModuleService>();
|
||||||
services.AddScoped<IPageModuleService, PageModuleService>();
|
services.AddScoped<IPageModuleService, PageModuleService>();
|
||||||
services.AddScoped<IUserService, UserService>();
|
services.AddScoped<IUserService, UserService>();
|
||||||
|
services.AddScoped<IProfileService, ProfileService>();
|
||||||
|
services.AddScoped<IRoleService, RoleService>();
|
||||||
|
services.AddScoped<IUserRoleService, UserRoleService>();
|
||||||
|
services.AddScoped<ISettingService, SettingService>();
|
||||||
|
services.AddScoped<IFileService, FileService>();
|
||||||
|
|
||||||
// dynamically register module contexts and repository services
|
// dynamically register module contexts and repository services
|
||||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
@ -57,7 +61,7 @@ namespace Oqtane.Client
|
||||||
.ToArray();
|
.ToArray();
|
||||||
foreach (Type implementationtype in implementationtypes)
|
foreach (Type implementationtype in implementationtypes)
|
||||||
{
|
{
|
||||||
Type servicetype = Type.GetType(implementationtype.FullName.Replace(implementationtype.Name, "I" + implementationtype.Name));
|
Type servicetype = Type.GetType(implementationtype.AssemblyQualifiedName.Replace(implementationtype.Name, "I" + implementationtype.Name));
|
||||||
if (servicetype != null)
|
if (servicetype != null)
|
||||||
{
|
{
|
||||||
services.AddScoped(servicetype, implementationtype); // traditional service interface
|
services.AddScoped(servicetype, implementationtype); // traditional service interface
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes.Controls
|
||||||
@using Oqtane.Client.Themes.Controls
|
@namespace Oqtane.Themes
|
||||||
@using Oqtane.Client.Shared
|
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
<div id="modal" class="modal" style="display: block">
|
<div id="modal" class="modal" style="display: block">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -23,7 +22,7 @@
|
||||||
@code {
|
@code {
|
||||||
string closeurl;
|
string closeurl;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
closeurl = NavigateUrl();
|
closeurl = NavigateUrl();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,32 +16,37 @@ namespace Oqtane.Themes
|
||||||
|
|
||||||
public string NavigateUrl()
|
public string NavigateUrl()
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState);
|
return NavigateUrl(PageState.Page.Path);
|
||||||
}
|
|
||||||
|
|
||||||
public string NavigateUrl(bool reload)
|
|
||||||
{
|
|
||||||
return Utilities.NavigateUrl(PageState, reload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string path)
|
public string NavigateUrl(string path)
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState, path);
|
return NavigateUrl(path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NavigateUrl(string path, bool reload)
|
public string NavigateUrl(string path, string parameters)
|
||||||
{
|
{
|
||||||
return Utilities.NavigateUrl(PageState, path, reload);
|
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string EditUrl(string action)
|
|
||||||
{
|
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string EditUrl(string action, string parameters)
|
public string EditUrl(string action, string parameters)
|
||||||
{
|
{
|
||||||
return Utilities.EditUrl(PageState, ModuleState, action, parameters);
|
return EditUrl(ModuleState.ModuleId, action, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,6 +3,8 @@
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeObjectBase
|
@inherits ThemeObjectBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -11,6 +13,8 @@
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject IPageModuleService PageModuleService
|
@inject IPageModuleService PageModuleService
|
||||||
|
|
||||||
|
@if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||||
|
{
|
||||||
<div id="actions" class="overlay">
|
<div id="actions" class="overlay">
|
||||||
<a href="javascript:void(0)" class="closebtn" onclick="closeActions()">x</a>
|
<a href="javascript:void(0)" class="closebtn" onclick="closeActions()">x</a>
|
||||||
<div class="overlay-content">
|
<div class="overlay-content">
|
||||||
|
@ -44,7 +48,7 @@
|
||||||
<label for="Pane" class="control-label" style="color: white !important;">Pane: </label>
|
<label for="Pane" class="control-label" style="color: white !important;">Pane: </label>
|
||||||
<select class="form-control" @bind="@pane">
|
<select class="form-control" @bind="@pane">
|
||||||
<option value=""><Select Pane></option>
|
<option value=""><Select Pane></option>
|
||||||
@foreach (string pane in PageState.Page.Panes.Split(';'))
|
@foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
<option value="@pane">@pane Pane</option>
|
<option value="@pane">@pane Pane</option>
|
||||||
}
|
}
|
||||||
|
@ -68,10 +72,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="oi oi-menu" style="@display" onclick="openActions()"></span>
|
|
||||||
|
@if (PageState.EditMode)
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-outline-primary active" data-toggle="button" aria-pressed="true" autocomplete="off" @onclick="EditMode">
|
||||||
|
<span class="oi oi-pencil"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-outline-primary" data-toggle="button" aria-pressed="false" autocomplete="off" @onclick="EditMode">
|
||||||
|
<span class="oi oi-pencil"></span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
<span class="oi oi-menu" onclick="openActions()"></span>
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
string display = "display: none";
|
|
||||||
List<ModuleDefinition> moduledefinitions;
|
List<ModuleDefinition> moduledefinitions;
|
||||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||||
int pagemanagementmoduleid = -1;
|
int pagemanagementmoduleid = -1;
|
||||||
|
@ -80,7 +98,9 @@
|
||||||
string title = "";
|
string title = "";
|
||||||
string containertype;
|
string containertype;
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||||
{
|
{
|
||||||
moduledefinitions = PageState.ModuleDefinitions;
|
moduledefinitions = PageState.ModuleDefinitions;
|
||||||
containers = ThemeService.GetContainerTypes(PageState.Themes);
|
containers = ThemeService.GetContainerTypes(PageState.Themes);
|
||||||
|
@ -89,19 +109,17 @@
|
||||||
{
|
{
|
||||||
pagemanagementmoduleid = modules.FirstOrDefault().ModuleId;
|
pagemanagementmoduleid = modules.FirstOrDefault().ModuleId;
|
||||||
}
|
}
|
||||||
if (UserService.IsAuthorized(PageState.User, PageState.Page.EditPermissions))
|
|
||||||
{
|
|
||||||
display = "display: inline";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddModule()
|
private async Task AddModule()
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||||
{
|
{
|
||||||
Module module = new Module();
|
Module module = new Module();
|
||||||
module.SiteId = PageState.Site.SiteId;
|
module.SiteId = PageState.Site.SiteId;
|
||||||
module.ModuleDefinitionName = moduledefinitionname;
|
module.ModuleDefinitionName = moduledefinitionname;
|
||||||
module.ViewPermissions = PageState.Page.ViewPermissions;
|
module.Permissions = PageState.Page.Permissions;
|
||||||
module.EditPermissions = PageState.Page.EditPermissions;
|
|
||||||
await ModuleService.AddModuleAsync(module);
|
await ModuleService.AddModuleAsync(module);
|
||||||
|
|
||||||
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, moduledefinitionname);
|
List<Module> modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId, moduledefinitionname);
|
||||||
|
@ -116,10 +134,14 @@
|
||||||
}
|
}
|
||||||
pagemodule.Title = title;
|
pagemodule.Title = title;
|
||||||
pagemodule.Pane = pane;
|
pagemodule.Pane = pane;
|
||||||
pagemodule.Order = 0;
|
pagemodule.Order = int.MaxValue;
|
||||||
pagemodule.ContainerType = containertype;
|
pagemodule.ContainerType = containertype;
|
||||||
await PageModuleService.AddPageModuleAsync(pagemodule);
|
await PageModuleService.AddPageModuleAsync(pagemodule);
|
||||||
UriHelper.NavigateTo(NavigateUrl(true));
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
|
||||||
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PageUrl(string action)
|
private string PageUrl(string action)
|
||||||
|
@ -130,16 +152,35 @@
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "Add":
|
case "Add":
|
||||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action;
|
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "");
|
||||||
break;
|
break;
|
||||||
case "Edit":
|
case "Edit":
|
||||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action + "&id=" + PageState.Page.PageId.ToString();
|
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "id=" + PageState.Page.PageId.ToString());
|
||||||
break;
|
break;
|
||||||
case "Delete":
|
case "Delete":
|
||||||
url = "admin/pages?mid=" + pagemanagementmoduleid.ToString() + "&ctl=" + action + "&id=" + PageState.Page.PageId.ToString();
|
url = EditUrl("admin/pages", pagemanagementmoduleid, action, "id=" + PageState.Page.PageId.ToString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditMode()
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||||
|
{
|
||||||
|
if (PageState.EditMode)
|
||||||
|
{
|
||||||
|
PageState.EditMode = false;
|
||||||
|
PageState.DesignMode = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PageState.EditMode = true;
|
||||||
|
PageState.DesignMode = true;
|
||||||
|
}
|
||||||
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + PageState.EditMode.ToString().ToLower()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Providers
|
@using Oqtane.Providers
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Models
|
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeObjectBase
|
@inherits ThemeObjectBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -26,7 +26,12 @@
|
||||||
@code {
|
@code {
|
||||||
private void LoginUser()
|
private void LoginUser()
|
||||||
{
|
{
|
||||||
UriHelper.NavigateTo(NavigateUrl("login?returnurl=" + PageState.Page.Path));
|
string returnurl = PageState.Alias.Path;
|
||||||
|
if (PageState.Page.Path != "/")
|
||||||
|
{
|
||||||
|
returnurl += "/" + PageState.Page.Path;
|
||||||
|
}
|
||||||
|
UriHelper.NavigateTo("login?returnurl=" + returnurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LogoutUser()
|
private async Task LogoutUser()
|
||||||
|
@ -38,13 +43,16 @@
|
||||||
{
|
{
|
||||||
// server-side Blazor
|
// server-side Blazor
|
||||||
var interop = new Interop(jsRuntime);
|
var interop = new Interop(jsRuntime);
|
||||||
await interop.SubmitForm("/logout/", "");
|
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||||
|
var fields = new { __RequestVerificationToken = antiforgerytoken, returnurl = (PageState.Alias.Path + "/" + PageState.Page.Path) };
|
||||||
|
await interop.SubmitForm("/logout/", fields);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// client-side Blazor
|
// client-side Blazor
|
||||||
authstateprovider.NotifyAuthenticationChanged();
|
authstateprovider.NotifyAuthenticationChanged();
|
||||||
UriHelper.NavigateTo(NavigateUrl("login", true));
|
PageState.Reload = Constants.ReloadSite;
|
||||||
|
UriHelper.NavigateTo(NavigateUrl(PageState.Page.Path, "logout"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeObjectBase
|
@inherits ThemeObjectBase
|
||||||
|
|
||||||
@((MarkupString)logo)
|
@((MarkupString)logo)
|
||||||
|
@ -6,11 +7,12 @@
|
||||||
@code {
|
@code {
|
||||||
string logo = "";
|
string logo = "";
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
if (PageState.Site.Logo != "")
|
if (PageState.Site.Logo != "")
|
||||||
{
|
{
|
||||||
logo = "<a href=\"" + PageState.Alias.Url + "\"><img src=\"/Sites/" + PageState.Site.SiteId.ToString() + "/" + PageState.Site.Logo + "\" alt=\"" + PageState.Site.Name + "\"/></a>";
|
logo = "<a href=\"" + PageState.Alias.Url + "\"><img src=\"" + PageState.Alias.SiteRootUrl + PageState.Site.Logo + "\" alt=\"" + PageState.Site.Name + "\"/></a>";
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models;
|
@using Oqtane.Models;
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeObjectBase
|
@inherits ThemeObjectBase
|
||||||
@inject IPageService PageService
|
@inject IPageService PageService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
@ -18,11 +20,11 @@
|
||||||
}
|
}
|
||||||
@foreach (var p in pages)
|
@foreach (var p in pages)
|
||||||
{
|
{
|
||||||
if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions))
|
if (p.IsNavigation && UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions))
|
||||||
{
|
{
|
||||||
string url = NavigateUrl(p.Path);
|
string url = NavigateUrl(p.Path);
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
|
<NavLink @key="@p.PageId" class="nav-link" href="@url" Match="NavLinkMatch.All">
|
||||||
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
|
@ -34,13 +36,13 @@
|
||||||
List<Page> pages;
|
List<Page> pages;
|
||||||
Page parent = null;
|
Page parent = null;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
// if current page has no children
|
// if current page has no children
|
||||||
if (PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).FirstOrDefault() == null)
|
if (PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).FirstOrDefault() == null)
|
||||||
{
|
{
|
||||||
// display list of pages which have same parent as current page
|
// display list of pages which have same parent as current page
|
||||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).ToList();
|
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).OrderBy(item => item.Order).ToList();
|
||||||
// if current page has parent
|
// if current page has parent
|
||||||
if (PageState.Page.ParentId != null)
|
if (PageState.Page.ParentId != null)
|
||||||
{
|
{
|
||||||
|
@ -50,9 +52,10 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// display list of pages which are children of current page
|
// display list of pages which are children of current page
|
||||||
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList();
|
pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).OrderBy(item => item.Order).ToList();
|
||||||
// current page is parent
|
// current page is parent
|
||||||
parent = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).FirstOrDefault();
|
parent = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
68
Oqtane.Client/Themes/Controls/Menu2.razor
Normal file
68
Oqtane.Client/Themes/Controls/Menu2.razor
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Oqtane.Themes
|
||||||
|
@using Oqtane.Services
|
||||||
|
@using Oqtane.Models;
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
|
@inherits ThemeObjectBase
|
||||||
|
@inject IUserService UserService
|
||||||
|
|
||||||
|
@if (menu != "")
|
||||||
|
{
|
||||||
|
@((MarkupString)menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
string menu = "";
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
int level = -1;
|
||||||
|
int securitylevel = int.MaxValue;
|
||||||
|
|
||||||
|
menu = "<ul class=\"nav flex-column\">\n";
|
||||||
|
foreach (Page p in PageState.Pages.Where(item => item.IsNavigation))
|
||||||
|
{
|
||||||
|
for (int l = p.Level; l < level; l++)
|
||||||
|
{
|
||||||
|
menu += "</ul>\n";
|
||||||
|
menu += "</div>\n";
|
||||||
|
}
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, "View", p.Permissions) && p.Level <= securitylevel)
|
||||||
|
{
|
||||||
|
securitylevel = int.MaxValue;
|
||||||
|
if (p.HasChildren)
|
||||||
|
{
|
||||||
|
menu += "<li class=\"nav-item px-3\">\n";
|
||||||
|
menu += "<a class=\"nav-link collapsed\" href=\"#submenu" + p.PageId.ToString() + "\" data-toggle=\"collapse\" data-target=\"#submenu" + p.PageId.ToString() + "\">";
|
||||||
|
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>" + p.Name;
|
||||||
|
menu += "</a>\n";
|
||||||
|
menu += "<div class=\"collapse\" id=\"submenu" + p.PageId.ToString() + "\" aria-expanded=\"false\">\n";
|
||||||
|
menu += "<ul class=\"nav flex-column\">\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu += "<li class=\"nav-item px-3\">\n";
|
||||||
|
menu += "<a class=\"nav-link\" href=\"" + NavigateUrl(p.Path) + "\">";
|
||||||
|
menu += "<span class=\"oi " + p.Icon + "\" aria-hidden=\"true\"></span>" + p.Name;
|
||||||
|
menu += "</a>\n";
|
||||||
|
menu += "</li>\n";
|
||||||
|
}
|
||||||
|
level = p.Level;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (securitylevel == int.MaxValue)
|
||||||
|
{
|
||||||
|
securitylevel = p.Level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int l = 0; l < level; l++)
|
||||||
|
{
|
||||||
|
menu += "</ul>\n";
|
||||||
|
menu += "</div>\n";
|
||||||
|
}
|
||||||
|
menu += "</ul>";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,18 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Services
|
@using Oqtane.Services
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
|
@using Oqtane.Shared
|
||||||
|
@using Oqtane.Security
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
@inject IPageModuleService PageModuleService
|
@inject IPageModuleService PageModuleService
|
||||||
|
|
||||||
<div class="dropdown" style="@display">
|
@if (PageState.DesignMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||||
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
{
|
||||||
|
<div class="dropdown">
|
||||||
|
<button type="button" class="btn dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||||
@foreach (var action in actions)
|
@foreach (var action in actions)
|
||||||
{
|
{
|
||||||
|
@ -15,23 +20,33 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
string display = "display: none";
|
|
||||||
List<ActionViewModel> actions;
|
List<ActionViewModel> actions;
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||||
{
|
{
|
||||||
actions = new List<ActionViewModel>();
|
actions = new List<ActionViewModel>();
|
||||||
if (ModuleState.PaneModuleIndex > 0)
|
if (ModuleState.PaneModuleIndex > 0)
|
||||||
{
|
{
|
||||||
actions.Add(new ActionViewModel { Action = "up", Name = "Move Up" });
|
actions.Add(new ActionViewModel { Action = "<<", Name = "Move To Top" });
|
||||||
|
}
|
||||||
|
if (ModuleState.PaneModuleIndex > 0)
|
||||||
|
{
|
||||||
|
actions.Add(new ActionViewModel { Action = "<", Name = "Move Up" });
|
||||||
}
|
}
|
||||||
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
||||||
{
|
{
|
||||||
actions.Add(new ActionViewModel { Action = "down", Name = "Move Down" });
|
actions.Add(new ActionViewModel { Action = ">", Name = "Move Down" });
|
||||||
}
|
}
|
||||||
foreach (string pane in PageState.Page.Panes.Split(';'))
|
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
||||||
|
{
|
||||||
|
actions.Add(new ActionViewModel { Action = ">>", Name = "Move To Bottom" });
|
||||||
|
}
|
||||||
|
foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (pane != ModuleState.Pane)
|
if (pane != ModuleState.Pane)
|
||||||
{
|
{
|
||||||
|
@ -40,48 +55,57 @@
|
||||||
}
|
}
|
||||||
actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" });
|
actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" });
|
||||||
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" });
|
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" });
|
||||||
|
|
||||||
if (UserService.IsAuthorized(PageState.User, ModuleState.EditPermissions))
|
|
||||||
{
|
|
||||||
display = "display: inline";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task ModuleAction(string action)
|
protected async Task ModuleAction(string action)
|
||||||
{
|
{
|
||||||
PageModule pagemodule = new PageModule();
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||||
pagemodule.PageModuleId = ModuleState.PageModuleId;
|
{
|
||||||
pagemodule.PageId = ModuleState.PageId;
|
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||||
pagemodule.ModuleId = ModuleState.ModuleId;
|
|
||||||
pagemodule.Title = ModuleState.Title;
|
|
||||||
pagemodule.Pane = ModuleState.Pane;
|
|
||||||
pagemodule.Order = ModuleState.Order;
|
|
||||||
pagemodule.ContainerType = ModuleState.ContainerType;
|
|
||||||
|
|
||||||
string path = PageState.Page.Path + "?reload=true";
|
string url = NavigateUrl();
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "up":
|
case "<<":
|
||||||
pagemodule.Order += -1;
|
pagemodule.Order = 0;
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
break;
|
break;
|
||||||
case "down":
|
case "<":
|
||||||
pagemodule.Order += 1;
|
pagemodule.Order -= 3;
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
break;
|
||||||
|
case ">":
|
||||||
|
pagemodule.Order += 3;
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
break;
|
||||||
|
case ">>":
|
||||||
|
pagemodule.Order = int.MaxValue;
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
break;
|
break;
|
||||||
case "settings":
|
case "settings":
|
||||||
if (path == "") { path += "/"; }
|
url = EditUrl(pagemodule.ModuleId, "Settings");
|
||||||
path = PageState.Page.Path + "?mid=" + pagemodule.ModuleId.ToString() + "&ctl=Settings";
|
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
break;
|
break;
|
||||||
default: // move to pane
|
default: // move to pane
|
||||||
|
string pane = pagemodule.Pane;
|
||||||
pagemodule.Pane = action;
|
pagemodule.Pane = action;
|
||||||
|
pagemodule.Order = int.MaxValue; // add to bottom of pane
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pane);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UriHelper.NavigateTo(NavigateUrl(path));
|
PageState.Reload = Constants.ReloadPage;
|
||||||
|
UriHelper.NavigateTo(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionViewModel
|
public class ActionViewModel
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
|
|
||||||
@title
|
@title
|
||||||
|
@ -6,12 +7,13 @@
|
||||||
@code {
|
@code {
|
||||||
string title = "";
|
string title = "";
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
title = ModuleState.Title;
|
title = ModuleState.Title;
|
||||||
if (PageState.Control == "Settings")
|
if (PageState.Control == "Settings")
|
||||||
{
|
{
|
||||||
title = PageState.Control;
|
title = PageState.Control;
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeObjectBase
|
@inherits ThemeObjectBase
|
||||||
@inject IUriHelper UriHelper
|
@inject IUriHelper UriHelper
|
||||||
|
|
||||||
|
@ -7,7 +8,7 @@
|
||||||
<text>...</text>
|
<text>...</text>
|
||||||
</Authorizing>
|
</Authorizing>
|
||||||
<Authorized>
|
<Authorized>
|
||||||
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">@context.User.Identity.Name</button>
|
<button type="button" class="btn btn-primary" @onclick="@UpdateProfile">@context.User.Identity.Name</button>
|
||||||
</Authorized>
|
</Authorized>
|
||||||
<NotAuthorized>
|
<NotAuthorized>
|
||||||
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
|
||||||
|
@ -21,6 +22,11 @@
|
||||||
{
|
{
|
||||||
UriHelper.NavigateTo(NavigateUrl("register"));
|
UriHelper.NavigateTo(NavigateUrl("register"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateProfile()
|
||||||
|
{
|
||||||
|
UriHelper.NavigateTo(NavigateUrl("profile"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes.Controls
|
||||||
@using Oqtane.Client.Themes.Controls
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Client.Shared
|
@namespace Oqtane.Themes
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row px-4">
|
<div class="row px-4">
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Oqtane.Themes
|
namespace Oqtane.Themes
|
||||||
{
|
{
|
||||||
public interface ITheme
|
public interface ITheme
|
||||||
{
|
{
|
||||||
string Name { get; }
|
Dictionary<string, string> Properties { get; }
|
||||||
string Version { get; }
|
|
||||||
string Owner { get; }
|
|
||||||
string Url { get; }
|
|
||||||
string Contact { get; }
|
|
||||||
string License { get; }
|
|
||||||
string Dependencies { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Client.Themes.Controls
|
@using Oqtane.Themes.Controls
|
||||||
@using Oqtane.Client.Shared
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Themes.Theme1
|
||||||
@inherits ContainerBase
|
@inherits ContainerBase
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row px-4">
|
<div class="row px-4">
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
namespace Oqtane.Themes.Theme1
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Oqtane.Themes.Theme1
|
||||||
{
|
{
|
||||||
public class Theme : ITheme
|
public class Theme : ITheme
|
||||||
{
|
{
|
||||||
public string Name { get { return "Theme1"; } }
|
public Dictionary<string, string> Properties
|
||||||
public string Version { get { return "1.0.0"; } }
|
{
|
||||||
public string Owner { get { return ""; } }
|
get
|
||||||
public string Url { get { return ""; } }
|
{
|
||||||
public string Contact { get { return ""; } }
|
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||||
public string License { get { return ""; } }
|
{
|
||||||
public string Dependencies { get { return ""; } }
|
{ "Name", "Theme1" },
|
||||||
|
{ "Version", "1.0.0" }
|
||||||
|
};
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@using Oqtane.Themes
|
@using Oqtane.Themes
|
||||||
@using Oqtane.Client.Themes.Controls
|
@using Oqtane.Themes.Controls
|
||||||
@using Oqtane.Client.Shared
|
@using Oqtane.Shared
|
||||||
|
@namespace Oqtane.Themes.Theme1
|
||||||
@inherits ThemeBase
|
@inherits ThemeBase
|
||||||
|
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user