diff --git a/LICENSE b/LICENSE index 9a5062f7..6b68cd26 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2020 .NET Foundation +Copyright (c) 2018-2021 .NET Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Oqtane.Client/App.razor b/Oqtane.Client/App.razor index 01022680..82a0b24a 100644 --- a/Oqtane.Client/App.razor +++ b/Oqtane.Client/App.razor @@ -12,11 +12,13 @@ { @if (string.IsNullOrEmpty(_installation.Message)) { - - - - - +
+ + + + + +
} else { @@ -28,27 +30,50 @@ } @code { + [Parameter] + public string AntiForgeryToken { get; set; } + + [Parameter] + public string Runtime { get; set; } + + [Parameter] + public string RenderMode { get; set; } + private bool _initialized = false; + private string _display = "display: none;"; private Installation _installation = new Installation { Success = false, Message = "" }; private PageState PageState { get; set; } + protected override async Task OnParametersSetAsync() + { + _installation = await InstallationService.IsInstalled(); + if (_installation.Alias != null) + { + SiteState.Alias = _installation.Alias; + SiteState.AntiForgeryToken = AntiForgeryToken; + } + else + { + _installation.Message = "Site Not Configured Correctly - No Matching Alias Exists For Host Name"; + } + _initialized = true; + } + protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender && !_initialized) + if (firstRender) { - var interop = new Interop(JSRuntime); - SiteState.AntiForgeryToken = await interop.GetElementByName(Constants.RequestVerificationToken); - _installation = await InstallationService.IsInstalled(); - if (_installation.Alias != null) + if (string.IsNullOrEmpty(AntiForgeryToken)) { - SiteState.Alias = _installation.Alias; + // parameter values are not set when running on WebAssembly (seems to be a .NET 5 bug) - need to retrieve using JSInterop + var interop = new Interop(JSRuntime); + AntiForgeryToken = await interop.GetElementByName(Constants.RequestVerificationToken); + SiteState.AntiForgeryToken = AntiForgeryToken; + Runtime = await interop.GetElementByName("app_runtime"); + RenderMode = await interop.GetElementByName("app_rendermode"); } - else - { - _installation.Message = "Site Not Configured Correctly - No Matching Alias Exists For Host Name"; - } - _initialized = true; + _display = ""; StateHasChanged(); } } diff --git a/Oqtane.Client/Installer/Controls/LocalDBConfig.razor b/Oqtane.Client/Installer/Controls/LocalDBConfig.razor index 0785fe04..5d27d986 100644 --- a/Oqtane.Client/Installer/Controls/LocalDBConfig.razor +++ b/Oqtane.Client/Installer/Controls/LocalDBConfig.razor @@ -1,41 +1,30 @@ @namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl -@inject IStringLocalizer Localizer -@{ - foreach (var field in _connectionStringFields) - { - var fieldId = field.Name.ToLowerInvariant(); - field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm")); - - - - - - - - - - } -} +
+ +
+ +
+
+
+ +
+ +
+
@code { - private readonly List _connectionStringFields = new() - { - new() {Name = "Server", FriendlyName = "Server", Value = "(LocalDb)\\MSSQLLocalDB", HelpText="Enter the database server"}, - new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"} - }; + private string _server = "(LocalDb)\\MSSQLLocalDB"; + private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); public string GetConnectionString() { var connectionString = String.Empty; - var server = _connectionStringFields[0].Value; - var database = _connectionStringFields[1].Value; - - if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(database)) + if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database)) { - connectionString = $"Data Source={server};AttachDbFilename=|DataDirectory|\\{database}.mdf;Initial Catalog={database};Integrated Security=SSPI;"; + connectionString = $"Data Source={_server};AttachDbFilename=|DataDirectory|\\{_database}.mdf;Initial Catalog={_database};Integrated Security=SSPI;"; } return connectionString; diff --git a/Oqtane.Client/Installer/Controls/MySQLConfig.razor b/Oqtane.Client/Installer/Controls/MySQLConfig.razor index 7bd1f512..7de576b0 100644 --- a/Oqtane.Client/Installer/Controls/MySQLConfig.razor +++ b/Oqtane.Client/Installer/Controls/MySQLConfig.razor @@ -1,54 +1,58 @@ @namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl -@inject IStringLocalizer Localizer -@{ - foreach (var field in _connectionStringFields) - { - var fieldId = field.Name.ToLowerInvariant(); - var fieldType = (field.Name == "Pwd") ? "password" : "text"; - field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm")); - - - - - - - - - - } -} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
@code { - private readonly List _connectionStringFields = new() - { - new() {Name = "Server", FriendlyName = "Server", Value = "127.0.0.1", HelpText="Enter the database server"}, - new() {Name = "Port", FriendlyName = "Port", Value = "3306", HelpText="Enter the port used to connect to the server"}, - new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"}, - new() {Name = "Uid", FriendlyName = "User Id", Value = "", HelpText="Enter the username to use for the database"}, - new() {Name = "Pwd", FriendlyName = "Password", Value = "", HelpText="Enter the password to use for the database"} - }; + private string _server = "127.0.0.1"; + private string _port = "3306"; + private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); + private string _uid = String.Empty; + private string _pwd = String.Empty; public string GetConnectionString() { var connectionString = String.Empty; - var server = _connectionStringFields[0].Value; - var port = _connectionStringFields[1].Value; - var database = _connectionStringFields[2].Value; - var userId = _connectionStringFields[3].Value; - var password = _connectionStringFields[4].Value; - - if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(database) && !String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(password)) + if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database) && !String.IsNullOrEmpty(_uid) && !String.IsNullOrEmpty(_pwd)) { - connectionString = $"Server={server};Database={database};Uid={userId};Pwd={password};"; + connectionString = $"Server={_server};Database={_database};Uid={_uid};Pwd={_pwd};"; } - if (!String.IsNullOrEmpty(port)) + if (!String.IsNullOrEmpty(_port)) { - connectionString += $"Port={port};"; + connectionString += $"Port={_port};"; } + return connectionString; } } \ No newline at end of file diff --git a/Oqtane.Client/Installer/Controls/PostgreSQLConfig.razor b/Oqtane.Client/Installer/Controls/PostgreSQLConfig.razor index 012d6fdb..d3ff4eca 100644 --- a/Oqtane.Client/Installer/Controls/PostgreSQLConfig.razor +++ b/Oqtane.Client/Installer/Controls/PostgreSQLConfig.razor @@ -1,89 +1,76 @@ @namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl -@inject IStringLocalizer Localizer -@inject IStringLocalizer SharedLocalizer +@inject IStringLocalizer Localizer -@{ - foreach (var field in _connectionStringFields) - { - var fieldId = field.Name.ToLowerInvariant(); - if (field.Name != "IntegratedSecurity") - { - var isVisible = ""; - var fieldType = (field.Name == "Pwd") ? "password" : "text"; - if ((field.Name == "Uid" || field.Name == "Pwd")) - { - var intSecurityField = _connectionStringFields.Single(f => f.Name == "IntegratedSecurity"); - if (intSecurityField != null) - { - isVisible = (Convert.ToBoolean(intSecurityField.Value)) ? "display: none;" : ""; - } - } - - field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm")); - - - - - - - - - - } - else - { - - - - - - - - - } - } +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+@if (_security == "custom") +{ +
+ +
+ +
+
+
+ +
+ +
+
} @code { - private readonly List _connectionStringFields = new() - { - new() { Name = "Server", FriendlyName = "Server", Value = "127.0.0.1", HelpText = "Enter the database server" }, - new() { Name = "Port", FriendlyName = "Port", Value = "5432", HelpText = "Enter the port used to connect to the server" }, - new() { Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText = "Enter the name of the database" }, - new() { Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true", HelpText = "Select if you want integrated security or not" }, - new() { Name = "Uid", FriendlyName = "User Id", Value = "", HelpText = "Enter the username to use for the database" }, - new() { Name = "Pwd", FriendlyName = "Password", Value = "", HelpText = "Enter the password to use for the database" } - }; + private string _server = "127.0.0.1"; + private string _port = "5432"; + private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); + private string _security = "integrated"; + private string _uid = String.Empty; + private string _pwd = String.Empty; public string GetConnectionString() { var connectionString = String.Empty; - var server = _connectionStringFields[0].Value; - var port = _connectionStringFields[1].Value; - var database = _connectionStringFields[2].Value; - var integratedSecurity = Boolean.Parse(_connectionStringFields[3].Value); - var userId = _connectionStringFields[4].Value; - var password = _connectionStringFields[5].Value; - - if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(database) && !String.IsNullOrEmpty(port)) + if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database) && !String.IsNullOrEmpty(_port)) { - connectionString = $"Server={server};Port={port};Database={database};"; + connectionString = $"Server={_server};Port={_port};Database={_database};"; } - if (integratedSecurity) + if (_security == "integrated") { connectionString += "Integrated Security=true;"; } else { - if (!String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(password)) + if (!String.IsNullOrEmpty(_uid) && !String.IsNullOrEmpty(_pwd)) { - connectionString += $"User ID={userId};Password={password};"; + connectionString += $"User ID={_uid};Password={_pwd};"; } else { diff --git a/Oqtane.Client/Installer/Controls/SqlServerConfig.razor b/Oqtane.Client/Installer/Controls/SqlServerConfig.razor index 25ddd0ab..905f8006 100644 --- a/Oqtane.Client/Installer/Controls/SqlServerConfig.razor +++ b/Oqtane.Client/Installer/Controls/SqlServerConfig.razor @@ -1,87 +1,69 @@ @namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl -@inject IStringLocalizer Localizer -@inject IStringLocalizer SharedLocalizer +@inject IStringLocalizer Localizer -@{ - foreach (var field in _connectionStringFields) - { - var fieldId = field.Name.ToLowerInvariant(); - if (field.Name != "IntegratedSecurity") - { - var isVisible = ""; - var fieldType = (field.Name == "Pwd") ? "password" : "text"; - if ((field.Name == "Uid" || field.Name == "Pwd")) - { - var intSecurityField = _connectionStringFields.Single(f => f.Name == "IntegratedSecurity"); - if (intSecurityField != null) - { - isVisible = (Convert.ToBoolean(intSecurityField.Value)) ? "display: none;" : ""; - } - } - - field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm")); - - - - - - - - - - } - else - { - - - - - - - - - } - } +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+@if (_security == "custom") +{ +
+ +
+ +
+
+
+ +
+ +
+
} @code { - private readonly List _connectionStringFields = new() - { - new() { Name = "Server", FriendlyName = "Server", Value = ".", HelpText = "Enter the database server" }, - new() { Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText = "Enter the name of the database" }, - new() { Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true", HelpText = "Select if you want integrated security or not" }, - new() { Name = "Uid", FriendlyName = "User Id", Value = "", HelpText = "Enter the username to use for the database" }, - new() { Name = "Pwd", FriendlyName = "Password", Value = "", HelpText = "Enter the password to use for the database" } - }; + private string _server = String.Empty; + private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm"); + private string _security = "integrated"; + private string _uid = String.Empty; + private string _pwd = String.Empty; public string GetConnectionString() { var connectionString = String.Empty; - var server = _connectionStringFields[0].Value; - var database = _connectionStringFields[1].Value; - var integratedSecurity = Boolean.Parse(_connectionStringFields[2].Value); - var userId = _connectionStringFields[3].Value; - var password = _connectionStringFields[4].Value; - - if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(database)) + if (!String.IsNullOrEmpty(_server) && !String.IsNullOrEmpty(_database)) { - connectionString = $"Data Source={server};Initial Catalog={database};"; + connectionString = $"Data Source={_server};Initial Catalog={_database};"; } - if (integratedSecurity) + if (_security == "integrated") { connectionString += "Integrated Security=SSPI;"; } else { - if (!String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(password)) + if (!String.IsNullOrEmpty(_uid) && !String.IsNullOrEmpty(_pwd)) { - connectionString += $"User ID={userId};Password={password};"; + connectionString += $"User ID={_uid};Password={_pwd};"; } else { @@ -91,5 +73,4 @@ return connectionString; } - } \ No newline at end of file diff --git a/Oqtane.Client/Installer/Controls/SqliteConfig.razor b/Oqtane.Client/Installer/Controls/SqliteConfig.razor index e0445c7c..f35e5d6d 100644 --- a/Oqtane.Client/Installer/Controls/SqliteConfig.razor +++ b/Oqtane.Client/Installer/Controls/SqliteConfig.razor @@ -1,39 +1,23 @@ @namespace Oqtane.Installer.Controls @implements Oqtane.Interfaces.IDatabaseConfigControl -@inject IStringLocalizer Localizer -@{ - foreach (var field in _connectionStringFields) - { - var fieldId = field.Name.ToLowerInvariant(); - field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm")); - - - - - - - - - - } -} +
+ +
+ +
+
@code { - private readonly List _connectionStringFields = new() - { - new() {Name = "Server", FriendlyName = "File Name", Value = "Oqtane-{{Date}}.db", HelpText="Enter the file name to use for the database"} - }; + private string _server = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + ".db"; public string GetConnectionString() { var connectionstring = String.Empty; - var server = _connectionStringFields[0].Value; - - if (!String.IsNullOrEmpty(server)) + if (!String.IsNullOrEmpty(_server)) { - connectionstring = $"Data Source={server};"; + connectionstring = $"Data Source={_server};"; } return connectionstring; diff --git a/Oqtane.Client/Installer/Installer.razor b/Oqtane.Client/Installer/Installer.razor index e0a1ac71..7c656e13 100644 --- a/Oqtane.Client/Installer/Installer.razor +++ b/Oqtane.Client/Installer/Installer.razor @@ -20,78 +20,64 @@

@Localizer["DatabaseConfig"]


- - - - - - - @{ - if (_databaseConfigType != null) - { - @DatabaseConfigComponent; - } + } + + + + @{ + if (_databaseConfigType != null) + { + @DatabaseConfigComponent; } - -
- - - + @if (_databases != null) + { + foreach (var database in _databases) { - foreach (var database in _databases) + if (database.IsDefault) { - if (database.IsDefault) - { - - } - else - { - - } + + } + else + { + } } - -
+ } +

@Localizer["ApplicationAdmin"]


- - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+

@@ -116,7 +102,7 @@ private object _databaseConfig; private RenderFragment DatabaseConfigComponent { get; set; } - private string _hostUsername = UserNames.Host; + private string _hostUsername = string.Empty; private string _hostPassword = string.Empty; private string _confirmPassword = string.Empty; private string _hostEmail = string.Empty; @@ -164,7 +150,8 @@ if (firstRender) { var interop = new Interop(JSRuntime); - await interop.IncludeLink("app-stylesheet", "stylesheet", "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css", "text/css", "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T", "anonymous", ""); + await interop.IncludeLink("", "stylesheet", "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css", "text/css", "sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC", "anonymous", ""); + await interop.IncludeScript("", "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js", "sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM", "anonymous", "", "head", ""); } } @@ -176,7 +163,7 @@ connectionString = databaseConfigControl.GetConnectionString(); } - if (connectionString != "" && _hostUsername != "" && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && _hostEmail != "" && _hostEmail.Contains("@")) + if (connectionString != "" && !string.IsNullOrEmpty(_hostUsername) && _hostPassword.Length >= 6 && _hostPassword == _confirmPassword && !string.IsNullOrEmpty(_hostEmail) && _hostEmail.Contains("@")) { _loadingDisplay = ""; StateHasChanged(); @@ -190,9 +177,10 @@ DatabaseType = database.DBType, ConnectionString = connectionString, Aliases = uri.Authority, - HostEmail = _hostEmail, + HostUsername = _hostUsername, HostPassword = _hostPassword, - HostName = UserNames.Host, + HostEmail = _hostEmail, + HostName = _hostUsername, TenantName = TenantNames.Master, IsNewTenant = true, SiteName = Constants.DefaultSite, @@ -215,5 +203,4 @@ _message = Localizer["Message.Require.DbInfo"]; } } - } diff --git a/Oqtane.Client/Modules/Admin/Files/Add.razor b/Oqtane.Client/Modules/Admin/Files/Add.razor index 727c0bcf..a36e6cc2 100644 --- a/Oqtane.Client/Modules/Admin/Files/Add.razor +++ b/Oqtane.Client/Modules/Admin/Files/Add.razor @@ -9,55 +9,60 @@ - - - - - -
- - +
+
+ +
-
+ + + @SharedLocalizer["Cancel"]
@if (_folders != null) { - - - - - - - - - -
- - - -
- - - -
- - @SharedLocalizer["Cancel"] +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + @SharedLocalizer["Cancel"] +
}
@code { - private string url = string.Empty; + private ElementReference form; + private bool validated = false; + private string _url = string.Empty; private List _folders; private int _folderId = -1; + private string _name = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -73,37 +78,48 @@ private async Task Download() { - if (url == string.Empty || _folderId == -1) + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning); - return; - } + if (_url == string.Empty || _folderId == -1) + { + AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning); + return; + } - var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1); + if (string.IsNullOrEmpty(_name)) + { + _name = _url.Substring(_url.LastIndexOf("/", StringComparison.Ordinal) + 1); + } - if (!Constants.UploadableFiles.Split(',') - .Contains(Path.GetExtension(filename).ToLower().Replace(".", ""))) - { - AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning); - return; - } + if (!Constants.UploadableFiles.Split(',').Contains(Path.GetExtension(_name).ToLower().Replace(".", ""))) + { + AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning); + return; + } - if (!filename.IsPathOrFileValid()) - { - AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning); - return; - } + if (!_name.IsPathOrFileValid()) + { + AddModuleMessage(Localizer["Message.Required.UrlName"], MessageType.Warning); + return; + } - try - { - await FileService.UploadFileAsync(url, _folderId); - await logger.LogInformation("File Downloaded Successfully From Url {Url}", url); - AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success); + try + { + await FileService.UploadFileAsync(_url, _folderId, _name); + await logger.LogInformation("File Downloaded Successfully From Url {Url}", _url); + AddModuleMessage(Localizer["Success.Download.File"], MessageType.Success); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", _url, ex.Message); + AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error); + } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message); - AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } -} +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Files/Details.razor b/Oqtane.Client/Modules/Admin/Files/Details.razor index 44e7e3a2..56eca8c7 100644 --- a/Oqtane.Client/Modules/Admin/Files/Details.razor +++ b/Oqtane.Client/Modules/Admin/Files/Details.razor @@ -8,49 +8,54 @@ @if (_folders != null) { - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - @SharedLocalizer["Cancel"] -
-
- +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + @SharedLocalizer["Cancel"] +
+
+ +
} @code { + private ElementReference form; + private bool validated = false; private int _fileId = -1; private string _name; private List _folders; private int _folderId = -1; + private string _description = string.Empty; private int _size; private string _createdBy; private DateTime _createdOn; @@ -72,6 +77,7 @@ { _name = file.Name; _folderId = file.FolderId; + _description = file.Description; _size = file.Size; _createdBy = file.CreatedBy; _createdOn = file.CreatedOn; @@ -88,26 +94,36 @@ private async Task SaveFile() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (_name.IsPathOrFileValid()) + try { - File file = await FileService.GetFileAsync(_fileId); - file.Name = _name; - file.FolderId = _folderId; - file = await FileService.UpdateFileAsync(file); - await logger.LogInformation("File Saved {File}", file); - NavigationManager.NavigateTo(NavigateUrl()); + if (_name.IsPathOrFileValid()) + { + File file = await FileService.GetFileAsync(_fileId); + file.Name = _name; + file.FolderId = _folderId; + file.Description = _description; + file = await FileService.UpdateFileAsync(file); + await logger.LogInformation("File Saved {File}", file); + NavigationManager.NavigateTo(NavigateUrl()); + } + else + { + AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); + } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); + await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); + AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); - AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } -} +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Files/Edit.razor b/Oqtane.Client/Modules/Admin/Files/Edit.razor index 48d5ef79..4f53443f 100644 --- a/Oqtane.Client/Modules/Admin/Files/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Files/Edit.razor @@ -8,57 +8,67 @@ @if (_folders != null) { - - - - - - - - - - - - - - - - -
- - - + @if (PageState.QueryString.ContainsKey("id")) + { + + } + @foreach (Folder folder in _folders) + { + + } + + + +
+ +
+ +
+
+
+ +
@if (PageState.QueryString.ContainsKey("id")) { - + } - @foreach (Folder folder in _folders) + else { - + } - -
- - - -
- - - @if (PageState.QueryString.ContainsKey("id")) - { - - } - else - { - - } -
- - -
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + +
+
+ + + @if (!_isSystem) { @@ -79,11 +89,15 @@ } @code { + private ElementReference form; + private bool validated = false; private List _folders; private int _folderId = -1; private int _parentId = -1; private string _name; private string _type = FolderTypes.Private; + private string _imagesizes = string.Empty; + private string _capacity = "0"; private bool _isSystem; private string _permissions = string.Empty; private string _createdBy; @@ -114,6 +128,8 @@ _parentId = folder.ParentId ?? -1; _name = folder.Name; _type = folder.Type; + _imagesizes = folder.ImageSizes; + _capacity = folder.Capacity.ToString(); _isSystem = folder.IsSystem; _permissions = folder.Permissions; _createdBy = folder.CreatedBy; @@ -125,7 +141,6 @@ else { _parentId = _folders[0].FolderId; - _permissions = string.Empty; } } catch (Exception ex) @@ -137,70 +152,81 @@ private async Task SaveFolder() { - if (_name == string.Empty || _parentId == -1) + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - AddModuleMessage(Localizer["Message.Required.FolderParent"], MessageType.Warning); - return; - } - - if (!_name.IsPathOrFileValid()) - { - AddModuleMessage(Localizer["Message.Folder.InvalidName"], MessageType.Warning); - return; - } - - try - { - Folder folder; - if (_folderId != -1) + if (_name == string.Empty || _parentId == -1) { - folder = await FolderService.GetFolderAsync(_folderId); - } - else - { - folder = new Folder(); + AddModuleMessage(Localizer["Message.Required.FolderParent"], MessageType.Warning); + return; } - folder.SiteId = PageState.Site.SiteId; - - if (_parentId == -1) + if (!_name.IsPathOrFileValid()) { - folder.ParentId = null; - } - else - { - folder.ParentId = _parentId; + AddModuleMessage(Localizer["Message.Folder.InvalidName"], MessageType.Warning); + return; } - folder.Name = _name; - folder.Type = _type; - folder.IsSystem = _isSystem; - folder.Permissions = _permissionGrid.GetPermissions(); + try + { + Folder folder; + if (_folderId != -1) + { + folder = await FolderService.GetFolderAsync(_folderId); + } + else + { + folder = new Folder(); + } - if (_folderId != -1) - { - folder = await FolderService.UpdateFolderAsync(folder); - } - else - { - folder = await FolderService.AddFolderAsync(folder); - } + folder.SiteId = PageState.Site.SiteId; - if (folder != null) - { - await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId); - await logger.LogInformation("Folder Saved {Folder}", folder); - NavigationManager.NavigateTo(NavigateUrl()); + if (_parentId == -1) + { + folder.ParentId = null; + } + else + { + folder.ParentId = _parentId; + } + + folder.Name = _name; + folder.Type = _type; + folder.ImageSizes = _imagesizes; + folder.Capacity = int.Parse(_capacity); + folder.IsSystem = _isSystem; + folder.Permissions = _permissionGrid.GetPermissions(); + + if (_folderId != -1) + { + folder = await FolderService.UpdateFolderAsync(folder); + } + else + { + folder = await FolderService.AddFolderAsync(folder); + } + + if (folder != null) + { + await FolderService.UpdateFolderOrderAsync(folder.SiteId, folder.FolderId, folder.ParentId); + await logger.LogInformation("Folder Saved {Folder}", folder); + NavigationManager.NavigateTo(NavigateUrl()); + } + else + { + AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error); + } } - else + catch (Exception ex) { + await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message); AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message); - AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } @@ -242,4 +268,4 @@ AddModuleMessage(Localizer["Error.Folder.Delete"], MessageType.Error); } } -} +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Files/Index.razor b/Oqtane.Client/Modules/Admin/Files/Index.razor index e119515c..11684f3f 100644 --- a/Oqtane.Client/Modules/Admin/Files/Index.razor +++ b/Oqtane.Client/Modules/Admin/Files/Index.razor @@ -8,34 +8,34 @@ @if (_files != null) { - - - - - - -
+
+
+
-
+ +
-
+ +
    -
+ + +
-   -   - @SharedLocalizer["Name"] - @Localizer["Modified"] - @Localizer["Type"] - @Localizer["Size"] +   +   + @SharedLocalizer["Name"] + @Localizer["Modified"] + @Localizer["Type"] + @Localizer["Size"]
diff --git a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor index 31d982c3..72e56897 100644 --- a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor @@ -5,98 +5,111 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - - -
- - - -
- - - -
- - - -
- - - -
- -@SharedLocalizer["Cancel"] -
-
- +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+
+ + @SharedLocalizer["Cancel"] +
+
+ +
@code { + private ElementReference form; + private bool validated = false; 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 DateTime? _startDate = null; + private string _startTime = string.Empty; + private DateTime? _endDate = null; + private string _endTime = string.Empty; private string _retentionHistory = string.Empty; - private string _nextExecution = string.Empty; + private DateTime? _nextDate = null; + private string _nextTime = string.Empty; private string createdby; private DateTime createdon; private string modifiedby; @@ -117,10 +130,22 @@ _isEnabled = job.IsEnabled.ToString(); _interval = job.Interval.ToString(); _frequency = job.Frequency; - _startDate = (job.StartDate != null) ? job.StartDate.ToString() : string.Empty; - _endDate = (job.EndDate != null) ? job.EndDate.ToString() : string.Empty; + _startDate = job.StartDate; + if (job.StartDate != null && job.StartDate.Value.TimeOfDay.TotalSeconds != 0) + { + _startTime = job.StartDate.Value.ToString("HH:mm"); + } + _endDate = job.EndDate; + if (job.EndDate != null && job.EndDate.Value.TimeOfDay.TotalSeconds != 0) + { + _endTime = job.EndDate.Value.ToString("HH:mm"); + } _retentionHistory = job.RetentionHistory.ToString(); - _nextExecution = job.NextExecution.ToString(); + _nextDate = job.NextExecution; + if (job.NextExecution != null && job.NextExecution.Value.TimeOfDay.TotalSeconds != 0) + { + _nextTime = job.NextExecution.Value.ToString("HH:mm"); + } createdby = job.CreatedBy; createdon = job.CreatedOn; modifiedby = job.ModifiedBy; @@ -136,7 +161,9 @@ private async Task SaveJob() { - if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty) + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { var job = await JobService.GetJobAsync(_jobId); job.Name = _name; @@ -144,35 +171,34 @@ job.IsEnabled = Boolean.Parse(_isEnabled); job.Frequency = _frequency; job.Interval = int.Parse(_interval); - - if (_startDate == string.Empty) + job.StartDate = _startDate; + if (job.StartDate != null) { - job.StartDate = null; + job.StartDate = job.StartDate.Value.Date; + if (!string.IsNullOrEmpty(_startTime)) + { + job.StartDate = DateTime.Parse(job.StartDate.Value.ToShortDateString() + " " + _startTime); + } } - else + job.EndDate = _endDate; + if (job.EndDate != null) { - job.StartDate = DateTime.Parse(_startDate); + job.EndDate = job.EndDate.Value.Date; + if (!string.IsNullOrEmpty(_endTime)) + { + job.EndDate = DateTime.Parse(job.EndDate.Value.ToShortDateString() + " " + _endTime); + } } - - if (_endDate == string.Empty) - { - job.EndDate = null; - } - else - { - job.EndDate = DateTime.Parse(_endDate); - } - - if (_nextExecution == string.Empty) - { - job.NextExecution = null; - } - else - { - job.NextExecution = DateTime.Parse(_nextExecution); - } - job.RetentionHistory = int.Parse(_retentionHistory); + job.NextExecution = _nextDate; + if (job.NextExecution != null) + { + job.NextExecution = job.NextExecution.Value.Date; + if (!string.IsNullOrEmpty(_nextTime)) + { + job.NextExecution = DateTime.Parse(job.NextExecution.Value.ToShortDateString() + " " + _nextTime); + } + } try { @@ -191,5 +217,4 @@ AddModuleMessage(Localizer["Message.Required.JobInfo"], MessageType.Warning); } } - } diff --git a/Oqtane.Client/Modules/Admin/Languages/Add.razor b/Oqtane.Client/Modules/Admin/Languages/Add.razor index 636305aa..69b6f97e 100644 --- a/Oqtane.Client/Modules/Admin/Languages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Languages/Add.razor @@ -23,50 +23,48 @@ else } else { - - - - - - - - - -
- - - -
- - - -
- +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
} @SharedLocalizer["Cancel"] - - - - - - - -
+
+
+
+ -
-   + -
+ + + @if (_packages != null) { @@ -77,10 +75,26 @@ else

@context.Name

  by:  @context.Owner
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)
- @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |  @SharedLocalizer["Search.Version"]: @context.Version  |  @SharedLocalizer["Search.Source"]: @context.PackageUrl + @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   + @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |   + @SharedLocalizer["Search.Version"]: @context.Version + @((MarkupString)(context.TrialPeriod > 0 ? "  |  " + context.TrialPeriod + " " + @SharedLocalizer["Trial"] + "" : "")) - - + + @if (context.Price != null && !string.IsNullOrEmpty(context.PackageUrl)) + { + + } + + + @if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl)) + { + @context.Price.Value.ToString("$#,##0.00") + } + else + { + + }
@@ -97,30 +111,69 @@ else } - - - - - -
- - - -
+
+
+ +
+ +
+
+
@SharedLocalizer["Cancel"]
} +@if (_productname != "") +{ +
+ +
+} + @code { + private ElementReference form; + private bool validated = false; + private string _code = string.Empty; private string _isDefault = "False"; private string _message; private IEnumerable _supportedCultures; private IEnumerable _availableCultures; private List _packages; + private string _price = "free"; private string _search = ""; + private string _productname = ""; + private string _license = ""; + private string _packageid = ""; + private string _version = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -146,7 +199,22 @@ else private async Task LoadTranslations() { - _packages = await PackageService.GetPackagesAsync("translation", _search); + _packages = await PackageService.GetPackagesAsync("translation", _search, _price, ""); + } + + private async void PriceChanged(ChangeEventArgs e) + { + try + { + _price = (string)e.Value; + _search = ""; + await LoadTranslations(); + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error On PriceChanged"); + } } private async Task Search() @@ -176,31 +244,88 @@ else private async Task SaveLanguage() { - var language = new Language + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - SiteId = PageState.Page.SiteId, - Name = CultureInfo.GetCultureInfo(_code).DisplayName, - Code = _code, - IsDefault = (_isDefault == null ? false : Boolean.Parse(_isDefault)) - }; + var language = new Language + { + SiteId = PageState.Page.SiteId, + Name = CultureInfo.GetCultureInfo(_code).DisplayName, + Code = _code, + IsDefault = (_isDefault == null ? false : Boolean.Parse(_isDefault)) + }; + try + { + language = await LanguageService.AddLanguageAsync(language); + + if (language.IsDefault) + { + await SetCultureAsync(language.Code); + } + + await logger.LogInformation("Language Added {Language}", language); + + NavigationManager.NavigateTo(NavigateUrl()); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message); + AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error); + } + } + else + { + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + } + } + + + private void HideModal() + { + _productname = ""; + _license = ""; + StateHasChanged(); + } + + private async Task GetPackage(string packageid, string version) + { try { - language = await LanguageService.AddLanguageAsync(language); - - if (language.IsDefault) + var package = await PackageService.GetPackageAsync(packageid, version); + if (package != null) { - await SetCultureAsync(language.Code); + _productname = package.Name; + if (!string.IsNullOrEmpty(package.License)) + { + _license = package.License.Replace("\n", "
"); + } + _packageid = package.PackageId; + _version = package.Version; } - - await logger.LogInformation("Language Added {Language}", language); - - NavigationManager.NavigateTo(NavigateUrl()); + StateHasChanged(); } catch (Exception ex) { - await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message); - AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error); + await logger.LogError(ex, "Error Getting Package {PackageId} {Version}", packageid, version); + AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error); + } + } + + private async Task DownloadPackage() + { + try + { + await PackageService.DownloadPackageAsync(_packageid, _version, "Packages"); + await logger.LogInformation("Language Package {Name} {Version} Downloaded Successfully", _packageid, _version); + AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success); + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading Translation {Name} {Version}", _packageid, _version); + AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error); } } @@ -217,22 +342,6 @@ else } } - private async Task DownloadLanguage(string packageid, string version) - { - try - { - await PackageService.DownloadPackageAsync(packageid, version, "Packages"); - await logger.LogInformation("Language Paclage {Name} {Version} Downloaded Successfully", packageid, version); - AddModuleMessage(Localizer["Success.Language.Download"], MessageType.Success); - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Downloading Translation {Name} {Version}", packageid, version); - AddModuleMessage(Localizer["Error.Language.Download"], MessageType.Error); - } - } - private async Task SetCultureAsync(string culture) { if (culture != CultureInfo.CurrentUICulture.Name) diff --git a/Oqtane.Client/Modules/Admin/Languages/Index.razor b/Oqtane.Client/Modules/Admin/Languages/Index.razor index b8a3d21d..08fc569b 100644 --- a/Oqtane.Client/Modules/Admin/Languages/Index.razor +++ b/Oqtane.Client/Modules/Admin/Languages/Index.razor @@ -29,9 +29,9 @@ else @if (UpgradeAvailable(context.Code)) - { + { - } + } diff --git a/Oqtane.Client/Modules/Admin/Login/Index.razor b/Oqtane.Client/Modules/Admin/Login/Index.razor index 868031fd..8399ae95 100644 --- a/Oqtane.Client/Modules/Admin/Login/Index.razor +++ b/Oqtane.Client/Modules/Admin/Login/Index.razor @@ -59,7 +59,7 @@ public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous; public override List Resources => new List() -{ + { new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } }; @@ -84,10 +84,12 @@ if (user != null) { + await logger.LogInformation(LogFunction.Security, "Email Verified For For Username {Username}", _username); _message = Localizer["Success.Account.Verified"]; } else { + await logger.LogError(LogFunction.Security, "Email Verification Failed For Username {Username}", _username); _message = Localizer["Message.Account.NotVerfied"]; _type = MessageType.Warning; } @@ -98,7 +100,10 @@ { if (firstRender) { - await username.FocusAsync(); + if(PageState.User == null) + { + await username.FocusAsync(); + } } } @@ -118,7 +123,7 @@ if (user.IsAuthenticated) { - await logger.LogInformation("Login Successful For Username {Username}", _username); + await logger.LogInformation(LogFunction.Security, "Login Successful For Username {Username}", _username); // server-side Blazor needs to post to the Login page so that the cookies are set correctly var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = _returnUrl }; string url = Utilities.TenantUrl(PageState.Alias, "/pages/login/"); @@ -126,7 +131,7 @@ } else { - await logger.LogInformation("Login Failed For Username {Username}", _username); + await logger.LogError(LogFunction.Security, "Login Failed For Username {Username}", _username); AddModuleMessage(Localizer["Error.Login.Fail"], MessageType.Error); } } @@ -140,14 +145,14 @@ user = await UserService.LoginUserAsync(user, true, _remember); if (user.IsAuthenticated) { - await logger.LogInformation("Login Successful For Username {Username}", _username); + await logger.LogInformation(LogFunction.Security, "Login Successful For Username {Username}", _username); var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider)); authstateprovider.NotifyAuthenticationChanged(); NavigationManager.NavigateTo(NavigateUrl(_returnUrl, true)); } else { - await logger.LogInformation("Login Failed For Username {Username}", _username); + await logger.LogError(LogFunction.Security, "Login Failed For Username {Username}", _username); AddModuleMessage(Localizer["Error.Login.Fail"], MessageType.Error); } } @@ -171,6 +176,7 @@ if (user != null) { await UserService.ForgotPasswordAsync(user); + await logger.LogInformation(LogFunction.Security, "Password Reset Notification Sent For Username {Username}", _username); _message = "Please Check The Email Address Associated To Your User Account For A Password Reset Notification"; } else diff --git a/Oqtane.Client/Modules/Admin/Logs/Detail.razor b/Oqtane.Client/Modules/Admin/Logs/Detail.razor index 65fa7a2c..91e4d0e7 100644 --- a/Oqtane.Client/Modules/Admin/Logs/Detail.razor +++ b/Oqtane.Client/Modules/Admin/Logs/Detail.razor @@ -9,206 +9,246 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - - - - - - - - - - - - - - - - @if (_pageName != string.Empty) - { - - - - - } - @if (_moduleTitle != string.Empty) - { - - - - - } - @if (_username != string.Empty) - { - - - - - } - - - - - - - - - - - - - @if (!string.IsNullOrEmpty(_exception)) - { - - - - - } - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
-@SharedLocalizer["Cancel"] +
+
-@code { - 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; +
- public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; +
+
+
- protected override async Task OnInitializedAsync() - { - try +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (_pageName != string.Empty) { - _logId = Int32.Parse(PageState.QueryString["id"]); - var log = await LogService.GetLogAsync(_logId); - if (log != null) +
+ +
+ +
+
+ } + @if (_moduleTitle != string.Empty) + { +
+ +
+ +
+
+ } + @if (_username != string.Empty) + { +
+ +
+ +
+
+ } +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (!string.IsNullOrEmpty(_exception)) + { +
+ +
+ +
+
+ } +
+ +
+ +
+
+
+ +
+ +
+
+ + @SharedLocalizer["Cancel"] + + @code { + 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; + + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; + + protected override async Task OnInitializedAsync() + { + try { - _logDate = log.LogDate.ToString(CultureInfo.CurrentCulture); - _level = log.Level; - _feature = log.Feature; - _function = log.Function; - _category = log.Category; - - if (log.PageId != null) + _logId = Int32.Parse(PageState.QueryString["id"]); + var log = await LogService.GetLogAsync(_logId); + if (log != null) { - var page = await PageService.GetPageAsync(log.PageId.Value); - if (page != null) - { - _pageName = page.Name; - } - } + _logDate = log.LogDate.ToString(CultureInfo.CurrentCulture); + _level = log.Level; + _feature = log.Feature; + _function = log.Function; + _category = log.Category; - if (log.PageId != null && log.ModuleId != null) - { - var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value); - if (pagemodule != null) + if (log.PageId != null) { - _moduleTitle = pagemodule.Title; + var page = await PageService.GetPageAsync(log.PageId.Value); + if (page != null) + { + _pageName = page.Name; + } } - } - if (log.UserId != null) - { - var user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId); - if (user != null) + if (log.PageId != null && log.ModuleId != null) { - _username = user.Username; + var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value); + if (pagemodule != null) + { + _moduleTitle = pagemodule.Title; + } } - } - _url = log.Url; - _template = log.MessageTemplate; - _message = log.Message; - _exception = log.Exception; - _properties = log.Properties; - _server = log.Server; + if (log.UserId != null) + { + 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; + _exception = log.Exception; + _properties = log.Properties; + _server = log.Server; + } + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Loading Log {LogId} {Error}", _logId, ex.Message); + AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error); } } - catch (Exception ex) - { - await logger.LogError(ex, "Error Loading Log {LogId} {Error}", _logId, ex.Message); - AddModuleMessage(Localizer["Error.Log.Load"], MessageType.Error); - } } -} diff --git a/Oqtane.Client/Modules/Admin/Logs/Index.razor b/Oqtane.Client/Modules/Admin/Logs/Index.razor index 02bd9d62..920ec709 100644 --- a/Oqtane.Client/Modules/Admin/Logs/Index.razor +++ b/Oqtane.Client/Modules/Admin/Logs/Index.razor @@ -10,9 +10,9 @@ } else { - - - - - - -
+
+
+


-
+ +


-
+ +


-
+ + + @if (_logs.Any()) {
-   - @Localizer["Date"] - @Localizer["Level"] - @Localizer["Feature"] - @Localizer["Function"] +   + @Localizer["Date"] + @Localizer["Level"] + @Localizer["Feature"] + @Localizer["Function"]
diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor index a6ac643b..25df6b21 100644 --- a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor @@ -10,82 +10,75 @@ @if (string.IsNullOrEmpty(_moduledefinitionname) && _templates != null) { - - - - - - - - - - - - - - - - - - - - - - @if (!string.IsNullOrEmpty(_location)) - { - - - - + + + +
+ +
+ +
+
+ @if (!string.IsNullOrEmpty(_location)) + { +
+ +
+ +
+
+ } + + + } -
- - - -
- - - -
- - - -
- - - -
- - - + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ -
- - - -
- -} -else -{ - + else + { + + } @code { + private ElementReference form; + private bool validated = false; private string _moduledefinitionname = string.Empty; private string _owner = string.Empty; private string _module = string.Empty; @@ -124,9 +117,11 @@ else private async Task CreateModule() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") + try { var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference }; moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition); @@ -139,14 +134,14 @@ else AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); + await logger.LogError(ex, "Error Creating Module"); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Creating Module"); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor index 400ec49b..ec123cc7 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor @@ -9,19 +9,19 @@ - - - - - - - -
+
+
+
+ -
-   + -
+ + + @if (_packages != null) { @@ -32,10 +32,26 @@

@context.Name

  by:  @context.Owner
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)
- @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |  @SharedLocalizer["Search.Version"]: @context.Version  |  @SharedLocalizer["Search.Source"]: @context.PackageUrl + @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   + @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |   + @SharedLocalizer["Search.Version"]: @context.Version + @((MarkupString)(context.TrialPeriod > 0 ? "  |  " + context.TrialPeriod + " " + @SharedLocalizer["Trial"] + "" : "")) - - + + @if (context.Price != null && !string.IsNullOrEmpty(context.PackageUrl)) + { + + } + + + @if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl)) + { + @context.Price.Value.ToString("$#,##0.00") + } + else + { + + }
@@ -50,25 +66,61 @@ } - - - - - -
- - +
+
+ +
-
+ + +
+@if (_productname != "") +{ +
+ +
+} + @SharedLocalizer["Cancel"] @code { private List _packages; + private string _price = "free"; private string _search = ""; + private string _productname = ""; + private string _license = ""; + private string _packageid = ""; + private string _version = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; @@ -88,7 +140,7 @@ private async Task LoadModuleDefinitions() { var moduledefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); - _packages = await PackageService.GetPackagesAsync("module", _search); + _packages = await PackageService.GetPackagesAsync("module", _search, _price, ""); if (_packages != null) { @@ -102,6 +154,21 @@ } } + private async void PriceChanged(ChangeEventArgs e) + { + try + { + _price = (string)e.Value; + _search = ""; + await LoadModuleDefinitions(); + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error On PriceChanged"); + } + } + private async Task Search() { try @@ -127,6 +194,55 @@ } } + private void HideModal() + { + _productname = ""; + _license = ""; + StateHasChanged(); + } + + private async Task GetPackage(string packageid, string version) + { + try + { + var package = await PackageService.GetPackageAsync(packageid, version); + if (package != null) + { + _productname = package.Name; + if (!string.IsNullOrEmpty(package.License)) + { + _license = package.License.Replace("\n", "
"); + } + _packageid = package.PackageId; + _version = package.Version; + } + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Getting Package {PackageId} {Version}", packageid, version); + AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error); + } + } + + private async Task DownloadPackage() + { + try + { + await PackageService.DownloadPackageAsync(_packageid, _version, "Packages"); + await logger.LogInformation("Package {PackageId} {Version} Downloaded Successfully", _packageid, _version); + AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success); + _productname = ""; + _license = ""; + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading Package {PackageId} {Version}", _packageid, _version); + AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error); + } + } + private async Task InstallModules() { try @@ -139,20 +255,4 @@ await logger.LogError(ex, "Error Installing Module"); } } - - private async Task DownloadModule(string packageid, string version) - { - try - { - await PackageService.DownloadPackageAsync(packageid, version, "Packages"); - await logger.LogInformation("Module {ModuleDefinitionName} {Version} Downloaded Successfully", packageid, version); - AddModuleMessage(Localizer["Success.Module.Download"], MessageType.Success); - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version}", packageid, version); - AddModuleMessage(Localizer["Error.Module.Download"], MessageType.Error); - } - } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor index c4fae60b..6adc392a 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor @@ -10,79 +10,71 @@ @if (_templates != null) { - - - - - - - - - - - - - - - - - - - - - - @if (!string.IsNullOrEmpty(_location)) - { - - - - - } -
- - - -
- - - -
- - - -
- - - -
- - - + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ -
- - - -
- - @SharedLocalizer["Cancel"] + + + +
+ +
+ +
+
+ @if (!string.IsNullOrEmpty(_location)) + { +
+ +
+ +
+
+ } + + + @SharedLocalizer["Cancel"] + } @code { + private ElementReference form; + private bool validated = false; private string _owner = string.Empty; private string _module = string.Empty; private string _description = string.Empty; @@ -111,23 +103,32 @@ private async Task CreateModule() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") + try { - var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference }; - moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition); - GetLocation(); - AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); + if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") + { + var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference }; + moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition); + GetLocation(); + AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); + } + else + { + AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); + } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); + await logger.LogError(ex, "Error Creating Module"); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Creating Module"); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor index 604a5904..aa1da441 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor @@ -7,101 +7,81 @@ - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
+ + +
- - - - -
- -
+
+
+ +
+
@@ -111,6 +91,8 @@ @code { + private ElementReference form; + private bool validated = false; private int _moduleDefinitionId; private string _name; private string _version; @@ -168,30 +150,39 @@ private async Task SaveModuleDefinition() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); - if (moduledefinition.Name != _name) + try { - moduledefinition.Name = _name; + var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); + if (moduledefinition.Name != _name) + { + moduledefinition.Name = _name; + } + if (moduledefinition.Description != _description) + { + moduledefinition.Description = _description; + } + if (moduledefinition.Categories != _categories) + { + moduledefinition.Categories = _categories; + } + moduledefinition.Permissions = _permissionGrid.GetPermissions(); + await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); + await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); + NavigationManager.NavigateTo(NavigateUrl()); } - if (moduledefinition.Description != _description) + catch (Exception ex) { - moduledefinition.Description = _description; + await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); + AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); } - if (moduledefinition.Categories != _categories) - { - moduledefinition.Categories = _categories; - } - moduledefinition.Permissions = _permissionGrid.GetPermissions(); - await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); - await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); - NavigationManager.NavigateTo(NavigateUrl()); } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); - AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor index 70a3abba..abce34a4 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor @@ -22,6 +22,7 @@ else   @SharedLocalizer["Name"] @SharedLocalizer["Version"] + @SharedLocalizer["Expires"]   @@ -34,11 +35,14 @@ else @context.Name @context.Version + + @((MarkupString)PurchaseLink(context.PackageName)) + @if (UpgradeAvailable(context.PackageName, context.Version)) - { + { - } + } @@ -67,10 +71,31 @@ else } } + private string PurchaseLink(string packagename) + { + string link = ""; + if (!string.IsNullOrEmpty(packagename) && _packages != null) + { + var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault(); + if (package != null) + { + if (package.ExpiryDate != null && package.ExpiryDate.Value.Date != DateTime.MaxValue.Date) + { + link += "" + package.ExpiryDate.Value.Date.ToString("MMM dd, yyyy") + ""; + if (!string.IsNullOrEmpty(package.PaymentUrl)) + { + link += "  " + SharedLocalizer["Extend"] + ""; + } + } + } + } + return link; + } + private bool UpgradeAvailable(string packagename, string version) { var upgradeavailable = false; - if (_packages != null) + if (!string.IsNullOrEmpty(packagename) && _packages != null) { var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault(); if (package != null) diff --git a/Oqtane.Client/Modules/Admin/Modules/Export.razor b/Oqtane.Client/Modules/Admin/Modules/Export.razor index 41c7d73b..fb5938f4 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Export.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Export.razor @@ -5,31 +5,35 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - -
- - - -
+
+
+ +
+ +
+
+
+ @SharedLocalizer["Cancel"] - @code { private string _content = string.Empty; - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; public override string Title => "Export Content"; private async Task ExportModule() { - _content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId); + try + { + _content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId); + AddModuleMessage(Localizer["Success.Content.Export"], MessageType.Success); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Exporting Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); + AddModuleMessage(Localizer["Error.Module.Export"], MessageType.Error); + } } } diff --git a/Oqtane.Client/Modules/Admin/Modules/Import.razor b/Oqtane.Client/Modules/Admin/Modules/Import.razor index 833dbefc..7241b294 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Import.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Import.razor @@ -5,53 +5,63 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - -
- - - -
- -@SharedLocalizer["Cancel"] +
+
+
+ +
+ +
+
+
+ + + @SharedLocalizer["Cancel"] +
@code { private string _content = string.Empty; + private ElementReference form; + private bool validated = false; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; public override string Title => "Import Content"; private async Task ImportModule() { - if (_content != string.Empty) + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - try + if (_content != string.Empty) { - bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content); - if (success) + try { - AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success); + bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content); + if (success) + { + AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success); + } + else + { + AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning); + } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning); + await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); + AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); - AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error); + AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); } } else { - AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Modules/Settings.razor b/Oqtane.Client/Modules/Admin/Modules/Settings.razor index 7fc04462..e86ba978 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Settings.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Settings.razor @@ -8,97 +8,93 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - @if (_containers != null) - { - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - + + +
+ +
+ -
- } -
- - @if (_permissions != null) - { - - - - -
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ + } + + + @if (_permissions != null) + { +
+
-
+ + + + } +
+ @if (_moduleSettingsType != null) + { + + @ModuleSettingsComponent + } - - @if (_moduleSettingsType != null) - { - - @ModuleSettingsComponent - - } - @if (_containerSettingsType != null) - { - - @ContainerSettingsComponent - - } -
- -@SharedLocalizer["Cancel"] -
-
- + @if (_containerSettingsType != null) + { + + @ContainerSettingsComponent + + } + +
+ + @SharedLocalizer["Cancel"] +
+
+ + @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; public override string Title => "Module Settings"; + private ElementReference form; + private bool validated = false; private List _themes; private List _containers = new List(); private string _title; @@ -179,52 +175,61 @@ private async Task SaveModule() { - if (!string.IsNullOrEmpty(_title)) + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); - pagemodule.PageId = int.Parse(_pageId); - pagemodule.Title = _title; - pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty; - if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType) + if (!string.IsNullOrEmpty(_title)) { - pagemodule.ContainerType = string.Empty; - } - if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) - { - pagemodule.ContainerType = string.Empty; - } - await PageModuleService.UpdatePageModuleAsync(pagemodule); - await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); - - var module = ModuleState; - module.AllPages = bool.Parse(_allPages); - module.Permissions = _permissionGrid.GetPermissions(); - await ModuleService.UpdateModuleAsync(module); - - if (_moduleSettingsType != null) - { - if (_moduleSettings is ISettingsControl moduleSettingsControl) + var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); + pagemodule.PageId = int.Parse(_pageId); + pagemodule.Title = _title; + pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty; + if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType) { - // module settings updated using explicit interface - await moduleSettingsControl.UpdateSettings(); + pagemodule.ContainerType = string.Empty; } - else + if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) { - // legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component ) - _moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null); + pagemodule.ContainerType = string.Empty; } - } + await PageModuleService.UpdatePageModuleAsync(pagemodule); + await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); - if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) + var module = ModuleState; + module.AllPages = bool.Parse(_allPages); + module.Permissions = _permissionGrid.GetPermissions(); + await ModuleService.UpdateModuleAsync(module); + + if (_moduleSettingsType != null) + { + if (_moduleSettings is ISettingsControl moduleSettingsControl) + { + // module settings updated using explicit interface + await moduleSettingsControl.UpdateSettings(); + } + else + { + // legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component ) + _moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null); + } + } + + if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) + { + await containerSettingsControl.UpdateSettings(); + } + + NavigationManager.NavigateTo(NavigateUrl()); + } + else { - await containerSettingsControl.UpdateSettings(); + AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); } - - NavigationManager.NavigateTo(NavigateUrl()); } else { - AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 91a2f391..583b62f2 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -6,176 +6,154 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - @if (_themeList != null) - { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - + + +
+ +
+ +
+
+
+ +
+ + @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) { - + } - -
- - - - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) - { - - } -
- - - -
- - - -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - -
-
- } -
- - - - - -
- -
-
- @if (_themeSettingsType != null) - { - - @ThemeSettingsComponent + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ }
- } -
- - + +
+
+ +
+
+
+ @if (_themeSettingsType != null) + { + + @ThemeSettingsComponent + + } + + + + @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -187,7 +165,7 @@ private string _name; private string _title; private string _path = string.Empty; - private string _parentid; + private string _parentid = "-1"; private string _insert = ">>"; private List _children; private int _childid = -1; @@ -204,6 +182,8 @@ private object _themeSettings; private RenderFragment ThemeSettingsComponent { get; set; } private bool _refresh = false; + private ElementReference form; + private bool validated = false; protected override async Task OnInitializedAsync() { @@ -300,110 +280,125 @@ private async Task SavePage() { - Page page = null; - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_themetype) && _containertype != "-") + Page page = null; + try { - page = new Page(); - page.SiteId = PageState.Page.SiteId; - page.Name = _name; - page.Title = _title; - if (_path == "") + if (!string.IsNullOrEmpty(_themetype) && _containertype != "-") { - _path = _name; - } - - if (_path.Contains("/")) - { - _path = _path.Substring(_path.LastIndexOf("/") + 1); - } - - if (string.IsNullOrEmpty(_parentid)) - { - page.ParentId = null; - page.Path = Utilities.GetFriendlyUrl(_path); - } - else - { - page.ParentId = Int32.Parse(_parentid); - var parent = PageState.Pages.Where(item => item.PageId == page.ParentId).FirstOrDefault(); - if (parent.Path == string.Empty) + page = new Page(); + page.SiteId = PageState.Page.SiteId; + page.Name = _name; + page.Title = _title; + if (string.IsNullOrEmpty(_path)) { - page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); + _path = _name; + } + + if (_path.Contains("/")) + { + _path = _path.Substring(_path.LastIndexOf("/") + 1); + } + + if (_parentid == "-1") + { + page.ParentId = null; + page.Path = Utilities.GetFriendlyUrl(_path); } else { - page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path); + page.ParentId = Int32.Parse(_parentid); + 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); + } + else + { + page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path); + } } - } - if (!PagePathIsUnique(page.Path, page.SiteId, _pageList)) - { - AddModuleMessage(string.Format(Localizer["Message.Page.Exists"], _path), MessageType.Warning); - return; - } + if(PagePathIsDeleted(page.Path, page.SiteId, _pageList)) + { + AddModuleMessage(string.Format(Localizer["Message.Page.Deleted"], _path), MessageType.Warning); + return; + } - Page child; - switch (_insert) - { - case "<<": - page.Order = 0; - break; - case "<": - child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault(); - page.Order = child.Order - 1; - break; - case ">": - child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault(); - page.Order = child.Order + 1; - break; - case ">>": - page.Order = int.MaxValue; - break; - } + if (!PagePathIsUnique(page.Path, page.SiteId, _pageList)) + { + AddModuleMessage(string.Format(Localizer["Message.Page.Exists"], _path), MessageType.Warning); + return; + } - page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation)); - page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); - page.Url = _url; - page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; - if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) - { - page.ThemeType = string.Empty; - } - page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty; - if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType) - { - page.DefaultContainerType = string.Empty; - } - page.Icon = (_icon == null ? string.Empty : _icon); - page.Permissions = _permissionGrid.GetPermissions(); - page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable)); - page.UserId = null; + Page child; + switch (_insert) + { + case "<<": + page.Order = 0; + break; + case "<": + child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault(); + page.Order = child.Order - 1; + break; + case ">": + child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault(); + page.Order = child.Order + 1; + break; + case ">>": + page.Order = int.MaxValue; + break; + } - page = await PageService.AddPageAsync(page); - await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId); + page.IsNavigation = (_isnavigation == null ? true : Boolean.Parse(_isnavigation)); + page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); + page.Url = _url; + page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; + if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) + { + page.ThemeType = string.Empty; + } + page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty; + if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType) + { + page.DefaultContainerType = string.Empty; + } + page.Icon = (_icon == null ? string.Empty : _icon); + page.Permissions = _permissionGrid.GetPermissions(); + page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable)); + page.UserId = null; - await logger.LogInformation("Page Added {Page}", page); - if (PageState.QueryString.ContainsKey("cp")) - { - NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); + page = await PageService.AddPageAsync(page); + await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId); + + await logger.LogInformation("Page Added {Page}", page); + if (PageState.QueryString.ContainsKey("cp")) + { + NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); + } + else + { + NavigationManager.NavigateTo(NavigateUrl(page.Path)); + } } else { - NavigationManager.NavigateTo(NavigateUrl(page.Path)); + AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); } - } - else - { - AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); - } + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); + AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); + } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); - AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } @@ -423,4 +418,9 @@ { return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath); } + + private static bool PagePathIsDeleted(string pagePath, int siteId, List existingPages) + { + return existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.IsDeleted == true); + } } diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 3e1c964a..00e02fab 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -7,192 +7,173 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - @if (_themeList != null) - { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - + + +
+ +
+ -
- - - - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) - { - - } -
- - - -
- - - -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - + @if (_parentid == _currentparentid) { - + } - -
- - - -
- - - -
- - - + + @foreach (Page page in _children) + { + + } + + } + + +
+ +
+ -
-
-

