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:
Hisham Bin Ateya 2020-03-31 17:21:05 +03:00 committed by GitHub
parent c9baa2bb56
commit 66ad089088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 958 additions and 829 deletions

View File

@ -19,6 +19,7 @@
@code { @code {
private bool _initialized; private bool _initialized;
private bool _installed; private bool _installed;
private PageState PageState { get; set; } private PageState PageState { get; set; }
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()

View File

@ -19,13 +19,13 @@
</div> </div>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } var List<Page> _pages;
List<Page> _pages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override void OnInitialized() protected override void OnInitialized()
{ {
Page admin = PageState.Pages.FirstOrDefault(item => item.Path == "admin"); var admin = PageState.Pages.FirstOrDefault(item => item.Path == "admin");
_pages = PageState.Pages.Where(item => item.ParentId == admin?.PageId).ToList(); _pages = PageState.Pages.Where(item => item.ParentId == admin?.PageId).ToList();
} }
} }

View File

@ -3,7 +3,7 @@
@inject IModuleService ModuleService @inject IModuleService ModuleService
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -13,6 +13,7 @@
string message = "A Problem Was Encountered Loading Module " + module.ModuleDefinitionName; string message = "A Problem Was Encountered Loading Module " + module.ModuleDefinitionName;
AddModuleMessage(message, MessageType.Error); AddModuleMessage(message, MessageType.Error);
} }
await logger.LogCritical("Error Loading Module {Module}", module); await logger.LogCritical("Error Loading Module {Module}", module);
} }
} }

View File

