diff --git a/Oqtane.Client/Modules/Admin/Files/Add.razor b/Oqtane.Client/Modules/Admin/Files/Add.razor index 2ce5aaed..4021a033 100644 --- a/Oqtane.Client/Modules/Admin/Files/Add.razor +++ b/Oqtane.Client/Modules/Admin/Files/Add.razor @@ -7,52 +7,48 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- - -
-
- -
- -
+ + +
+
+ +
+
- @SharedLocalizer["Cancel"] - - - @if (_folders != null) - { -
-
- -
- -
-
-
- -
- -
-
+
+ @SharedLocalizer["Cancel"] +
+ + @if (_folders != null) + { +
+
+ +
+
- - @SharedLocalizer["Cancel"] - } - - - +
+
+ +
+ +
+
+
+ + @SharedLocalizer["Cancel"] + } +
+ @code { - private ElementReference form; - private bool validated = false; private string url = string.Empty; private List _folders; private int _folderId = -1; @@ -71,46 +67,37 @@ private async Task Download() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + if (url == string.Empty || _folderId == -1) { - if (url == string.Empty || _folderId == -1) - { - AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning); - return; - } - - var filename = 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 (!filename.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); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message); - AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error); - } + AddModuleMessage(Localizer["Message.Required.UrlFolder"], MessageType.Warning); + return; } - else + + var filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1); + + if (!Constants.UploadableFiles.Split(',') + .Contains(Path.GetExtension(filename).ToLower().Replace(".", ""))) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Download.InvalidExtension"], MessageType.Warning); + return; + } + + if (!filename.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); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading File From Url {Url} {Error}", url, ex.Message); + AddModuleMessage(Localizer["Error.Download.InvalidUrl"], MessageType.Error); } } -} \ 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 68a2548a..14610ca6 100644 --- a/Oqtane.Client/Modules/Admin/Files/Details.razor +++ b/Oqtane.Client/Modules/Admin/Files/Details.razor @@ -8,43 +8,39 @@ @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; @@ -86,35 +82,26 @@ private async Task SaveFile() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + if (_name.IsPathOrFileValid()) { - if (_name.IsPathOrFileValid()) - { - 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()); - } - else - { - AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); - } + 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()); } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); - AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); + AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); + AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); } } } diff --git a/Oqtane.Client/Modules/Admin/Files/Edit.razor b/Oqtane.Client/Modules/Admin/Files/Edit.razor index 0f6337f2..611b593f 100644 --- a/Oqtane.Client/Modules/Admin/Files/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Files/Edit.razor @@ -8,77 +8,73 @@ @if (_folders != null) { -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- @if (PageState.QueryString.ContainsKey("id")) - { - - } - else - { - - } -
-
-
-
- - - -
-
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ @if (PageState.QueryString.ContainsKey("id")) + { + + } + else + { + + } +
+
+
+
+ + - @if (!_isSystem) - { - - @((MarkupString)" ") - } - @SharedLocalizer["Cancel"] - @if (!_isSystem && PageState.QueryString.ContainsKey("id")) - { - @((MarkupString)" ") - - } -
-
- @if (PageState.QueryString.ContainsKey("id")) - { - - } - +
+
+
+ + @if (!_isSystem) + { + + @((MarkupString)" ") + } + @SharedLocalizer["Cancel"] + @if (!_isSystem && PageState.QueryString.ContainsKey("id")) + { + @((MarkupString)" ") + + } +
+
+ @if (PageState.QueryString.ContainsKey("id")) + { + + } } @code { - private ElementReference form; - private bool validated = false; private List _folders; private int _folderId = -1; private int _parentId = -1; @@ -137,79 +133,70 @@ private async Task SaveFolder() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + if (_name == string.Empty || _parentId == -1) { - if (_name == string.Empty || _parentId == -1) + 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) { - AddModuleMessage(Localizer["Message.Required.FolderParent"], MessageType.Warning); - return; + folder = await FolderService.GetFolderAsync(_folderId); + } + else + { + folder = new Folder(); } - if (!_name.IsPathOrFileValid()) + folder.SiteId = PageState.Site.SiteId; + + if (_parentId == -1) { - AddModuleMessage(Localizer["Message.Folder.InvalidName"], MessageType.Warning); - return; + folder.ParentId = null; + } + else + { + folder.ParentId = _parentId; } - try + folder.Name = _name; + folder.Type = _type; + folder.IsSystem = _isSystem; + folder.Permissions = _permissionGrid.GetPermissions(); + + if (_folderId != -1) { - Folder folder; - if (_folderId != -1) - { - folder = await FolderService.GetFolderAsync(_folderId); - } - else - { - folder = new Folder(); - } - - folder.SiteId = PageState.Site.SiteId; - - if (_parentId == -1) - { - folder.ParentId = null; - } - else - { - folder.ParentId = _parentId; - } - - folder.Name = _name; - folder.Type = _type; - 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); - } + folder = await FolderService.UpdateFolderAsync(folder); } - catch (Exception ex) + 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 { - await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message); AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Folder {FolderId} {Error}", _folderId, ex.Message); + AddModuleMessage(Localizer["Error.Folder.Save"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor index 50a2af33..f5f04239 100644 --- a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor @@ -5,77 +5,73 @@ @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; @@ -125,9 +121,7 @@ private async Task SaveJob() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty) { var job = await JobService.GetJobAsync(_jobId); job.Name = _name; @@ -182,4 +176,5 @@ 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 f93a7511..4657fe52 100644 --- a/Oqtane.Client/Modules/Admin/Languages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Languages/Add.razor @@ -23,31 +23,29 @@ else } else { -
-
-
- -
- -
-
-
- -
- -
+
+
+ +
+
- - +
+ +
+ +
+
+
+ } @SharedLocalizer["Cancel"] @@ -109,9 +107,6 @@ else } @code { - private ElementReference form; - private bool validated = false; - private string _code = string.Empty; private string _isDefault = "False"; private string _message; @@ -174,40 +169,31 @@ else private async Task SaveLanguage() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + var language = new Language { - 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) { - 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); + await SetCultureAsync(language.Code); } + + await logger.LogInformation("Language Added {Language}", language); + + NavigationManager.NavigateTo(NavigateUrl()); } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Adding Language {Language} {Error}", language, ex.Message); + AddModuleMessage(Localizer["Error.Language.Add"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor index 74774e7e..06149841 100644 --- a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor @@ -10,75 +10,71 @@ @if (string.IsNullOrEmpty(_moduledefinitionname) && _templates != null) { -
-
-
- -
- -
+
+
+ +
+
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- @if (!string.IsNullOrEmpty(_location)) - { -
- -
- -
-
- }
- - - } - else +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (!string.IsNullOrEmpty(_location)) { - - +
+ +
+ +
+
+ } +
+ + +} +else +{ + } @code { - private ElementReference form; - private bool validated = false; private string _moduledefinitionname = string.Empty; private string _owner = string.Empty; private string _module = string.Empty; @@ -117,11 +113,9 @@ private async Task CreateModule() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + 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); @@ -134,14 +128,14 @@ AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Creating Module"); + AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Creating Module"); } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor index e341d69d..765ae2df 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor @@ -10,71 +10,67 @@ @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; @@ -103,32 +99,23 @@ private async Task CreateModule() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") { - 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); - } + 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); } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Creating Module"); + AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Creating Module"); } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor index 6a8f7105..d75464d1 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor @@ -5,94 +5,90 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- - + + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
- +
- +
- +
- +
- +
- + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
- -
+
+
+ +
+
+
- - - - @SharedLocalizer["Cancel"] -
-
- - +
+
+
+ +@SharedLocalizer["Cancel"] +
+
+ @code { - private ElementReference form; - private bool validated = false; private int _moduleDefinitionId; private string _name; private string _version; @@ -150,39 +146,30 @@ private async Task SaveModuleDefinition() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); + if (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()); + moduledefinition.Name = _name; } - catch (Exception ex) + if (moduledefinition.Description != _description) { - await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); - AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); + 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()); } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); + AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); } } } diff --git a/Oqtane.Client/Modules/Admin/Modules/Export.razor b/Oqtane.Client/Modules/Admin/Modules/Export.razor index d3977dc3..d02706ef 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Export.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Export.razor @@ -5,39 +5,28 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- +
@SharedLocalizer["Cancel"] -
- -@code { - private ElementReference form; - private bool validated = false; - private string _content = string.Empty; - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; - public override string Title => "Export Content"; - private async Task ExportModule() - { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + @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); } - else - { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); - } } -} diff --git a/Oqtane.Client/Modules/Admin/Modules/Import.razor b/Oqtane.Client/Modules/Admin/Modules/Import.razor index 709317ed..33b7a8d4 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Import.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Import.razor @@ -5,7 +5,6 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
@@ -18,21 +17,15 @@ @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"; + @code { + private string _content = string.Empty; - private async Task ImportModule() - { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; + public override string Title => "Import Content"; + + private async Task ImportModule() { if (_content != string.Empty) { @@ -59,9 +52,4 @@ AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); } } - else - { - 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 c2c3f6ef..cbf32fef 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Settings.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Settings.razor @@ -8,92 +8,88 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- - - @if (_containers != null) - { -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+ + + @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; @@ -174,61 +170,52 @@ private async Task SaveModule() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + if (!string.IsNullOrEmpty(_title)) { - if (!string.IsNullOrEmpty(_title)) + 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) { - 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) - { - 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) - { - // 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()); + pagemodule.ContainerType = string.Empty; } - else + if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) { - AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); + 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) + { + // 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 { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index bfca6df5..7190ea8f 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -6,154 +6,151 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer - -
- - - @if (_themeList != null) - { -
-
- -
- -
-
-
- -
- -
-
-
- -
- - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) - { - - } -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- } -
- + + + @if (_themeList != null) + {
- + +
+ +
+
+
+ +
+ +
+
+
+ +
+ + @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
-
- @if (_themeSettingsType != null) - { - - @ThemeSettingsComponent - + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
} -
- - - +
+ +
+
+ +
+
+
+ @if (_themeSettingsType != null) + { + + @ThemeSettingsComponent + + } +
+ + @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -182,8 +179,6 @@ private object _themeSettings; private RenderFragment ThemeSettingsComponent { get; set; } private bool _refresh = false; - private ElementReference form; - private bool validated = false; protected override async Task OnInitializedAsync() { @@ -280,119 +275,110 @@ private async Task SavePage() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + Page page = null; + try { - Page page = null; - try + if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_themetype) && _containertype != "-") { - if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_themetype) && _containertype != "-") + page = new Page(); + page.SiteId = PageState.Page.SiteId; + page.Name = _name; + page.Title = _title; + if (_path == "") { - page = new Page(); - page.SiteId = PageState.Page.SiteId; - page.Name = _name; - page.Title = _title; - if (_path == "") - { - _path = _name; - } + _path = _name; + } - if (_path.Contains("/")) - { - _path = _path.Substring(_path.LastIndexOf("/") + 1); - } + 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.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; - } - - 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.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 = 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)); - } + if (string.IsNullOrEmpty(_parentid)) + { + page.ParentId = null; + page.Path = Utilities.GetFriendlyUrl(_path); } else { - AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); + 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; + } + + 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.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 = 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)); + } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); - AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); + AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); } + } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); + AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 24bc32ca..5b55f62c 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -7,172 +7,168 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- - - @if (_themeList != null) - { -
-
- -
- -
-
-
- -
- -
-
-
- -
- - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) - { - - } -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-

