Client fixes

Client is partially done.
227 warnings left out of 1500
I like Rider
This commit is contained in:
Pavel Vesely
2020-03-15 15:18:32 +01:00
parent 5b3feaf26f
commit cf6643aef3
92 changed files with 1283 additions and 1262 deletions

View File

@ -1,6 +1,6 @@
@namespace Oqtane.UI
<CascadingValue Value="@ModuleState">
<CascadingValue Value="@_moduleState">
@DynamicComponent
</CascadingValue>
@ -13,13 +13,13 @@
RenderFragment DynamicComponent { get; set; }
Module ModuleState;
Module _moduleState;
protected override void OnParametersSet()
{
ModuleState = Module; // passed in from Pane component
string container = ModuleState.ContainerType;
if (PageState.ModuleId != -1 && PageState.Action != "" && ModuleState.UseAdminContainer)
_moduleState = Module; // passed in from Pane component
string container = _moduleState.ContainerType;
if (PageState.ModuleId != -1 && PageState.Action != "" && _moduleState.UseAdminContainer)
{
container = Constants.DefaultAdminContainer;
}

View File

@ -18,10 +18,10 @@
<tbody>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Database Type: </label>
<label class="control-label" style="font-weight: bold">Database Type: </label>
</td>
<td>
<select class="custom-select" @bind="@DatabaseType">
<select class="custom-select" @bind="@_databaseType">
<option value="LocalDB">Local Database</option>
<option value="SQLServer">SQL Server</option>
</select>
@ -29,23 +29,23 @@
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Server: </label>
<label class="control-label" style="font-weight: bold">Server: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@ServerName" />
<input type="text" class="form-control" @bind="@_serverName" />
</td>
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Database: </label>
<label class="control-label" style="font-weight: bold">Database: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@DatabaseName" />
<input type="text" class="form-control" @bind="@_databaseName" />
</td>
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Integrated Security: </label>
<label class="control-label" style="font-weight: bold">Integrated Security: </label>
</td>
<td>
<select class="custom-select" @onchange="SetIntegratedSecurity">
@ -54,20 +54,20 @@
</select>
</td>
</tr>
<tr style="@IntegratedSecurityDisplay">
<tr style="@_integratedSecurityDisplay">
<td>
<label for="Title" class="control-label" style="font-weight: bold">Username: </label>
<label class="control-label" style="font-weight: bold">Username: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@Username" />
<input type="text" class="form-control" @bind="@_username" />
</td>
</tr>
<tr style="@IntegratedSecurityDisplay">
<tr style="@_integratedSecurityDisplay">
<td>
<label for="Title" class="control-label" style="font-weight: bold">Password: </label>
<label class="control-label" style="font-weight: bold">Password: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@Password" />
<input type="password" class="form-control" @bind="@_password" />
</td>
</tr>
</tbody>
@ -79,34 +79,34 @@
<tbody>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Username: </label>
<label class="control-label" style="font-weight: bold">Username: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@HostUsername" readonly />
<input type="text" class="form-control" @bind="@_hostUsername" readonly />
</td>
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Password: </label>
<label class="control-label" style="font-weight: bold">Password: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@HostPassword" />
<input type="password" class="form-control" @bind="@_hostPassword" />
</td>
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Confirm: </label>
<label class="control-label" style="font-weight: bold">Confirm: </label>
</td>
<td>
<input type="password" class="form-control" @bind="@ConfirmPassword" />
<input type="password" class="form-control" @bind="@_confirmPassword" />
</td>
</tr>
<tr>
<td>
<label for="Title" class="control-label" style="font-weight: bold">Email: </label>
<label class="control-label" style="font-weight: bold">Email: </label>
</td>
<td>
<input type="text" class="form-control" @bind="@HostEmail" />
<input type="text" class="form-control" @bind="@_hostEmail" />
</td>
</tr>
</tbody>
@ -117,61 +117,61 @@
<div class="row">
<div class="mx-auto text-center">
<button type="button" class="btn btn-success" @onclick="Install">Install Now</button><br /><br />
@((MarkupString)@Message)
@((MarkupString)_message)
</div>
<div class="app-progress-indicator" style="@LoadingDisplay"></div>
<div class="app-progress-indicator" style="@_loadingDisplay"></div>
</div>
</div>
@code {
private string DatabaseType = "LocalDB";
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
private string DatabaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
private string Username = "";
private string Password = "";
private string HostUsername = Constants.HostUser;
private string HostPassword = "";
private string ConfirmPassword = "";
private string HostEmail = "";
private string Message = "";
private string _databaseType = "LocalDB";
private string _serverName = "(LocalDb)\\MSSQLLocalDB";
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
private string _username = "";
private string _password = "";
private string _hostUsername = Constants.HostUser;
private string _hostPassword = "";
private string _confirmPassword = "";
private string _hostEmail = "";
private string _message = "";
private string IntegratedSecurityDisplay = "display: none;";
private string LoadingDisplay = "display: none;";
private string _integratedSecurityDisplay = "display: none;";
private string _loadingDisplay = "display: none;";
private void SetIntegratedSecurity(ChangeEventArgs e)
{
if (Convert.ToBoolean((string)e.Value))
{
IntegratedSecurityDisplay = "display: none;";
_integratedSecurityDisplay = "display: none;";
}
else
{
IntegratedSecurityDisplay = "";
_integratedSecurityDisplay = "";
}
}
private async Task Install()
{
if (HostUsername != "" && HostPassword.Length >= 6 && HostPassword == ConfirmPassword && HostEmail != "")
if (_hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "")
{
LoadingDisplay = "";
_loadingDisplay = "";
StateHasChanged();
string connectionstring = "";
if (DatabaseType == "LocalDB")
if (_databaseType == "LocalDB")
{
connectionstring = "Data Source=" + ServerName + ";AttachDbFilename=|DataDirectory|\\" + DatabaseName + ".mdf;Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI;";
connectionstring = "Data Source=" + _serverName + ";AttachDbFilename=|DataDirectory|\\" + _databaseName + ".mdf;Initial Catalog=" + _databaseName + ";Integrated Security=SSPI;";
}
else
{
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
if (IntegratedSecurityDisplay == "display: none;")
connectionstring = "Data Source=" + _serverName + ";Initial Catalog=" + _databaseName + ";";
if (_integratedSecurityDisplay == "display: none;")
{
connectionstring += "Integrated Security=SSPI;";
}
else
{
connectionstring += "User ID=" + Username + ";Password=" + Password;
connectionstring += "User ID=" + _username + ";Password=" + _password;
}
}
@ -189,23 +189,23 @@
User user = new User();
user.SiteId = site.SiteId;
user.Username = HostUsername;
user.Password = HostPassword;
user.Email = HostEmail;
user.DisplayName = HostUsername;
user.Username = _hostUsername;
user.Password = _hostPassword;
user.Email = _hostEmail;
user.DisplayName = _hostUsername;
user = await UserService.AddUserAsync(user);
NavigationManager.NavigateTo("", true);
}
else
{
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
LoadingDisplay = "display: none;";
_message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
_loadingDisplay = "display: none;";
}
}
else
{
Message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
_message = "<div class=\"alert alert-danger\" role=\"alert\">Please Enter All Fields And Ensure Passwords Match And Are Greater Than 5 Characters In Length</div>";
}
}
}