@ -70,11 +70,11 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string url = string.Empty;
private List<Folder> _folders;
private int _folderId = -1;
string url = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
List<Folder> _folders;
int _folderId = -1;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -90,7 +90,7 @@
{ {
try try
{ {
if (url != "" && _folderId != -1) if (url != string.Empty && _folderId != -1)
{ {
await FileService.UploadFileAsync(url, _folderId); await FileService.UploadFileAsync(url, _folderId);
await logger.LogInformation("File Downloaded Successfully From Url {Url}", url); await logger.LogInformation("File Downloaded Successfully From Url {Url}", url);

View File

@ -56,24 +56,25 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<Folder> _folders;
public override string Title { get { return "Folder Management"; } } private int _folderId = -1;
private string _name;
List<Folder> _folders; private int _parentId = -1;
int _folderId = -1; private bool _isSystem;
string _name; private string _permissions = string.Empty;
int _parentId = -1; private string _createdBy;
bool _isSystem; private DateTime _createdOn;
string _permissions = ""; private string _modifiedBy;
string _createdBy; private DateTime _modifiedOn;
DateTime _createdOn;
string _modifiedBy;
DateTime _modifiedOn;
#pragma warning disable 649 #pragma warning disable 649
PermissionGrid _permissionGrid; private PermissionGrid _permissionGrid;
#pragma warning restore 649 #pragma warning restore 649
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
public override string Title => "Folder Management";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
@ -99,7 +100,7 @@
else else
{ {
_parentId = _folders[0].FolderId; _parentId = _folders[0].FolderId;
_permissions = ""; _permissions = string.Empty;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -113,7 +114,7 @@
{ {
try try
{ {
if (_name != "" && _parentId != -1) if (_name != string.Empty && _parentId != -1)
{ {
Folder folder; Folder folder;
if (_folderId != -1) if (_folderId != -1)
@ -126,6 +127,7 @@
} }
folder.SiteId = PageState.Site.SiteId; folder.SiteId = PageState.Site.SiteId;
if (_parentId == -1) if (_parentId == -1)
{ {
folder.ParentId = null; folder.ParentId = null;
@ -134,6 +136,7 @@
{ {
folder.ParentId = _parentId; folder.ParentId = _parentId;
} }
folder.Name = _name; folder.Name = _name;
folder.IsSystem = _isSystem; folder.IsSystem = _isSystem;
folder.Permissions = _permissionGrid.GetPermissions(); folder.Permissions = _permissionGrid.GetPermissions();
@ -146,6 +149,7 @@
{ {
folder = await FolderService.AddFolderAsync(folder); folder = await FolderService.AddFolderAsync(folder);
} }
await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId); await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId);
await logger.LogInformation("Folder Saved {Folder}", folder); await logger.LogInformation("Folder Saved {Folder}", folder);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());

View File

@ -49,17 +49,18 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<Folder> _folders;
private int _folderId = -1;
private List<File> _files;
List<Folder> _folders; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
int _folderId = -1;
List<File> _files;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
try try
{ {
_folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId); _folders = await FolderService.GetFoldersAsync(PageState.Site.SiteId);
if (_folderId == -1 && _folders.Count > 0) if (_folderId == -1 && _folders.Count > 0)
{ {
_folderId = _folders[0].FolderId; _folderId = _folders[0].FolderId;

View File

@ -74,28 +74,29 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private string _name = string.Empty;
private string _jobType = string.Empty;
private string _isEnabled = "True";
private string _interval = string.Empty;
private string _frequency = string.Empty;
private string _startDate = string.Empty;
private string _endDate = string.Empty;
private string _retentionHistory = "10";
string _name = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string _jobType = "";
string _isEnabled = "True";
string _interval = "";
string _frequency = "";
string _startDate = "";
string _endDate = "";
string _retentionHistory = "10";
private async Task SaveJob() private async Task SaveJob()
{ {
if (_name != "" && !string.IsNullOrEmpty(_jobType) && _frequency != "" && _interval != "" && _retentionHistory != "") if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty)
{ {
Job job = new Job(); var job = new Job();
job.Name = _name; job.Name = _name;
job.JobType = _jobType; job.JobType = _jobType;
job.IsEnabled = Boolean.Parse(_isEnabled); job.IsEnabled = Boolean.Parse(_isEnabled);
job.Frequency = _frequency; job.Frequency = _frequency;
job.Interval = int.Parse(_interval); job.Interval = int.Parse(_interval);
if (_startDate == "")
if (_startDate == string.Empty)
{ {
job.StartDate = null; job.StartDate = null;
} }
@ -103,7 +104,8 @@
{ {
job.StartDate = DateTime.Parse(_startDate); job.StartDate = DateTime.Parse(_startDate);
} }
if (_endDate == "")
if (_endDate == string.Empty)
{ {
job.EndDate = null; job.EndDate = null;
} }
@ -111,6 +113,7 @@
{ {
job.EndDate = DateTime.Parse(_endDate); job.EndDate = DateTime.Parse(_endDate);
} }
job.RetentionHistory = int.Parse(_retentionHistory); job.RetentionHistory = int.Parse(_retentionHistory);
job.IsStarted = false; job.IsStarted = false;
job.IsExecuting = false; job.IsExecuting = false;

View File

@ -74,17 +74,17 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private int _jobId;
private string _name = string.Empty;
private string _jobType = string.Empty;
private string _isEnabled = "True";
private string _interval = string.Empty;
private string _frequency = string.Empty;
private string _startDate = string.Empty;
private string _endDate = string.Empty;
private string _retentionHistory = string.Empty;
int _jobId; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string _name = "";
string _jobType = "";
string _isEnabled = "True";
string _interval = "";
string _frequency = "";
string _startDate = "";
string _endDate = "";
string _retentionHistory = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -99,8 +99,8 @@
_isEnabled = job.IsEnabled.ToString(); _isEnabled = job.IsEnabled.ToString();
_interval = job.Interval.ToString(); _interval = job.Interval.ToString();
_frequency = job.Frequency; _frequency = job.Frequency;
_startDate = (job.StartDate != null) ? job.StartDate.ToString() : ""; _startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty;
_endDate = (job.EndDate != null) ? job.EndDate.ToString() : ""; _endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty;
_retentionHistory = job.RetentionHistory.ToString(); _retentionHistory = job.RetentionHistory.ToString();
} }
} }
@ -113,15 +113,16 @@
private async Task SaveJob() private async Task SaveJob()
{ {
if (_name != "" && !string.IsNullOrEmpty(_jobType) && _frequency != "" && _interval != "" && _retentionHistory != "") if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty)
{ {
Job job = await JobService.GetJobAsync(_jobId); var job = await JobService.GetJobAsync(_jobId);
job.Name = _name; job.Name = _name;
job.JobType = _jobType; job.JobType = _jobType;
job.IsEnabled = Boolean.Parse(_isEnabled); job.IsEnabled = Boolean.Parse(_isEnabled);
job.Frequency = _frequency; job.Frequency = _frequency;
job.Interval = int.Parse(_interval); job.Interval = int.Parse(_interval);
if (_startDate == "")
if (_startDate == string.Empty)
{ {
job.StartDate = null; job.StartDate = null;
} }
@ -129,7 +130,8 @@
{ {
job.StartDate = DateTime.Parse(_startDate); job.StartDate = DateTime.Parse(_startDate);
} }
if (_endDate == "")
if (_endDate == string.Empty)
{ {
job.EndDate = null; job.EndDate = null;
} }
@ -137,6 +139,7 @@
{ {
job.EndDate = DateTime.Parse(_endDate); job.EndDate = DateTime.Parse(_endDate);
} }
job.RetentionHistory = int.Parse(_retentionHistory); job.RetentionHistory = int.Parse(_retentionHistory);
try try

View File

@ -47,9 +47,9 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Job> _jobs;
List<Job> _jobs; public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
@ -58,7 +58,7 @@ else
private string DisplayStatus(bool isEnabled, bool isExecuting) private string DisplayStatus(bool isEnabled, bool isExecuting)
{ {
string status = ""; var status = string.Empty;
if (!isEnabled) if (!isEnabled)
{ {
status = "Disabled"; status = "Disabled";
@ -81,7 +81,7 @@ else
private string DisplayFrequency(int interval, string frequency) private string DisplayFrequency(int interval, string frequency)
{ {
string result = "Every " + interval.ToString() + " "; var result = "Every " + interval.ToString() + " ";
switch (frequency) switch (frequency)
{ {
case "m": case "m":
@ -97,10 +97,12 @@ else
result += "Month"; result += "Month";
break; break;
} }
if (interval > 1) if (interval > 1)
{ {
result += "s"; result += "s";
} }
return result; return result;
} }

View File

@ -28,23 +28,25 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<JobLog> _jobLogs;
List<JobLog> _jobLogs; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
_jobLogs = await JobLogService.GetJobLogsAsync(); _jobLogs = await JobLogService.GetJobLogsAsync();
if (PageState.QueryString.ContainsKey("id")) if (PageState.QueryString.ContainsKey("id"))
{ {
_jobLogs = _jobLogs.Where(item => item.JobId == Int32.Parse(PageState.QueryString["id"])).ToList(); _jobLogs = _jobLogs.Where(item => item.JobId == Int32.Parse(PageState.QueryString["id"])).ToList();
} }
_jobLogs = _jobLogs.OrderByDescending(item => item.JobLogId).ToList(); _jobLogs = _jobLogs.OrderByDescending(item => item.JobLogId).ToList();
} }
private string DisplayStatus(bool isExecuting, bool? succeeded) private string DisplayStatus(bool isExecuting, bool? succeeded)
{ {
string status = ""; var status = string.Empty;
if (isExecuting) if (isExecuting)
{ {
status = "Executing"; status = "Executing";
@ -60,6 +62,7 @@ else
status = "Failed"; status = "Failed";
} }
} }
return status; return status;
} }
} }

View File

@ -5,7 +5,7 @@
@inject IUserService UserService @inject IUserService UserService
@inject IServiceProvider ServiceProvider @inject IServiceProvider ServiceProvider
@if (_message != "") @if (_message != string.Empty)
{ {
<ModuleMessage Message="@_message" Type="@_type" /> <ModuleMessage Message="@_message" Type="@_type" />
} }
@ -41,14 +41,14 @@
</AuthorizeView> </AuthorizeView>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } private string _returnUrl = string.Empty;
private string _message = string.Empty;
private MessageType _type = MessageType.Info;
private string _username = string.Empty;
private string _password = string.Empty;
private bool _remember = false;
string _returnUrl = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
string _message = "";
MessageType _type = MessageType.Info;
string _username = "";
string _password = "";
bool _remember = false;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -56,13 +56,15 @@
{ {
_returnUrl = PageState.QueryString["returnurl"]; _returnUrl = PageState.QueryString["returnurl"];
} }
if (PageState.QueryString.ContainsKey("name")) if (PageState.QueryString.ContainsKey("name"))
{ {
_username = PageState.QueryString["name"]; _username = PageState.QueryString["name"];
} }
if (PageState.QueryString.ContainsKey("token")) if (PageState.QueryString.ContainsKey("token"))
{ {
User user = new User(); var user = new User();
user.SiteId = PageState.Site.SiteId; user.SiteId = PageState.Site.SiteId;
user.Username = _username; user.Username = _username;
user = await UserService.VerifyEmailAsync(user, PageState.QueryString["token"]); user = await UserService.VerifyEmailAsync(user, PageState.QueryString["token"]);
@ -84,11 +86,12 @@
if (PageState.Runtime == Runtime.Server) if (PageState.Runtime == Runtime.Server)
{ {
// server-side Blazor // server-side Blazor
User user = new User(); var user = new User();
user.SiteId = PageState.Site.SiteId; user.SiteId = PageState.Site.SiteId;
user.Username = _username; user.Username = _username;
user.Password = _password; user.Password = _password;
user = await UserService.LoginUserAsync(user, false, false); user = await UserService.LoginUserAsync(user, false, false);
if (user.IsAuthenticated) if (user.IsAuthenticated)
{ {
await logger.LogInformation("Login Successful For Username {Username}", _username); await logger.LogInformation("Login Successful For Username {Username}", _username);
@ -107,7 +110,7 @@
else else
{ {
// client-side Blazor // client-side Blazor
User user = new User(); var user = new User();
user.SiteId = PageState.Site.SiteId; user.SiteId = PageState.Site.SiteId;
user.Username = _username; user.Username = _username;
user.Password = _password; user.Password = _password;
@ -134,9 +137,9 @@
private async Task Forgot() private async Task Forgot()
{ {
if (_username != "") if (_username != string.Empty)
{ {
User user = await UserService.GetUserAsync(_username, PageState.Site.SiteId); var user = await UserService.GetUserAsync(_username, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
await UserService.ForgotPasswordAsync(user); await UserService.ForgotPasswordAsync(user);
@ -152,6 +155,7 @@
{ {
_message = "Please Enter The Username Related To Your Account And Then Select The Forgot Password Option Again"; _message = "Please Enter The Username Related To Your Account And Then Select The Forgot Password Option Again";
} }
StateHasChanged(); StateHasChanged();
} }
} }

View File

@ -48,7 +48,7 @@
<input class="form-control" @bind="@_category" disabled /> <input class="form-control" @bind="@_category" disabled />
</td> </td>
</tr> </tr>
@if (_pageName != "") @if (_pageName != string.Empty)
{ {
<tr> <tr>
<td> <td>
@ -59,7 +59,7 @@
</td> </td>
</tr> </tr>
} }
@if (_moduleTitle != "") @if (_moduleTitle != string.Empty)
{ {
<tr> <tr>
<td> <td>
@ -70,7 +70,7 @@
</td> </td>
</tr> </tr>
} }
@if (_username != "") @if (_username != string.Empty)
{ {
<tr> <tr>
<td> <td>
@ -136,30 +136,30 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int _logId;
private string _logDate = string.Empty;
private string _level = string.Empty;
private string _feature = string.Empty;
private string _function = string.Empty;
private string _category = string.Empty;
private string _pageName = string.Empty;
private string _moduleTitle = string.Empty;
private string _username = string.Empty;
private string _url = string.Empty;
private string _template = string.Empty;
private string _message = string.Empty;
private string _exception = string.Empty;
private string _properties = string.Empty;
private string _server = string.Empty;
int _logId; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string _logDate = "";
string _level = "";
string _feature = "";
string _function = "";
string _category = "";
string _pageName = "";
string _moduleTitle = "";
string _username = "";
string _url = "";
string _template = "";
string _message = "";
string _exception = "";
string _properties = "";
string _server = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
_logId = Int32.Parse(PageState.QueryString["id"]); _logId = Int32.Parse(PageState.QueryString["id"]);
Log log = await LogService.GetLogAsync(_logId); var log = await LogService.GetLogAsync(_logId);
if (log != null) if (log != null)
{ {
_logDate = log.LogDate.ToString(CultureInfo.CurrentCulture); _logDate = log.LogDate.ToString(CultureInfo.CurrentCulture);
@ -167,30 +167,34 @@
_feature = log.Feature; _feature = log.Feature;
_function = log.Function; _function = log.Function;
_category = log.Category; _category = log.Category;
if (log.PageId != null) if (log.PageId != null)
{ {
Page page = await PageService.GetPageAsync(log.PageId.Value); var page = await PageService.GetPageAsync(log.PageId.Value);
if (page != null) if (page != null)
{ {
_pageName = page.Name; _pageName = page.Name;
} }
} }
if (log.PageId != null && log.ModuleId != null) if (log.PageId != null && log.ModuleId != null)
{ {
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value); var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value);
if (pagemodule != null) if (pagemodule != null)
{ {
_moduleTitle = pagemodule.Title; _moduleTitle = pagemodule.Title;
} }
} }
if (log.UserId != null) if (log.UserId != null)
{ {
User user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId); var user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
_username = user.Username; _username = user.Username;
} }
} }
_url = log.Url; _url = log.Url;
_template = log.MessageTemplate; _template = log.MessageTemplate;
_message = log.Message; _message = log.Message;

View File

@ -71,12 +71,12 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string _level = "-";
private string _function = "-";
private string _rows = "10";
private List<Log> _logs;
string _level = "-"; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string _function = "-";
string _rows = "10";
List<Log> _logs;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -139,12 +139,12 @@ else
private async Task GetLogs() private async Task GetLogs()
{ {
_logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? "" : _level), ((_function == "-") ? "" : _function), int.Parse(_rows)); _logs = await LogService.GetLogsAsync(PageState.Site.SiteId, ((_level == "-") ? string.Empty : _level), ((_function == "-") ? string.Empty : _function), int.Parse(_rows));
} }
private string GetClass(string function) private string GetClass(string function)
{ {
string classname = ""; string classname = string.Empty;
switch (function) switch (function)
{ {
case "Create": case "Create":
@ -163,7 +163,7 @@ else
classname = "table-secondary"; classname = "table-secondary";
break; break;
default: default:
classname = ""; classname = string.Empty;
break; break;
} }
return classname; return classname;

View File

@ -26,10 +26,10 @@
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button> <button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private string _name = string.Empty;
private string _description = string.Empty;
string _name = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string _description = "";
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -42,7 +42,7 @@
{ {
if (!string.IsNullOrEmpty(_name)) if (!string.IsNullOrEmpty(_name))
{ {
ModuleDefinition moduleDefinition = new ModuleDefinition { Name = _name, Description = _description }; var moduleDefinition = new ModuleDefinition { Name = _name, Description = _description };
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId); await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
} }
else else

View File

@ -42,16 +42,17 @@
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Package> _packages;
List<Package> _packages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
List<ModuleDefinition> moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
_packages = await PackageService.GetPackagesAsync("module"); _packages = await PackageService.GetPackagesAsync("module");
foreach(Package package in _packages.ToArray()) foreach(Package package in _packages.ToArray())
{ {
if (moduledefinitions.Exists(item => Utilities.GetTypeName(item.ModuleDefinitionName) == package.PackageId)) if (moduledefinitions.Exists(item => Utilities.GetTypeName(item.ModuleDefinitionName) == package.PackageId))

View File

@ -26,26 +26,26 @@
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo> <AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int _moduleDefinitionId;
private string _name;
int _moduleDefinitionId; private string _permissions;
string _name; private string _createdby;
string _permissions; private DateTime _createdon;
string _createdby; private string _modifiedby;
DateTime _createdon; private DateTime _modifiedon;
string _modifiedby;
DateTime _modifiedon;
#pragma warning disable 649 #pragma warning disable 649
PermissionGrid _permissionGrid; private PermissionGrid _permissionGrid;
#pragma warning restore 649 #pragma warning restore 649
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
_moduleDefinitionId = Int32.Parse(PageState.QueryString["id"]); _moduleDefinitionId = Int32.Parse(PageState.QueryString["id"]);
ModuleDefinition moduleDefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); var moduleDefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
if (moduleDefinition != null) if (moduleDefinition != null)
{ {
_name = moduleDefinition.Name; _name = moduleDefinition.Name;
@ -67,7 +67,7 @@
{ {
try try
{ {
ModuleDefinition moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
moduledefinition.Permissions = _permissionGrid.GetPermissions(); moduledefinition.Permissions = _permissionGrid.GetPermissions();
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);

View File

@ -41,10 +41,10 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<ModuleDefinition> _moduleDefinitions;
private List<Package> _packages;
List<ModuleDefinition> _moduleDefinitions; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
List<Package> _packages;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -62,12 +62,13 @@ else
private bool UpgradeAvailable(string moduledefinitionname, string version) private bool UpgradeAvailable(string moduledefinitionname, string version)
{ {
bool upgradeavailable = false; var upgradeavailable = false;
Package package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault(); var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault();
if (package != null) if (package != null)
{ {
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
} }
return upgradeavailable; return upgradeavailable;
} }

View File

@ -20,10 +20,11 @@
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string _content = string.Empty;
public override string Title { get { return "Export Module"; } }
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
public override string Title => "Export Module";
string _content = "";
private async Task ExportModule() private async Task ExportModule()
{ {

View File

@ -20,15 +20,14 @@
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string _content = string.Empty;
public override string Title { get { return "Import Module"; } }
string _content = "";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
public override string Title => "Import Module";
private async Task ImportModule() private async Task ImportModule()
{ {
if (_content != "") if (_content != string.Empty)
{ {
try try
{ {

View File

@ -91,22 +91,21 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } } private Dictionary<string, string> _containers;
public override string Title { get { return "Module Settings"; } } private string _title;
private string _containerType;
private string _permissionNames = "";
private string _permissions;
private string _pageId;
private PermissionGrid _permissionGrid;
private Type _settingsModuleType;
private string _settingstitle = "Other Settings";
private object _settings;
Dictionary<string, string> _containers; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
string _title; public override string Title => "Module Settings";
string _containerType;
string _permissionNames = "";
string _permissions;
string _pageId;
PermissionGrid _permissionGrid; private RenderFragment DynamicComponent { get; set; }
Type _settingsModuleType;
string _settingstitle = "Other Settings";
RenderFragment DynamicComponent { get; set; }
object _settings;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -134,20 +133,21 @@
private async Task SaveModule() private async Task SaveModule()
{ {
Module module = ModuleState; var module = ModuleState;
module.Permissions = _permissionGrid.GetPermissions(); module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module); await ModuleService.UpdateModuleAsync(module);
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
pagemodule.PageId = int.Parse(_pageId); pagemodule.PageId = int.Parse(_pageId);
pagemodule.Title = _title; pagemodule.Title = _title;
pagemodule.ContainerType = _containerType; pagemodule.ContainerType = _containerType;
await PageModuleService.UpdatePageModuleAsync(pagemodule); await PageModuleService.UpdatePageModuleAsync(pagemodule);
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
if (_settingsModuleType != null) if (_settingsModuleType != null)
{ {
Type moduleType = Type.GetType(ModuleState.ModuleType); var moduleType = Type.GetType(ModuleState.ModuleType);
if (moduleType != null) if (moduleType != null)
{ {
moduleType.GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component moduleType.GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component

View File

@ -118,7 +118,7 @@
</td> </td>
<td> <td>
<select class="form-control" @onchange="(e => ThemeChanged(e))"> <select class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value=string.Empty>&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
<option value="@item.Key">@item.Value</option> <option value="@item.Key">@item.Value</option>
@ -132,7 +132,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_layouttype"> <select class="form-control" @bind="@_layouttype">
<option value="">&lt;Select Layout&gt;</option> <option value=string.Empty>&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@panelayout.Key">@panelayout.Value</option>
@ -160,30 +160,26 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private List<Theme> _themeList;
private List<Page> _pageList;
private string _name;
private string _path = string.Empty;
private string _parentid;
private string _insert = ">>";
private List<Page> _children;
private int _childid = -1;
private string _isnavigation = "True";
private string _ispersonalizable = "False";
private string _mode = "view";
private string _themetype = string.Empty;
private string _layouttype = string.Empty;
private string _icon = string.Empty;
private string _permissions = string.Empty;
private PermissionGrid _permissionGrid;
Dictionary<string, string> _themes = new Dictionary<string, string>(); public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
List<Theme> _themeList;
List<Page> _pageList;
string _name = "";
string _title = "";
string _path = "";
string _parentid;
string _insert = ">>";
List<Page> _children;
int _childid = -1;
string _url = "";
string _isnavigation = "True";
string _ispersonalizable = "False";
string _mode = "view";
string _themetype = "";
string _layouttype = "";
string _icon = "";
string _permissions = "";
PermissionGrid _permissionGrid;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -199,7 +195,7 @@
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = PageState.Site.DefaultLayoutType; _layouttype = PageState.Site.DefaultLayoutType;
_permissions = ""; _permissions = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -235,7 +231,7 @@
try try
{ {
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "") if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
} }
@ -243,6 +239,7 @@
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
} }
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -257,7 +254,7 @@
Page page = null; Page page = null;
try try
{ {
if (_name != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
{ {
page = new Page(); page = new Page();
page.SiteId = PageState.Page.SiteId; page.SiteId = PageState.Page.SiteId;
@ -267,10 +264,12 @@
{ {
_path = _name; _path = _name;
} }
if (_path.Contains("/")) if (_path.Contains("/"))
{ {
_path = _path.Substring(_path.LastIndexOf("/") + 1); _path = _path.Substring(_path.LastIndexOf("/") + 1);
} }
if (string.IsNullOrEmpty(_parentid)) if (string.IsNullOrEmpty(_parentid))
{ {
page.ParentId = null; page.ParentId = null;
@ -279,8 +278,8 @@
else else
{ {
page.ParentId = Int32.Parse(_parentid); page.ParentId = Int32.Parse(_parentid);
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault(); var parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
if (parent.Path == "") if (parent.Path == string.Empty)
{ {
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
} }
@ -289,6 +288,7 @@
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path); page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
} }
} }
Page child; Page child;
switch (_insert) switch (_insert)
{ {
@ -307,22 +307,25 @@
page.Order = int.MaxValue; page.Order = int.MaxValue;
break; break;
} }
page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation)); page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation));
page.Url = _url; page.Url = _url;
page.EditMode = (_mode == "edit" ? true : false); page.EditMode = (_mode == "edit" ? true : false);
page.ThemeType = _themetype; page.ThemeType = _themetype;
page.LayoutType = (_layouttype == null ? "" : _layouttype); page.LayoutType = (_layouttype == null ? string.Empty : _layouttype);
page.Icon = (_icon == null ? "" : _icon); page.Icon = (_icon == null ? string.Empty : _icon);
page.Permissions = _permissionGrid.GetPermissions(); page.Permissions = _permissionGrid.GetPermissions();
if (page.ThemeType == PageState.Site.DefaultThemeType) if (page.ThemeType == PageState.Site.DefaultThemeType)
{ {
page.ThemeType = ""; page.ThemeType = string.Empty;
} }
if (page.LayoutType == PageState.Site.DefaultLayoutType) if (page.LayoutType == PageState.Site.DefaultLayoutType)
{ {
page.LayoutType = ""; page.LayoutType = string.Empty;
} }
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable)); page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
page.UserId = null; page.UserId = null;

View File

@ -129,7 +129,7 @@
</td> </td>
<td> <td>
<select class="form-control" @onchange="(e => ThemeChanged(e))"> <select class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value=string.Empty>&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
if (item.Key == _themetype) if (item.Key == _themetype)
@ -150,7 +150,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_layouttype"> <select class="form-control" @bind="@_layouttype">
<option value="">&lt;Select Layout&gt;</option> <option value=string.Empty>&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@panelayout.Key">@panelayout.Value</option>
@ -181,41 +181,38 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
Dictionary<string, string> _themes = new Dictionary<string, string>(); private List<Theme> _themeList;
Dictionary<string, string> _panelayouts = new Dictionary<string, string>(); private List<Page> _pageList;
private int _pageId;
List<Theme> _themeList; private string _name;
List<Page> _pageList; private string _path;
int _pageId; private string _currentparentid;
string _name = ""; private string _parentid;
string _title = ""; private string _insert = "=";
string _path = ""; private List<Page> _children;
string _currentparentid; private int _childid = -1;
string _parentid; private string _isnavigation;
string _insert = "="; private string _ispersonalizable;
List<Page> _children; private string _mode;
int _childid = -1; private string _themetype;
string _isnavigation; private string _layouttype;
string _url = ""; private string _icon;
string _ispersonalizable; private string _permissions;
string _mode; private string _createdby;
string _themetype; private DateTime _createdon;
string _layouttype; private string _modifiedby;
string _icon; private DateTime _modifiedon;
string _permissions; private string _deletedby;
string _createdby; private DateTime? _deletedon;
DateTime _createdon;
string _modifiedby;
DateTime _modifiedon;
string _deletedby;
DateTime? _deletedon;
#pragma warning disable 649 #pragma warning disable 649
PermissionGrid _permissionGrid; private PermissionGrid _permissionGrid;
#pragma warning restore 649 #pragma warning restore 649
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
@ -227,24 +224,27 @@
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeTypes(_themeList);
_pageId = Int32.Parse(PageState.QueryString["id"]); _pageId = Int32.Parse(PageState.QueryString["id"]);
Page page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
if (page != null) if (page != null)
{ {
_name = page.Name; _name = page.Name;
_title = page.Title; _title = page.Title;
_path = page.Path; _path = page.Path;
if (_path.Contains("/")) if (_path.Contains("/"))
{ {
_path = _path.Substring(_path.LastIndexOf("/") + 1); _path = _path.Substring(_path.LastIndexOf("/") + 1);
} }
if (page.ParentId == null) if (page.ParentId == null)
{ {
_parentid = ""; _parentid = string.Empty;
} }
else else
{ {
_parentid = page.ParentId.ToString(); _parentid = page.ParentId.ToString();
} }
_currentparentid = _parentid; _currentparentid = _parentid;
_isnavigation = page.IsNavigation.ToString(); _isnavigation = page.IsNavigation.ToString();
_url = page.Url; _url = page.Url;
@ -305,7 +305,7 @@
try try
{ {
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "") if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
} }
@ -327,7 +327,7 @@
Page page = null; Page page = null;
try try
{ {
if (_name != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)))
{ {
page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
string currentPath = page.Path; string currentPath = page.Path;
@ -335,6 +335,7 @@
page.Name = _name; page.Name = _name;
page.Title = _title; page.Title = _title;
if (_path == "" && _name.ToLower() != "home") if (_path == "" && _name.ToLower() != "home")
if (_path == string.Empty && _name.ToLower() != "home")
{ {
_path = _name; _path = _name;
} }
@ -351,7 +352,7 @@
{ {
page.ParentId = Int32.Parse(_parentid); page.ParentId = Int32.Parse(_parentid);
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId); Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == "") if (parent.Path == string.Empty)
{ {
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
} }
@ -385,24 +386,24 @@
page.Url = _url; page.Url = _url;
page.EditMode = (_mode == "edit"); page.EditMode = (_mode == "edit");
page.ThemeType = _themetype; page.ThemeType = _themetype;
page.LayoutType = _layouttype ?? ""; page.LayoutType = _layouttype ?? string.Empty;
page.Icon = _icon ?? ""; page.Icon = _icon ?? string.Empty;
page.Permissions = _permissionGrid.GetPermissions(); page.Permissions = _permissionGrid.GetPermissions();
if (page.ThemeType == PageState.Site.DefaultThemeType) if (page.ThemeType == PageState.Site.DefaultThemeType)
{ {
page.ThemeType = ""; page.ThemeType = string.Empty;
} }
if (page.LayoutType == PageState.Site.DefaultLayoutType) if (page.LayoutType == PageState.Site.DefaultLayoutType)
{ {
page.LayoutType = ""; page.LayoutType = string.Empty;
} }
page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable)); page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
page.UserId = null; page.UserId = null;
page = await PageService.UpdatePageAsync(page); page = await PageService.UpdatePageAsync(page);
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId); await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
if (_currentparentid == "") if (_currentparentid == string.Empty)
{ {
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null); await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null);
} }

View File

@ -22,13 +22,14 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
private async Task DeletePage(Page page) private async Task DeletePage(Page page)
{ {
try try
{ {
page.IsDeleted = true; page.IsDeleted = true;
await PageService.UpdatePageAsync(page); await PageService.UpdatePageAsync(page);
await logger.LogInformation("Page Deleted {Page}", page); await logger.LogInformation("Page Deleted {Page}", page);
NavigationManager.NavigateTo(NavigateUrl("admin/pages")); NavigationManager.NavigateTo(NavigateUrl("admin/pages"));

View File

@ -87,19 +87,20 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int _profileid = -1;
public override string Actions { get { return "Add,Edit"; } } private string _name = string.Empty;
private string _title = string.Empty;
private string _description = string.Empty;
private string _category = string.Empty;
private string _vieworder = "0";
private string _maxlength = "0";
private string _defaultvalue = string.Empty;
private string _isrequired = "False";
private string _isprivate = "False";
int _profileid = -1; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string _name = "";
string _title = ""; public override string Actions => "Add,Edit";
string _description = "";
string _category = "";
string _vieworder = "0";
string _maxlength = "0";
string _defaultvalue = "";
string _isrequired = "False";
string _isprivate = "False";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -108,7 +109,7 @@
if (PageState.QueryString.ContainsKey("id")) if (PageState.QueryString.ContainsKey("id"))
{ {
_profileid = Int32.Parse(PageState.QueryString["id"]); _profileid = Int32.Parse(PageState.QueryString["id"]);
Profile profile = await ProfileService.GetProfileAsync(_profileid); var profile = await ProfileService.GetProfileAsync(_profileid);
if (profile != null) if (profile != null)
{ {
_name = profile.Name; _name = profile.Name;
@ -143,6 +144,7 @@
{ {
profile = new Profile(); profile = new Profile();
} }
profile.Name = _name; profile.Name = _name;
profile.Title = _title; profile.Title = _title;
profile.Description = _description; profile.Description = _description;
@ -153,6 +155,7 @@
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired)); profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate)); profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
profile = await ProfileService.UpdateProfileAsync(profile); profile = await ProfileService.UpdateProfileAsync(profile);
await logger.LogInformation("Profile Saved {Profile}", profile); await logger.LogInformation("Profile Saved {Profile}", profile);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }

View File

@ -25,9 +25,9 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<Profile> _profiles;
List<Profile> _profiles; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

View File

@ -81,10 +81,10 @@
</div> </div>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<Page> _pages;
private List<Module> _modules;
List<Page> _pages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
List<Module> _modules;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -147,7 +147,7 @@
{ {
try try
{ {
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId); var pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
pagemodule.IsDeleted = false; pagemodule.IsDeleted = false;
await PageModuleService.UpdatePageModuleAsync(pagemodule); await PageModuleService.UpdatePageModuleAsync(pagemodule);
await logger.LogInformation("Module Restored {Module}", module); await logger.LogInformation("Module Restored {Module}", module);
@ -168,10 +168,12 @@
await PageModuleService.DeletePageModuleAsync(module.PageModuleId); await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
// check if there are any remaining module instances in the site // check if there are any remaining module instances in the site
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId); _modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
if (!_modules.Exists(item => item.ModuleId == module.ModuleId)) if (!_modules.Exists(item => item.ModuleId == module.ModuleId))
{ {
await ModuleService.DeleteModuleAsync(module.ModuleId); await ModuleService.DeleteModuleAsync(module.ModuleId);
} }
await logger.LogInformation("Module Permanently Deleted {Module}", module); await logger.LogInformation("Module Permanently Deleted {Module}", module);
await Load(); await Load();
StateHasChanged(); StateHasChanged();

View File

@ -3,7 +3,7 @@
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject IUserService UserService @inject IUserService UserService
@if (_message != "") @if (_message != string.Empty)
{ {
<ModuleMessage Message="@_message" Type="MessageType.Info" /> <ModuleMessage Message="@_message" Type="MessageType.Info" />
} }
@ -34,31 +34,32 @@
</div> </div>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } private string _message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
private string _username = string.Empty;
private string _password = string.Empty;
private string _confirm = string.Empty;
private string _email = string.Empty;
private string _displayName = string.Empty;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
string _message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
string _username = "";
string _password = "";
string _confirm = "";
string _email = "";
string _displayName = "";
bool _isEmailValid = false;
private async Task Register() private async Task Register()
{ {
try try
{ {
_message = ""; _message = string.Empty;
_isEmailValid = Utilities.IsValidEmail(_email); _isEmailValid = Utilities.IsValidEmail(_email);
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
{ {
if (_password == _confirm) if (_password == _confirm)
{ {
User user = new User var user = new User
{ {
SiteId = PageState.Site.SiteId, SiteId = PageState.Site.SiteId,
Username = _username, Username = _username,
DisplayName = (_displayName == "" ? _username : _displayName), DisplayName = (_displayName == string.Empty ? _username : _displayName),
Email = _email, Email = _email,
Password = _password Password = _password
}; };
@ -94,6 +95,5 @@
private void Cancel() private void Cancel()
{ {
NavigationManager.NavigateTo(NavigateUrl("")); NavigationManager.NavigateTo(NavigateUrl(string.Empty));
}
} }

View File

@ -21,11 +21,11 @@
</div> </div>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } private string _username = string.Empty;
private string _password = string.Empty;
private string _confirm = string.Empty;
string _username = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
string _password = "";
string _confirm = "";
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -35,7 +35,7 @@
} }
else else
{ {
NavigationManager.NavigateTo(NavigateUrl("")); NavigationManager.NavigateTo(NavigateUrl(string.Empty));
} }
} }
@ -43,11 +43,11 @@
{ {
try try
{ {
if (_username != "" && _password != "" && _confirm != "") if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty)
{ {
if (_password == _confirm) if (_password == _confirm)
{ {
User user = new User var user = new User
{ {
SiteId = PageState.Site.SiteId, SiteId = PageState.Site.SiteId,
Username = _username, Username = _username,
@ -85,6 +85,6 @@
private void Cancel() private void Cancel()
{ {
NavigationManager.NavigateTo(NavigateUrl("")); NavigationManager.NavigateTo(NavigateUrl(string.Empty));
} }
} }

View File

@ -36,15 +36,15 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string _name = string.Empty;
private string _description = string.Empty;
private string _isautoassigned = "False";
string _name = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string _description = "";
string _isautoassigned = "False";
private async Task SaveRole() private async Task SaveRole()
{ {
Role role = new Role(); var role = new Role();
role.SiteId = PageState.Page.SiteId; role.SiteId = PageState.Page.SiteId;
role.Name = _name; role.Name = _name;
role.Description = _description; role.Description = _description;

View File

@ -36,19 +36,19 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int _roleid;
private string _name = string.Empty;
private string _description = string.Empty;
private string _isautoassigned = "False";
int _roleid; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string _name = "";
string _description = "";
string _isautoassigned = "False";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
_roleid = Int32.Parse(PageState.QueryString["id"]); _roleid = Int32.Parse(PageState.QueryString["id"]);
Role role = await RoleService.GetRoleAsync(_roleid); var role = await RoleService.GetRoleAsync(_roleid);
if (role != null) if (role != null)
{ {
_name = role.Name; _name = role.Name;
@ -65,7 +65,7 @@
private async Task SaveRole() private async Task SaveRole()
{ {
Role role = await RoleService.GetRoleAsync(_roleid); var role = await RoleService.GetRoleAsync(_roleid);
role.Name = _name; role.Name = _name;
role.Description = _description; role.Description = _description;
role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned)); role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned));

View File

@ -25,9 +25,9 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<Role> _roles;
List<Role> _roles; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {

View File

@ -56,7 +56,7 @@
</td> </td>
<td> <td>
<select class="form-control" @onchange="(e => ThemeChanged(e))"> <select class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value=string.Empty>&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
if (item.Key == _themetype) if (item.Key == _themetype)
@ -77,7 +77,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_layouttype"> <select class="form-control" @bind="@_layouttype">
<option value="">&lt;Select Layout&gt;</option> <option value=string.Empty>&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@panelayout.Key">@panelayout.Value</option>
@ -91,7 +91,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_containertype"> <select class="form-control" @bind="@_containertype">
<option value="">&lt;Select Container&gt;</option> <option value=string.Empty>&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (KeyValuePair<string, string> container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.Key">@container.Value</option>
@ -216,46 +216,34 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private Dictionary<string, string> _themes;
private Dictionary<string, string> _panelayouts;
private Dictionary<string, string> _containers;
private List<Theme> _themeList;
private string _name = string.Empty;
private List<Tenant> _tenantList;
private string _tenant = string.Empty;
private List<Alias> _aliasList;
private string _urls = string.Empty;
private int _logofileid = -1;
private FileManager _filemanager;
private string _themetype;
private string _layouttype;
private string _containertype
private string _smtphost = string.Empty;
private string _smtpport = string.Empty;
private string _smtpssl = string.Empty;
private string _smtpusername = string.Empty;
private string _smtppassword = string.Empty;
private string _createdby;
private DateTime _createdon;
private string _modifiedby;
private DateTime _modifiedon;
private string _deletedby;
private DateTime? _deletedon;
private string _isdeleted;
Dictionary<string, string> _themes; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
Dictionary<string, string> _panelayouts;
Dictionary<string, string> _containers;
List<Theme> _themeList;
string _name = "";
List<Tenant> _tenantList;
string _tenant = "";
List<Alias> _aliasList;
string _urls = "";
int _logofileid = -1;
FileManager _logofilemanager;
int _faviconfileid = -1;
FileManager _faviconfilemanager;
string _themetype;
string _layouttype;
string _containertype;
string _allowregistration;
string _smtphost = "";
string _smtpport = "";
string _smtpssl = "";
string _smtpusername = "";
string _smtppassword = "";
string _pwaisenabled;
int _pwaappiconfileid = -1;
FileManager _pwaappiconfilemanager;
int _pwasplashiconfileid = -1;
FileManager _pwasplashiconfilemanager;
string _createdby;
DateTime _createdon;
string _modifiedby;
DateTime _modifiedon;
string _deletedby;
DateTime? _deletedon;
string _isdeleted;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -277,22 +265,36 @@
{ {
_logofileid = site.LogoFileId.Value; _logofileid = site.LogoFileId.Value;
} }
if (site.FaviconFileId != null) if (site.FaviconFileId != null)
{ {
_faviconfileid = site.FaviconFileId.Value; _faviconfileid = site.FaviconFileId.Value;
} }
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_allowregistration = site.AllowRegistration.ToString(); _allowregistration = site.AllowRegistration.ToString();
Dictionary<string, string> settings = await SettingService.GetSiteSettingsAsync(site.SiteId); var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
_smtphost = SettingService.GetSetting(settings, "SMTPHost", ""); _smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
_smtpport = SettingService.GetSetting(settings, "SMTPPort", ""); _smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", ""); _smtpssl = SettingService.GetSetting(settings, "SMTPSSL", string.Empty);
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", ""); _smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", ""); _smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);
_pwaisenabled = site.PwaIsEnabled.ToString();
if (site.PwaAppIconFileId != null)
{
_pwaappiconfileid = site.PwaAppIconFileId.Value;
}
if (site.PwaSplashIconFileId != null)
{
_pwasplashiconfileid = site.PwaSplashIconFileId.Value;
}
_pwaisenabled = site.PwaIsEnabled.ToString(); _pwaisenabled = site.PwaIsEnabled.ToString();
if (site.PwaAppIconFileId != null) if (site.PwaAppIconFileId != null)
@ -328,7 +330,7 @@
try try
{ {
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "") if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
} }
@ -349,9 +351,9 @@
{ {
try try
{ {
if (_name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
{ {
bool unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId)) if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
@ -359,36 +361,35 @@
unique = false; unique = false;
} }
} }
if (unique) if (unique)
{ {
Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId, PageState.Alias); var site = await SiteService.GetSiteAsync(PageState.Site.SiteId, PageState.Alias);
if (site != null) if (site != null)
{ {
site.Name = _name; site.Name = _name;
site.LogoFileId = null; site.LogoFileId = null;
int logofileid = _logofilemanager.GetFileId(); var logofileid = _filemanager.GetFileId();
if (logofileid != -1) if (logofileid != -1)
{ {
site.LogoFileId = logofileid; site.LogoFileId = logofileid;
} }
int faviconfileid = _faviconfilemanager.GetFileId();
if (faviconfileid != -1)
{
site.FaviconFileId = faviconfileid;
}
site.DefaultThemeType = _themetype; site.DefaultThemeType = _themetype;
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype); site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype);
site.DefaultContainerType = _containertype; site.DefaultContainerType = _containertype;
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));
site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled)); site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));
int pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
if (pwaappiconfileid != -1) if (pwaappiconfileid != -1)
{ {
site.PwaAppIconFileId = pwaappiconfileid; site.PwaAppIconFileId = pwaappiconfileid;
} }
int pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
if (pwasplashiconfileid != -1) if (pwasplashiconfileid != -1)
{ {
site.PwaSplashIconFileId = pwasplashiconfileid; site.PwaSplashIconFileId = pwasplashiconfileid;
@ -397,7 +398,7 @@
site = await SiteService.UpdateSiteAsync(site, PageState.Alias); site = await SiteService.UpdateSiteAsync(site, PageState.Alias);
_urls = _urls.Replace("\n", ","); _urls = _urls.Replace("\n", ",");
string[] names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
{ {
if (!names.Contains(alias.Name)) if (!names.Contains(alias.Name))
@ -405,6 +406,7 @@
await AliasService.DeleteAliasAsync(alias.AliasId); await AliasService.DeleteAliasAsync(alias.AliasId);
} }
} }
foreach (string name in names) foreach (string name in names)
{ {
if (!_aliasList.Exists(item => item.Name == name)) if (!_aliasList.Exists(item => item.Name == name))
@ -417,7 +419,7 @@
} }
} }
Dictionary<string, string> settings = await SettingService.GetSiteSettingsAsync(site.SiteId); var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
SettingService.SetSetting(settings, "SMTPHost", _smtphost); SettingService.SetSetting(settings, "SMTPHost", _smtphost);
SettingService.SetSetting(settings, "SMTPPort", _smtpport); SettingService.SetSetting(settings, "SMTPPort", _smtpport);
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl); SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);

View File

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

View File

@ -39,7 +39,7 @@
</td> </td>
<td> <td>
<select class="form-control" @onchange="(e => ThemeChanged(e))"> <select class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value=string.Empty>&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
if (item.Key == _themetype) if (item.Key == _themetype)
@ -60,7 +60,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_layouttype"> <select class="form-control" @bind="@_layouttype">
<option value="">&lt;Select Layout&gt;</option> <option value=string.Empty>&lt;Select Layout&gt;</option>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key">@panelayout.Value</option> <option value="@panelayout.Key">@panelayout.Value</option>
@ -74,7 +74,7 @@
</td> </td>
<td> <td>
<select class="form-control" @bind="@_containertype"> <select class="form-control" @bind="@_containertype">
<option value="">&lt;Select Container&gt;</option> <option value=string.Empty>&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (KeyValuePair<string, string> container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.Key">@container.Value</option>
@ -103,30 +103,28 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private Dictionary<string, string> _themes;
private Dictionary<string, string> _panelayouts;
private Dictionary<string, string> _containers;
private Alias _alias;
private List<Theme> _themeList;
private string _name = string.Empty;
private List<Tenant> _tenantList;
private string _tenant = string.Empty;
private List<Alias> _aliasList;
private string _urls = string.Empty;
private string _themetype;
private string _layouttype;
private string _containertype;
private string _createdby;
private DateTime _createdon;
private string _modifiedby;
private DateTime _modifiedon;
private string _deletedby;
private DateTime? _deletedon;
private string _isdeleted;
Dictionary<string, string> _themes; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
Dictionary<string, string> _panelayouts;
Dictionary<string, string> _containers;
Alias _alias;
List<Theme> _themeList;
string _name = "";
List<Tenant> _tenantList;
string _tenant = "";
List<Alias> _aliasList;
string _urls = "";
string _themetype;
string _layouttype;
string _containertype;
string _createdby;
DateTime _createdon;
string _modifiedby;
DateTime _modifiedon;
string _deletedby;
DateTime? _deletedon;
string _isdeleted;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -136,21 +134,22 @@
_aliasList = await AliasService.GetAliasesAsync(); _aliasList = await AliasService.GetAliasesAsync();
_alias = _aliasList.Find(item => item.AliasId == Int32.Parse(PageState.QueryString["id"])); _alias = _aliasList.Find(item => item.AliasId == Int32.Parse(PageState.QueryString["id"]));
Site site = await SiteService.GetSiteAsync(_alias.SiteId, _alias); var site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
if (site != null) if (site != null)
{ {
_name = site.Name; _name = site.Name;
_tenantList = await TenantService.GetTenantsAsync(); _tenantList = await TenantService.GetTenantsAsync();
_tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name; _tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name;
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
{ {
_urls += alias.Name + "\n"; _urls += alias.Name + "\n";
} }
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_createdby = site.CreatedBy; _createdby = site.CreatedBy;
_createdon = site.CreatedOn; _createdon = site.CreatedOn;
_modifiedby = site.ModifiedBy; _modifiedby = site.ModifiedBy;
@ -165,7 +164,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
await Log(_alias, LogLevel.Error, "", ex, "Error Loading Site {SiteId} {Error}", _alias.SiteId, ex.Message); await Log(_alias, LogLevel.Error, string.Empty, ex, "Error Loading Site {SiteId} {Error}", _alias.SiteId, ex.Message);
AddModuleMessage(ex.Message, MessageType.Error); AddModuleMessage(ex.Message, MessageType.Error);
} }
} }
@ -175,7 +174,7 @@
try try
{ {
_themetype = (string)e.Value; _themetype = (string)e.Value;
if (_themetype != "") if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
} }
@ -183,6 +182,7 @@
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
} }
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -196,9 +196,9 @@
{ {
try try
{ {
if (_name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
{ {
bool unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
if (_aliasList.Exists(item => item.Name == name && item.SiteId != _alias.SiteId && item.TenantId != _alias.TenantId)) if (_aliasList.Exists(item => item.Name == name && item.SiteId != _alias.SiteId && item.TenantId != _alias.TenantId))
@ -206,22 +206,24 @@
unique = false; unique = false;
} }
} }
if (unique) if (unique)
{ {
Site site = await SiteService.GetSiteAsync(_alias.SiteId, _alias); var site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
if (site != null) if (site != null)
{ {
site.Name = _name; site.Name = _name;
site.LogoFileId = null; site.LogoFileId = null;
site.DefaultThemeType = _themetype; site.DefaultThemeType = _themetype;
site.DefaultLayoutType = _layouttype ?? ""; site.DefaultLayoutType = _layouttype ?? string.Empty;
site.DefaultContainerType = _containertype; site.DefaultContainerType = _containertype;
site.IsDeleted = (_isdeleted == null || Boolean.Parse(_isdeleted)); site.IsDeleted = (_isdeleted == null || Boolean.Parse(_isdeleted));
site = await SiteService.UpdateSiteAsync(site, _alias); site = await SiteService.UpdateSiteAsync(site, _alias);
_urls = _urls.Replace("\n", ","); _urls = _urls.Replace("\n", ",");
string[] names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
{ {
if (!names.Contains(alias.Name)) if (!names.Contains(alias.Name))
@ -229,6 +231,7 @@
await AliasService.DeleteAliasAsync(alias.AliasId); await AliasService.DeleteAliasAsync(alias.AliasId);
} }
} }
foreach (string name in names) foreach (string name in names)
{ {
if (!_aliasList.Exists(item => item.Name == name)) if (!_aliasList.Exists(item => item.Name == name))
@ -260,7 +263,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
await Log(_alias, LogLevel.Error, "", ex, "Error Saving Site {SiteId} {Error}", _alias.SiteId, ex.Message); await Log(_alias, LogLevel.Error, string.Empty, ex, "Error Saving Site {SiteId} {Error}", _alias.SiteId, ex.Message);
AddModuleMessage("Error Saving Site", MessageType.Error); AddModuleMessage("Error Saving Site", MessageType.Error);
} }
} }

View File

@ -27,17 +27,17 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Alias> _sites;
private string _scheme;
List<Alias> _sites; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string _scheme;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
Uri uri = new Uri(NavigationManager.Uri); var uri = new Uri(NavigationManager.Uri);
_scheme = uri.Scheme + "://"; _scheme = uri.Scheme + "://";
List<Alias> aliases = await AliasService.GetAliasesAsync(); var aliases = await AliasService.GetAliasesAsync();
_sites = new List<Alias>(); _sites = new List<Alias>();
foreach (Alias alias in aliases) foreach (Alias alias in aliases)
{ {
@ -56,11 +56,13 @@ else
{ {
await SiteService.DeleteSiteAsync(alias.SiteId, alias); await SiteService.DeleteSiteAsync(alias.SiteId, alias);
await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId); await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId);
List<Alias> aliases = await AliasService.GetAliasesAsync();
var aliases = await AliasService.GetAliasesAsync();
foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId)) foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId))
{ {
await AliasService.DeleteAliasAsync(a.AliasId); await AliasService.DeleteAliasAsync(a.AliasId);
} }
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }
else else

View File

@ -43,12 +43,12 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Tenant> _tenants;
private string _tenantid = "-1";
private string _sql = string.Empty;
private string _results = string.Empty;
List<Tenant> _tenants; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string _tenantid = "-1";
string _sql = "";
string _results = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -59,7 +59,7 @@ else
{ {
if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql)) if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql))
{ {
SqlQuery sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql }; var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql };
sqlquery = await SqlService.ExecuteQueryAsync(sqlquery); sqlquery = await SqlService.ExecuteQueryAsync(sqlquery);
_results = DisplayResults(sqlquery.Results); _results = DisplayResults(sqlquery.Results);
} }
@ -71,27 +71,33 @@ else
private string DisplayResults(List<Dictionary<string, string>> results) private string DisplayResults(List<Dictionary<string, string>> results)
{ {
string table = ""; var table = string.Empty;
foreach (Dictionary<string, string> item in results) foreach (Dictionary<string, string> item in results)
{ {
if (table == "") if (table == string.Empty)
{ {
table = "<div class=\"table-responsive\">"; table = "<div class=\"table-responsive\">";
table += "<table class=\"table table-bordered\"><thead><tr>"; table += "<table class=\"table table-bordered\"><thead><tr>";
foreach (KeyValuePair<string, string> kvp in item) foreach (KeyValuePair<string, string> kvp in item)
{ {
table += "<th scope=\"col\">" + kvp.Key + "</th>"; table += "<th scope=\"col\">" + kvp.Key + "</th>";
} }
table += "</tr></thead><tbody>"; table += "</tr></thead><tbody>";
} }
table += "<tr>"; table += "<tr>";
foreach (KeyValuePair<string, string> kvp in item) foreach (KeyValuePair<string, string> kvp in item)
{ {
table += "<td>" + kvp.Value + "</td>"; table += "<td>" + kvp.Value + "</td>";
} }
table += "</tr>"; table += "</tr>";
} }
if (table != "")
if (table != string.Empty)
{ {
table += "</tbody></table></div>"; table += "</tbody></table></div>";
} }
@ -99,6 +105,7 @@ else
{ {
table = "No Results Returned"; table = "No Results Returned";
} }
return table; return table;
} }
} }

View File

@ -72,15 +72,16 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private string name = string.Empty;
private string type = "LocalDB";
private string server = "(LocalDb)\\MSSQLLocalDB";
private string database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
private string username = string.Empty;
private string password = string.Empty;
private string schema = string.Empty;
private string integratedsecurity = "display: none;";
string name = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string type = "LocalDB";
string server = "(LocalDb)\\MSSQLLocalDB";
string database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
string username = "";
string password = "";
string integratedsecurity = "display: none;";
private void SetIntegratedSecurity(ChangeEventArgs e) private void SetIntegratedSecurity(ChangeEventArgs e)
{ {
@ -90,7 +91,7 @@
} }
else else
{ {
integratedsecurity = ""; integratedsecurity = string.Empty;
} }
} }
@ -100,7 +101,7 @@
{ {
ShowProgressIndicator(); ShowProgressIndicator();
string connectionString = ""; var connectionstring = string.Empty;
if (type == "LocalDB") if (type == "LocalDB")
{ {
connectionString = "Data Source=" + server + ";AttachDbFilename=|DataDirectory|\\" + database + ".mdf;Initial Catalog=" + database + ";Integrated Security=SSPI;"; connectionString = "Data Source=" + server + ";AttachDbFilename=|DataDirectory|\\" + database + ".mdf;Initial Catalog=" + database + ";Integrated Security=SSPI;";
@ -108,6 +109,7 @@
else else
{ {
connectionString = "Data Source=" + server + ";Initial Catalog=" + database + ";"; connectionString = "Data Source=" + server + ";Initial Catalog=" + database + ";";
if (integratedsecurity == "display: none;") if (integratedsecurity == "display: none;")
{ {
connectionString += "Integrated Security=SSPI;"; connectionString += "Integrated Security=SSPI;";
@ -125,11 +127,11 @@
ConnectionString = connectionString, ConnectionString = connectionString,
}; };
Installation installation = await InstallationService.Install(config); var installation = await InstallationService.Install(config);
if (installation.Success) if (installation.Success)
{ {
//TODO : Move to Database Manager //TODO : Move to Database Manager
Tenant tenant = new Tenant var tenant = new Tenant
{ {
Name = name, Name = name,
DBConnectionString = connectionString, DBConnectionString = connectionString,

View File

@ -26,18 +26,19 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private int tenantid;
private string name = string.Empty;
private string connectionstring = string.Empty;
private string schema = string.Empty;
int tenantid; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
string name = "";
string connectionstring = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
tenantid = Int32.Parse(PageState.QueryString["id"]); tenantid = Int32.Parse(PageState.QueryString["id"]);
Tenant tenant = await TenantService.GetTenantAsync(tenantid); var tenant = await TenantService.GetTenantAsync(tenantid);
if (tenant != null) if (tenant != null)
{ {
name = tenant.Name; name = tenant.Name;
@ -56,11 +57,13 @@
try try
{ {
connectionstring = connectionstring.Replace("\\\\", "\\"); connectionstring = connectionstring.Replace("\\\\", "\\");
Tenant tenant = await TenantService.GetTenantAsync(tenantid); var tenant = await TenantService.GetTenantAsync(tenantid);
if (tenant != null) if (tenant != null)
{ {
tenant.Name = name; tenant.Name = name;
tenant.DBConnectionString = connectionstring; tenant.DBConnectionString = connectionstring;
tenant.DBSchema = schema;
await TenantService.UpdateTenantAsync(tenant); await TenantService.UpdateTenantAsync(tenant);
await logger.LogInformation("Tenant Saved {TenantId}", tenantid); await logger.LogInformation("Tenant Saved {TenantId}", tenantid);

View File

@ -26,9 +26,9 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Tenant> tenants;
List<Tenant> tenants; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {

View File

@ -41,14 +41,15 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Package> packages;
List<Package> packages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
List<Theme> themes = await ThemeService.GetThemesAsync(); var themes = await ThemeService.GetThemesAsync();
packages = await PackageService.GetPackagesAsync("theme"); packages = await PackageService.GetPackagesAsync("theme");
foreach(Package package in packages.ToArray()) foreach(Package package in packages.ToArray())
{ {
if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId)) if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId))

View File

@ -39,10 +39,10 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private List<Theme> themes;
private List<Package> packages;
List<Theme> themes; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
List<Package> packages;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -52,12 +52,13 @@ else
private bool UpgradeAvailable(string themename, string version) private bool UpgradeAvailable(string themename, string version)
{ {
bool upgradeavailable = false; var upgradeavailable = false;
Package package = packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault(); var package = packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault();
if (package != null) if (package != null)
{ {
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
} }
return upgradeavailable; return upgradeavailable;
} }

View File

@ -26,14 +26,14 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } private bool upgradeavailable = false;
bool upgradeavailable = false; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
List<Package> packages = await PackageService.GetPackagesAsync("framework"); var packages = await PackageService.GetPackagesAsync("framework");
Package package = packages.FirstOrDefault(); var package = packages.FirstOrDefault();
if (package != null) if (package != null)
{ {
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0); upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);

View File

@ -46,13 +46,14 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } private List<UserRole> userroles;
public override string Title { get { return "Send Notification"; } } private string userid = "-1";
private string subject = "";
private string body = "";
List<UserRole> userroles; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
string userid = "-1";
string subject = ""; public override string Title => "Send Notification";
string body = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -71,7 +72,7 @@
private async Task Send() private async Task Send()
{ {
Notification notification = new Notification(); var notification = new Notification();
try try
{ {
notification.SiteId = PageState.Site.SiteId; notification.SiteId = PageState.Site.SiteId;

View File

@ -172,20 +172,20 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } private string username = string.Empty;
private string password = string.Empty;
private string confirm = string.Empty;
private string email = string.Empty;
private string displayname = string.Empty;
private FileManager filemanager;
private int photofileid = -1;
private List<Profile> profiles;
private Dictionary<string, string> settings;
private string category = string.Empty;
private string filter = "to";
private List<Notification> notifications;
string username = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
string password = "";
string confirm = "";
string email = "";
string displayname = "";
FileManager filemanager;
int photofileid = -1;
List<Profile> profiles;
Dictionary<string, string> settings;
string category = "";
string filter = "to";
List<Notification> notifications;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -196,12 +196,15 @@
username = PageState.User.Username; username = PageState.User.Username;
email = PageState.User.Email; email = PageState.User.Email;
displayname = PageState.User.DisplayName; displayname = PageState.User.DisplayName;
if (PageState.User.PhotoFileId != null) if (PageState.User.PhotoFileId != null)
{ {
photofileid = PageState.User.PhotoFileId.Value; photofileid = PageState.User.PhotoFileId.Value;
} }
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId); profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
await LoadNotificationsAsync(); await LoadNotificationsAsync();
} }
else else
@ -223,29 +226,29 @@
} }
private string GetProfileValue(string SettingName, string DefaultValue) private string GetProfileValue(string SettingName, string DefaultValue)
{ => SettingService.GetSetting(settings, SettingName, DefaultValue);
return SettingService.GetSetting(settings, SettingName, DefaultValue);
}
private async Task Save() private async Task Save()
{ {
try try
{ {
if (username != "" && email != "") if (username != string.Empty && email != string.Empty)
{ {
if (password == confirm) if (password == confirm)
{ {
User user = PageState.User; var user = PageState.User;
user.Username = username; user.Username = username;
user.Password = password; user.Password = password;
user.Email = email; user.Email = email;
user.DisplayName = (displayname == "" ? username : displayname); user.DisplayName = (displayname == string.Empty ? username : displayname);
user.PhotoFileId = null; user.PhotoFileId = null;
photofileid = filemanager.GetFileId(); photofileid = filemanager.GetFileId();
if (photofileid != -1) if (photofileid != -1)
{ {
user.PhotoFileId = photofileid; user.PhotoFileId = photofileid;
} }
await UserService.UpdateUserAsync(user); await UserService.UpdateUserAsync(user);
await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId); await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId);
await logger.LogInformation("User Profile Saved"); await logger.LogInformation("User Profile Saved");
@ -269,12 +272,12 @@
private void Cancel() private void Cancel()
{ {
NavigationManager.NavigateTo(NavigateUrl("")); NavigationManager.NavigateTo(NavigateUrl(string.Empty));
} }
private void ProfileChanged(ChangeEventArgs e, string SettingName) private void ProfileChanged(ChangeEventArgs e, string SettingName)
{ {
string value = (string)e.Value; var value = (string)e.Value;
settings = SettingService.SetSetting(settings, SettingName, value); settings = SettingService.SetSetting(settings, SettingName, value);
} }
@ -291,6 +294,7 @@
{ {
await NotificationService.DeleteNotificationAsync(Notification.NotificationId); await NotificationService.DeleteNotificationAsync(Notification.NotificationId);
} }
await logger.LogInformation("Notification Deleted {Notification}", Notification); await logger.LogInformation("Notification Deleted {Notification}", Notification);
await LoadNotificationsAsync(); await LoadNotificationsAsync();
StateHasChanged(); StateHasChanged();
@ -305,6 +309,7 @@
private async void FilterChanged(ChangeEventArgs e) private async void FilterChanged(ChangeEventArgs e)
{ {
filter = (string)e.Value; filter = (string)e.Value;
await LoadNotificationsAsync(); await LoadNotificationsAsync();
StateHasChanged(); StateHasChanged();
} }

View File

@ -52,7 +52,7 @@
</td> </td>
</tr> </tr>
</table> </table>
@if (reply != "") @if (reply != string.Empty)
{ {
<button type="button" class="btn btn-primary" @onclick="Send">Send</button> <button type="button" class="btn btn-primary" @onclick="Send">Send</button>
} }
@ -70,17 +70,17 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } private int notificationid;
public override string Title { get { return "View Notification"; } } private string title = string.Empty;
private List<UserRole> userroles;
private string userid = "-1";
private string subject = string.Empty;
private string createdon = string.Empty;
private string body = string.Empty;
private string reply = string.Empty;
int notificationid; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
string title = ""; public override string Title => "View Notification";
List<UserRole> userroles;
string userid = "-1";
string subject = "";
string createdon = "";
string body = "";
string reply = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -110,6 +110,7 @@
userid = notification.ToUserId.ToString(); userid = notification.ToUserId.ToString();
} }
} }
subject = notification.Subject; subject = notification.Subject;
createdon = notification.CreatedOn.ToString(); createdon = notification.CreatedOn.ToString();
body = notification.Body; body = notification.Body;
@ -132,11 +133,11 @@
private async Task Send() private async Task Send()
{ {
Notification notification = new Notification(); var notification = new Notification();
notification.SiteId = PageState.Site.SiteId; notification.SiteId = PageState.Site.SiteId;
notification.FromUserId = PageState.User.UserId; notification.FromUserId = PageState.User.UserId;
notification.ToUserId = int.Parse(userid); notification.ToUserId = int.Parse(userid);
notification.ToEmail = ""; notification.ToEmail = string.Empty;
notification.Subject = subject; notification.Subject = subject;
notification.Body = body; notification.Body = body;
notification.ParentId = notificationid; notification.ParentId = notificationid;

View File

@ -76,16 +76,16 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private string username = string.Empty;
private string password = string.Empty;
private string confirm = string.Empty;
private string email = string.Empty;
private string displayname = string.Empty;
private List<Profile> profiles;
private Dictionary<string, string> settings;
private string category = string.Empty;
string username = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string password = "";
string confirm = "";
string email = "";
string displayname = "";
List<Profile> profiles;
Dictionary<string, string> settings;
string category = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -105,11 +105,11 @@
{ {
try try
{ {
if (username != "" && password != "" && confirm != "" && email != "") if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty)
{ {
if (password == confirm) if (password == confirm)
{ {
User user = new User(); var user = new User();
user.SiteId = PageState.Site.SiteId; user.SiteId = PageState.Site.SiteId;
user.Username = username; user.Username = username;
user.Password = password; user.Password = password;
@ -150,7 +150,7 @@
private void ProfileChanged(ChangeEventArgs e, string SettingName) private void ProfileChanged(ChangeEventArgs e, string SettingName)
{ {
string value = (string)e.Value; var value = (string)e.Value;
settings = SettingService.SetSetting(settings, SettingName, value); settings = SettingService.SetSetting(settings, SettingName, value);
} }

View File

@ -106,26 +106,26 @@
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int userid;
private string username = string.Empty;
private string password = string.Empty;
private string confirm = string.Empty;
private string email = string.Empty;
private string displayname = string.Empty;
private FileManager filemanager;
private int photofileid = -1;
private List<Profile> profiles;
private Dictionary<string, string> settings;
private string category = string.Empty;
private string createdby;
private DateTime createdon;
private string modifiedby;
private DateTime modifiedon;
private string deletedby;
private DateTime? deletedon;
private string isdeleted;
int userid; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
string username = "";
string password = "";
string confirm = "";
string email = "";
string displayname = "";
FileManager filemanager;
int photofileid = -1;
List<Profile> profiles;
Dictionary<string, string> settings;
string category = "";
string createdby;
DateTime createdon;
string modifiedby;
DateTime modifiedon;
string deletedby;
DateTime? deletedon;
string isdeleted;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -134,16 +134,18 @@
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId); profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
userid = Int32.Parse(PageState.QueryString["id"]); userid = Int32.Parse(PageState.QueryString["id"]);
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
username = user.Username; username = user.Username;
email = user.Email; email = user.Email;
displayname = user.DisplayName; displayname = user.DisplayName;
if (user.PhotoFileId != null) if (user.PhotoFileId != null)
{ {
photofileid = user.PhotoFileId.Value; photofileid = user.PhotoFileId.Value;
} }
settings = await SettingService.GetUserSettingsAsync(user.UserId); settings = await SettingService.GetUserSettingsAsync(user.UserId);
createdby = user.CreatedBy; createdby = user.CreatedBy;
createdon = user.CreatedOn; createdon = user.CreatedOn;
@ -162,19 +164,17 @@
} }
private string GetProfileValue(string SettingName, string DefaultValue) private string GetProfileValue(string SettingName, string DefaultValue)
{ => SettingService.GetSetting(settings, SettingName, DefaultValue);
return SettingService.GetSetting(settings, SettingName, DefaultValue);
}
private async Task SaveUser() private async Task SaveUser()
{ {
try try
{ {
if (username != "" && password != "" && confirm != "" && email != "") if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty)
{ {
if (password == confirm) if (password == confirm)
{ {
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
user.SiteId = PageState.Site.SiteId; user.SiteId = PageState.Site.SiteId;
user.Username = username; user.Username = username;
user.Password = password; user.Password = password;
@ -182,10 +182,12 @@
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname; user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
user.PhotoFileId = null; user.PhotoFileId = null;
photofileid = filemanager.GetFileId(); photofileid = filemanager.GetFileId();
if (photofileid != -1) if (photofileid != -1)
{ {
user.PhotoFileId = photofileid; user.PhotoFileId = photofileid;
} }
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted)); user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
user = await UserService.UpdateUserAsync(user); user = await UserService.UpdateUserAsync(user);
@ -213,7 +215,7 @@
private void ProfileChanged(ChangeEventArgs e, string SettingName) private void ProfileChanged(ChangeEventArgs e, string SettingName)
{ {
string value = (string)e.Value; var value = (string)e.Value;
settings = SettingService.SetSetting(settings, SettingName, value); settings = SettingService.SetSetting(settings, SettingName, value);
} }

View File

@ -28,9 +28,9 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private List<UserRole> userroles;
List<UserRole> userroles; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -42,7 +42,7 @@ else
{ {
try try
{ {
User user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId); var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
if (user != null) if (user != null)
{ {
await UserService.DeleteUserAsync(user.UserId); await UserService.DeleteUserAsync(user.UserId);

View File

@ -65,14 +65,14 @@ else
} }
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } private int userid;
private List<Role> roles;
private int roleid = -1;
private string effectivedate = string.Empty;
private string expirydate = string.Empty;
private List<UserRole> userroles;
int userid; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
List<Role> roles;
int roleid = -1;
string effectivedate = "";
string expirydate = "";
List<UserRole> userroles;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -109,7 +109,7 @@ else
{ {
if (roleid != -1) if (roleid != -1)
{ {
UserRole userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault(); var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault();
if (userrole != null) if (userrole != null)
{ {
if (string.IsNullOrEmpty(effectivedate)) if (string.IsNullOrEmpty(effectivedate))
@ -120,6 +120,7 @@ else
{ {
userrole.EffectiveDate = DateTime.Parse(effectivedate); userrole.EffectiveDate = DateTime.Parse(effectivedate);
} }
if (string.IsNullOrEmpty(expirydate)) if (string.IsNullOrEmpty(expirydate))
{ {
userrole.ExpiryDate = null; userrole.ExpiryDate = null;
@ -135,6 +136,7 @@ else
userrole = new UserRole(); userrole = new UserRole();
userrole.UserId = userid; userrole.UserId = userid;
userrole.RoleId = roleid; userrole.RoleId = roleid;
if (string.IsNullOrEmpty(effectivedate)) if (string.IsNullOrEmpty(effectivedate))
{ {
userrole.EffectiveDate = null; userrole.EffectiveDate = null;
@ -143,6 +145,7 @@ else
{ {
userrole.EffectiveDate = DateTime.Parse(effectivedate); userrole.EffectiveDate = DateTime.Parse(effectivedate);
} }
if (string.IsNullOrEmpty(expirydate)) if (string.IsNullOrEmpty(expirydate))
{ {
userrole.ExpiryDate = null; userrole.ExpiryDate = null;
@ -151,8 +154,10 @@ else
{ {
userrole.ExpiryDate = DateTime.Parse(expirydate); userrole.ExpiryDate = DateTime.Parse(expirydate);
} }
await UserRoleService.AddUserRoleAsync(userrole); await UserRoleService.AddUserRoleAsync(userrole);
} }
await GetUserRoles(); await GetUserRoles();
await logger.LogInformation("User Assigned To Role {UserRole}", userrole); await logger.LogInformation("User Assigned To Role {UserRole}", userrole);
AddModuleMessage("User Assigned To Role", MessageType.Success); AddModuleMessage("User Assigned To Role", MessageType.Success);

View File

@ -39,6 +39,11 @@
} }
@code { @code {
private bool _visible = false;
private bool _editmode = true;
private bool _authorized = false;
private string _iconSpan = string.Empty;
[Parameter] [Parameter]
public string Header { get; set; } // required public string Header { get; set; } // required
@ -69,11 +74,6 @@
[Parameter] [Parameter]
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
bool _visible = false;
bool _editmode = true;
bool _authorized = false;
string _iconSpan = "";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
if (string.IsNullOrEmpty(Text)) if (string.IsNullOrEmpty(Text))

View File

@ -15,6 +15,15 @@
} }
@code { @code {
private string _text = string.Empty;
private string _url = string.Empty;
private string _parameters = string.Empty;
private string _classname = "btn btn-primary";
private string _style = string.Empty;
private bool _editmode = true;
private bool _authorized = false;
private string _iconSpan = string.Empty;
[Parameter] [Parameter]
public string Action { get; set; } // required public string Action { get; set; } // required
@ -42,15 +51,6 @@
[Parameter] [Parameter]
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
string _text = "";
string _url = "";
string _parameters = "";
string _classname = "btn btn-primary";
string _style = "";
bool _editmode = true;
bool _authorized = false;
string _iconSpan = "";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_text = Action; _text = Action;
@ -90,14 +90,14 @@
private bool IsAuthorized() private bool IsAuthorized()
{ {
bool authorized = false; var authorized = false;
if (PageState.EditMode || !_editmode) if (PageState.EditMode || !_editmode)
{ {
SecurityAccessLevel security = SecurityAccessLevel.Host; var security = SecurityAccessLevel.Host;
if (Security == null) if (Security == null)
{ {
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ","); var typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
Type moduleType = Type.GetType(typename); var moduleType = Type.GetType(typename);
if (moduleType != null) if (moduleType != null)
{ {
var moduleobject = Activator.CreateInstance(moduleType); var moduleobject = Activator.CreateInstance(moduleType);
@ -113,6 +113,7 @@
{ {
security = Security.Value; security = Security.Value;
} }
switch (security) switch (security)
{ {
case SecurityAccessLevel.Anonymous: case SecurityAccessLevel.Anonymous:
@ -132,6 +133,7 @@
break; break;
} }
} }
return authorized; return authorized;
} }
} }

View File

@ -1,12 +1,15 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleBase
@if (_text != "") @if (_text != string.Empty)
{ {
@((MarkupString)_text) @((MarkupString)_text)
} }
@code { @code {
private string _text = string.Empty;
[Parameter] [Parameter]
public string CreatedBy { get; set; } public string CreatedBy { get; set; }
@ -31,50 +34,57 @@
[Parameter] [Parameter]
public string Style { get; set; } public string Style { get; set; }
string _text = "";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_text = ""; _text = string.Empty;
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null) if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
{ {
_text += "<p style=\"" + Style + "\">Created "; _text += "<p style=\string.Empty + Style + "\">Created ";
if (!String.IsNullOrEmpty(CreatedBy)) if (!String.IsNullOrEmpty(CreatedBy))
{ {
_text += " by <b>" + CreatedBy + "</b>"; _text += " by <b>" + CreatedBy + "</b>";
} }
if (CreatedOn != null) if (CreatedOn != null)
{ {
_text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null) if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
{ {
_text += "<p style=\"" + Style + "\">Last modified "; _text += "<p style=\string.Empty + Style + "\">Last modified ";
if (!String.IsNullOrEmpty(ModifiedBy)) if (!String.IsNullOrEmpty(ModifiedBy))
{ {
_text += " by <b>" + ModifiedBy + "</b>"; _text += " by <b>" + ModifiedBy + "</b>";
} }
if (ModifiedOn != null) if (ModifiedOn != null)
{ {
_text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue) if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
{ {
_text += "<p style=\"" + Style + "\">Deleted "; _text += "<p style=\string.Empty + Style + "\">Deleted ";
if (!String.IsNullOrEmpty(DeletedBy)) if (!String.IsNullOrEmpty(DeletedBy))
{ {
_text += " by <b>" + DeletedBy + "</b>"; _text += " by <b>" + DeletedBy + "</b>";
} }
if (DeletedOn != null) if (DeletedOn != null)
{ {
_text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
} }

View File

@ -70,7 +70,7 @@
@((MarkupString)_message) @((MarkupString)_message)
} }
</div> </div>
@if (_image != "") @if (_image != string.Empty)
{ {
<div class="col-auto"> <div class="col-auto">
@((MarkupString)_image) @((MarkupString)_image)
@ -81,6 +81,21 @@
} }
@code { @code {
private string _id;
private List<Folder> _folders;
private int _folderid = -1;
private List<File> _files = new List<File>();
private int _fileid = -1;
private bool _showfiles = true;
private string _fileinputid = string.Empty;
private string _progressinfoid = string.Empty;
private string _progressbarid = string.Empty;
private string _filter = "*";
private bool _uploadmultiple = false;
private bool _haseditpermission = false;
private string _message = string.Empty;
private string _image = string.Empty;
[Parameter] [Parameter]
public string Folder { get; set; } // optional - for setting a specific folder by default public string Folder { get; set; } // optional - for setting a specific folder by default
@ -99,21 +114,6 @@
[Parameter] [Parameter]
public string UploadMultiple { get; set; } // optional - enable multiple file uploads - default false public string UploadMultiple { get; set; } // optional - enable multiple file uploads - default false
string _id;
List<Folder> _folders;
int _folderid = -1;
List<File> _files = new List<File>();
int _fileid = -1;
bool _showfiles = true;
string _fileinputid = "";
string _progressinfoid = "";
string _progressbarid = "";
string _filter = "*";
bool _uploadmultiple = false;
bool _haseditpermission = false;
string _message = "";
string _image = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (!string.IsNullOrEmpty(Folder)) if (!string.IsNullOrEmpty(Folder))
@ -205,13 +205,13 @@
private async Task FolderChanged(ChangeEventArgs e) private async Task FolderChanged(ChangeEventArgs e)
{ {
_message = ""; _message = string.Empty;
try try
{ {
_folderid = int.Parse((string)e.Value); _folderid = int.Parse((string)e.Value);
await GetFiles(); await GetFiles();
_fileid = -1; _fileid = -1;
_image = ""; _image = string.Empty;
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -223,30 +223,31 @@
private async Task FileChanged(ChangeEventArgs e) private async Task FileChanged(ChangeEventArgs e)
{ {
_message = ""; _message = string.Empty;
_fileid = int.Parse((string)e.Value); _fileid = int.Parse((string)e.Value);
await SetImage(); await SetImage();
StateHasChanged(); StateHasChanged();
} }
private async Task SetImage() private async Task SetImage()
{ {
_image = ""; _image = string.Empty;
if (_fileid != -1) if (_fileid != -1)
{ {
File file = await FileService.GetFileAsync(_fileid); File file = await FileService.GetFileAsync(_fileid);
if (file.ImageHeight != 0 && file.ImageWidth != 0) if (file.ImageHeight != 0 && file.ImageWidth != 0)
{ {
int maxwidth = 200; var maxwidth = 200;
int maxheight = 200; var maxheight = 200;
double ratioX = (double)maxwidth / (double)file.ImageWidth; var ratioX = (double)maxwidth / (double)file.ImageWidth;
double ratioY = (double)maxheight / (double)file.ImageHeight; var ratioY = (double)maxheight / (double)file.ImageHeight;
double ratio = ratioX < ratioY ? ratioX : ratioY; var ratio = ratioX < ratioY ? ratioX : ratioY;
_image = "<img src=\"" + ContentUrl(_fileid) + "\" alt=\"" + file.Name + _image = "<img src=\string.Empty + ContentUrl(_fileid) + "\" alt=\string.Empty + file.Name +
"\" width=\"" + Convert.ToInt32(file.ImageWidth * ratio).ToString() + "\" width=\string.Empty + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
"\" height=\"" + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />"; "\" height=\string.Empty + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
} }
} }
} }
@ -254,7 +255,7 @@
private async Task UploadFile() private async Task UploadFile()
{ {
var interop = new Interop(JsRuntime); var interop = new Interop(JsRuntime);
string[] upload = await interop.GetFiles(_fileinputid); var upload = await interop.GetFiles(_fileinputid);
if (upload.Length > 0) if (upload.Length > 0)
{ {
try try
@ -268,14 +269,16 @@
{ {
result = await FileService.UploadFilesAsync(_folderid, upload, _id); result = await FileService.UploadFilesAsync(_folderid, upload, _id);
} }
if (result == "")
if (result == string.Empty)
{ {
await logger.LogInformation("File Upload Succeeded {Files}", upload); await logger.LogInformation("File Upload Succeeded {Files}", upload);
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>"; _message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
await GetFiles(); await GetFiles();
if (upload.Length == 1) if (upload.Length == 1)
{ {
File file = _files.Where(item => item.Name == upload[0]).FirstOrDefault(); var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
if (file != null) if (file != null)
{ {
_fileid = file.FileId; _fileid = file.FileId;
@ -304,7 +307,8 @@
private async Task DeleteFile() private async Task DeleteFile()
{ {
_message = ""; _message = string.Empty;
try try
{ {
await FileService.DeleteFileAsync(_fileid); await FileService.DeleteFileAsync(_fileid);
@ -322,9 +326,6 @@
} }
} }
public int GetFileId() public int GetFileId() => _fileid;
{
return _fileid;
}
} }

View File

@ -11,8 +11,8 @@ else
} }
@code { @code {
string _openLabel = ""; private string _openLabel = string.Empty;
string _closeLabel = "</label>"; private string _closeLabel = "</label>";
[Parameter] [Parameter]
public RenderFragment ChildContent { get; set; } // required - the title of the label public RenderFragment ChildContent { get; set; } // required - the title of the label
@ -31,12 +31,14 @@ else
_openLabel = "<label"; _openLabel = "<label";
if (!string.IsNullOrEmpty(For)) if (!string.IsNullOrEmpty(For))
{ {
_openLabel += " for=\"" + For + "\""; _openLabel += " for=\string.Empty + For + "\string.Empty;
} }
if (!string.IsNullOrEmpty(Class)) if (!string.IsNullOrEmpty(Class))
{ {
_openLabel += " class=\"" + Class + "\""; _openLabel += " class=\string.Empty + Class + "\string.Empty;
} }
_openLabel += ">"; _openLabel += ">";
} }
} }

View File

@ -8,15 +8,15 @@
} }
@code { @code {
private string _message = string.Empty;
private string _classname = "alert alert-danger";
[Parameter] [Parameter]
public string Message { get; set; } public string Message { get; set; }
[Parameter] [Parameter]
public MessageType Type { get; set; } public MessageType Type { get; set; }
string _message = "";
string _classname = "alert alert-danger";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
if (!string.IsNullOrEmpty(Message)) if (!string.IsNullOrEmpty(Message))
@ -35,7 +35,7 @@
private string GetMessageType(MessageType type) private string GetMessageType(MessageType type)
{ {
string classname = ""; var classname = string.Empty;
switch (type) switch (type)
{ {
case MessageType.Success: case MessageType.Success:
@ -51,6 +51,7 @@
classname = "alert alert-danger"; classname = "alert alert-danger";
break; break;
} }
return classname; return classname;
} }
} }

View File

@ -64,12 +64,12 @@
</p> </p>
@code { @code {
int _pages = 0; private int _pages = 0;
int _page = 1; private int _page = 1;
int _maxItems; private int _maxItems;
int _maxPages; private int _maxPages;
int _startPage; private int _startPage;
int _endPage; private int _endPage;
[Parameter] [Parameter]
public string Format { get; set; } public string Format { get; set; }
@ -95,7 +95,7 @@
[Parameter] [Parameter]
public string Class { get; set; } public string Class { get; set; }
IEnumerable<TableItem> ItemList { get; set; } private IEnumerable<TableItem> ItemList { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
@ -103,6 +103,7 @@
{ {
Format = "Table"; Format = "Table";
} }
if (string.IsNullOrEmpty(Class)) if (string.IsNullOrEmpty(Class))
{ {
if (Format == "Table") if (Format == "Table")
@ -114,6 +115,7 @@
Class = "container"; Class = "container";
} }
} }
if (string.IsNullOrEmpty(PageSize)) if (string.IsNullOrEmpty(PageSize))
{ {
_maxItems = 10; _maxItems = 10;
@ -122,6 +124,7 @@
{ {
_maxItems = int.Parse(PageSize); _maxItems = int.Parse(PageSize);
} }
if (string.IsNullOrEmpty(DisplayPages)) if (string.IsNullOrEmpty(DisplayPages))
{ {
_maxPages = 5; _maxPages = 5;
@ -144,6 +147,7 @@
{ {
ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems); ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems);
_page = currentPage; _page = currentPage;
StateHasChanged(); StateHasChanged();
} }
@ -168,6 +172,7 @@
{ {
_endPage = _pages; _endPage = _pages;
} }
StateHasChanged(); StateHasChanged();
} }
else if (direction == "back") else if (direction == "back")
@ -201,6 +206,7 @@
_page -= 1; _page -= 1;
} }
} }
UpdateList(_page); UpdateList(_page);
} }
} }

View File

@ -74,6 +74,13 @@
} }
@code { @code {
private string _permissionnames = string.Empty;
private List<Role> _roles;
private List<PermissionString> _permissions;
private List<User> _users = new List<User>();
private string _username = string.Empty;
private string _message = string.Empty;
[Parameter] [Parameter]
public string EntityName { get; set; } public string EntityName { get; set; }
@ -83,13 +90,6 @@
[Parameter] [Parameter]
public string Permissions { get; set; } public string Permissions { get; set; }
string _permissionnames = "";
List<Role> _roles;
List<PermissionString> _permissions;
List<User> _users = new List<User>();
string _username = "";
string _message = "";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (string.IsNullOrEmpty(PermissionNames)) if (string.IsNullOrEmpty(PermissionNames))
@ -105,6 +105,7 @@
_roles.Insert(0, new Role { Name = Constants.AllUsersRole }); _roles.Insert(0, new Role { Name = Constants.AllUsersRole });
_permissions = new List<PermissionString>(); _permissions = new List<PermissionString>();
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
// initialize with admin role // initialize with admin role
@ -120,13 +121,14 @@
{ {
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions; _permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
} }
if (permissionstring.Permissions.Contains("[")) if (permissionstring.Permissions.Contains("["))
{ {
foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries))
{ {
if (user.Contains("]")) if (user.Contains("]"))
{ {
int userid = int.Parse(user.Substring(0, user.IndexOf("]"))); var userid = int.Parse(user.Substring(0, user.IndexOf("]")));
if (_users.Where(item => item.UserId == userid).FirstOrDefault() == null) if (_users.Where(item => item.UserId == userid).FirstOrDefault() == null)
{ {
_users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId)); _users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId));
@ -158,16 +160,9 @@
} }
private bool GetPermissionDisabled(string roleName) private bool GetPermissionDisabled(string roleName)
{ => roleName == Constants.AdminRole
if (roleName == Constants.AdminRole) ? true
{ : false;
return true;
}
else
{
return false;
}
}
private async Task AddUser() private async Task AddUser()
{ {
@ -175,7 +170,7 @@
{ {
try try
{ {
User user = await UserService.GetUserAsync(_username, ModuleState.SiteId); var user = await UserService.GetUserAsync(_username, ModuleState.SiteId);
if (user != null) if (user != null)
{ {
_users.Add(user); _users.Add(user);
@ -186,16 +181,17 @@
_message = "Username Does Not Exist"; _message = "Username Does Not Exist";
} }
} }
_username = "";
_username = string.Empty;
} }
private void PermissionChanged(bool? value, string permissionName, string securityId) private void PermissionChanged(bool? value, string permissionName, string securityId)
{ {
bool? selected = value; var selected = value;
PermissionString permission = _permissions.Find(item => item.PermissionName == permissionName); var permission = _permissions.Find(item => item.PermissionName == permissionName);
if (permission != null) if (permission != null)
{ {
List<string> ids = permission.Permissions.Split(';').ToList(); var ids = permission.Permissions.Split(';').ToList();
ids.Remove(securityId); // remove grant permission ids.Remove(securityId); // remove grant permission
ids.Remove("!" + securityId); // remove deny permission ids.Remove("!" + securityId); // remove deny permission
@ -211,6 +207,7 @@
case null: case null:
break; // permission not specified break; // permission not specified
} }
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray()); _permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray());
} }
} }

View File

@ -27,6 +27,12 @@
</div> </div>
@code { @code {
private ElementReference _editorElement;
private ElementReference _toolBar;
private bool _filemanagervisible = false;
private FileManager _fileManager;
private string _message = string.Empty;
[Parameter] [Parameter]
public RenderFragment ToolbarContent { get; set; } public RenderFragment ToolbarContent { get; set; }
@ -42,12 +48,6 @@
[Parameter] [Parameter]
public string DebugLevel { get; set; } = "info"; public string DebugLevel { get; set; } = "info";
private ElementReference _editorElement;
private ElementReference _toolBar;
bool _filemanagervisible = false;
FileManager _fileManager;
string _message = "";
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) if (firstRender)
@ -102,14 +102,14 @@
{ {
if (_filemanagervisible) if (_filemanagervisible)
{ {
int fileid = _fileManager.GetFileId(); var fileid = _fileManager.GetFileId();
if (fileid != -1) if (fileid != -1)
{ {
await RichTextEditorInterop.InsertImage( await RichTextEditorInterop.InsertImage(
JsRuntime, JsRuntime,
_editorElement, ContentUrl(fileid)); _editorElement, ContentUrl(fileid));
_filemanagervisible = false; _filemanagervisible = false;
_message = ""; _message = string.Empty;
} }
else else
{ {
@ -119,15 +119,17 @@
else else
{ {
_filemanagervisible = true; _filemanagervisible = true;
_message = ""; _message = string.Empty;
} }
StateHasChanged(); StateHasChanged();
} }
public void CloseFileManager() public void CloseFileManager()
{ {
_filemanagervisible = false; _filemanagervisible = false;
_message = ""; _message = string.Empty;
StateHasChanged(); StateHasChanged();
} }

View File

@ -16,12 +16,13 @@
</CascadingValue> </CascadingValue>
@code { @code {
private List<TabPanel> _tabPanels = new List<TabPanel>();
// Next line is needed so we are able to add <TabPanel> components inside // Next line is needed so we are able to add <TabPanel> components inside
[Parameter] [Parameter]
public RenderFragment ChildContent { get; set; } public RenderFragment ChildContent { get; set; }
public TabPanel ActiveTabPanel { get; set; } public TabPanel ActiveTabPanel { get; set; }
List<TabPanel> _tabPanels = new List<TabPanel>();
internal void AddTabPanel(TabPanel tabPanel) internal void AddTabPanel(TabPanel tabPanel)
{ {
@ -31,12 +32,12 @@
StateHasChanged(); StateHasChanged();
} }
string GetButtonClass(TabPanel tabPanel) private string GetButtonClass(TabPanel tabPanel)
{ => tabPanel == ActiveTabPanel
return tabPanel == ActiveTabPanel ? "btn-primary" : "btn-secondary"; ? "btn-primary"
} : "btn-secondary";
void ActivateTabPanel(TabPanel tabPanel) private void ActivateTabPanel(TabPanel tabPanel)
{ {
ActiveTabPanel = tabPanel; ActiveTabPanel = tabPanel;
} }

View File

@ -3,6 +3,10 @@
<img src="@_src" title="@_title" @onclick="SetValue" /> <img src="@_src" title="@_title" @onclick="SetValue" />
@code { @code {
private bool? _value = null;
private string _title;
private string _src = string.Empty;
[Parameter] [Parameter]
public bool? Value { get; set; } public bool? Value { get; set; }
@ -12,10 +16,6 @@
[Parameter] [Parameter]
public Action<bool?> OnChange { get; set; } public Action<bool?> OnChange { get; set; }
bool? _value = null;
string _title;
string _src = "";
protected override void OnInitialized() protected override void OnInitialized()
{ {
_value = Value; _value = Value;
@ -38,6 +38,7 @@
_value = true; _value = true;
break; break;
} }
SetImage(); SetImage();
OnChange(_value); OnChange(_value);
} }
@ -57,9 +58,10 @@
break; break;
case null: case null:
_src = "images/null.png"; _src = "images/null.png";
_title = ""; _title = string.Empty;
break; break;
} }
StateHasChanged(); StateHasChanged();
} }
} }

View File

@ -7,9 +7,9 @@ Current count: @currentCount
<br /> <br />
@code { @code {
int currentCount = 0; private int currentCount = 0;
void IncrementCount() private void IncrementCount()
{ {
currentCount++; currentCount++;
} }

View File

@ -16,7 +16,7 @@
<RichTextEditor @ref="@RichTextEditorHtml"> <RichTextEditor @ref="@RichTextEditorHtml">
<ToolbarContent> <ToolbarContent>
<select class="ql-header"> <select class="ql-header">
<option selected=""></option> <option selected=string.Empty></option>
<option value="1"></option> <option value="1"></option>
<option value="2"></option> <option value="2"></option>
<option value="3"></option> <option value="3"></option>
@ -67,16 +67,19 @@
</div> </div>
@code { @code {
private string _visibleText = "d-none";
private string _visibleRich;
private bool _richTextEditorMode;
private RichTextEditor RichTextEditorHtml;
private string content;
private string createdby;
private DateTime createdon;
private string modifiedby;
private DateTime modifiedon;
public override SecurityAccessLevel SecurityAccessLevel public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
{
get { return SecurityAccessLevel.Edit; }
}
public override string Title public override string Title => "Edit Html/Text";
{
get { return "Edit Html/Text"; }
}
public bool RichTextEditorMode public bool RichTextEditorMode
{ {
@ -88,27 +91,16 @@
if (_richTextEditorMode) if (_richTextEditorMode)
{ {
_visibleText = "d-none"; _visibleText = "d-none";
_visibleRich = ""; _visibleRich = string.Empty;
} }
else else
{ {
_visibleText = ""; _visibleText = string.Empty;
_visibleRich = "d-none"; _visibleRich = "d-none";
} }
} }
} }
string _visibleText = "d-none";
string _visibleRich;
bool _richTextEditorMode;
RichTextEditor RichTextEditorHtml;
string content;
string createdby;
DateTime createdon;
string modifiedby;
DateTime modifiedon;
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
try try
@ -131,8 +123,8 @@
private async Task LoadText() private async Task LoadText()
{ {
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager); var htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); var htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null) if (htmltext != null)
{ {
content = htmltext.Content; content = htmltext.Content;
@ -170,12 +162,12 @@
content = await RichTextEditorHtml.GetHtml(); content = await RichTextEditorHtml.GetHtml();
} }
content = content.Replace(((PageState.Alias.Path == "") ? "/~" : PageState.Alias.Path) + Constants.ContentUrl, Constants.ContentUrl); content = content.Replace(((PageState.Alias.Path == string.Empty) ? "/~" : PageState.Alias.Path) + Constants.ContentUrl, Constants.ContentUrl);
try try
{ {
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager); var htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); var htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null) if (htmltext != null)
{ {
htmltext.Content = content; htmltext.Content = content;
@ -188,6 +180,7 @@
htmltext.Content = content; htmltext.Content = content;
await htmltextservice.AddHtmlTextAsync(htmltext); await htmltextservice.AddHtmlTextAsync(htmltext);
} }
await logger.LogInformation("Html/Text Content Saved {HtmlText}", htmltext); await logger.LogInformation("Html/Text Content Saved {HtmlText}", htmltext);
NavigationManager.NavigateTo(NavigateUrl()); NavigationManager.NavigateTo(NavigateUrl());
} }

View File

@ -13,14 +13,14 @@
<br /><br /> <br /><br />
@code { @code {
string content = ""; private string content = "";
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
try try
{ {
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager); var htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); var htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null) if (htmltext != null)
{ {
content = htmltext.Content; content = htmltext.Content;

View File

@ -32,7 +32,7 @@ else
} }
@code { @code {
WeatherForecast[] forecasts; private WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

View File

@ -21,7 +21,7 @@
</div> </div>
@code { @code {
public override string Panes { get { return "Content"; } } public override string Panes => "Content";
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {

View File

@ -1,28 +1,29 @@
@namespace Oqtane.Themes.Controls @namespace Oqtane.Themes.Controls
@inherits ThemeControlBase @inherits ThemeControlBase
@if (breadcrumbs != "") @if (breadcrumbs != string.Empty)
{ {
@((MarkupString)breadcrumbs) @((MarkupString)breadcrumbs)
} }
@code { @code {
string breadcrumbs = ""; string breadcrumbs = string.Empty;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
breadcrumbs = ""; breadcrumbs = string.Empty;
int? pageid = PageState.Page.PageId; var pageid = PageState.Page.PageId;
for (int i = PageState.Pages.Count - 1; i >= 0; i--) for (int i = PageState.Pages.Count - 1; i >= 0; i--)
{ {
Page p = PageState.Pages[i]; var p = PageState.Pages[i];
if (p.PageId == pageid) if (p.PageId == pageid)
{ {
breadcrumbs = "<li class=\"breadcrumb-item" + ((p.PageId == PageState.Page.PageId) ? " active" : "") + breadcrumbs = "<li class=\"breadcrumb-item" + ((p.PageId == PageState.Page.PageId) ? " active" : string.Empty) +
"\"><a href=\"" + NavigateUrl(p.Path) + "\">" + p.Name + "</a></li>" + breadcrumbs; "\"><a href=\"" + NavigateUrl(p.Path) + "\">" + p.Name + "</a></li>" + breadcrumbs;
pageid = p.ParentId; pageid = p.ParentId;
} }
} }
if (breadcrumbs != "") if (breadcrumbs != "")
{ {
breadcrumbs = "<ol class=\"breadcrumb\">" + breadcrumbs + "</ol>"; breadcrumbs = "<ol class=\"breadcrumb\">" + breadcrumbs + "</ol>";

View File

@ -196,6 +196,22 @@
} }
@code { @code {
private bool _deleteConfirmation = false;
private string _moduleType = "new";
private List<string> _categories = new List<string>();
private List<ModuleDefinition> _allModuleDefinitions;
private List<ModuleDefinition> _moduleDefinitions;
private List<Page> _pages = new List<Page>();
private string _pageId = "-";
private string _moduleId = "-";
private List<Module> _modules = new List<Module>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private string _moduleDefinitionName = "-";
private string _pane = "";
private string _title = "";
private string _containerType = "";
private string _display = "display: none;";
private string _message = "";
[Parameter] [Parameter]
public string ButtonClass { get; set; } public string ButtonClass { get; set; }
@ -209,37 +225,23 @@
[Parameter] [Parameter]
public string BodyClass { get; set; } public string BodyClass { get; set; }
bool _deleteConfirmation = false;
string _moduleType = "new";
List<string> _categories = new List<string>();
List<ModuleDefinition> _allModuleDefinitions;
List<ModuleDefinition> _moduleDefinitions;
List<Page> _pages = new List<Page>();
string _pageId = "-";
string _moduleId = "-";
List<Module> _modules = new List<Module>();
Dictionary<string, string> _containers = new Dictionary<string, string>();
string _moduleDefinitionName = "-";
string _pane = "";
string _title = "";
string _containerType = "";
string _display = "display: none;";
string _message = "";
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
if (string.IsNullOrEmpty(ButtonClass)) if (string.IsNullOrEmpty(ButtonClass))
{ {
ButtonClass = "btn-outline-primary"; ButtonClass = "btn-outline-primary";
} }
if (string.IsNullOrEmpty(CardClass)) if (string.IsNullOrEmpty(CardClass))
{ {
CardClass = "card bg-secondary mb-3"; CardClass = "card bg-secondary mb-3";
} }
if (string.IsNullOrEmpty(HeaderClass)) if (string.IsNullOrEmpty(HeaderClass))
{ {
HeaderClass = "card-header text-white"; HeaderClass = "card-header text-white";
} }
if (string.IsNullOrEmpty(BodyClass)) if (string.IsNullOrEmpty(BodyClass))
{ {
BodyClass = "card-body"; BodyClass = "card-body";
@ -250,6 +252,7 @@
_pages?.Clear(); _pages?.Clear();
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); _allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
foreach (ModuleDefinition moduledefinition in _allModuleDefinitions) foreach (ModuleDefinition moduledefinition in _allModuleDefinitions)
{ {
if (moduledefinition.Categories != "") if (moduledefinition.Categories != "")
@ -263,7 +266,9 @@
} }
} }
} }
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList(); _moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
foreach (Page p in PageState.Pages) foreach (Page p in PageState.Pages)
{ {
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions)) if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions))
@ -271,9 +276,10 @@
_pages.Add(p); _pages.Add(p);
} }
} }
var panes = PageState.Page.Panes.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries); var panes = PageState.Page.Panes.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);
_pane = panes.Count() == 1 ? panes.SingleOrDefault() : ""; _pane = panes.Count() == 1 ? panes.SingleOrDefault() : "";
List<Theme> themes = await ThemeService.GetThemesAsync(); var themes = await ThemeService.GetThemesAsync();
_containers = ThemeService.GetContainerTypes(themes); _containers = ThemeService.GetContainerTypes(themes);
_containerType = PageState.Site.DefaultContainerType; _containerType = PageState.Site.DefaultContainerType;
} }
@ -281,7 +287,7 @@
private void CategoryChanged(ChangeEventArgs e) private void CategoryChanged(ChangeEventArgs e)
{ {
string category = (string) e.Value; var category = (string) e.Value;
if (category == "-") if (category == "-")
{ {
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList(); _moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
@ -290,6 +296,7 @@
{ {
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(category)).ToList(); _moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(category)).ToList();
} }
_moduleDefinitionName = "-"; _moduleDefinitionName = "-";
StateHasChanged(); StateHasChanged();
} }
@ -298,6 +305,7 @@
{ {
_pageId = (string) e.Value; _pageId = (string) e.Value;
_modules?.Clear(); _modules?.Clear();
if (_pageId != "-") if (_pageId != "-")
{ {
foreach (Module module in PageState.Modules.Where(item => item.PageId == int.Parse(_pageId) && !item.IsDeleted)) foreach (Module module in PageState.Modules.Where(item => item.PageId == int.Parse(_pageId) && !item.IsDeleted))
@ -308,6 +316,7 @@
} }
} }
} }
_moduleId = "-"; _moduleId = "-";
StateHasChanged(); StateHasChanged();
} }
@ -346,6 +355,7 @@
pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(_moduleId))?.Title; pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(_moduleId))?.Title;
} }
} }
pageModule.Pane = _pane; pageModule.Pane = _pane;
pageModule.Order = int.MaxValue; pageModule.Order = int.MaxValue;
pageModule.ContainerType = _containerType; pageModule.ContainerType = _containerType;
@ -428,16 +438,19 @@
case "Admin": case "Admin":
// get admin dashboard moduleid // get admin dashboard moduleid
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule); module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule);
if (module != null) if (module != null)
{ {
NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, module.ModuleId, "Index", "")); NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, module.ModuleId, "Index", ""));
} }
break; break;
case "Add": case "Add":
case "Edit": case "Edit":
string url = ""; string url = "";
// get page management moduleid // get page management moduleid
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule); module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule);
if (module != null) if (module != null)
{ {
switch (location) switch (location)
@ -450,10 +463,12 @@
break; break;
} }
} }
if (url != "") if (url != "")
{ {
NavigationManager.NavigateTo(url); NavigationManager.NavigateTo(url);
} }
break; break;
} }
} }
@ -467,7 +482,8 @@
private async Task DeletePage() private async Task DeletePage()
{ {
ConfirmDelete(); ConfirmDelete();
Page page = PageState.Page;
var page = PageState.Page;
try try
{ {
if (page.UserId == null) if (page.UserId == null)

View File

@ -21,11 +21,12 @@
@code { @code {
private void LoginUser() private void LoginUser()
{ {
string returnurl = PageState.Alias.Path; var returnurl = PageState.Alias.Path;
if (PageState.Page.Path != "/") if (PageState.Page.Path != "/")
{ {
returnurl += "/" + PageState.Page.Path; returnurl += "/" + PageState.Page.Path;
} }
NavigationManager.NavigateTo(NavigateUrl("login", "returnurl=" + returnurl)); NavigationManager.NavigateTo(NavigateUrl("login", "returnurl=" + returnurl));
} }

View File

@ -11,7 +11,7 @@
{ {
if (PageState.Site.LogoFileId != null) if (PageState.Site.LogoFileId != null)
{ {
Uri uri = new Uri(NavigationManager.Uri); var uri = new Uri(NavigationManager.Uri);
logo = "<a href=\"" + uri.Scheme + "://" + uri.Authority + "\"><img src=\"" + ContentUrl(PageState.Site.LogoFileId.Value) + "\" alt=\"" + PageState.Site.Name + "\"/></a>"; logo = "<a href=\"" + uri.Scheme + "://" + uri.Authority + "\"><img src=\"" + ContentUrl(PageState.Site.LogoFileId.Value) + "\" alt=\"" + PageState.Site.Name + "\"/></a>";
} }
} }

View File

@ -1,7 +1,7 @@
@namespace Oqtane.Themes.Controls @namespace Oqtane.Themes.Controls
@inherits ThemeControlBase @inherits ThemeControlBase
@if (menu != "") @if (menu != string.Empty)
{ {
<div class="app-menu"> <div class="app-menu">
@((MarkupString)menu) @((MarkupString)menu)
@ -9,11 +9,11 @@
} }
@code { @code {
private string menu = string.Empty;
[Parameter] [Parameter]
public string Orientation { get; set; } public string Orientation { get; set; }
string menu = "";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
switch (Orientation) switch (Orientation)
@ -29,8 +29,8 @@
private void CreateVerticalMenu() private void CreateVerticalMenu()
{ {
int level = -1; var level = -1;
int securitylevel = int.MaxValue; var securitylevel = int.MaxValue;
menu = "<ul class=\"nav flex-column\">\n"; menu = "<ul class=\"nav flex-column\">\n";
@ -47,21 +47,25 @@
} }
else else
{ {
string target = ""; string target = String.Empty;
if (p.Url.StartsWith("http")) if (p.Url.StartsWith("http"))
{ {
target = " target=\"_new\""; target = " target=\"_new\"";
} }
menu += "<a href=\"" + p.Url + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\"" + target + ">"; menu += "<a href=\"" + p.Url + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\"" + target + ">";
} }
menu += "<a href=\string.Empty + NavigateUrl(p.Path) + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\">";
if (p.HasChildren) if (p.HasChildren)
{ {
menu += "<i class=\"oi oi-chevron-right\"></i>"; menu += "<i class=\"oi oi-chevron-right\"></i>";
} }
if (p.Icon != "")
if (p.Icon != string.Empty)
{ {
menu += "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span>"; menu += "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span>";
} }
menu += p.Name; menu += p.Name;
menu += "</a>\n"; menu += "</a>\n";
menu += "</li>\n"; menu += "</li>\n";
@ -76,17 +80,19 @@
} }
} }
} }
menu += "</ul>"; menu += "</ul>";
} }
private void CreateHorizontalMenu() private void CreateHorizontalMenu()
{ {
string url = ""; var url = String.Empty;
string target = ""; var target = String.Empty;
menu = "<button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#Menu\" aria-controls=\"Menu\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button>"; menu = "<button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#Menu\" aria-controls=\"Menu\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button>";
menu += "<div class=\"collapse navbar-collapse\" id=\"Menu\">"; menu += "<div class=\"collapse navbar-collapse\" id=\"Menu\">";
menu += "<ul class=\"navbar-nav mr-auto\">"; menu += "<ul class=\"navbar-nav mr-auto\">";
foreach (Page p in PageState.Pages.Where(item => item.IsNavigation && !item.IsDeleted)) foreach (Page p in PageState.Pages.Where(item => item.IsNavigation && !item.IsDeleted))
{ {
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions) && p.ParentId == PageState.Page.ParentId && p.Level == PageState.Page.Level) if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions) && p.ParentId == PageState.Page.ParentId && p.Level == PageState.Page.Level)
@ -94,7 +100,7 @@
if (string.IsNullOrEmpty(p.Url)) if (string.IsNullOrEmpty(p.Url))
{ {
url = NavigateUrl(p.Path); url = NavigateUrl(p.Path);
target = ""; target = String.Empty;
} }
else else
{ {
@ -108,19 +114,20 @@
if (p.PageId == PageState.Page.PageId) if (p.PageId == PageState.Page.PageId)
{ {
menu += "<li class=\"nav-item active\">" + menu += "<li class=\"nav-item active\">" +
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" + "<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") + ((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
p.Name + " <span class=\"sr-only\">(current)</span></a></li>"; p.Name + " <span class=\"sr-only\">(current)</span></a></li>";
} }
else else
{ {
menu += "<li class=\"nav-item\">" + menu += "<li class=\"nav-item\">" +
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" + "<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") + ((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
p.Name + "</a></li>"; p.Name + "</a></li>";
} }
} }
} }
menu += "</ul>"; menu += "</ul>";
menu += "</div>"; menu += "</div>";
} }

View File

@ -23,7 +23,7 @@
} }
@code { @code {
List<ActionViewModel> actions; private List<ActionViewModel> actions;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
@ -31,29 +31,36 @@
{ {
actions = new List<ActionViewModel>(); actions = new List<ActionViewModel>();
actions.Add(new ActionViewModel { Action = "settings", Name = "Manage Settings" }); actions.Add(new ActionViewModel { Action = "settings", Name = "Manage Settings" });
if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerAssemblyName != "") if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerAssemblyName != "")
{ {
actions.Add(new ActionViewModel { Action = "import", Name = "Import Content" }); actions.Add(new ActionViewModel { Action = "import", Name = "Import Content" });
actions.Add(new ActionViewModel { Action = "export", Name = "Export Content" }); actions.Add(new ActionViewModel { Action = "export", Name = "Export Content" });
} }
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete Module" }); actions.Add(new ActionViewModel { Action = "delete", Name = "Delete Module" });
actions.Add(new ActionViewModel { Action = "", Name = "" }); actions.Add(new ActionViewModel { Action = "", Name = "" });
if (ModuleState.PaneModuleIndex > 0) if (ModuleState.PaneModuleIndex > 0)
{ {
actions.Add(new ActionViewModel { Action = "<<", Name = "Move To Top" }); actions.Add(new ActionViewModel { Action = "<<", Name = "Move To Top" });
} }
if (ModuleState.PaneModuleIndex > 0) if (ModuleState.PaneModuleIndex > 0)
{ {
actions.Add(new ActionViewModel { Action = "<", Name = "Move Up" }); 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 = ">", Name = "Move Down" }); actions.Add(new ActionViewModel { Action = ">", Name = "Move Down" });
} }
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1)) if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
{ {
actions.Add(new ActionViewModel { Action = ">>", Name = "Move To Bottom" }); actions.Add(new ActionViewModel { Action = ">>", Name = "Move To Bottom" });
} }
foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{ {
if (pane != ModuleState.Pane) if (pane != ModuleState.Pane)

View File

@ -4,7 +4,7 @@
@((MarkupString)title) @((MarkupString)title)
@code { @code {
string title = ""; private title = "";
protected override Task OnParametersSetAsync() protected override Task OnParametersSetAsync()
{ {

View File

@ -14,7 +14,7 @@
</main> </main>
@code { @code {
public override string Panes { get { return ""; } } public override string Panes => string.Empty;
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {

View File

@ -14,5 +14,5 @@
</div> </div>
@code { @code {
public override string Panes { get { return "Top;Left;Content;Right;Bottom"; } } public override string Panes => "Top;Left;Content;Right;Bottom";
} }

View File

@ -6,5 +6,5 @@
</div> </div>
@code { @code {
public override string Panes { get { return "Content"; } } public override string Panes => "Content";
} }

View File

@ -5,6 +5,8 @@
</CascadingValue> </CascadingValue>
@code { @code {
private Module _moduleState;
[CascadingParameter] [CascadingParameter]
protected PageState PageState { get; set; } protected PageState PageState { get; set; }
@ -13,8 +15,6 @@
RenderFragment DynamicComponent { get; set; } RenderFragment DynamicComponent { get; set; }
Module _moduleState;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
_moduleState = Module; // passed in from Pane component _moduleState = Module; // passed in from Pane component

View File

@ -134,20 +134,14 @@
private string _confirmPassword = ""; private string _confirmPassword = "";
private string _hostEmail = ""; private string _hostEmail = "";
private string _message = ""; private string _message = "";
private string _integratedSecurityDisplay = "display: none;"; private string _integratedSecurityDisplay = "display: none;";
private string _loadingDisplay = "display: none;"; private string _loadingDisplay = "display: none;";
private void SetIntegratedSecurity(ChangeEventArgs e) private void SetIntegratedSecurity(ChangeEventArgs e)
{ {
if (Convert.ToBoolean((string) e.Value)) _integratedSecurityDisplay = Convert.ToBoolean((string)e.Value)
{ ? "display: none;"
_integratedSecurityDisplay = "display: none;"; : string.Empty;
}
else
{
_integratedSecurityDisplay = "";
}
} }
private async Task Install() private async Task Install()
@ -157,7 +151,7 @@
_loadingDisplay = ""; _loadingDisplay = "";
StateHasChanged(); StateHasChanged();
string connectionstring = ""; var connectionstring = "";
if (_databaseType == "LocalDB") if (_databaseType == "LocalDB")
{ {
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;"; connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
@ -184,7 +178,7 @@
IsMaster = true, IsMaster = true,
}; };
Installation installation = await InstallationService.Install(config); var installation = await InstallationService.Install(config);
//TODO: Should be moved to Database manager //TODO: Should be moved to Database manager
if (installation.Success) if (installation.Success)
{ {

View File

@ -11,6 +11,9 @@
} }
@code { @code {
private string _message;
private bool _progressindicator = false;
[CascadingParameter] [CascadingParameter]
protected PageState PageState { get; set; } protected PageState PageState { get; set; }
@ -18,11 +21,8 @@
private Module ModuleState { get; set; } private Module ModuleState { get; set; }
private ModuleMessage ModuleMessage { get; set; } private ModuleMessage ModuleMessage { get; set; }
string _message;
RenderFragment DynamicComponent { get; set; } private RenderFragment DynamicComponent { get; set; }
bool _progressindicator = false;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {

View File

@ -12,6 +12,9 @@
</div> </div>
@code { @code {
private string _paneadminborder = "";
private string _panetitle = "";
[CascadingParameter] [CascadingParameter]
protected PageState PageState { get; set; } protected PageState PageState { get; set; }
@ -20,9 +23,6 @@
RenderFragment DynamicComponent { get; set; } RenderFragment DynamicComponent { get; set; }
string _paneadminborder = "";
string _panetitle = "";
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
if (PageState.EditMode && !PageState.Page.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane) 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); Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
if (module != null) if (module != null)
{ {
string typename = module.ModuleType; var typename = module.ModuleType;
// check for core module actions component // check for core module actions component
if (Constants.DefaultModuleActions.Contains(PageState.Action)) if (Constants.DefaultModuleActions.Contains(PageState.Action))
{ {
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action); typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
} }
Type moduleType = Type.GetType(typename);
var moduleType = Type.GetType(typename);
if (moduleType != null) if (moduleType != null)
{ {
bool authorized = false; bool authorized = false;
@ -61,7 +62,6 @@
} }
else else
{ {
// verify security access level for this module control
switch (module.SecurityAccessLevel) switch (module.SecurityAccessLevel)
{ {
case SecurityAccessLevel.Anonymous: case SecurityAccessLevel.Anonymous:
@ -81,12 +81,14 @@
break; break;
} }
} }
if (authorized) if (authorized)
{ {
if (!Constants.DefaultModuleActions.Contains(PageState.Action) && module.ControlTitle != "") if (!Constants.DefaultModuleActions.Contains(PageState.Action) && module.ControlTitle != "")
{ {
module.Title = module.ControlTitle; module.Title = module.ControlTitle;
} }
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent)); builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
builder.AddAttribute(1, "Module", module); builder.AddAttribute(1, "Module", module);
builder.CloseComponent(); builder.CloseComponent();

View File

@ -12,7 +12,7 @@
{ {
DynamicComponent = builder => DynamicComponent = builder =>
{ {
Type layoutType = Type.GetType(PageState.Page.LayoutType); var layoutType = Type.GetType(PageState.Page.LayoutType);
if (layoutType != null) if (layoutType != null)
{ {
builder.OpenComponent(0, layoutType); builder.OpenComponent(0, layoutType);

View File

@ -20,17 +20,17 @@
@code { @code {
private string _absoluteUri;
private bool _navigationInterceptionEnabled;
private PageState _pagestate;
[CascadingParameter] [CascadingParameter]
PageState PageState { get; set; } PageState PageState { get; set; }
[Parameter] [Parameter]
public Action<PageState> OnStateChange { get; set; } public Action<PageState> OnStateChange { get; set; }
PageState _pagestate; private RenderFragment DynamicComponent { get; set; }
RenderFragment DynamicComponent { get; set; }
string _absoluteUri;
bool _navigationInterceptionEnabled;
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -77,22 +77,22 @@
Page page; Page page;
User user = null; User user = null;
List<Module> modules; List<Module> modules;
int moduleid = -1; var moduleid = -1;
string action = ""; var action = "";
bool editmode = false; var editmode = false;
Reload reload = Reload.None; var reload = Reload.None;
DateTime lastsyncdate = DateTime.UtcNow; var lastsyncdate = DateTime.UtcNow;
Runtime runtime = GetRuntime(); var runtime = GetRuntime();
// get Url path and querystring ( and remove anchors ) // 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) if (path.IndexOf("#") != -1)
{ {
path = path.Substring(0, path.IndexOf("#")); path = path.Substring(0, path.IndexOf("#"));
} }
// parse querystring and remove // parse querystring and remove
Dictionary<string, string> querystring = new Dictionary<string, string>(); var querystring = new Dictionary<string, string>();
if (path.IndexOf("?") != -1) if (path.IndexOf("?") != -1)
{ {
querystring = ParseQueryString(path); querystring = ParseQueryString(path);
@ -137,6 +137,7 @@
{ {
site = PageState.Site; site = PageState.Site;
} }
if (site != null) if (site != null)
{ {
if (PageState == null || reload == Reload.Site) if (PageState == null || reload == Reload.Site)
@ -174,14 +175,19 @@
// format path and remove alias // format path and remove alias
path = path.Replace("//", "/"); path = path.Replace("//", "/");
if (!path.EndsWith("/")) { path += "/"; }
if (!path.EndsWith("/"))
{
path += "/";
}
if (alias.Path != "") if (alias.Path != "")
{ {
path = path.Replace(alias.Path + "/", ""); path = path.Replace(alias.Path + "/", "");
} }
// extract admin route elements from path // extract admin route elements from path
string[] segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
int result; int result;
// check if path has moduleid and control specification ie. page/moduleid/control/ // check if path has moduleid and control specification ie. page/moduleid/control/
if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result)) if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
@ -199,6 +205,7 @@
path = path.Replace(moduleid.ToString() + "/", ""); path = path.Replace(moduleid.ToString() + "/", "");
} }
} }
// remove trailing slash so it can be used as a key for Pages // remove trailing slash so it can be used as a key for Pages
if (path.EndsWith("/")) path = path.Substring(0, path.Length - 1); if (path.EndsWith("/")) path = path.Substring(0, path.Length - 1);
@ -210,6 +217,7 @@
{ {
page = PageState.Page; page = PageState.Page;
} }
// failsafe in case router cannot locate the home page for the site // failsafe in case router cannot locate the home page for the site
if (page == null && path == "") if (page == null && path == "")
{ {
@ -313,6 +321,7 @@
_navigationInterceptionEnabled = true; _navigationInterceptionEnabled = true;
return NavigationInterception.EnableNavigationInterceptionAsync(); return NavigationInterception.EnableNavigationInterceptionAsync();
} }
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -337,6 +346,7 @@
} }
} }
} }
return querystring; return querystring;
} }
@ -356,6 +366,7 @@
page.LayoutType = site.DefaultLayoutType; page.LayoutType = site.DefaultLayoutType;
} }
Type type; Type type;
if (!string.IsNullOrEmpty(page.LayoutType)) if (!string.IsNullOrEmpty(page.LayoutType))
{ {
type = Type.GetType(page.LayoutType); type = Type.GetType(page.LayoutType);
@ -364,24 +375,26 @@
{ {
type = Type.GetType(page.ThemeType); 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); page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
} }
catch catch
{ {
// error loading theme or layout // error loading theme or layout
} }
return page; return page;
} }
private List<Module> ProcessModules(List<Module> modules, int pageid, int moduleid, string control, string panes, string defaultcontainertype) 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) foreach (Module module in modules)
{ {
if (module.PageId == pageid || module.ModuleId == moduleid) if (module.PageId == pageid || module.ModuleId == moduleid)
{ {
string typename = ""; var typename = string.Empty;
if (module.ModuleDefinition != null) if (module.ModuleDefinition != null)
{ {
typename = module.ModuleDefinition.ControlTypeTemplate; typename = module.ModuleDefinition.ControlTypeTemplate;
@ -390,6 +403,7 @@
{ {
typename = Constants.ErrorModule; typename = Constants.ErrorModule;
} }
if (module.ModuleId == moduleid && control != "") if (module.ModuleId == moduleid && control != "")
{ {
// check if the module defines custom routes // check if the module defines custom routes
@ -445,6 +459,7 @@
{ {
paneindex.Add(module.Pane, 0); paneindex.Add(module.Pane, 0);
} }
module.PaneModuleIndex = paneindex[module.Pane]; module.PaneModuleIndex = paneindex[module.Pane];
if (string.IsNullOrEmpty(module.ContainerType)) if (string.IsNullOrEmpty(module.ContainerType))
@ -458,18 +473,12 @@
{ {
module.PaneModuleCount = paneindex[module.Pane] + 1; module.PaneModuleCount = paneindex[module.Pane] + 1;
} }
return modules; return modules;
} }
private Runtime GetRuntime() private Runtime GetRuntime()
{ => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"))
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"))) ? Runtime.WebAssembly
{ : Runtime.Server;
return Runtime.WebAssembly;
}
else
{
return Runtime.Server;
}
}
} }

View File

@ -31,7 +31,7 @@
DynamicComponent = builder => DynamicComponent = builder =>
{ {
Type themeType = Type.GetType(PageState.Page.ThemeType); var themeType = Type.GetType(PageState.Page.ThemeType);
if (themeType != null) if (themeType != null)
{ {
builder.OpenComponent(0, themeType); builder.OpenComponent(0, themeType);