- - } -
- - @if (_permissions != null) - { -
-
- - -
-
- - } -
- @if (_themeSettingsType != null) + + + @if (_themeList != null) { - - @ThemeSettingsComponent - +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+

+ } -
- - - + + + @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(); @@ -355,143 +351,134 @@ private async Task SavePage() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + Page page = null; + try { - Page page = null; - try + if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && _containertype != "-") { - if (_name != string.Empty && !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") + { + _path = _name; + } + if (_path.Contains("/")) { - 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") - { - _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) - { - 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) - { - 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)); - } + _path = _path.Substring(_path.LastIndexOf("/") + 1); + } + if (string.IsNullOrEmpty(_parentid) || _parentid == "-1") + { + page.ParentId = null; + page.Path = Utilities.GetFriendlyUrl(_path); } else { - AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); + 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) + { + 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)); } } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); - AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); + AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message); + AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor index a334c2bb..0a6ce896 100644 --- a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor @@ -5,90 +5,86 @@ @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; @@ -144,54 +140,45 @@ private async Task SaveProfile() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + Profile profile; + if (_profileid != -1) { - 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); - } - - await logger.LogInformation("Profile Saved {Profile}", profile); - NavigationManager.NavigateTo(NavigateUrl()); + profile = await ProfileService.GetProfileAsync(_profileid); } - catch (Exception ex) + else { - await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message); - AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error); + 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); + } + + await logger.LogInformation("Profile Saved {Profile}", profile); + NavigationManager.NavigateTo(NavigateUrl()); } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message); + AddModuleMessage(Localizer["Error.Profile.Save"], MessageType.Error); } } } diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 53c5382c..27bf0d1a 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -7,54 +7,52 @@ @if (PageState.Site.AllowRegistration) { -
- - - ... - - - - - - -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
+ + + ... + + + + + + +
+
+ +
+
-
- - - - - +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
} else { @@ -63,8 +61,6 @@ 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; @@ -74,58 +70,49 @@ else private async Task Register() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + bool _isEmailValid = Utilities.IsValidEmail(_email); + + if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) { - bool _isEmailValid = Utilities.IsValidEmail(_email); - - if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) + if (_password == _confirm) { - if (_password == _confirm) + var user = new User { - 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); + 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); - } + if (user != null) + { + await logger.LogInformation("User Created {Username} {Email}", _username, _email); + AddModuleMessage(Localizer["Info.User.AccountCreate"], MessageType.Info); } else { - AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); + await logger.LogError("Error Adding User {Username} {Email}", _username, _email); + AddModuleMessage(Localizer["Error.User.AddInfo"], MessageType.Error); } } else { - AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); } } - 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(Localizer["Message.Required.UserInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message); + AddModuleMessage(Localizer["Error.User.Add"], MessageType.Error); } } @@ -133,4 +120,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 31ebb1f5..64acc352 100644 --- a/Oqtane.Client/Modules/Admin/Reset/Index.razor +++ b/Oqtane.Client/Modules/Admin/Reset/Index.razor @@ -5,28 +5,24 @@ @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; @@ -47,54 +43,45 @@ private async Task Reset() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty) { - if (_username != string.Empty && _password != string.Empty && _confirm != string.Empty) + if (_password == _confirm) { - if (_password == _confirm) + var user = new User { - var user = new User - { - SiteId = PageState.Site.SiteId, - Username = _username, - Password = _password - }; - user = await UserService.ResetPasswordAsync(user, PageState.QueryString["token"]); + 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")); - } - else - { - await logger.LogError("Error Resetting User Password {Username}", _username); - AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error); - } + if (user != null) + { + await logger.LogInformation("User Password Reset {Username}", _username); + NavigationManager.NavigateTo(NavigateUrl("login")); } else { - AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); + await logger.LogError("Error Resetting User Password {Username}", _username); + AddModuleMessage(Localizer["Error.Password.ResetInfo"], MessageType.Error); } } else { - AddModuleMessage(Localizer["Message.Required.UserInfo"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Password.NoMatch"], MessageType.Warning); } } - 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(Localizer["Message.Required.UserInfo"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Resetting User Password {Username} {Error}", _username, ex.Message); + AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Add.razor b/Oqtane.Client/Modules/Admin/Roles/Add.razor index f20a721d..c7daf524 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Add.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Add.razor @@ -22,7 +22,7 @@
- @@ -72,7 +72,7 @@ } else { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning); } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Edit.razor b/Oqtane.Client/Modules/Admin/Roles/Edit.razor index b217acce..50eec71b 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Edit.razor @@ -22,7 +22,7 @@
- @@ -101,7 +101,7 @@ } else { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(Localizer["Message.InfoRequired"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/Roles/Users.razor b/Oqtane.Client/Modules/Admin/Roles/Users.razor index 92015116..8799a816 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Users.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Users.razor @@ -12,70 +12,65 @@ 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,78 +118,59 @@ else private async Task SaveUserRole() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + if (userid != -1) { - if (userid != -1) + var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault(); + if (userrole != null) { - 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(); + userrole.EffectiveDate = effectivedate; + userrole.ExpiryDate = expirydate; + await UserRoleService.UpdateUserRoleAsync(userrole); } else { - AddModuleMessage(Localizer["Message.Required.UserSelect"], MessageType.Warning); + 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(); } - 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(Localizer["Message.Required.UserSelect"], MessageType.Warning); } } - - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving User Roles {RoleId} {Error}", roleid, ex.Message); + AddModuleMessage(Localizer["Error.User.SaveRole"], MessageType.Error); } } private async Task DeleteUserRole(int UserRoleId) { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - 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); - } + await UserRoleService.DeleteUserRoleAsync(UserRoleId); + await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId); + AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success); + await GetUserRoles(); + StateHasChanged(); } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message); + AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error); } } } diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 2443c039..974eb07b 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -13,217 +13,213 @@ @if (_initialized) { -
+
+
+ +
+ +
+
+
+ +
+ @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + { + + } + else + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
- +
- +
- +
- @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) - { - - } - else - { - - } +
- +
- + + @foreach (var theme in _themes) + { + + } + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+ @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(); @@ -388,130 +384,121 @@ private async Task SaveSite() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try + if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-") { - if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-") + var unique = true; + if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) { - var unique = true; - if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host)) + foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { - foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId)) { - if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId)) - { - unique = false; - } + unique = false; } } + } - if (unique) + if (unique) + { + var site = await SiteService.GetSiteAsync(PageState.Site.SiteId); + if (site != null) { - var site = await SiteService.GetSiteAsync(PageState.Site.SiteId); - if (site != null) + 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) { - bool refresh = (site.DefaultThemeType != _themetype || site.DefaultContainerType != _containertype); + site.LogoFileId = logofileid; + } + var faviconFieldId = _faviconfilemanager.GetFileId(); + if (faviconFieldId != -1) + { + site.FaviconFileId = faviconFieldId; + } + site.DefaultThemeType = _themetype; + site.DefaultContainerType = _containertype; + site.AdminContainerType = _admincontainertype; - site.Name = _name; - site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); - site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); + 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.LogoFileId = null; - var logofileid = _logofilemanager.GetFileId(); - if (logofileid != -1) + 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 = 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()) + if (!names.Contains(alias.Name)) { - 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); - } + await AliasService.DeleteAliasAsync(alias.AliasId); } } - await logger.LogInformation("Site Settings Saved {Site}", site); - - if (refresh) + foreach (string name in names) { - NavigationManager.NavigateTo(NavigateUrl()); // refresh to show new theme or container - } - else - { - AddModuleMessage(Localizer["Success.Settings.SaveSite"], MessageType.Success); + 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); + } } } - } - else - { - AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning); + + 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.Required.SiteName"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Aliases.Taken"], MessageType.Warning); } } - 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(Localizer["Message.Required.SiteName"], MessageType.Warning); } } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message); + AddModuleMessage(Localizer["Error.SaveSite"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/Sites/Add.razor b/Oqtane.Client/Modules/Admin/Sites/Add.razor index 7bdda0c9..4dba923a 100644 --- a/Oqtane.Client/Modules/Admin/Sites/Add.razor +++ b/Oqtane.Client/Modules/Admin/Sites/Add.razor @@ -19,140 +19,136 @@ } else { -
-
-
- -
- -
+
+
+ +
+
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- @if (_tenantid == "+") - { -
-
-
-
- -
- -
-
-
- -
- -
-
- if (_databaseConfigType != null) - { - @DatabaseConfigComponent; - } -
- -
- -
-
-
- -
- -
-
- }
-
-
- - @SharedLocalizer["Cancel"] - +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (_tenantid == "+") + { +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ if (_databaseConfigType != null) + { + @DatabaseConfigComponent; + } +
+ +
+ +
+
+
+ +
+ +
+
+ } +
+
+
+ + @SharedLocalizer["Cancel"] } @code { private List _databases; - private ElementReference form; - private bool validated = false; private string _databaseName = "LocalDB"; private Type _databaseConfigType; private object _databaseConfig; @@ -256,120 +252,111 @@ else private async Task SaveSite() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-") { - if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && _containertype != "-" && _sitetemplatetype != "-") + var duplicates = new List(); + var aliases = await AliasService.GetAliasesAsync(); + foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { - var duplicates = new List(); - var aliases = await AliasService.GetAliasesAsync(); - foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + if (aliases.Exists(item => item.Name == name)) { - if (aliases.Exists(item => item.Name == name)) - { - duplicates.Add(name); - } + duplicates.Add(name); } + } - if (duplicates.Count == 0) + if (duplicates.Count == 0) + { + InstallConfig config = new InstallConfig(); + + if (_tenantid == "+") { - InstallConfig config = new InstallConfig(); - - if (_tenantid == "+") + if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null) { - 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) { - // 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) { - var connectionString = String.Empty; - if (_databaseConfig is IDatabaseConfigControl databaseConfigControl) - { - connectionString = databaseConfigControl.GetConnectionString(); - } - var database = _databases.SingleOrDefault(d => d.Name == _databaseName); + 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); - } + 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.InvalidPassword"], MessageType.Error); + AddModuleMessage(Localizer["Error.Required.ServerDatabase"], MessageType.Error); } } else { - AddModuleMessage(Localizer["Error.TenantName.Exists"], MessageType.Error); + AddModuleMessage(Localizer["Error.InvalidPassword"], 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(Localizer["Error.TenantName.Exists"], MessageType.Error); } } else { - AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning); + 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 { - AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning); + AddModuleMessage(string.Format(Localizer["Message.SiteName.InUse"], string.Join(", ", duplicates.ToArray())), MessageType.Warning); } } else { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + AddModuleMessage(Localizer["Message.Required.Tenant"], MessageType.Warning); } } } diff --git a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor index 3422bb69..257a690d 100644 --- a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor +++ b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor @@ -5,130 +5,126 @@ @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer -
- - -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
@Localizer["Register"] -
+ + +
+
+ +
+
-

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