- - } -
- - @if (_permissions != null) - { - - - - -
- -
- } -
- @if (_themeSettingsType != null) - { - - @ThemeSettingsComponent + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+

+ + }
- } -
- - + + @if (_permissions != null) + { +
+
+ + +
+
+ + } +
+ @if (_themeSettingsType != null) + { + + @ThemeSettingsComponent + +
+ } + + + + @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; + private ElementReference form; + private bool validated = false; private List _themeList; private List _themes = new List(); private List _containers = new List(); @@ -202,7 +183,7 @@ private string _title; private string _path; private string _currentparentid; - private string _parentid; + private string _parentid = "-1"; private string _insert = "="; private List _children; private int _childid = -1; @@ -251,7 +232,7 @@ if (page.ParentId == null) { - _parentid = string.Empty; + _parentid = "-1"; } else { @@ -375,134 +356,142 @@ private async Task SavePage() { - Page page = null; - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && _containertype != "-") + Page page = null; + try { - page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); - string currentPath = page.Path; + if (!string.IsNullOrEmpty(_themetype) && _containertype != "-") + { + page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); + string currentPath = page.Path; - page.Name = _name; - page.Title = _title; - if (_path == "" && _name.ToLower() != "home") - if (_path == string.Empty && _name.ToLower() != "home") + page.Name = _name; + page.Title = _title; + if (string.IsNullOrEmpty(_path) && _name.ToLower() != "home") { _path = _name; } - if (_path.Contains("/")) - { - _path = _path.Substring(_path.LastIndexOf("/") + 1); - } - if (string.IsNullOrEmpty(_parentid) || _parentid == "-1") - { - page.ParentId = null; - page.Path = Utilities.GetFriendlyUrl(_path); - } - else - { - page.ParentId = Int32.Parse(_parentid); - Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId); - if (parent.Path == string.Empty) + if (_path.Contains("/")) { - page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); + _path = _path.Substring(_path.LastIndexOf("/") + 1); + } + if (_parentid == "-1") + { + page.ParentId = null; + page.Path = Utilities.GetFriendlyUrl(_path); } else { - page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path); + page.ParentId = Int32.Parse(_parentid); + Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId); + if (parent.Path == string.Empty) + { + page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); + } + else + { + page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path); + } } - } - if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList)) - { - AddModuleMessage(string.Format(Localizer["Mesage.Page.PathExists"], _path), MessageType.Warning); - return; - } - - if (_insert != "=") - { - Page child; - switch (_insert) + if (!PagePathIsUnique(page.Path, page.SiteId, page.PageId, _pageList)) { - case "<<": - page.Order = 0; - break; - case "<": - child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid); - if (child != null) page.Order = child.Order - 1; - break; - case ">": - child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid); - if (child != null) page.Order = child.Order + 1; - break; - case ">>": - page.Order = int.MaxValue; - break; + AddModuleMessage(string.Format(Localizer["Mesage.Page.PathExists"], _path), MessageType.Warning); + return; } - } - page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation)); - page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); - page.Url = _url; - page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; - if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) - { - page.ThemeType = string.Empty; - } - page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty; - if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType) - { - page.DefaultContainerType = string.Empty; - } - page.Icon = _icon ?? string.Empty; - page.Permissions = _permissionGrid.GetPermissions(); - 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 == string.Empty) - { - await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null); + if (_insert != "=") + { + Page child; + switch (_insert) + { + case "<<": + page.Order = 0; + break; + case "<": + child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid); + if (child != null) page.Order = child.Order - 1; + break; + case ">": + child = PageState.Pages.FirstOrDefault(item => item.PageId == _childid); + if (child != null) page.Order = child.Order + 1; + break; + case ">>": + page.Order = int.MaxValue; + break; + } + } + page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation)); + page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable)); + page.Url = _url; + page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; + if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) + { + page.ThemeType = string.Empty; + } + page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty; + if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType) + { + page.DefaultContainerType = string.Empty; + } + page.Icon = _icon ?? string.Empty; + page.Permissions = _permissionGrid.GetPermissions(); + 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 == string.Empty) + { + await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, null); + } + else + { + await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid)); + } + + // update child paths + if (_parentid != _currentparentid) + { + foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath))) + { + p.Path = p.Path.Replace(currentPath, page.Path); + await PageService.UpdatePageAsync(p); + } + } + + if (_themeSettingsType != null && _themeSettings is ISettingsControl themeSettingsControl) + { + await themeSettingsControl.UpdateSettings(); + } + + await logger.LogInformation("Page Saved {Page}", page); + if (PageState.QueryString.ContainsKey("cp")) + { + NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); + } + else + { + NavigationManager.NavigateTo(NavigateUrl(page.Path)); + } } else { - await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, int.Parse(_currentparentid)); - } - - // update child paths - if (_parentid != _currentparentid) - { - foreach (Page p in PageState.Pages.Where(item => item.Path.StartsWith(currentPath))) - { - p.Path = p.Path.Replace(currentPath, page.Path); - await PageService.UpdatePageAsync(p); - } - } - - if (_themeSettingsType != null && _themeSettings is ISettingsControl themeSettingsControl) - { - await themeSettingsControl.UpdateSettings(); - } - - await logger.LogInformation("Page Saved {Page}", page); - if (PageState.QueryString.ContainsKey("cp")) - { - NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); - } - else - { - NavigationManager.NavigateTo(NavigateUrl(page.Path)); + AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); + AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); - AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor index 5249172b..4280b053 100644 --- a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor @@ -5,105 +5,90 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- -@SharedLocalizer["Cancel"] -@if (PageState.QueryString.ContainsKey("id")) -{ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+

