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 {
private bool _initialized;
private bool _installed;
private PageState PageState { get; set; }
protected override async Task OnParametersSetAsync()

View File

@ -19,13 +19,13 @@
</div>
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
List<Page> _pages;
var List<Page> _pages;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
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();
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -74,28 +74,29 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@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 = "";
string _jobType = "";
string _isEnabled = "True";
string _interval = "";
string _frequency = "";
string _startDate = "";
string _endDate = "";
string _retentionHistory = "10";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
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.JobType = _jobType;
job.IsEnabled = Boolean.Parse(_isEnabled);
job.Frequency = _frequency;
job.Interval = int.Parse(_interval);
if (_startDate == "")
if (_startDate == string.Empty)
{
job.StartDate = null;
}
@ -103,7 +104,8 @@
{
job.StartDate = DateTime.Parse(_startDate);
}
if (_endDate == "")
if (_endDate == string.Empty)
{
job.EndDate = null;
}
@ -111,6 +113,7 @@
{
job.EndDate = DateTime.Parse(_endDate);
}
job.RetentionHistory = int.Parse(_retentionHistory);
job.IsStarted = false;
job.IsExecuting = false;

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
@inject IUserService UserService
@inject IServiceProvider ServiceProvider
@if (_message != "")
@if (_message != string.Empty)
{
<ModuleMessage Message="@_message" Type="@_type" />
}
@ -41,14 +41,14 @@
</AuthorizeView>
@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 = "";
string _message = "";
MessageType _type = MessageType.Info;
string _username = "";
string _password = "";
bool _remember = false;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
protected override async Task OnInitializedAsync()
{
@ -56,13 +56,15 @@
{
_returnUrl = PageState.QueryString["returnurl"];
}
if (PageState.QueryString.ContainsKey("name"))
{
_username = PageState.QueryString["name"];
}
if (PageState.QueryString.ContainsKey("token"))
{
User user = new User();
var user = new User();
user.SiteId = PageState.Site.SiteId;
user.Username = _username;
user = await UserService.VerifyEmailAsync(user, PageState.QueryString["token"]);
@ -84,11 +86,12 @@
if (PageState.Runtime == Runtime.Server)
{
// server-side Blazor
User user = new User();
var user = new User();
user.SiteId = PageState.Site.SiteId;
user.Username = _username;
user.Password = _password;
user = await UserService.LoginUserAsync(user, false, false);
if (user.IsAuthenticated)
{
await logger.LogInformation("Login Successful For Username {Username}", _username);
@ -107,7 +110,7 @@
else
{
// client-side Blazor
User user = new User();
var user = new User();
user.SiteId = PageState.Site.SiteId;
user.Username = _username;
user.Password = _password;
@ -134,9 +137,9 @@
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)
{
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";
}
StateHasChanged();
}
}
}

View File

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

View File

@ -71,12 +71,12 @@ else
}
@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 = "-";
string _function = "-";
string _rows = "10";
List<Log> _logs;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
@ -139,12 +139,12 @@ else
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)
{
string classname = "";
string classname = string.Empty;
switch (function)
{
case "Create":
@ -163,7 +163,7 @@ else
classname = "table-secondary";
break;
default:
classname = "";
classname = string.Empty;
break;
}
return classname;

View File

@ -25,11 +25,11 @@
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
@code {
private string _name = string.Empty;
private string _description = string.Empty;
string _name = "";
string _description = "";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override void OnInitialized()
{
@ -42,7 +42,7 @@
{
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);
}
else

View File

@ -42,16 +42,17 @@
@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()
{
try
{
List<ModuleDefinition> moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
_packages = await PackageService.GetPackagesAsync("module");
foreach(Package package in _packages.ToArray())
{
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>
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
int _moduleDefinitionId;
string _name;
string _permissions;
string _createdby;
DateTime _createdon;
string _modifiedby;
DateTime _modifiedon;
private int _moduleDefinitionId;
private string _name;
private string _permissions;
private string _createdby;
private DateTime _createdon;
private string _modifiedby;
private DateTime _modifiedon;
#pragma warning disable 649
PermissionGrid _permissionGrid;
private PermissionGrid _permissionGrid;
#pragma warning restore 649
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
try
{
_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)
{
_name = moduleDefinition.Name;
@ -67,7 +67,7 @@
{
try
{
ModuleDefinition moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
moduledefinition.Permissions = _permissionGrid.GetPermissions();
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);

View File

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

View File

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

View File

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

View File

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

View File

@ -118,7 +118,7 @@
</td>
<td>
<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)
{
<option value="@item.Key">@item.Value</option>
@ -132,7 +132,7 @@
</td>
<td>
<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)
{
<option value="@panelayout.Key">@panelayout.Value</option>
@ -160,30 +160,26 @@
}
@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>();
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;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
@ -199,7 +195,7 @@
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = PageState.Site.DefaultLayoutType;
_permissions = "";
_permissions = string.Empty;
}
catch (Exception ex)
{
@ -235,7 +231,7 @@
try
{
_themetype = (string)e.Value;
if (_themetype != "")
if (_themetype != string.Empty)
{
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
}
@ -243,6 +239,7 @@
{
_panelayouts = new Dictionary<string, string>();
}
StateHasChanged();
}
catch (Exception ex)
@ -257,7 +254,7 @@
Page page = null;
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.SiteId = PageState.Page.SiteId;
@ -267,10 +264,12 @@
{
_path = _name;
}
if (_path.Contains("/"))
{
_path = _path.Substring(_path.LastIndexOf("/") + 1);
}
if (string.IsNullOrEmpty(_parentid))
{
page.ParentId = null;
@ -279,8 +278,8 @@
else
{
page.ParentId = Int32.Parse(_parentid);
Page parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
if (parent.Path == "")
var parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault();
if (parent.Path == string.Empty)
{
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
}
@ -289,6 +288,7 @@
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
Page child;
switch (_insert)
{
@ -307,22 +307,25 @@
page.Order = int.MaxValue;
break;
}
page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation));
page.Url = _url;
page.EditMode = (_mode == "edit" ? true : false);
page.ThemeType = _themetype;
page.LayoutType = (_layouttype == null ? "" : _layouttype);
page.Icon = (_icon == null ? "" : _icon);
page.LayoutType = (_layouttype == null ? string.Empty : _layouttype);
page.Icon = (_icon == null ? string.Empty : _icon);
page.Permissions = _permissionGrid.GetPermissions();
if (page.ThemeType == PageState.Site.DefaultThemeType)
{
page.ThemeType = "";
page.ThemeType = string.Empty;
}
if (page.LayoutType == PageState.Site.DefaultLayoutType)
{
page.LayoutType = "";
page.LayoutType = string.Empty;
}
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
page.UserId = null;

View File

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

View File

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

View File

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

View File

@ -25,9 +25,9 @@ else
}
@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()
{

View File

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

View File

@ -3,7 +3,7 @@
@inject NavigationManager NavigationManager
@inject IUserService UserService
@if (_message != "")
@if (_message != string.Empty)
{
<ModuleMessage Message="@_message" Type="MessageType.Info" />
}
@ -34,31 +34,32 @@
</div>
@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()
{
try
{
_message = "";
_message = string.Empty;
_isEmailValid = Utilities.IsValidEmail(_email);
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
{
if (_password == _confirm)
{
User user = new User
var user = new User
{
SiteId = PageState.Site.SiteId,
Username = _username,
DisplayName = (_displayName == "" ? _username : _displayName),
DisplayName = (_displayName == string.Empty ? _username : _displayName),
Email = _email,
Password = _password
};
@ -94,6 +95,5 @@
private void Cancel()
{
NavigationManager.NavigateTo(NavigateUrl(""));
NavigationManager.NavigateTo(NavigateUrl(string.Empty));
}
}

View File

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

View File

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

View File

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

View File

@ -25,9 +25,9 @@ else
}
@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()
{

View File

@ -56,7 +56,7 @@
</td>
<td>
<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)
{
if (item.Key == _themetype)
@ -77,7 +77,7 @@
</td>
<td>
<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)
{
<option value="@panelayout.Key">@panelayout.Value</option>
@ -91,7 +91,7 @@
</td>
<td>
<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)
{
<option value="@container.Key">@container.Value</option>
@ -216,46 +216,34 @@
}
@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;
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;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
@ -277,22 +265,36 @@
{
_logofileid = site.LogoFileId.Value;
}
if (site.FaviconFileId != null)
{
_faviconfileid = site.FaviconFileId.Value;
}
_themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType;
_containertype = site.DefaultContainerType;
_allowregistration = site.AllowRegistration.ToString();
Dictionary<string, string> settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
_smtphost = SettingService.GetSetting(settings, "SMTPHost", "");
_smtpport = SettingService.GetSetting(settings, "SMTPPort", "");
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "");
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", "");
_smtppassword = SettingService.GetSetting(settings, "SMTPPassword", "");
var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
_smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
_smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
_smtpssl = SettingService.GetSetting(settings, "SMTPSSL", string.Empty);
_smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
_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();
if (site.PwaAppIconFileId != null)
@ -328,7 +330,7 @@
try
{
_themetype = (string)e.Value;
if (_themetype != "")
if (_themetype != string.Empty)
{
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
}
@ -349,9 +351,9 @@
{
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))
{
if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
@ -359,36 +361,35 @@
unique = false;
}
}
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)
{
site.Name = _name;
site.LogoFileId = null;
int logofileid = _logofilemanager.GetFileId();
var logofileid = _filemanager.GetFileId();
if (logofileid != -1)
{
site.LogoFileId = logofileid;
}
int faviconfileid = _faviconfilemanager.GetFileId();
if (faviconfileid != -1)
{
site.FaviconFileId = faviconfileid;
}
site.DefaultThemeType = _themetype;
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype);
site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype);
site.DefaultContainerType = _containertype;
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));
site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));
int pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
if (pwaappiconfileid != -1)
{
site.PwaAppIconFileId = pwaappiconfileid;
}
int pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
if (pwasplashiconfileid != -1)
{
site.PwaSplashIconFileId = pwasplashiconfileid;
@ -397,7 +398,7 @@
site = await SiteService.UpdateSiteAsync(site, PageState.Alias);
_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())
{
if (!names.Contains(alias.Name))
@ -405,6 +406,7 @@
await AliasService.DeleteAliasAsync(alias.AliasId);
}
}
foreach (string name in names)
{
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, "SMTPPort", _smtpport);
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);