View File

@ -43,7 +43,7 @@ namespace Oqtane.UI
}
}
public Task IncludeCSS(string id, string url)
public Task IncludeCss(string id, string url)
{
try
{

View File

@ -1,11 +1,11 @@
@namespace Oqtane.UI
<ModuleMessage Message="@message" Type="MessageType.Error" />
<ModuleMessage Message="@_message" Type="MessageType.Error" />
<CascadingValue Value="this">
<ModuleMessage @ref="modulemessage" />
<ModuleMessage @ref="ModuleMessage" />
@DynamicComponent
</CascadingValue>
@if (progressindicator)
@if (_progressindicator)
{
<div class="app-progress-indicator"></div>
}
@ -17,12 +17,12 @@
[CascadingParameter]
private Module ModuleState { get; set; }
private ModuleMessage modulemessage { get; set; }
string message;
private ModuleMessage ModuleMessage { get; set; }
string _message;
RenderFragment DynamicComponent { get; set; }
bool progressindicator = false;
bool _progressindicator = false;
protected override void OnParametersSet()
{
@ -48,12 +48,12 @@
else
{
// module does not exist with typename specified
message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
_message = "Module Does Not Have A Component Named " + Utilities.GetTypeNameLastSegment(typename, 0) + ".razor";
}
}
else
{
message = "Something is wrong with moduletype";
_message = "Something is wrong with moduletype";
}
};
@ -61,20 +61,20 @@
public void AddModuleMessage(string message, MessageType type)
{
progressindicator = false;
_progressindicator = false;
StateHasChanged();
modulemessage.SetModuleMessage(message, type);
ModuleMessage.SetModuleMessage(message, type);
}
public void ShowProgressIndicator()
{
progressindicator = true;
_progressindicator = true;
StateHasChanged();
}
public void HideProgressIndicator()
{
progressindicator = false;
_progressindicator = false;
StateHasChanged();
}
}

View File