-
- -} + + @SharedLocalizer["Cancel"] + @if (PageState.QueryString.ContainsKey("id")) + { +
+
+ + } +
@code { private int _profileid = -1; + private ElementReference form; + private bool validated = false; private string _name = string.Empty; private string _title = string.Empty; private string _description = string.Empty; @@ -159,45 +144,54 @@ private async Task SaveProfile() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - Profile profile; - if (_profileid != -1) + try { - profile = await ProfileService.GetProfileAsync(_profileid); - } - else - { - profile = new Profile(); - } + Profile profile; + if (_profileid != -1) + { + profile = await ProfileService.GetProfileAsync(_profileid); + } + else + { + profile = new Profile(); + } - profile.SiteId = PageState.Site.SiteId; - profile.Name = _name; - profile.Title = _title; - profile.Description = _description; - profile.Category = _category; - profile.ViewOrder = int.Parse(_vieworder); - profile.MaxLength = int.Parse(_maxlength); - profile.DefaultValue = _defaultvalue; - profile.Options = _options; - profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired)); - profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate)); - if (_profileid != -1) - { - profile = await ProfileService.UpdateProfileAsync(profile); - } - else - { - profile = await ProfileService.AddProfileAsync(profile); - } + profile.SiteId = PageState.Site.SiteId; + profile.Name = _name; + profile.Title = _title; + profile.Description = _description; + profile.Category = _category; + profile.ViewOrder = int.Parse(_vieworder); + profile.MaxLength = int.Parse(_maxlength); + profile.DefaultValue = _defaultvalue; + profile.Options = _options; + profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired)); + profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate)); + if (_profileid != -1) + { + profile = await ProfileService.UpdateProfileAsync(profile); + } + else + { + profile = await ProfileService.AddProfileAsync(profile); + } - await logger.LogInformation("Profile Saved {Profile}", profile); - NavigationManager.NavigateTo(NavigateUrl()); + await logger.LogInformation("Profile Saved {Profile}", profile); + NavigationManager.NavigateTo(NavigateUrl()); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message); + AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error); + } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message); - AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index f942eb84..d33131c2 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -16,52 +16,43 @@ - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
} @@ -72,6 +63,8 @@ else @code { private string _username = string.Empty; + private ElementReference form; + private bool validated = false; private string _password = string.Empty; private string _confirm = string.Empty; private string _email = string.Empty; @@ -81,49 +74,58 @@ else private async Task Register() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - bool _isEmailValid = Utilities.IsValidEmail(_email); - - if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) + try { - if (_password == _confirm) - { - var user = new User - { - SiteId = PageState.Site.SiteId, - Username = _username, - DisplayName = (_displayname == string.Empty ? _username : _displayname), - Email = _email, - Password = _password - }; - user = await UserService.AddUserAsync(user); + bool _isEmailValid = Utilities.IsValidEmail(_email); - if (user != null) + if (_isEmailValid) + { + if (_password == _confirm) { - await logger.LogInformation("User Created {Username} {Email}", _username, _email); - AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info); + var user = new User + { + SiteId = PageState.Site.SiteId, + Username = _username, + DisplayName = (_displayname == string.Empty ? _username : _displayname), + Email = _email, + Password = _password + }; + user = await UserService.AddUserAsync(user); + + if (user != null) + { + await logger.LogInformation("User Created {Username} {Email}", _username, _email); + AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info); + } + else + { + await logger.LogError("Error Adding User {Username} {Email}", _username, _email); + AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error); + } } else { - await logger.LogError("Error Adding User {Username} {Email}", _username, _email); - AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error); + AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); } } else { - AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); + await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message); + AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message); - AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } @@ -131,4 +133,4 @@ else { NavigationManager.NavigateTo(NavigateUrl(string.Empty)); } -} \ No newline at end of file +} diff --git a/Oqtane.Client/Modules/Admin/Reset/Index.razor b/Oqtane.Client/Modules/Admin/Reset/Index.razor index 64acc352..545a573d 100644 --- a/Oqtane.Client/Modules/Admin/Reset/Index.razor +++ b/Oqtane.Client/Modules/Admin/Reset/Index.razor @@ -5,24 +5,28 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
-
- - +
+
+
+ + +
+
+ + +
+
+ + +
+ +
-
- - -
-
- - -
- - -
+ @code { + private ElementReference form; + private bool validated = false; private string _username = string.Empty; private string _password = string.Empty; private string _confirm = string.Empty; @@ -43,45 +47,54 @@ private async Task Reset() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty) + try { - if (_password == _confirm) + if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty) { - var user = new User + if (_password == _confirm) { - SiteId = PageState.Site.SiteId, - Username = _username, - Password = _password - }; - user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]); + var user = new User + { + SiteId = PageState.Site.SiteId, + Username = _username, + Password = _password + }; + user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]); - if (user != null) - { - await logger.LogInformation("User Password Reset {Username}", _username); - NavigationManager.NavigateTo(NavigateUrl("login")); + if (user != null) + { + await logger.LogInformation("User Password Reset {Username}", _username); + NavigationManager.NavigateTo(NavigateUrl("login")); + } + else + { + await logger.LogError("Error Resetting User Password {Username}", _username); + AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error); + } } else { - await logger.LogError("Error Resetting User Password {Username}", _username); - AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error); + AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); } } else { - AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); + await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message); + AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message); - AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Add.razor b/Oqtane.Client/Modules/Admin/Roles/Add.razor index 905d8061..f20a721d 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Add.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Add.razor @@ -6,37 +6,32 @@ @inject IStringLocalizer SharedLocalizer
- - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - - -
- - @SharedLocalizer["Cancel"] +
+ +