View File

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

View File

@ -39,7 +39,7 @@
</td>
<td>
<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)
{
if (item.Key == _themetype)
@ -60,7 +60,7 @@
</td>
<td>
<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)
{
<option value="@panelayout.Key">@panelayout.Value</option>
@ -74,7 +74,7 @@
</td>
<td>
<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)
{
<option value="@container.Key">@container.Value</option>
@ -103,30 +103,28 @@
}
@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;
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;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync()
{
@ -136,21 +134,22 @@
_aliasList = await AliasService.GetAliasesAsync();
_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)
{
_name = site.Name;
_tenantList = await TenantService.GetTenantsAsync();
_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())
{
_urls += alias.Name + "\n";
}
_themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType;
_containertype = site.DefaultContainerType;
_createdby = site.CreatedBy;
_createdon = site.CreatedOn;
_modifiedby = site.ModifiedBy;
@ -165,7 +164,7 @@
}
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);
}
}
@ -175,7 +174,7 @@
try
{
_themetype = (string)e.Value;
if (_themetype != "")
if (_themetype != string.Empty)
{
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
}
@ -183,6 +182,7 @@
{
_panelayouts = new Dictionary<string, string>();
}
StateHasChanged();
}
catch (Exception ex)
@ -196,9 +196,9 @@
{
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))
{
if (_aliasList.Exists(item => item.Name == name && item.SiteId != _alias.SiteId && item.TenantId != _alias.TenantId))
@ -206,22 +206,24 @@
unique = false;
}
}
if (unique)
{
Site site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
var site = await SiteService.GetSiteAsync(_alias.SiteId, _alias);
if (site != null)
{
site.Name = _name;
site.LogoFileId = null;
site.DefaultThemeType = _themetype;
site.DefaultLayoutType = _layouttype ?? "";
site.DefaultLayoutType = _layouttype ?? string.Empty;
site.DefaultContainerType = _containertype;
site.IsDeleted = (_isdeleted == null || Boolean.Parse(_isdeleted));
site = await SiteService.UpdateSiteAsync(site, _alias);
_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())
{
if (!names.Contains(alias.Name))
@ -229,6 +231,7 @@
await AliasService.DeleteAliasAsync(alias.AliasId);
}
}
foreach (string name in names)
{
if (!_aliasList.Exists(item => item.Name == name))
@ -260,7 +263,7 @@
}
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);
}
}

