Support for third party modules, improved error handling, standardardized enum naming, reorganized interface definitions, support for DB script upgrades, added Settings entity
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
@if (!Installed)
|
||||
{
|
||||
<Installer />
|
||||
<Installer Installed="@Installed" />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -42,50 +42,51 @@
|
||||
</AuthorizeView>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||
|
||||
public string Message { get; set; } = "";
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
public bool Remember { get; set; } = false;
|
||||
public string Message { get; set; } = "";
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
public bool Remember { get; set; } = false;
|
||||
|
||||
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)
|
||||
private async Task Login()
|
||||
{
|
||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||
|
||||
var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
|
||||
if (authstateprovider == null)
|
||||
User user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = Username;
|
||||
user.Password = Password;
|
||||
user.IsPersistent = Remember;
|
||||
user = await UserService.LoginUserAsync(user);
|
||||
if (user.IsAuthenticated)
|
||||
{
|
||||
// server-side Blazor
|
||||
var interop = new Interop(jsRuntime);
|
||||
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||
var fields = new { __RequestVerificationToken = antiforgerytoken, username = Username, password = Password, remember = Remember, returnurl = ReturnUrl };
|
||||
await interop.SubmitForm("/login/", fields);
|
||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||
|
||||
var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
|
||||
if (authstateprovider == null)
|
||||
{
|
||||
// server-side Blazor
|
||||
var interop = new Interop(jsRuntime);
|
||||
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||
var fields = new { __RequestVerificationToken = antiforgerytoken, username = Username, password = Password, remember = Remember, returnurl = ReturnUrl };
|
||||
await interop.SubmitForm("/login/", fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
// client-side Blazor
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// client-side Blazor
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl(ReturnUrl));
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Login Failed. Please Remember That Passwords Are Case Sensitive.</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Login Failed. Please Remember That Passwords Are Case Sensitive.</div>";
|
||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||
UriHelper.NavigateTo(ReturnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
string ReturnUrl = PageState.QueryString["returnurl"];
|
||||
UriHelper.NavigateTo(ReturnUrl);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<ModuleDefinition> moduledefinitions;
|
||||
|
||||
|
@ -63,11 +63,15 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@DynamicComponent
|
||||
|
||||
<button type="button" class="btn btn-success" @onclick="@SaveModule">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
|
||||
@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"; } }
|
||||
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
@ -77,6 +81,9 @@
|
||||
string editpermissions;
|
||||
string pageid;
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
object settings;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
title = ModuleState.Title;
|
||||
@ -85,6 +92,17 @@
|
||||
viewpermissions = ModuleState.ViewPermissions;
|
||||
editpermissions = ModuleState.EditPermissions;
|
||||
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()
|
||||
@ -94,17 +112,19 @@
|
||||
module.EditPermissions = editpermissions;
|
||||
await ModuleService.UpdateModuleAsync(module);
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
pagemodule.PageModuleId = ModuleState.PageModuleId;
|
||||
pagemodule.PageId = Int32.Parse(pageid);
|
||||
pagemodule.ModuleId = ModuleState.ModuleId;
|
||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||
pagemodule.Title = title;
|
||||
pagemodule.Pane = ModuleState.Pane;
|
||||
pagemodule.Order = ModuleState.Order;
|
||||
pagemodule.ContainerType = containertype;
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,7 +115,7 @@
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
@ -115,7 +115,7 @@
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
@ -116,7 +116,7 @@
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
||||
|
@ -36,5 +36,5 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Admin; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||
|
||||
public string Username { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
@ -28,6 +28,7 @@
|
||||
private async Task RegisterUser()
|
||||
{
|
||||
User user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = Username;
|
||||
user.DisplayName = Username;
|
||||
user.Roles = "Administrators;";
|
||||
|
@ -60,7 +60,7 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Tenant> tenants;
|
||||
string tenantid;
|
||||
|
@ -31,7 +31,7 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Site> sites;
|
||||
|
||||
|
@ -29,7 +29,7 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Theme> Themes;
|
||||
|
||||
|
@ -30,7 +30,7 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Host; } }
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<User> Users;
|
||||
|
||||
|
@ -54,23 +54,26 @@
|
||||
if (moduleType != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
case SecurityAccessLevelEnum.Anonymous:
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevelEnum.View:
|
||||
case SecurityAccessLevel.View:
|
||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.ViewPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Edit:
|
||||
case SecurityAccessLevel.Edit:
|
||||
authorized = UserService.IsAuthorized(PageState.User, ModuleState.EditPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Admin:
|
||||
case SecurityAccessLevel.Admin:
|
||||
authorized = UserService.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Host:
|
||||
authorized = PageState.User.IsSuperUser;
|
||||
case SecurityAccessLevel.Host:
|
||||
if (PageState.User != null)
|
||||
{
|
||||
authorized = PageState.User.IsSuperUser;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
44
Oqtane.Client/Modules/Controls/ModuleMessage.razor
Normal file
44
Oqtane.Client/Modules/Controls/ModuleMessage.razor
Normal file
@ -0,0 +1,44 @@
|
||||
@using Oqtane.Modules
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (authorized)
|
||||
{
|
||||
<div class="@type">
|
||||
@Message
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
private MessageType Type { get; set; }
|
||||
|
||||
[Parameter]
|
||||
private string Message { get; set; }
|
||||
|
||||
string type = "alert alert-success"; // optional
|
||||
bool authorized = false;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
if (PageState.User != null)
|
||||
{
|
||||
authorized = PageState.User.IsSuperUser;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
</form>
|
||||
|
||||
@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"; } }
|
||||
|
||||
HtmlTextInfo htmltext;
|
||||
|
@ -16,7 +16,7 @@
|
||||
@code {
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper);
|
||||
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
|
@ -3,7 +3,7 @@
|
||||
public interface IModuleControl
|
||||
{
|
||||
string Title { get; }
|
||||
SecurityAccessLevelEnum SecurityAccessLevel { get; }
|
||||
SecurityAccessLevel SecurityAccessLevel { get; }
|
||||
string Actions { get; } // can be specified as a comma delimited set of values
|
||||
}
|
||||
}
|
||||
|
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
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace Oqtane.Modules
|
||||
|
||||
public virtual string Title { get { return ""; } }
|
||||
|
||||
public virtual SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.View; } set { } } // default security
|
||||
public virtual SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } set { } } // default security
|
||||
|
||||
public virtual string Actions { get { return ""; } }
|
||||
|
||||
@ -25,7 +25,12 @@ namespace Oqtane.Modules
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
return NavigateUrl(path, "");
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, string parameters)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(string action)
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public enum SecurityAccessLevelEnum
|
||||
public enum SecurityAccessLevel
|
||||
{
|
||||
Anonymous,
|
||||
View,
|
||||
|
@ -21,7 +21,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:14246/"
|
||||
"applicationUrl": "http://localhost:44358/"
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ namespace Oqtane.Services
|
||||
public interface IPageModuleService
|
||||
{
|
||||
Task<List<PageModule>> GetPageModulesAsync();
|
||||
Task<PageModule> GetPageModuleAsync(int PageModuleId);
|
||||
Task<PageModule> AddPageModuleAsync(PageModule PageModule);
|
||||
Task<PageModule> UpdatePageModuleAsync(PageModule PageModule);
|
||||
Task DeletePageModuleAsync(int PageModuleId);
|
27
Oqtane.Client/Services/Interfaces/ISettingService.cs
Normal file
27
Oqtane.Client/Services/Interfaces/ISettingService.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface ISettingService
|
||||
{
|
||||
Task<List<Setting>> GetModuleSettingsAsync(int ModuleId);
|
||||
|
||||
Task<Setting> UpdateModuleSettingsAsync(List<Setting> ModuleSettings, int ModuleId, string SettingName, string SettingValue);
|
||||
|
||||
|
||||
Task<List<Setting>> GetSettingsAsync(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(List<Setting> Settings, string SettingName, string DefaultValue);
|
||||
}
|
||||
}
|
@ -31,6 +31,11 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<List<PageModule>>(apiurl);
|
||||
}
|
||||
|
||||
public async Task<PageModule> GetPageModuleAsync(int PageModuleId)
|
||||
{
|
||||
return await http.GetJsonAsync<PageModule>(apiurl + "/" + PageModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<PageModule> AddPageModuleAsync(PageModule PageModule)
|
||||
{
|
||||
return await http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||
|
92
Oqtane.Client/Services/SettingService.cs
Normal file
92
Oqtane.Client/Services/SettingService.cs
Normal file
@ -0,0 +1,92 @@
|
||||
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;
|
||||
using System;
|
||||
|
||||
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<List<Setting>> GetModuleSettingsAsync(int ModuleId)
|
||||
{
|
||||
return await GetSettingsAsync("Module", ModuleId);
|
||||
}
|
||||
|
||||
public async Task<Setting> UpdateModuleSettingsAsync(List<Setting> ModuleSettings, int ModuleId, string SettingName, string SettingValue)
|
||||
{
|
||||
Setting setting = ModuleSettings.Where(item => item.SettingName == SettingName).FirstOrDefault();
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new Setting();
|
||||
setting.EntityName = "Module";
|
||||
setting.EntityId = ModuleId;
|
||||
setting.SettingName = SettingName;
|
||||
setting.SettingValue = SettingValue;
|
||||
setting = await AddSettingAsync(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.SettingValue = SettingValue;
|
||||
setting = await UpdateSettingAsync(setting);
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
public async Task<List<Setting>> GetSettingsAsync(string EntityName, int EntityId)
|
||||
{
|
||||
List<Setting> Settings = await http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
return Settings.OrderBy(item => item.SettingName).ToList();
|
||||
}
|
||||
|
||||
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(List<Setting> Settings, string SettingName, string DefaultValue)
|
||||
{
|
||||
string value = DefaultValue;
|
||||
Setting setting = Settings.Where(item => item.SettingName == SettingName).FirstOrDefault();
|
||||
if (setting != null)
|
||||
{
|
||||
value = setting.SettingValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
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 ModuleMessageControl = "Oqtane.Client.Modules.Controls.ModuleMessage, Oqtane.Client";
|
||||
public const string DefaultControl = "Index";
|
||||
|
||||
public const string AdminPane = "Admin";
|
||||
|
@ -1,5 +1,6 @@
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Modules
|
||||
|
||||
<CascadingValue Value="@ModuleState">
|
||||
@DynamicComponent
|
||||
@ -26,12 +27,16 @@
|
||||
Type containerType = Type.GetType(container);
|
||||
if (containerType != null)
|
||||
{
|
||||
builder.OpenComponent(ModuleState.ModuleId, containerType); // set sequence to moduleid so that component tree is able to differentiate
|
||||
builder.OpenComponent(0, containerType);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
else
|
||||
{
|
||||
// container does not exist with type specified
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
|
||||
builder.AddAttribute(1, "Type", MessageType.Error);
|
||||
builder.AddAttribute(2, "Message", "Error Loading Module Container " + container);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -113,85 +113,80 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
private bool Installed { get; set; }
|
||||
|
||||
private string DatabaseType = "LocalDB";
|
||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||
private string Username = "";
|
||||
private string Password = "";
|
||||
private string HostUsername = "host";
|
||||
private string HostPassword = "";
|
||||
private string Message = "";
|
||||
private string DatabaseType = "LocalDB";
|
||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||
private string Username = "";
|
||||
private string Password = "";
|
||||
private string HostUsername = "host";
|
||||
private string HostPassword = "";
|
||||
private string Message = "";
|
||||
|
||||
private string IntegratedSecurityDisplay = "display:none;";
|
||||
private string LoadingDisplay = "display:none;";
|
||||
private string IntegratedSecurityDisplay = "display:none;";
|
||||
private string LoadingDisplay = "display:none;";
|
||||
|
||||
private bool Installed = true;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
var response = await InstallationService.IsInstalled();
|
||||
Installed = response.Success;
|
||||
}
|
||||
|
||||
private void SetIntegratedSecurity(UIChangeEventArgs e)
|
||||
{
|
||||
if (Convert.ToBoolean(e.Value))
|
||||
private void SetIntegratedSecurity(UIChangeEventArgs e)
|
||||
{
|
||||
IntegratedSecurityDisplay = "display:none;";
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegratedSecurityDisplay = "";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Install()
|
||||
{
|
||||
if (HostPassword.Length >= 6)
|
||||
{
|
||||
LoadingDisplay = "";
|
||||
StateHasChanged();
|
||||
|
||||
string connectionstring = "";
|
||||
if (DatabaseType == "LocalDB")
|
||||
if (Convert.ToBoolean(e.Value))
|
||||
{
|
||||
connectionstring = "Data Source=" + ServerName + ";AttachDbFilename=|DataDirectory|\\" + DatabaseName + ".mdf;Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI;";
|
||||
IntegratedSecurityDisplay = "display:none;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
|
||||
if (IntegratedSecurityDisplay == "display:none;")
|
||||
IntegratedSecurityDisplay = "";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Install()
|
||||
{
|
||||
if (HostPassword.Length >= 6)
|
||||
{
|
||||
LoadingDisplay = "";
|
||||
StateHasChanged();
|
||||
|
||||
string connectionstring = "";
|
||||
if (DatabaseType == "LocalDB")
|
||||
{
|
||||
connectionstring += "Integrated Security=SSPI;";
|
||||
connectionstring = "Data Source=" + ServerName + ";AttachDbFilename=|DataDirectory|\\" + DatabaseName + ".mdf;Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring += "User ID=" + Username + ";Password=" + Password;
|
||||
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
|
||||
if (IntegratedSecurityDisplay == "display:none;")
|
||||
{
|
||||
connectionstring += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionstring += "User ID=" + Username + ";Password=" + Password;
|
||||
|
||||
}
|
||||
}
|
||||
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||
if (response.Success)
|
||||
{
|
||||
User user = new User();
|
||||
user.SiteId = 1;
|
||||
user.Username = HostUsername;
|
||||
user.DisplayName = HostUsername;
|
||||
user.Password = HostPassword;
|
||||
user.IsSuperUser = true;
|
||||
user.Roles = "";
|
||||
await UserService.AddUserAsync(user);
|
||||
UriHelper.NavigateTo("", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
||||
LoadingDisplay = "display:none;";
|
||||
}
|
||||
}
|
||||
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||
if (response.Success)
|
||||
{
|
||||
User user = new User();
|
||||
user.Username = HostUsername;
|
||||
user.DisplayName = HostUsername;
|
||||
user.Password = HostPassword;
|
||||
user.IsSuperUser = true;
|
||||
user.Roles = "";
|
||||
await UserService.AddUserAsync(user);
|
||||
UriHelper.NavigateTo("", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
||||
LoadingDisplay = "display:none;";
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Password Must Be 6 Characters Or Greater</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">Password Must Be 6 Characters Or Greater</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Modules
|
||||
|
||||
@DynamicComponent
|
||||
|
||||
@ -18,18 +19,26 @@
|
||||
{
|
||||
string typename = ModuleState.ModuleType;
|
||||
if (PageState.Control == "Settings") // module settings are a core component
|
||||
{
|
||||
{
|
||||
typename = Constants.DefaultSettingsControl;
|
||||
}
|
||||
Type moduleType = Type.GetType(typename);
|
||||
Type moduleType = null;
|
||||
if (typename != null)
|
||||
{
|
||||
moduleType = Type.GetType(typename);
|
||||
}
|
||||
if (moduleType != null)
|
||||
{
|
||||
builder.OpenComponent(ModuleState.ModuleId, moduleType); // set sequence to moduleid so that component tree is able to differentiate
|
||||
builder.OpenComponent(0, moduleType);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
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, "Type", MessageType.Error);
|
||||
builder.AddAttribute(2, "Message", "Error Loading Component For Module " + ModuleState.ModuleDefinitionName);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -52,23 +52,23 @@
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
// verify security access level for this module control
|
||||
SecurityAccessLevelEnum SecurityAccessLevel = (SecurityAccessLevelEnum)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
SecurityAccessLevel SecurityAccessLevel = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
bool authorized = false;
|
||||
switch (SecurityAccessLevel)
|
||||
{
|
||||
case SecurityAccessLevelEnum.Anonymous:
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevelEnum.View:
|
||||
case SecurityAccessLevel.View:
|
||||
authorized = UserService.IsAuthorized(PageState.User, module.ViewPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Edit:
|
||||
case SecurityAccessLevel.Edit:
|
||||
authorized = UserService.IsAuthorized(PageState.User, module.EditPermissions);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Admin:
|
||||
case SecurityAccessLevel.Admin:
|
||||
authorized = UserService.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
break;
|
||||
case SecurityAccessLevelEnum.Host:
|
||||
case SecurityAccessLevel.Host:
|
||||
authorized = PageState.User.IsSuperUser;
|
||||
break;
|
||||
}
|
||||
|
@ -55,10 +55,18 @@
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
{
|
||||
if (PageState == null)
|
||||
{
|
||||
await Refresh();
|
||||
// misconfigured api calls should not be processed through the router
|
||||
if (!_absoluteUri.Contains("~/api/"))
|
||||
{
|
||||
await Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(this.GetType().FullName + ": Error: " + _absoluteUri + " is not mapped to a Controller");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Modules
|
||||
|
||||
@DynamicComponent
|
||||
|
||||
@ -19,7 +20,11 @@
|
||||
}
|
||||
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, "Type", MessageType.Error);
|
||||
builder.AddAttribute(2, "Message", "Error Loading Page Theme " + PageState.Page.ThemeType);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace Oqtane.Shared
|
||||
public class Utilities
|
||||
{
|
||||
|
||||
public static string NavigateUrl(string alias, string path)
|
||||
public static string NavigateUrl(string alias, string path, string parameters)
|
||||
{
|
||||
string url = "";
|
||||
if (alias != "")
|
||||
@ -17,6 +17,10 @@ namespace Oqtane.Shared
|
||||
{
|
||||
url += path + "/";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameters))
|
||||
{
|
||||
url += "?" + parameters;
|
||||
}
|
||||
if (!url.StartsWith("/"))
|
||||
{
|
||||
url = "/" + url;
|
||||
@ -26,7 +30,7 @@ namespace Oqtane.Shared
|
||||
|
||||
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
||||
{
|
||||
string url = NavigateUrl(alias, path);
|
||||
string url = NavigateUrl(alias, path, "");
|
||||
if ( url == "/" )
|
||||
{
|
||||
url = "";
|
||||
|
@ -46,7 +46,7 @@ namespace Oqtane.Client
|
||||
services.AddScoped<IModuleService, ModuleService>();
|
||||
services.AddScoped<IPageModuleService, PageModuleService>();
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
|
||||
services.AddScoped<ISettingService, SettingService>();
|
||||
|
||||
// dynamically register module contexts and repository services
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
@ -57,7 +57,7 @@ namespace Oqtane.Client
|
||||
.ToArray();
|
||||
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)
|
||||
{
|
||||
services.AddScoped(servicetype, implementationtype); // traditional service interface
|
||||
|
@ -21,14 +21,13 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
return NavigateUrl(path, "");
|
||||
}
|
||||
|
||||
public string EditUrl(string action)
|
||||
public string NavigateUrl(string path, string parameters)
|
||||
{
|
||||
return EditUrl(ModuleState.ModuleId, action);
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(string action, string parameters)
|
||||
{
|
||||
return EditUrl(ModuleState.ModuleId, action, parameters);
|
||||
|
@ -6,11 +6,12 @@
|
||||
@code {
|
||||
string logo = "";
|
||||
|
||||
protected override void OnInit()
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
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>";
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@
|
||||
List<Page> pages;
|
||||
Page parent = null;
|
||||
|
||||
protected override void OnInit()
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
// if current page has no children
|
||||
if (PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).FirstOrDefault() == null)
|
||||
@ -54,5 +54,6 @@
|
||||
// current page is parent
|
||||
parent = PageState.Pages.Where(item => item.ParentId == PageState.Page.ParentId).FirstOrDefault();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,13 @@
|
||||
@code {
|
||||
string title = "";
|
||||
|
||||
protected override void OnInit()
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
title = ModuleState.Title;
|
||||
if (PageState.Control == "Settings")
|
||||
{
|
||||
title = PageState.Control;
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,12 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
return NavigateUrl(path, "");
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, string parameters)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,12 @@ namespace Oqtane.Themes
|
||||
|
||||
public string NavigateUrl(string path)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path);
|
||||
return NavigateUrl(path, "");
|
||||
}
|
||||
|
||||
public string NavigateUrl(string path, string parameters)
|
||||
{
|
||||
return Utilities.NavigateUrl(PageState.Alias.Path, path, parameters);
|
||||
}
|
||||
|
||||
public string EditUrl(int moduleid, string action)
|
||||
|
Reference in New Issue
Block a user