-   - @Localizer["Access.ApiFramework"]  - - - - +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
@Localizer["Register"] +
+
+
+

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

+   + @Localizer["Access.ApiFramework"]  + +
+ @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - private ElementReference form; - private bool validated = false; private string _version = string.Empty; private string _clrversion = string.Empty; private string _osversion = string.Empty; @@ -167,31 +163,22 @@ private async Task SaveConfig() { - validated = true; - var interop = new Interop(JSRuntime); - if (await interop.FormValid(form)) + try { - try - { - var settings = new Dictionary(); - settings.Add("runtime", _runtime); - settings.Add("rendermode", _rendermode); - settings.Add("detailederrors", _detailederrors); - settings.Add("logginglevel", _logginglevel); - settings.Add("swagger", _swagger); - settings.Add("packageservice", _packageservice); - await SystemService.UpdateSystemInfoAsync(settings); - AddModuleMessage(Localizer["Success.UpdateConfig.Restart"], MessageType.Success); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Saving Configuration"); - AddModuleMessage(Localizer["Error.UpdateConfig"], MessageType.Error); - } + var settings = new Dictionary(); + settings.Add("runtime", _runtime); + settings.Add("rendermode", _rendermode); + settings.Add("detailederrors", _detailederrors); + settings.Add("logginglevel", _logginglevel); + settings.Add("swagger", _swagger); + settings.Add("packageservice", _packageservice); + await SystemService.UpdateSystemInfoAsync(settings); + AddModuleMessage(Localizer["Success.UpdateConfig.Restart"], MessageType.Success); } - else + catch (Exception ex) { - AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); + await logger.LogError(ex, "Error Saving Configuration"); + AddModuleMessage(Localizer["Error.UpdateConfig"], MessageType.Error); } } @@ -225,4 +212,4 @@ await logger.LogError(ex, "Error On Register"); } } -} +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Themes/Create.razor b/Oqtane.Client/Modules/Admin/Themes/Create.razor index 8f50ca5b..f563c1ff 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Create.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Create.razor @@ -11,66 +11,61 @@ @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 _theme = string.Empty; private List