View File

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

View File

@ -43,12 +43,12 @@ else
}
@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;
string _tenantid = "-1";
string _sql = "";
string _results = "";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
protected override async Task OnInitializedAsync()
{
@ -59,7 +59,7 @@ else
{
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);
_results = DisplayResults(sqlquery.Results);
}
@ -71,27 +71,33 @@ else
private string DisplayResults(List<Dictionary<string, string>> results)
{
string table = "";
var table = string.Empty;
foreach (Dictionary<string, string> item in results)
{
if (table == "")
if (table == string.Empty)
{
table = "<div class=\"table-responsive\">";
table += "<table class=\"table table-bordered\"><thead><tr>";
foreach (KeyValuePair<string, string> kvp in item)
{
table += "<th scope=\"col\">" + kvp.Key + "</th>";
}
table += "</tr></thead><tbody>";
}
table += "<tr>";
foreach (KeyValuePair<string, string> kvp in item)
{
table += "<td>" + kvp.Value + "</td>";
}
table += "</tr>";
}
if (table != "")
if (table != string.Empty)
{
table += "</tbody></table></div>";
}
@ -99,6 +105,7 @@ else
{
table = "No Results Returned";
}
return table;
}
}

View File

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

View File

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

View File

@ -26,9 +26,9 @@ else
}
@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()
{

View File

@ -41,14 +41,15 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@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()
{
List<Theme> themes = await ThemeService.GetThemesAsync();
var themes = await ThemeService.GetThemesAsync();
packages = await PackageService.GetPackagesAsync("theme");
foreach(Package package in packages.ToArray())
{
if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId))

View File

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

View File

@ -26,14 +26,14 @@
}
@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()
{
List<Package> packages = await PackageService.GetPackagesAsync("framework");
Package package = packages.FirstOrDefault();
var packages = await PackageService.GetPackagesAsync("framework");
var package = packages.FirstOrDefault();
if (package != null)
{
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);

View File

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

View File

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

View File

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

View File

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

View File

@ -106,26 +106,26 @@
}
@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;
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;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
@ -134,16 +134,18 @@
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
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)
{
username = user.Username;
email = user.Email;
displayname = user.DisplayName;
if (user.PhotoFileId != null)
{
photofileid = user.PhotoFileId.Value;
}
settings = await SettingService.GetUserSettingsAsync(user.UserId);
createdby = user.CreatedBy;
createdon = user.CreatedOn;
@ -162,19 +164,17 @@
}
private string GetProfileValue(string SettingName, string DefaultValue)
{
return SettingService.GetSetting(settings, SettingName, DefaultValue);
}
=> SettingService.GetSetting(settings, SettingName, DefaultValue);
private async Task SaveUser()
{
try
{
if (username != "" && password != "" && confirm != "" && email != "")
if (username != string.Empty && password != string.Empty && confirm != string.Empty && email != string.Empty)
{
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.Username = username;
user.Password = password;
@ -182,10 +182,12 @@
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
user.PhotoFileId = null;
photofileid = filemanager.GetFileId();
if (photofileid != -1)
{
user.PhotoFileId = photofileid;
}
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
user = await UserService.UpdateUserAsync(user);
@ -213,7 +215,7 @@
private void ProfileChanged(ChangeEventArgs e, string SettingName)
{
string value = (string)e.Value;
var value = (string)e.Value;
settings = SettingService.SetSetting(settings, SettingName, value);
}

View File

@ -28,9 +28,9 @@ else
}
@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()
{
@ -42,7 +42,7 @@ else
{
try
{
User user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
if (user != null)
{
await UserService.DeleteUserAsync(user.UserId);

View File

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

View File

@ -39,6 +39,11 @@
}
@code {
private bool _visible = false;
private bool _editmode = true;
private bool _authorized = false;
private string _iconSpan = string.Empty;
[Parameter]
public string Header { get; set; } // required
@ -69,11 +74,6 @@
[Parameter]
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()
{
if (string.IsNullOrEmpty(Text))

View File

@ -15,6 +15,15 @@
}
@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]
public string Action { get; set; } // required
@ -42,15 +51,6 @@
[Parameter]
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()
{
_text = Action;
@ -90,14 +90,14 @@
private bool IsAuthorized()
{
bool authorized = false;
var authorized = false;
if (PageState.EditMode || !_editmode)
{
SecurityAccessLevel security = SecurityAccessLevel.Host;
var security = SecurityAccessLevel.Host;
if (Security == null)
{
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
Type moduleType = Type.GetType(typename);
var typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
var moduleType = Type.GetType(typename);
if (moduleType != null)
{
var moduleobject = Activator.CreateInstance(moduleType);
@ -113,6 +113,7 @@
{
security = Security.Value;
}
switch (security)
{
case SecurityAccessLevel.Anonymous:
@ -132,6 +133,7 @@
break;
}
}
return authorized;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@
<RichTextEditor @ref="@RichTextEditorHtml">
<ToolbarContent>
<select class="ql-header">
<option selected=""></option>
<option selected=string.Empty></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
@ -67,16 +67,19 @@
</div>
@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
{
get { return SecurityAccessLevel.Edit; }
}
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
public override string Title
{
get { return "Edit Html/Text"; }
}
public override string Title => "Edit Html/Text";
public bool RichTextEditorMode
{
@ -88,27 +91,16 @@
if (_richTextEditorMode)
{
_visibleText = "d-none";
_visibleRich = "";
_visibleRich = string.Empty;
}
else
{
_visibleText = "";
_visibleText = string.Empty;
_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)
{
try
@ -131,8 +123,8 @@
private async Task LoadText()
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
var htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
var htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
content = htmltext.Content;
@ -170,12 +162,12 @@
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
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
var htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
var htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
htmltext.Content = content;
@ -188,6 +180,7 @@
htmltext.Content = content;
await htmltextservice.AddHtmlTextAsync(htmltext);
}
await logger.LogInformation("Html/Text Content Saved {HtmlText}", htmltext);
NavigationManager.NavigateTo(NavigateUrl());
}

View File

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

View File

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

View File

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

View File

@ -1,28 +1,29 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
@if (breadcrumbs != "")
@if (breadcrumbs != string.Empty)
{
@((MarkupString)breadcrumbs)
}
@code {
string breadcrumbs = "";
string breadcrumbs = string.Empty;
protected override void OnParametersSet()
{
breadcrumbs = "";
int? pageid = PageState.Page.PageId;
breadcrumbs = string.Empty;
var pageid = PageState.Page.PageId;
for (int i = PageState.Pages.Count - 1; i >= 0; i--)
{
Page p = PageState.Pages[i];
var p = PageState.Pages[i];
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;
pageid = p.ParentId;
}
}
if (breadcrumbs != "")
{
breadcrumbs = "<ol class=\"breadcrumb\">" + breadcrumbs + "</ol>";

View File

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

View File

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

View File

@ -11,7 +11,7 @@
{
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>";
}
}

View File

@ -1,7 +1,7 @@
@namespace Oqtane.Themes.Controls
@inherits ThemeControlBase
@if (menu != "")
@if (menu != string.Empty)
{
<div class="app-menu">
@((MarkupString)menu)
@ -9,11 +9,11 @@
}
@code {
private string menu = string.Empty;
[Parameter]
public string Orientation { get; set; }
string menu = "";
protected override void OnParametersSet()
{
switch (Orientation)
@ -29,8 +29,8 @@
private void CreateVerticalMenu()
{
int level = -1;
int securitylevel = int.MaxValue;
var level = -1;
var securitylevel = int.MaxValue;
menu = "<ul class=\"nav flex-column\">\n";
@ -47,21 +47,25 @@
}
else
{
string target = "";
string target = String.Empty;
if (p.Url.StartsWith("http"))
{
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=\string.Empty + NavigateUrl(p.Path) + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\">";
if (p.HasChildren)
{
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 += p.Name;
menu += "</a>\n";
menu += "</li>\n";
@ -76,17 +80,19 @@
}
}
}
menu += "</ul>";
}
private void CreateHorizontalMenu()
{
string url = "";
string target = "";
var url = String.Empty;
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 += "<div class=\"collapse navbar-collapse\" id=\"Menu\">";
menu += "<ul class=\"navbar-nav mr-auto\">";
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)
@ -94,7 +100,7 @@
if (string.IsNullOrEmpty(p.Url))
{
url = NavigateUrl(p.Path);
target = "";
target = String.Empty;
}
else
{
@ -108,19 +114,20 @@
if (p.PageId == PageState.Page.PageId)
{
menu += "<li class=\"nav-item active\">" +
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" +
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") +
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
((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>";
}
else
{
menu += "<li class=\"nav-item\">" +
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" +
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") +
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
p.Name + "</a></li>";
}
}
}
menu += "</ul>";
menu += "</div>";
}

View File

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

View File

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

View File

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

View File

@ -14,5 +14,5 @@
</div>
@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>
@code {
public override string Panes { get { return "Content"; } }
public override string Panes => "Content";
}

View File

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

View File

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

View File

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

View File

@ -12,6 +12,9 @@
</div>
@code {
private string _paneadminborder = "";
private string _panetitle = "";
[CascadingParameter]
protected PageState PageState { get; set; }
@ -20,9 +23,6 @@
RenderFragment DynamicComponent { get; set; }
string _paneadminborder = "";
string _panetitle = "";
protected override void OnParametersSet()
{
if (PageState.EditMode && !PageState.Page.EditMode && UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
@ -45,13 +45,14 @@
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
if (module != null)
{
string typename = module.ModuleType;
// check for core module actions component
var typename = module.ModuleType;
// check for core module actions component
if (Constants.DefaultModuleActions.Contains(PageState.Action))
{
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
}
Type moduleType = Type.GetType(typename);
var moduleType = Type.GetType(typename);
if (moduleType != null)
{
bool authorized = false;
@ -61,7 +62,6 @@
}
else
{
// verify security access level for this module control
switch (module.SecurityAccessLevel)
{
case SecurityAccessLevel.Anonymous:
@ -81,12 +81,14 @@
break;
}
}
if (authorized)
{
if (!Constants.DefaultModuleActions.Contains(PageState.Action) && module.ControlTitle != "")
{
module.Title = module.ControlTitle;
}
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
builder.AddAttribute(1, "Module", module);
builder.CloseComponent();
@ -94,7 +96,7 @@
}
else
{
// module control does not exist with name specified
// module control does not exist with name specified
}
}
}
@ -106,7 +108,7 @@
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
if (module != null && module.Pane.ToLower() == Name.ToLower())
{
// check if user is authorized to view module
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
@ -119,7 +121,7 @@
{
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray())
{
// check if user is authorized to view module
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));

View File

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

View File

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

View File

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