@ -3,10 +3,10 @@
@inject IModuleService ModuleService
@inject IModuleDefinitionService ModuleDefinitionService
<div class="@paneadminborder">
@if (panetitle != "")
<div class="@_paneadminborder">
@if (_panetitle != "")
{
@((MarkupString)panetitle)
@((MarkupString)_panetitle)
}
@DynamicComponent
</div>
@ -20,20 +20,20 @@
RenderFragment DynamicComponent { get; set; }
string paneadminborder = "";
string panetitle = "";
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)
{
paneadminborder = "app-pane-admin-border";
panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
_paneadminborder = "app-pane-admin-border";
_panetitle = "<div class=\"app-pane-admin-title\">" + Name + " Pane</div>";
}
else
{
paneadminborder = "";
panetitle = "";
_paneadminborder = "";
_panetitle = "";
}
DynamicComponent = builder =>
@ -42,12 +42,12 @@
{
if (Name.ToLower() == Constants.AdminPane.ToLower())
{
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
if (module != null)
{
string typename = module.ModuleType;
// check for core module actions component
if (Constants.DefaultModuleActions.Contains(PageState.Action))
// check for core module actions component
if (Constants.DefaultModuleActions.Contains(PageState.Action))
{
typename = Constants.DefaultModuleActionsTemplate.Replace(Constants.ActionToken, PageState.Action);
}
@ -57,21 +57,21 @@
bool authorized = false;
if (Constants.DefaultModuleActions.Contains(PageState.Action))
{
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, PageState.Page.Permissions);
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions);
}
else
{
// verify security access level for this module control
switch (module.SecurityAccessLevel)
// verify security access level for this module control
switch (module.SecurityAccessLevel)
{
case SecurityAccessLevel.Anonymous:
authorized = true;
break;
case SecurityAccessLevel.View:
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions);
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions);
break;
case SecurityAccessLevel.Edit:
authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, module.Permissions);
authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, module.Permissions);
break;
case SecurityAccessLevel.Admin:
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
@ -94,7 +94,7 @@
}
else
{
// module control does not exist with name specified
// module control does not exist with name specified
}
}
}
@ -103,11 +103,11 @@
{
if (PageState.ModuleId != -1)
{
Module module = PageState.Modules.Where(item => item.ModuleId == PageState.ModuleId).FirstOrDefault();
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
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions))
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
builder.AddAttribute(1, "Module", module);
@ -119,8 +119,8 @@
{
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
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, module.Permissions))
// check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{
builder.OpenComponent(0, Type.GetType(Constants.ContainerComponent));
builder.AddAttribute(1, "Module", module);
@ -129,7 +129,7 @@
}
}
}
};
}
};
}
}

View File

@ -30,7 +30,7 @@ namespace Oqtane.UI
quillElement);
}
internal static ValueTask<string> GetHTML(
internal static ValueTask<string> GetHtml(
IJSRuntime jsRuntime,
ElementReference quillElement)
{
@ -51,11 +51,11 @@ namespace Oqtane.UI
internal static ValueTask<object> LoadEditorContent(
IJSRuntime jsRuntime,
ElementReference quillElement,
string Content)
string content)
{
return jsRuntime.InvokeAsync<object>(
"interop.loadQuillContent",
quillElement, Content);
quillElement, content);
}
internal static ValueTask<object> EnableEditor(
@ -70,11 +70,11 @@ namespace Oqtane.UI
internal static ValueTask<object> InsertImage(
IJSRuntime jsRuntime,
ElementReference quillElement,
string ImageURL)
string imageUrl)
{
return jsRuntime.InvokeAsync<object>(
"interop.insertQuillImage",
quillElement, ImageURL);
quillElement, imageUrl);
}
}
}

View File

@ -12,6 +12,7 @@
@inject IModuleDefinitionService ModuleDefinitionService
@inject ILogService LogService
@using System.Diagnostics.CodeAnalysis
@using Oqtane.Enums
@implements IHandleAfterRender
@DynamicComponent
@ -24,7 +25,7 @@
[Parameter]
public Action<PageState> OnStateChange { get; set; }
PageState pagestate;
PageState _pagestate;
RenderFragment DynamicComponent { get; set; }
string _absoluteUri;
@ -237,18 +238,20 @@
{
page = await ProcessPage(page, site, user);
pagestate = new PageState();
pagestate.Alias = alias;
pagestate.Site = site;
pagestate.Pages = pages;
pagestate.Page = page;
pagestate.User = user;
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
pagestate.QueryString = querystring;
pagestate.ModuleId = moduleid;
pagestate.Action = action;
_pagestate = new PageState
{
Alias = alias,
Site = site,
Pages = pages,
Page = page,
User = user,
Uri = new Uri(_absoluteUri, UriKind.Absolute),
QueryString = querystring,
ModuleId = moduleid,
Action = action
};
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Action != pagestate.Action))
if (PageState != null && (PageState.ModuleId != _pagestate.ModuleId || PageState.Action != _pagestate.Action))
{
reload = Reload.Page;
}
@ -256,17 +259,17 @@
if (PageState == null || reload >= Reload.Page)
{
modules = await ModuleService.GetModulesAsync(site.SiteId);
modules = ProcessModules(modules, page.PageId, pagestate.ModuleId, pagestate.Action, page.Panes, site.DefaultContainerType);
modules = ProcessModules(modules, page.PageId, _pagestate.ModuleId, _pagestate.Action, page.Panes, site.DefaultContainerType);
}
else
{
modules = PageState.Modules;
}
pagestate.Modules = modules;
pagestate.EditMode = editmode;
pagestate.LastSyncDate = lastsyncdate;
_pagestate.Modules = modules;
_pagestate.EditMode = editmode;
_pagestate.LastSyncDate = lastsyncdate;
OnStateChange?.Invoke(pagestate);
OnStateChange?.Invoke(_pagestate);
}
}
else