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:
@ -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 = "";
|
||||
|
Reference in New Issue
Block a user