+ + @SharedLocalizer["Cancel"] + @code { @@ -77,7 +72,7 @@ } else { - AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Edit.razor b/Oqtane.Client/Modules/Admin/Roles/Edit.razor index 54d1bb0f..b217acce 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Edit.razor @@ -6,39 +6,34 @@ @inject IStringLocalizer SharedLocalizer
- - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - - -
- - @SharedLocalizer["Cancel"] -

- + + +

+ + @SharedLocalizer["Cancel"] +

+ +
@code { @@ -106,7 +101,7 @@ } else { - AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Users.razor b/Oqtane.Client/Modules/Admin/Roles/Users.razor index 4732c9f5..92015116 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Users.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Users.razor @@ -11,71 +11,71 @@ } else { - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - @SharedLocalizer["Cancel"] -
-

- -

- @Localizer["Users"] - @Localizer["Effective"] - @Localizer["Expiry"] -   -
- - @context.User.DisplayName - @context.EffectiveDate - @context.ExpiryDate - - - - - -

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+

+ + @SharedLocalizer["Cancel"] +
+
+

+ +

+ @Localizer["Users"] + @Localizer["Effective"] + @Localizer["Expiry"] +   +
+ + @context.User.DisplayName + @context.EffectiveDate + @context.ExpiryDate + + + + + +

+
+
+
} @code { + private ElementReference form; + private bool validated = false; + private int roleid; private string name = string.Empty; private List users; @@ -123,59 +123,78 @@ else private async Task SaveUserRole() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (userid != -1) + try { - var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault(); - if (userrole != null) + if (userid != -1) { - userrole.EffectiveDate = effectivedate; - userrole.ExpiryDate = expirydate; - await UserRoleService.UpdateUserRoleAsync(userrole); + var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault(); + if (userrole != null) + { + userrole.EffectiveDate = effectivedate; + userrole.ExpiryDate = expirydate; + await UserRoleService.UpdateUserRoleAsync(userrole); + } + else + { + userrole = new UserRole(); + userrole.UserId = userid; + userrole.RoleId = roleid; + userrole.EffectiveDate = effectivedate; + userrole.ExpiryDate = expirydate; + + await UserRoleService.AddUserRoleAsync(userrole); + } + + await logger.LogInformation("User Assigned To Role {UserRole}", userrole); + AddModuleMessage(Localizer["Success.User.AssignedRole"], MessageType.Success); + await GetUserRoles(); + StateHasChanged(); } else { - userrole = new UserRole(); - userrole.UserId = userid; - userrole.RoleId = roleid; - userrole.EffectiveDate = effectivedate; - userrole.ExpiryDate = expirydate; - - await UserRoleService.AddUserRoleAsync(userrole); + AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning); } - - await logger.LogInformation("User Assigned To Role {UserRole}", userrole); - AddModuleMessage(Localizer["Success.User.AssignedRole"], MessageType.Success); - await GetUserRoles(); - StateHasChanged(); } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning); + await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message); + AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error); } } - catch (Exception ex) + + else { - await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message); - AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } private async Task DeleteUserRole(int UserRoleId) { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - await UserRoleService.DeleteUserRoleAsync(UserRoleId); - await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId); - AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success); - await GetUserRoles(); - StateHasChanged(); + try + { + await UserRoleService.DeleteUserRoleAsync(UserRoleId); + await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId); + AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success); + await GetUserRoles(); + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message); + AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error); + } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message); - AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 328c039b..8602c80c 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -13,251 +13,217 @@ @if (_initialized) { - - - - - - - - - + +
+
+ +
+ +
+
+
+ +
+ @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + { + + } + else + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
-
- - - - - - - -
- - - -
- - - @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) - { - - } - else - { - - } -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - @Localizer["Smtp.Required.EnableNotificationJob"]
-
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- -

