Refactoring (#314)
* Refactoring * Refactoring * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Rename template .sql file * Modified null and empty string check. * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options * Refactoring * Refactoring * Check for a valid email. * Moved logic to the Utilities class. Co-authored-by: Aubrey <aubrey.b@treskcow.tech> Co-authored-by: MIchael Atwood <matwood@dragonmastery.com> Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
</CascadingValue>
|
||||
|
||||
@code {
|
||||
private Module _moduleState;
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
@ -13,8 +15,6 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
Module _moduleState;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
_moduleState = Module; // passed in from Pane component
|
||||
|
@ -134,20 +134,14 @@
|
||||
private string _confirmPassword = "";
|
||||
private string _hostEmail = "";
|
||||
private string _message = "";
|
||||
|
||||
private string _integratedSecurityDisplay = "display: none;";
|
||||
private string _loadingDisplay = "display: none;";
|
||||
|
||||
private void SetIntegratedSecurity(ChangeEventArgs e)
|
||||
{
|
||||
if (Convert.ToBoolean((string) e.Value))
|
||||
{
|
||||
_integratedSecurityDisplay = "display: none;";
|
||||
}
|
||||
else
|
||||
{
|
||||
_integratedSecurityDisplay = "";
|
||||
}
|
||||
_integratedSecurityDisplay = Convert.ToBoolean((string)e.Value)
|
||||
? "display: none;"
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
private async Task Install()
|
||||
@ -157,7 +151,7 @@
|
||||
_loadingDisplay = "";
|
||||
StateHasChanged();
|
||||
|
||||
string connectionstring = "";
|
||||
var connectionstring = "";
|
||||
if (_databaseType == "LocalDB")
|
||||
{
|
||||
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
|
||||
@ -184,7 +178,7 @@
|
||||
IsMaster = true,
|
||||
};
|
||||
|
||||
Installation installation = await InstallationService.Install(config);
|
||||
var installation = await InstallationService.Install(config);
|
||||
//TODO: Should be moved to Database manager
|
||||
if (installation.Success)
|
||||
{
|
||||
|
@ -11,6 +11,9 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _message;
|
||||
private bool _progressindicator = false;
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
@ -18,11 +21,8 @@
|
||||
private Module ModuleState { get; set; }
|
||||
|
||||
private ModuleMessage ModuleMessage { get; set; }
|
||||
string _message;
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
bool _progressindicator = false;
|
||||
private RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
@ -12,6 +12,9 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string _paneadminborder = "";
|
||||
private string _panetitle = "";
|
||||
|
||||
[CascadingParameter]
|
||||
protected PageState PageState { get; set; }
|
||||
|
||||
@ -20,9 +23,6 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
string _paneadminborder = "";
|
||||
string _panetitle = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (PageState.EditMode && !PageState.Page.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
@ -45,13 +45,14 @@
|
||||
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
||||
if (module != null)
|
||||
{
|
||||
string typename = module.ModuleType;
|
||||
// check for core module actions component
|
||||
var typename = module.ModuleType;
|
||||
// check for core module actions component
|
||||
if (Constants.DefaultModuleActions.Contains(PageState.Action))
|
||||
{
|
||||
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
|
||||
}
|
||||
Type moduleType = Type.GetType(typename);
|
||||
|
||||
var moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
bool authorized = false;
|
||||
@ -61,7 +62,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
// verify security access level for this module control
|
||||
switch (module.SecurityAccessLevel)
|
||||
{
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
@ -81,12 +81,14 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
if (!Constants.DefaultModuleActions.Contains(PageState.Action) && module.ControlTitle != "")
|
||||
{
|
||||
module.Title = module.ControlTitle;
|
||||
}
|
||||
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
|
||||
builder.AddAttribute(1, "Module", module);
|
||||
builder.CloseComponent();
|
||||
@ -94,7 +96,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
// module control does not exist with name specified
|
||||
// module control does not exist with name specified
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +108,7 @@
|
||||
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
||||
if (module != null && module.Pane.ToLower() == Name.ToLower())
|
||||
{
|
||||
// check if user is authorized to view module
|
||||
// check if user is authorized to view module
|
||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
|
||||
{
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
|
||||
@ -119,7 +121,7 @@
|
||||
{
|
||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray())
|
||||
{
|
||||
// check if user is authorized to view module
|
||||
// check if user is authorized to view module
|
||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
|
||||
{
|
||||
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
|
||||
|
@ -12,7 +12,7 @@
|
||||
{
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
Type layoutType = Type.GetType(PageState.Page.LayoutType);
|
||||
var layoutType = Type.GetType(PageState.Page.LayoutType);
|
||||
if (layoutType != null)
|
||||
{
|
||||
builder.OpenComponent(0, layoutType);
|
||||
|
@ -20,17 +20,17 @@
|
||||
|
||||
@code {
|
||||
|
||||
private string _absoluteUri;
|
||||
private bool _navigationInterceptionEnabled;
|
||||
private PageState _pagestate;
|
||||
|
||||
[CascadingParameter]
|
||||
PageState PageState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Action<PageState> OnStateChange { get; set; }
|
||||
|
||||
PageState _pagestate;
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
string _absoluteUri;
|
||||
bool _navigationInterceptionEnabled;
|
||||
private RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@ -77,22 +77,22 @@
|
||||
Page page;
|
||||
User user = null;
|
||||
List<Module> modules;
|
||||
int moduleid = -1;
|
||||
string action = "";
|
||||
bool editmode = false;
|
||||
Reload reload = Reload.None;
|
||||
DateTime lastsyncdate = DateTime.UtcNow;
|
||||
Runtime runtime = GetRuntime();
|
||||
var moduleid = -1;
|
||||
var action = "";
|
||||
var editmode = false;
|
||||
var reload = Reload.None;
|
||||
var lastsyncdate = DateTime.UtcNow;
|
||||
var runtime = GetRuntime();
|
||||
|
||||
// get Url path and querystring ( and remove anchors )
|
||||
string path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
||||
var path = new Uri(_absoluteUri).PathAndQuery.Substring(1);
|
||||
if (path.IndexOf("#") != -1)
|
||||
{
|
||||
path = path.Substring(0, path.IndexOf("#"));
|
||||
}
|
||||
|
||||
// parse querystring and remove
|
||||
Dictionary<string, string> querystring = new Dictionary<string, string>();
|
||||
var querystring = new Dictionary<string, string>();
|
||||
if (path.IndexOf("?") != -1)
|
||||
{
|
||||
querystring = ParseQueryString(path);
|
||||
@ -137,6 +137,7 @@
|
||||
{
|
||||
site = PageState.Site;
|
||||
}
|
||||
|
||||
if (site != null)
|
||||
{
|
||||
if (PageState == null || reload == Reload.Site)
|
||||
@ -174,14 +175,19 @@
|
||||
|
||||
// format path and remove alias
|
||||
path = path.Replace("//", "/");
|
||||
if (!path.EndsWith("/")) { path += "/"; }
|
||||
|
||||
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);
|
||||
var segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int result;
|
||||
// check if path has moduleid and control specification ie. page/moduleid/control/
|
||||
if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
|
||||
@ -199,6 +205,7 @@
|
||||
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);
|
||||
|
||||
@ -210,6 +217,7 @@
|
||||
{
|
||||
page = PageState.Page;
|
||||
}
|
||||
|
||||
// failsafe in case router cannot locate the home page for the site
|
||||
if (page == null && path == "")
|
||||
{
|
||||
@ -313,6 +321,7 @@
|
||||
_navigationInterceptionEnabled = true;
|
||||
return NavigationInterception.EnableNavigationInterceptionAsync();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@ -337,6 +346,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return querystring;
|
||||
}
|
||||
|
||||
@ -356,6 +366,7 @@
|
||||
page.LayoutType = site.DefaultLayoutType;
|
||||
}
|
||||
Type type;
|
||||
|
||||
if (!string.IsNullOrEmpty(page.LayoutType))
|
||||
{
|
||||
type = Type.GetType(page.LayoutType);
|
||||
@ -364,24 +375,26 @@
|
||||
{
|
||||
type = Type.GetType(page.ThemeType);
|
||||
}
|
||||
System.Reflection.PropertyInfo property = type.GetProperty("Panes");
|
||||
|
||||
var property = type.GetProperty("Panes");
|
||||
page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// error loading theme or layout
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
private List<Module> ProcessModules(List<Module> modules, int pageid, int moduleid, string control, string panes, string defaultcontainertype)
|
||||
{
|
||||
Dictionary<string, int> paneindex = new Dictionary<string, int>();
|
||||
var paneindex = new Dictionary<string, int>();
|
||||
foreach (Module module in modules)
|
||||
{
|
||||
if (module.PageId == pageid || module.ModuleId == moduleid)
|
||||
{
|
||||
string typename = "";
|
||||
var typename = string.Empty;
|
||||
if (module.ModuleDefinition != null)
|
||||
{
|
||||
typename = module.ModuleDefinition.ControlTypeTemplate;
|
||||
@ -390,6 +403,7 @@
|
||||
{
|
||||
typename = Constants.ErrorModule;
|
||||
}
|
||||
|
||||
if (module.ModuleId == moduleid && control != "")
|
||||
{
|
||||
// check if the module defines custom routes
|
||||
@ -445,6 +459,7 @@
|
||||
{
|
||||
paneindex.Add(module.Pane, 0);
|
||||
}
|
||||
|
||||
module.PaneModuleIndex = paneindex[module.Pane];
|
||||
|
||||
if (string.IsNullOrEmpty(module.ContainerType))
|
||||
@ -458,18 +473,12 @@
|
||||
{
|
||||
module.PaneModuleCount = paneindex[module.Pane] + 1;
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
private Runtime GetRuntime()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")))
|
||||
{
|
||||
return Runtime.WebAssembly;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Runtime.Server;
|
||||
}
|
||||
}
|
||||
=> RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"))
|
||||
? Runtime.WebAssembly
|
||||
: Runtime.Server;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
Type themeType = Type.GetType(PageState.Page.ThemeType);
|
||||
var themeType = Type.GetType(PageState.Page.ThemeType);
|
||||
if (themeType != null)
|
||||
{
|
||||
builder.OpenComponent(0, themeType);
|
||||
|
Reference in New Issue
Block a user