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:
@ -51,7 +51,7 @@ else
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||
<option value=""><Select Theme></option>
|
||||
<option value=string.Empty><Select Theme></option>
|
||||
@foreach (KeyValuePair<string, string> item in _themes)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
@ -65,7 +65,7 @@ else
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@_layouttype">
|
||||
<option value=""><Select Layout></option>
|
||||
<option value=string.Empty><Select Layout></option>
|
||||
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||
{
|
||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||
@ -79,7 +79,7 @@ else
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@_containertype">
|
||||
<option value=""><Select Container></option>
|
||||
<option value=string.Empty><Select Container></option>
|
||||
@foreach (KeyValuePair<string, string> container in _containers)
|
||||
{
|
||||
<option value="@container.Key">@container.Value</option>
|
||||
@ -93,7 +93,7 @@ else
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@_sitetemplatetype">
|
||||
<option value=""><Select Site Template></option>
|
||||
<option value=string.Empty><Select Site Template></option>
|
||||
@foreach (SiteTemplate siteTemplate in _siteTemplates)
|
||||
{
|
||||
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
|
||||
@ -126,25 +126,24 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
private Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||
private List<SiteTemplate> _siteTemplates;
|
||||
private List<Theme> _themeList;
|
||||
private List<Tenant> _tenants;
|
||||
private string _tenantid = "-1";
|
||||
private string _name = string.Empty;
|
||||
private string _urls = string.Empty;
|
||||
private string _themetype = string.Empty;
|
||||
private string _layouttype = string.Empty;
|
||||
private string _containertype = string.Empty;
|
||||
private string _sitetemplatetype = string.Empty;
|
||||
private bool _isinitialized = true;
|
||||
private string _username = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
|
||||
Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||
List<SiteTemplate> _siteTemplates;
|
||||
|
||||
List<Theme> _themeList;
|
||||
List<Tenant> _tenants;
|
||||
string _tenantid = "-1";
|
||||
string _name = "";
|
||||
string _urls = "";
|
||||
string _themetype = "";
|
||||
string _layouttype = "";
|
||||
string _containertype = "";
|
||||
string _sitetemplatetype = "";
|
||||
bool _isinitialized = true;
|
||||
string _username = "";
|
||||
string _password = "";
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@ -164,7 +163,7 @@ else
|
||||
_tenantid = (string)e.Value;
|
||||
if (_tenantid != "-1")
|
||||
{
|
||||
Tenant tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
if (tenant != null)
|
||||
{
|
||||
_isinitialized = tenant.IsInitialized;
|
||||
@ -184,7 +183,7 @@ else
|
||||
try
|
||||
{
|
||||
_themetype = (string)e.Value;
|
||||
if (_themetype != "")
|
||||
if (_themetype != string.Empty)
|
||||
{
|
||||
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||
}
|
||||
@ -192,6 +191,7 @@ else
|
||||
{
|
||||
_panelayouts = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -203,10 +203,10 @@ else
|
||||
|
||||
private async Task SaveSite()
|
||||
{
|
||||
if (_tenantid != "-1" && _name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype) && !string.IsNullOrEmpty(_sitetemplatetype))
|
||||
if (_tenantid != "-1" && _name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype) && !string.IsNullOrEmpty(_sitetemplatetype))
|
||||
{
|
||||
bool unique = true;
|
||||
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
||||
var unique = true;
|
||||
var aliases = await AliasService.GetAliasesAsync();
|
||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (aliases.Exists(item => item.Name == name))
|
||||
@ -214,13 +214,14 @@ else
|
||||
unique = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (unique)
|
||||
{
|
||||
bool isvalid = true;
|
||||
var isvalid = true;
|
||||
|
||||
if (!_isinitialized)
|
||||
{
|
||||
User user = new User();
|
||||
var user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = _username;
|
||||
user.Password = _password;
|
||||
@ -234,9 +235,10 @@ else
|
||||
|
||||
aliases = new List<Alias>();
|
||||
_urls = _urls.Replace("\n", ",");
|
||||
|
||||
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
Alias alias = new Alias();
|
||||
var alias = new Alias();
|
||||
alias.Name = name;
|
||||
alias.TenantId = int.Parse(_tenantid);
|
||||
alias.SiteId = -1;
|
||||
@ -244,13 +246,13 @@ else
|
||||
aliases.Add(alias);
|
||||
}
|
||||
|
||||
Site site = new Site();
|
||||
var site = new Site();
|
||||
site.TenantId = int.Parse(_tenantid);
|
||||
site.Name = _name;
|
||||
site.LogoFileId = null;
|
||||
site.FaviconFileId = null;
|
||||
site.DefaultThemeType = _themetype;
|
||||
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype);
|
||||
site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype);
|
||||
site.DefaultContainerType = _containertype;
|
||||
site.PwaIsEnabled = false;
|
||||
site.PwaAppIconFileId = null;
|
||||
@ -267,7 +269,7 @@ else
|
||||
|
||||
if (!_isinitialized)
|
||||
{
|
||||
User user = new User();
|
||||
var user = new User();
|
||||
user.SiteId = site.SiteId;
|
||||
user.Username = _username;
|
||||
user.Password = _password;
|
||||
@ -277,7 +279,7 @@ else
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
Tenant tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
if (tenant != null)
|
||||
{
|
||||
tenant.IsInitialized = true;
|
||||
@ -285,9 +287,10 @@ else
|
||||
}
|
||||
}
|
||||
}
|
||||
await Log(aliases[0], LogLevel.Information, "", null, "Site Created {Site}", site);
|
||||
|
||||
await Log(aliases[0], LogLevel.Information, string.Empty, null, "Site Created {Site}", site);
|
||||
|
||||
Uri uri = new Uri(NavigationManager.Uri);
|
||||
var uri = new Uri(NavigationManager.Uri);
|
||||
NavigationManager.NavigateTo(uri.Scheme + "://" + aliases[0].Name, true);
|
||||
}
|
||||
else
|
||||
@ -305,6 +308,5 @@ else
|
||||
{
|
||||
AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Container, And Site Template", MessageType.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user