-
-
- - - - - - - - - - - - - -
- - - -
- - - -
- - - -
-
- @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) - { -
- - - - - - - - - - - - - -
- - - -
- - - -
- - - -
+
- } -
- - -
-
- +
+
+
+
+
+
+ @Localizer["Smtp.Required.EnableNotificationJob"]
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +

+ +
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + { +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ } +
+ + +
+
+ + } @code { + private ElementReference form; + private bool validated = false; private bool _initialized = false; private List _themeList; private List _themes = new List(); @@ -422,121 +388,130 @@ private async Task SaveSite() { - try + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-") + try { - var unique = true; - if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-") { - foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + var unique = true; + if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) { - if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId)) + foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { - unique = false; + if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId)) + { + unique = false; + } } } - } - if (unique) - { - var site = await SiteService.GetSiteAsync(PageState.Site.SiteId); - if (site != null) + if (unique) { - bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype); - - site.Name = _name; - site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); - site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); - - site.LogoFileId = null; - var logofileid = _logofilemanager.GetFileId(); - if (logofileid != -1) + var site = await SiteService.GetSiteAsync(PageState.Site.SiteId); + if (site != null) { - site.LogoFileId = logofileid; - } - var faviconFieldId = _faviconfilemanager.GetFileId(); - if (faviconFieldId != -1) - { - site.FaviconFileId = faviconFieldId; - } - site.DefaultThemeType = _themetype; - site.DefaultContainerType = _containertype; - site.AdminContainerType = _admincontainertype; + bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype); - site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled)); - var pwaappiconfileid = _pwaappiconfilemanager.GetFileId(); - if (pwaappiconfileid != -1) - { - site.PwaAppIconFileId = pwaappiconfileid; - } - var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId(); - if (pwasplashiconfileid != -1) - { - site.PwaSplashIconFileId = pwasplashiconfileid; - } + site.Name = _name; + site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); + site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); - site = await SiteService.UpdateSiteAsync(site); - - var settings = await SettingService.GetSiteSettingsAsync(site.SiteId); - SettingService.SetSetting(settings, "SMTPHost", _smtphost); - SettingService.SetSetting(settings, "SMTPPort", _smtpport); - SettingService.SetSetting(settings, "SMTPSSL", _smtpssl); - SettingService.SetSetting(settings, "SMTPUsername", _smtpusername); - SettingService.SetSetting(settings, "SMTPPassword", _smtppassword); - SettingService.SetSetting(settings, "SMTPSender", _smtpsender); - await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId); - - if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) - { - var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) + site.LogoFileId = null; + var logofileid = _logofilemanager.GetFileId(); + if (logofileid != -1) { - if (!names.Contains(alias.Name)) + site.LogoFileId = logofileid; + } + var faviconFieldId = _faviconfilemanager.GetFileId(); + if (faviconFieldId != -1) + { + site.FaviconFileId = faviconFieldId; + } + site.DefaultThemeType = _themetype; + site.DefaultContainerType = _containertype; + site.AdminContainerType = _admincontainertype; + + site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled)); + var pwaappiconfileid = _pwaappiconfilemanager.GetFileId(); + if (pwaappiconfileid != -1) + { + site.PwaAppIconFileId = pwaappiconfileid; + } + var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId(); + if (pwasplashiconfileid != -1) + { + site.PwaSplashIconFileId = pwasplashiconfileid; + } + + site = await SiteService.UpdateSiteAsync(site); + + var settings = await SettingService.GetSiteSettingsAsync(site.SiteId); + SettingService.SetSetting(settings, "SMTPHost", _smtphost); + SettingService.SetSetting(settings, "SMTPPort", _smtpport); + SettingService.SetSetting(settings, "SMTPSSL", _smtpssl); + SettingService.SetSetting(settings, "SMTPUsername", _smtpusername); + SettingService.SetSetting(settings, "SMTPPassword", _smtppassword); + SettingService.SetSetting(settings, "SMTPSender", _smtpsender); + await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId); + + if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + { + var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) { - await AliasService.DeleteAliasAsync(alias.AliasId); + if (!names.Contains(alias.Name)) + { + await AliasService.DeleteAliasAsync(alias.AliasId); + } + } + + foreach (string name in names) + { + if (!_aliasList.Exists(item => item.Name == name)) + { + Alias alias = new Alias(); + alias.Name = name; + alias.TenantId = site.TenantId; + alias.SiteId = site.SiteId; + await AliasService.AddAliasAsync(alias); + } } } - foreach (string name in names) + await logger.LogInformation("Site Settings Saved {Site}", site); + + if (refresh) { - if (!_aliasList.Exists(item => item.Name == name)) - { - Alias alias = new Alias(); - alias.Name = name; - alias.TenantId = site.TenantId; - alias.SiteId = site.SiteId; - await AliasService.AddAliasAsync(alias); - } + NavigationManager.NavigateTo(NavigateUrl()); // refresh to show new theme or container + } + else + { + AddModuleMessage(Localizer["Success.Settings.SaveSite"], MessageType.Success); } } - - await logger.LogInformation("Site Settings Saved {Site}", site); - - if (refresh) - { - NavigationManager.NavigateTo(NavigateUrl()); // refresh to show new theme or container - } - else - { - AddModuleMessage(Localizer["Success.Settings.SaveSite"], MessageType.Success); - } + } + else + { + AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning); } } else { - AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.SiteName"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(Localizer["Message.Required.SiteName"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message); + AddModuleMessage(Localizer["Error.SaveSite"], MessageType.Error); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message); - AddModuleMessage(Localizer["Error.SaveSite"], MessageType.Error); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Sites/Add.razor b/Oqtane.Client/Modules/Admin/Sites/Add.razor index 016ff9d4..448c6682 100644 --- a/Oqtane.Client/Modules/Admin/Sites/Add.razor +++ b/Oqtane.Client/Modules/Admin/Sites/Add.razor @@ -19,158 +19,140 @@ } else { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @if (_tenantid == "+") - { - - - - - - - - - - - - if (_databaseConfigType != null) + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (_tenantid == "+") { - @DatabaseConfigComponent; +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ if (_databaseConfigType != null) + { + @DatabaseConfigComponent; + } +
+ +
+ +
+
+
+ +
+ +
+
} - - - - - - - - - } -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -
-
-
- - - -
- - - + + +
+ +
+ +
+
+
+ +
+ -
- - - -
- - - -
- - @SharedLocalizer["Cancel"] + +
+
+ + @SharedLocalizer["Cancel"] + } @code { private List _databases; + private ElementReference form; + private bool validated = false; private string _databaseName = "LocalDB"; private Type _databaseConfigType; private object _databaseConfig; @@ -274,111 +256,120 @@ else private async Task SaveSite() { - if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-") + validated = true; + var interop = new Interop(JSRuntime); + if (await interop.FormValid(form)) { - var duplicates = new List(); - var aliases = await AliasService.GetAliasesAsync(); - foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-") { - if (aliases.Exists(item => item.Name == name)) + var duplicates = new List(); + var aliases = await AliasService.GetAliasesAsync(); + foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { - duplicates.Add(name); - } - } - - if (duplicates.Count == 0) - { - InstallConfig config = new InstallConfig(); - - if (_tenantid == "+") - { - if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null) + if (aliases.Exists(item => item.Name == name)) { - // validate host credentials - var user = new User(); - user.SiteId = PageState.Site.SiteId; - user.Username = UserNames.Host; - user.Password = _hostpassword; - user = await UserService.LoginUserAsync(user, false, false); - if (user.IsAuthenticated) - { - var connectionString = String.Empty; - if (_databaseConfig is IDatabaseConfigControl databaseConfigControl) - { - connectionString = databaseConfigControl.GetConnectionString(); - } - var database = _databases.SingleOrDefault(d => d.Name == _databaseName); + duplicates.Add(name); + } + } - if (connectionString != "") + if (duplicates.Count == 0) + { + InstallConfig config = new InstallConfig(); + + if (_tenantid == "+") + { + if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null) + { + // validate host credentials + var user = new User(); + user.SiteId = PageState.Site.SiteId; + user.Username = UserNames.Host; + user.Password = _hostpassword; + user = await UserService.LoginUserAsync(user, false, false); + if (user.IsAuthenticated) { - config.TenantName = _tenantName; - config.DatabaseType = database.DBType; - config.ConnectionString = connectionString; - config.HostEmail = user.Email; - config.HostPassword = _hostpassword; - config.HostName = user.DisplayName; - config.IsNewTenant = true; + var connectionString = String.Empty; + if (_databaseConfig is IDatabaseConfigControl databaseConfigControl) + { + connectionString = databaseConfigControl.GetConnectionString(); + } + var database = _databases.SingleOrDefault(d => d.Name == _databaseName); + + if (connectionString != "") + { + config.TenantName = _tenantName; + config.DatabaseType = database.DBType; + config.ConnectionString = connectionString; + config.HostEmail = user.Email; + config.HostPassword = _hostpassword; + config.HostName = user.DisplayName; + config.IsNewTenant = true; + } + else + { + AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error); + } } else { - AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error); + AddModuleMessage(Localizer["Error.InvalidPassword"], MessageType.Error); } } else { - AddModuleMessage(Localizer["Error.InvalidPassword"], MessageType.Error); + AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error); } } else { - AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error); + var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid)); + if (tenant != null) + { + config.TenantName = tenant.Name; + config.DatabaseType = tenant.DBType; + config.ConnectionString = tenant.DBConnectionString; + config.IsNewTenant = false; + } + } + + if (!string.IsNullOrEmpty(config.TenantName)) + { + config.SiteName = _name; + config.Aliases = _urls; + config.DefaultTheme = _themetype; + config.DefaultContainer = _containertype; + config.DefaultAdminContainer = _admincontainertype; + config.SiteTemplate = _sitetemplatetype; + + ShowProgressIndicator(); + + var installation = await InstallationService.Install(config); + if (installation.Success) + { + var aliasname = config.Aliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0]; + var uri = new Uri(NavigationManager.Uri); + NavigationManager.NavigateTo(uri.Scheme + "://" + aliasname, true); + } + else + { + await logger.LogError("Error Creating Site {Error}", installation.Message); + AddModuleMessage(installation.Message, MessageType.Error); + } } } else { - var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid)); - if (tenant != null) - { - config.TenantName = tenant.Name; - config.DatabaseType = tenant.DBType; - config.ConnectionString = tenant.DBConnectionString; - config.IsNewTenant = false; - } - } - - if (!string.IsNullOrEmpty(config.TenantName)) - { - config.SiteName = _name; - config.Aliases = _urls; - config.DefaultTheme = _themetype; - config.DefaultContainer = _containertype; - config.DefaultAdminContainer = _admincontainertype; - config.SiteTemplate = _sitetemplatetype; - - ShowProgressIndicator(); - - var installation = await InstallationService.Install(config); - if (installation.Success) - { - var aliasname = config.Aliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0]; - var uri = new Uri(NavigationManager.Uri); - NavigationManager.NavigateTo(uri.Scheme + "://" + aliasname, true); - } - else - { - await logger.LogError("Error Creating Site {Error}", installation.Message); - AddModuleMessage(installation.Message, MessageType.Error); - } + AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning); } } else { - AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning); } } else { - AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning); + AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Sql/Index.razor b/Oqtane.Client/Modules/Admin/Sql/Index.razor index a74d8d54..b22d279e 100644 --- a/Oqtane.Client/Modules/Admin/Sql/Index.razor +++ b/Oqtane.Client/Modules/Admin/Sql/Index.razor @@ -13,12 +13,11 @@ } else { - - - - - + + @if (_tenantid != "-1") { - - - - - - - - - - - - + + +
+ +
+ +
+
} -
- - +
+ +
+ +
-
- - +
+ +
-
- - + + +
+ +
-
- - - -
+ +


- @if (!string.IsNullOrEmpty(_results)) + @if (_results != null) { - @((MarkupString)_results) + @if (_results.Count > 0) + { +
+ +
+ @foreach (KeyValuePair kvp in _results.First()) + { + @kvp.Key + } +
+ + @foreach (KeyValuePair kvp in context) + { + @kvp.Value + } + +
+
+ } + else + { + @Localizer["Return.NoResult"] + } +
+
} } @@ -71,7 +89,7 @@ else private string _database = string.Empty; private string _connectionstring = string.Empty; private string _sql = string.Empty; - private string _results = string.Empty; + private List> _results; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; @@ -118,7 +136,7 @@ else { var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql }; sqlquery = await SqlService.ExecuteQueryAsync(sqlquery); - _results = DisplayResults(sqlquery.Results); + _results = sqlquery.Results; AddModuleMessage(Localizer["Success.QueryExecuted"], MessageType.Success); } else @@ -132,44 +150,4 @@ else AddModuleMessage(ex.Message, MessageType.Error); } } - - private string DisplayResults(List> results) - { - var table = string.Empty; - foreach (Dictionary item in results) - { - if (table == string.Empty) - { - table = "
"; - table += ""; - - foreach (KeyValuePair kvp in item) - { - table += ""; - } - - table += ""; - } - - table += ""; - - foreach (KeyValuePair kvp in item) - { - table += ""; - } - - table += ""; - } - - if (table != string.Empty) - { - table += "
" + kvp.Key + "
" + kvp.Value + "
"; - } - else - { - table = Localizer["Return.NoResult"]; - } - - return table; - } } diff --git a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor index 1d8771d3..9cd52ff2 100644 --- a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor +++ b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor @@ -7,105 +7,79 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
  -
@Localizer["Register"] -
+ + +

- - - - - - - - - - - - - - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
+ + +

  @Localizer["Access.ApiFramework"]  @@ -220,20 +190,4 @@ await logger.LogError(ex, "Error Restarting Application"); } } - - private async Task RegisterChecked(ChangeEventArgs e) - { - try - { - if ((bool)e.Value) - { - await InstallationService.RegisterAsync(PageState.User.Email); - AddModuleMessage(Localizer["Success.Register"], MessageType.Success); - } - } - catch (Exception ex) - { - await logger.LogError(ex, "Error On Register"); - } - } } \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor index 41dbace0..1f810e9d 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Add.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor @@ -9,19 +9,19 @@ - - - - - - - -
+
+
+
+ -
-   + -
+ + + @if (_packages != null) { @@ -32,10 +32,26 @@

@context.Name

  @SharedLocalizer["Search.By"]:  @context.Owner
@(context.Description.Length > 400 ? (context.Description.Substring(0, 400) + "...") : context.Description)
- @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |  @SharedLocalizer["Search.Version"]: @context.Version  |  @SharedLocalizer["Search.Source"]: @context.PackageUrl + @(String.Format("{0:n0}", context.Downloads)) @SharedLocalizer["Search.Downloads"]  |   + @SharedLocalizer["Search.Released"]: @context.ReleaseDate.ToString("MMM dd, yyyy")  |   + @SharedLocalizer["Search.Version"]: @context.Version + @((MarkupString)(context.TrialPeriod > 0 ? "  |  " + context.TrialPeriod + " " + @SharedLocalizer["Trial"] + "" : "")) - - + + @if (context.Price != null && !string.IsNullOrEmpty(context.PackageUrl)) + { + + } + + + @if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl)) + { + @context.Price.Value.ToString("$#,##0.00") + } + else + { + + } @@ -50,25 +66,62 @@ }
- - - - - -
- - +
+
+ +
-
+ + + +
+@if (_productname != "") +{ +
+ +
+} + @SharedLocalizer["Cancel"] @code { private List _packages; + private string _price = "free"; private string _search = ""; + private string _productname = ""; + private string _license = ""; + private string _packageid = ""; + private string _version = ""; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; @@ -88,7 +141,7 @@ private async Task LoadThemes() { var themes = await ThemeService.GetThemesAsync(); - _packages = await PackageService.GetPackagesAsync("theme", _search); + _packages = await PackageService.GetPackagesAsync("theme", _search, _price, ""); if (_packages != null) { @@ -102,6 +155,21 @@ } } + private async void PriceChanged(ChangeEventArgs e) + { + try + { + _price = (string)e.Value; + _search = ""; + await LoadThemes(); + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error On PriceChanged"); + } + } + private async Task Search() { try @@ -127,6 +195,55 @@ } } + private void HideModal() + { + _productname = ""; + _license = ""; + StateHasChanged(); + } + + private async Task GetPackage(string packageid, string version) + { + try + { + var package = await PackageService.GetPackageAsync(packageid, version); + if (package != null) + { + _productname = package.Name; + if (!string.IsNullOrEmpty(package.License)) + { + _license = package.License.Replace("\n", "
"); + } + _packageid = package.PackageId; + _version = package.Version; + } + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Getting Package {PackageId} {Version}", packageid, version); + AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error); + } + } + + private async Task DownloadPackage() + { + try + { + await PackageService.DownloadPackageAsync(_packageid, _version, "Packages"); + await logger.LogInformation("Package {PackageId} {Version} Downloaded Successfully", _packageid, _version); + AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success); + _productname = ""; + _license = ""; + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading Package {PackageId} {Version}", _packageid, _version); + AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error); + } + } + private async Task InstallThemes() { try @@ -139,20 +256,4 @@ await logger.LogError(ex, "Error Installing Theme"); } } - - private async Task DownloadTheme(string packageid, string version) - { - try - { - await PackageService.DownloadPackageAsync(packageid, version, "Packages"); - await logger.LogInformation("Theme {ThemeName} {Version} Downloaded Successfully", packageid, version); - AddModuleMessage(Localizer["Success.Theme.Download"], MessageType.Success); - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Downloading Module {ThemeName} {Version}", packageid, version); - AddModuleMessage(Localizer["Error.Theme.Download"], MessageType.Error); - } - } } diff --git a/Oqtane.Client/Modules/Admin/Themes/Create.razor b/Oqtane.Client/Modules/Admin/Themes/Create.razor index ba3c1930..f563c1ff 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Create.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Create.razor @@ -11,66 +11,56 @@ @if (_templates != null) { - - - - - - - - - - - - - - - - - - @if (!string.IsNullOrEmpty(_location)) - { - - - - - } -
- - - -
- - - -
- - - + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ -
- - - -
- - - -
+ } + + + + + @if (!string.IsNullOrEmpty(_location)) { +
+ +
+ +
+
+ } + +
@SharedLocalizer["Cancel"] } diff --git a/Oqtane.Client/Modules/Admin/Themes/Index.razor b/Oqtane.Client/Modules/Admin/Themes/Index.razor index a2a3932e..e656d4c6 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Index.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor @@ -21,8 +21,9 @@ else
    - @SharedLocalizer["Name"] - @SharedLocalizer["Version"] + @SharedLocalizer["Name"] + @SharedLocalizer["Version"] + @SharedLocalizer["Expires"]  
@@ -35,11 +36,14 @@ else @context.Name @context.Version + + @((MarkupString)PurchaseLink(context.PackageName)) + @if (UpgradeAvailable(context.PackageName, context.Version)) - { + { - } + } @@ -69,10 +73,31 @@ else } } + private string PurchaseLink(string packagename) + { + string link = ""; + if (!string.IsNullOrEmpty(packagename) && _packages != null) + { + var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault(); + if (package != null) + { + if (package.ExpiryDate != null && package.ExpiryDate.Value.Date != DateTime.MaxValue.Date) + { + link += "" + package.ExpiryDate.Value.Date.ToString("MMM dd, yyyy") + ""; + if (!string.IsNullOrEmpty(package.PaymentUrl)) + { + link += "  " + SharedLocalizer["Extend"] + ""; + } + } + } + } + return link; + } + private bool UpgradeAvailable(string packagename, string version) { var upgradeavailable = false; - if (_packages != null) + if (!string.IsNullOrEmpty(packagename) && _packages != null) { var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault(); if (package != null) diff --git a/Oqtane.Client/Modules/Admin/Themes/View.razor b/Oqtane.Client/Modules/Admin/Themes/View.razor index a9bb2281..30cac439 100644 --- a/Oqtane.Client/Modules/Admin/Themes/View.razor +++ b/Oqtane.Client/Modules/Admin/Themes/View.razor @@ -6,64 +6,50 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - +
+
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
- - + + +
+ +
-
+ + + @SharedLocalizer["Cancel"] @code { diff --git a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor index 73679d5b..52e6f01f 100644 --- a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor +++ b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor @@ -22,16 +22,14 @@
- - - - - -
- - +
+
+ +
-
+ + +
@@ -46,7 +44,7 @@ { try { - List packages = await PackageService.GetPackagesAsync("framework"); + List packages = await PackageService.GetPackagesAsync("framework", "", "", ""); if (packages != null) { _package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault(); @@ -73,7 +71,7 @@ AddModuleMessage(Localizer["Info.Upgrade.Wait"], MessageType.Info); ShowProgressIndicator(); var interop = new Interop(JSRuntime); - await interop.RedirectBrowser(NavigateUrl(), 20); + await interop.RedirectBrowser(NavigateUrl(), 10); await InstallationService.Upgrade(); } catch (Exception ex) diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor index a10e0c3a..356be354 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor @@ -8,32 +8,27 @@ @if (PageState.User != null) { - - - - - - - - - - - -
- - - -
- - - -
- - -