diff --git a/Oqtane.Client/Modules/Admin/Jobs/Add.razor b/Oqtane.Client/Modules/Admin/Jobs/Add.razor deleted file mode 100644 index 8535d2c0..00000000 --- a/Oqtane.Client/Modules/Admin/Jobs/Add.razor +++ /dev/null @@ -1,141 +0,0 @@ -@namespace Oqtane.Modules.Admin.Jobs -@inherits ModuleBase -@inject NavigationManager NavigationManager -@inject IJobService JobService -@inject IStringLocalizer Localizer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - - -
- - - -
- - - -
- - - -
- -@Localizer["Cancel"] - -@code { - private string _name = string.Empty; - private string _jobType = string.Empty; - private string _isEnabled = "True"; - private string _interval = string.Empty; - private string _frequency = string.Empty; - private string _startDate = string.Empty; - private string _endDate = string.Empty; - private string _retentionHistory = "10"; - - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - - private async Task SaveJob() - { - if (_name != string.Empty && !string.IsNullOrEmpty(_jobType) && _frequency != string.Empty && _interval != string.Empty && _retentionHistory != string.Empty) - { - var job = new Job(); - job.Name = _name; - job.JobType = _jobType; - job.IsEnabled = Boolean.Parse(_isEnabled); - job.Frequency = _frequency; - job.Interval = int.Parse(_interval); - - if (_startDate == string.Empty) - { - job.StartDate = null; - } - else - { - job.StartDate = DateTime.Parse(_startDate); - } - - if (_endDate == string.Empty) - { - job.EndDate = null; - } - else - { - job.EndDate = DateTime.Parse(_endDate); - } - - job.RetentionHistory = int.Parse(_retentionHistory); - job.IsStarted = false; - job.IsExecuting = false; - job.NextExecution = null; - - try - { - job = await JobService.AddJobAsync(job); - await logger.LogInformation("Job Added {Job}", job); - NavigationManager.NavigateTo(NavigateUrl()); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Adding Job {Job} {Error}", job, ex.Message); - AddModuleMessage(Localizer["Error Adding Job"], MessageType.Error); - } - } - else - { - AddModuleMessage(Localizer["You Must Provide The Job Name, Type, Frequency, and Retention"], MessageType.Warning); - } - } - -} diff --git a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor index 65043de8..9a436b6d 100644 --- a/Oqtane.Client/Modules/Admin/Jobs/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Jobs/Edit.razor @@ -15,10 +15,10 @@ - + - + diff --git a/Oqtane.Client/Modules/Admin/Jobs/Index.razor b/Oqtane.Client/Modules/Admin/Jobs/Index.razor index 7a435f77..5aefdcbe 100644 --- a/Oqtane.Client/Modules/Admin/Jobs/Index.razor +++ b/Oqtane.Client/Modules/Admin/Jobs/Index.razor @@ -9,7 +9,6 @@ } else { -
diff --git a/Oqtane.Client/Modules/Admin/Languages/Add.razor b/Oqtane.Client/Modules/Admin/Languages/Add.razor new file mode 100644 index 00000000..7efbcf85 --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Languages/Add.razor @@ -0,0 +1,107 @@ +@namespace Oqtane.Modules.Admin.Languages +@inherits ModuleBase +@using System.Globalization +@using Microsoft.AspNetCore.Localization +@inject NavigationManager NavigationManager +@inject ILocalizationService LocalizationService +@inject ILanguageService LanguageService +@inject IStringLocalizer Localizer + +@if (_supportedCultures == null) +{ +

@Localizer["Loading..."]

+} +else +{ + @if (_supportedCultures?.Count() > 1) + { + + + + + + + + + +
+ + + +
+ + + +
+ + } + @Localizer["Cancel"] +} + +@code { + private string _code = string.Empty; + private string _isDefault = "False"; + + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; + + private IEnumerable _supportedCultures; + + protected override async Task OnParametersSetAsync() + { + _supportedCultures = await LocalizationService.GetCulturesAsync(); + if (_supportedCultures.Count() <= 1) + { + AddModuleMessage(Localizer["The Only Supported Culture That Has Been Defined Is English"], MessageType.Warning); + } + } + + private async Task SaveLanguage() + { + 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 Adding Language"], MessageType.Error); + } + } + + private async Task SetCultureAsync(string culture) + { + if (culture != CultureInfo.CurrentUICulture.Name) + { + var interop = new Interop(JSRuntime); + var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)); + await interop.SetCookie(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, 360); + + NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true); + } + } +} diff --git a/Oqtane.Client/Modules/Admin/Languages/Index.razor b/Oqtane.Client/Modules/Admin/Languages/Index.razor new file mode 100644 index 00000000..748c875b --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Languages/Index.razor @@ -0,0 +1,56 @@ +@namespace Oqtane.Modules.Admin.Languages +@inherits ModuleBase +@inject ILanguageService LanguageService +@inject IStringLocalizer Localizer + +@if (_languages == null) +{ +

@Localizer["Loading..."]

+} +else +{ + + + +
+   + @Localizer["Name"] + @Localizer["Code"] + @Localizer["Default?"] +
+ + + @context.Name + @context.Code + + +
+} + +@code { + private List _languages; + + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; + + protected override async Task OnParametersSetAsync() + { + _languages = await LanguageService.GetLanguagesAsync(PageState.Site.SiteId); + } + + private async Task DeleteLanguage(Language language) + { + try + { + await LanguageService.DeleteLanguageAsync(language.LanguageId); + await logger.LogInformation("Language Deleted {Language}", language); + + StateHasChanged(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Deleting Language {Language} {Error}", language, ex.Message); + + AddModuleMessage(Localizer["Error Deleting Language"], MessageType.Error); + } + } +} diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor index 79d5eb42..66794ad5 100644 --- a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor @@ -7,6 +7,7 @@ @inject ISettingService SettingService @inject IStringLocalizer Localizer @using System.Text.RegularExpressions +@using System.IO; @if (string.IsNullOrEmpty(_moduledefinitionname)) { @@ -113,7 +114,7 @@ else { try { - if (IsValid(_owner) && IsValid(_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); @@ -126,7 +127,7 @@ else } else { - AddModuleMessage(Localizer["You Must Provide A Valid Owner Name, Module Name, And Template"], MessageType.Warning); + AddModuleMessage(Localizer["You Must Provide A Valid Owner Name And Module Name ( ie. No Punctuation Or Spaces And The Values Cannot Be The Same ) And Choose A Template"], MessageType.Warning); } } catch (Exception ex) @@ -171,14 +172,18 @@ else Dictionary systeminfo = await SystemService.GetSystemInfoAsync(); if (systeminfo != null) { - string[] path = systeminfo["serverpath"].Split('\\'); + string[] path = systeminfo["serverpath"].Split(Path.DirectorySeparatorChar); if (_template == "internal") { - _location = string.Join("\\", path, 0, path.Length - 1) + "\\Oqtane.Client\\Modules\\" + _owner + "." + _module; + _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 1) + + Path.DirectorySeparatorChar + "Oqtane.Client" + + Path.DirectorySeparatorChar + "Modules" + + Path.DirectorySeparatorChar + _owner + "." + _module; } else { - _location = string.Join("\\", path, 0, path.Length - 2) + "\\" + _owner + "." + _module; + _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 2) + + Path.DirectorySeparatorChar + _owner + "." + _module; } } } diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor index 367abce8..70310bd4 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor @@ -60,7 +60,7 @@ - + diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor index a3f0b71e..538bf700 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor @@ -47,7 +47,7 @@ else public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { try { @@ -100,7 +100,8 @@ else try { await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId); - AddModuleMessage(Localizer["Module Deleted Successfully. You Must Restart Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success); + AddModuleMessage(Localizer["Module Deleted Successfully"], MessageType.Success); + StateHasChanged(); } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/Modules/Settings.razor b/Oqtane.Client/Modules/Admin/Modules/Settings.razor index a4bd4188..c6ebe5c3 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Settings.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Settings.razor @@ -1,4 +1,5 @@ @namespace Oqtane.Modules.Admin.Modules +@using Oqtane.Interfaces @inherits ModuleBase @inject NavigationManager NavigationManager @inject IThemeService ThemeService @@ -137,7 +138,7 @@ builder.AddComponentReferenceCapture(1, inst => { _settings = Convert.ChangeType(inst, _settingsModuleType); }); builder.CloseComponent(); }; - } + } } private async Task SaveModule() @@ -162,15 +163,16 @@ module.Permissions = _permissionGrid.GetPermissions(); await ModuleService.UpdateModuleAsync(module); - if (_settingsModuleType != null) + + if (_settings is ISettingsControl control) { - var moduleType = Type.GetType(ModuleState.ModuleType); - if (moduleType != null) - { - moduleType.GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component - } + await control.UpdateSettings(); + } + else + { + // Compatibility 2.0 fallback + _settings?.GetType().GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component } - NavigationManager.NavigateTo(NavigateUrl()); } diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 2a253ed1..171ab885 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -189,7 +189,7 @@ -@Localizer["Cancel"] + @code { private List _themeList; @@ -386,7 +386,14 @@ await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId); await logger.LogInformation("Page Added {Page}", page); - NavigationManager.NavigateTo(NavigateUrl(page.Path)); + 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 { @@ -401,6 +408,18 @@ } } + private void Cancel() + { + if (PageState.QueryString.ContainsKey("cp")) + { + NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); + } + else + { + NavigationManager.NavigateTo(NavigateUrl()); + } + } + private static bool PagePathIsUnique(string pagePath, int siteId, List existingPages) { return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath); diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 4a99881c..5efdd992 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -205,7 +205,7 @@ -@Localizer["Cancel"] + @code { private List _themeList; @@ -493,7 +493,14 @@ } await logger.LogInformation("Page Saved {Page}", page); - NavigationManager.NavigateTo(NavigateUrl(page.Path)); + 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 { @@ -507,6 +514,18 @@ } } + private void Cancel() + { + if (PageState.QueryString.ContainsKey("cp")) + { + NavigationManager.NavigateTo(NavigateUrl(PageState.Pages.First(item => item.PageId == int.Parse(PageState.QueryString["cp"])).Path)); + } + else + { + NavigationManager.NavigateTo(NavigateUrl()); + } + } + private static bool PagePathIsUnique(string pagePath, int siteId, int pageId, List existingPages) { return !existingPages.Any(page => page.SiteId == siteId && page.Path == pagePath && page.PageId != pageId); diff --git a/Oqtane.Client/Modules/Admin/Roles/Users.razor b/Oqtane.Client/Modules/Admin/Roles/Users.razor index 9ceae846..b9dcd431 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Users.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Users.razor @@ -38,7 +38,7 @@ else - + @@ -46,7 +46,7 @@ else - + @@ -75,8 +75,8 @@ else private string name = string.Empty; private List users; private int userid = -1; - private string effectivedate = string.Empty; - private string expirydate = string.Empty; + private DateTime? effectivedate = null; + private DateTime? expirydate = null; private List userroles; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; @@ -89,7 +89,10 @@ else Role role = await RoleService.GetRoleAsync(roleid); name = role.Name; users = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId); - users = users.Where(item => item.Role.Name == RoleNames.Registered).ToList(); + users = users + .Where(u => u.Role.Name == RoleNames.Registered) + .OrderBy(u => u.User.DisplayName) + .ToList(); await GetUserRoles(); } catch (Exception ex) @@ -122,23 +125,8 @@ else var userrole = userroles.Where(item => item.UserId == userid && item.RoleId == roleid).FirstOrDefault(); if (userrole != null) { - if (string.IsNullOrEmpty(effectivedate)) - { - userrole.EffectiveDate = null; - } - else - { - userrole.EffectiveDate = DateTime.Parse(effectivedate); - } - - if (string.IsNullOrEmpty(expirydate)) - { - userrole.ExpiryDate = null; - } - else - { - userrole.ExpiryDate = DateTime.Parse(expirydate); - } + userrole.EffectiveDate = effectivedate; + userrole.ExpiryDate = expirydate; await UserRoleService.UpdateUserRoleAsync(userrole); } else @@ -146,24 +134,8 @@ else userrole = new UserRole(); userrole.UserId = userid; userrole.RoleId = roleid; - - if (string.IsNullOrEmpty(effectivedate)) - { - userrole.EffectiveDate = null; - } - else - { - userrole.EffectiveDate = DateTime.Parse(effectivedate); - } - - if (string.IsNullOrEmpty(expirydate)) - { - userrole.ExpiryDate = null; - } - else - { - userrole.ExpiryDate = DateTime.Parse(expirydate); - } + userrole.EffectiveDate = effectivedate; + userrole.ExpiryDate = expirydate; await UserRoleService.AddUserRoleAsync(userrole); } diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 3910ab9b..acd0105b 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -10,128 +10,148 @@ @if (_initialized) { - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- - - -
- - - -
- - - -
- - - -
- - - -
- - - + + + + + + + + + + + + + + + + + + + + + + + + + @if (_layouts.Count > 0) + { + + + - @if (_layouts.Count > 0) - { - - - - - } - - - - - - - - - - - - -
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + +
- - - -
- - - -
- - - -
- - - -
+ } +
+ + + +
+ + + +
+ + + +
+ + + +
-
+
+ + + + + + +
+ @Localizer["Please Note That SMTP Requires The Notification Job To Be Enabled In the Scheduled Jobs"] +
- + @@ -139,7 +159,7 @@
- + @@ -147,15 +167,18 @@
- + - +
- + @@ -163,12 +186,20 @@
- +
+ + + +
@@ -205,7 +236,6 @@
- @Localizer["Cancel"]

@@ -229,12 +259,14 @@ private string _themetype = "-"; private string _layouttype = "-"; private string _containertype = "-"; + private string _admincontainertype = "-"; private string _allowregistration; private string _smtphost = string.Empty; private string _smtpport = string.Empty; - private string _smtpssl = string.Empty; + private string _smtpssl = "False"; private string _smtpusername = string.Empty; private string _smtppassword = string.Empty; + private string _smtpsender = string.Empty; private string _pwaisenabled; private int _pwaappiconfileid = -1; private FileManager _pwaappiconfilemanager; @@ -282,14 +314,16 @@ _layouttype = site.DefaultLayoutType; _containers = ThemeService.GetContainerControls(_themeList, _themetype); _containertype = site.DefaultContainerType; + _admincontainertype = site.AdminContainerType; _allowregistration = site.AllowRegistration.ToString(); var settings = await SettingService.GetSiteSettingsAsync(site.SiteId); _smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty); _smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty); - _smtpssl = SettingService.GetSetting(settings, "SMTPSSL", string.Empty); + _smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "False"); _smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty); _smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty); + _smtpsender = SettingService.GetSetting(settings, "SMTPSender", string.Empty); _pwaisenabled = site.PwaIsEnabled.ToString(); @@ -348,6 +382,7 @@ } _layouttype = "-"; _containertype = "-"; + _admincontainertype = ""; StateHasChanged(); } catch (Exception ex) @@ -388,6 +423,7 @@ site.DefaultThemeType = _themetype; site.DefaultLayoutType = (_layouttype == "-" ? string.Empty : _layouttype); site.DefaultContainerType = _containertype; + site.AdminContainerType = _admincontainertype; site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); @@ -435,11 +471,12 @@ 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); - await logger.LogInformation("Site Saved {Site}", site); + await logger.LogInformation("Site Settings Saved {Site}", site); - NavigationManager.NavigateTo(NavigateUrl()); + AddModuleMessage(Localizer["Site Settings Saved"], MessageType.Success); } } else diff --git a/Oqtane.Client/Modules/Admin/Sites/Add.razor b/Oqtane.Client/Modules/Admin/Sites/Add.razor index 2945f23a..a4b430e9 100644 --- a/Oqtane.Client/Modules/Admin/Sites/Add.razor +++ b/Oqtane.Client/Modules/Admin/Sites/Add.razor @@ -78,6 +78,21 @@ else + + + + + + + + @@ -225,6 +240,7 @@ else private string _themetype = "-"; private string _layouttype = "-"; private string _containertype = "-"; + private string _admincontainertype = ""; private string _sitetemplatetype = "-"; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; @@ -278,6 +294,7 @@ else } _layouttype = "-"; _containertype = "-"; + _admincontainertype = ""; StateHasChanged(); } catch (Exception ex) @@ -378,6 +395,7 @@ else config.DefaultTheme = _themetype; config.DefaultLayout = _layouttype; config.DefaultContainer = _containertype; + config.DefaultAdminContainer = _admincontainertype; config.SiteTemplate = _sitetemplatetype; ShowProgressIndicator(); diff --git a/Oqtane.Client/Modules/Admin/Sites/Edit.razor b/Oqtane.Client/Modules/Admin/Sites/Edit.razor index 3d01cf2e..b1afc85c 100644 --- a/Oqtane.Client/Modules/Admin/Sites/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Sites/Edit.razor @@ -18,14 +18,6 @@ - - - - - - - - @@ -86,6 +78,21 @@ + + + + + + + + @@ -97,6 +104,23 @@ + + + + + + + + + + + + + + + + +
@@ -114,13 +138,12 @@ private List _containers = new List(); private Alias _alias; private string _name = string.Empty; - private List _tenantList; - private string _tenant = string.Empty; private List _aliasList; private string _urls = string.Empty; private string _themetype; private string _layouttype; - private string _containertype; + private string _containertype = "-"; + private string _admincontainertype = "-"; private string _createdby; private DateTime _createdon; private string _modifiedby; @@ -128,6 +151,8 @@ private string _deletedby; private DateTime? _deletedon; private string _isdeleted; + private string _tenant = string.Empty; + private string _connectionstring = string.Empty; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; @@ -144,8 +169,6 @@ if (site != null) { _name = site.Name; - _tenantList = await TenantService.GetTenantsAsync(); - _tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name; foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList()) { @@ -158,6 +181,7 @@ _layouttype = site.DefaultLayoutType; _containers = ThemeService.GetContainerControls(_themeList, _themetype); _containertype = site.DefaultContainerType; + _admincontainertype = site.AdminContainerType; _createdby = site.CreatedBy; _createdon = site.CreatedOn; _modifiedby = site.ModifiedBy; @@ -166,6 +190,14 @@ _deletedon = site.DeletedOn; _isdeleted = site.IsDeleted.ToString(); + List tenants = await TenantService.GetTenantsAsync(); + Tenant tenant = tenants.Find(item => item.TenantId == site.TenantId); + if (tenant != null) + { + _tenant = tenant.Name; + _connectionstring = tenant.DBConnectionString; + } + _initialized = true; } } @@ -193,6 +225,7 @@ } _layouttype = "-"; _containertype = "-"; + _admincontainertype = ""; StateHasChanged(); } catch (Exception ex) @@ -228,6 +261,7 @@ site.DefaultThemeType = _themetype; site.DefaultLayoutType = _layouttype ?? string.Empty; site.DefaultContainerType = _containertype; + site.AdminContainerType = _admincontainertype; site.IsDeleted = (_isdeleted == null || Boolean.Parse(_isdeleted)); site = await SiteService.UpdateSiteAsync(site); diff --git a/Oqtane.Client/Modules/Admin/Tenants/Edit.razor b/Oqtane.Client/Modules/Admin/Tenants/Edit.razor deleted file mode 100644 index 247b338a..00000000 --- a/Oqtane.Client/Modules/Admin/Tenants/Edit.razor +++ /dev/null @@ -1,86 +0,0 @@ -@namespace Oqtane.Modules.Admin.Tenants -@inherits ModuleBase -@inject NavigationManager NavigationManager -@inject ITenantService TenantService -@inject IStringLocalizer Localizer - - - - - - - - - - - -
- - - @if (name == TenantNames.Master) - { - - } - else - { - - } -
- - - -
- -@Localizer["Cancel"] - -@code { - private int tenantid; - private string name = string.Empty; - private string connectionstring = string.Empty; - private string schema = string.Empty; - - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - - protected override async Task OnInitializedAsync() - { - try - { - tenantid = Int32.Parse(PageState.QueryString["id"]); - var tenant = await TenantService.GetTenantAsync(tenantid); - if (tenant != null) - { - name = tenant.Name; - connectionstring = tenant.DBConnectionString; - } - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", tenantid, ex.Message); - AddModuleMessage(Localizer["Error Loading Tenant"], MessageType.Error); - } - } - - private async Task SaveTenant() - { - try - { - connectionstring = connectionstring.Replace("\\\\", "\\"); - var tenant = await TenantService.GetTenantAsync(tenantid); - if (tenant != null) - { - tenant.Name = name; - tenant.DBConnectionString = connectionstring; - - await TenantService.UpdateTenantAsync(tenant); - await logger.LogInformation("Tenant Saved {TenantId}", tenantid); - - NavigationManager.NavigateTo(NavigateUrl()); - } - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Saving Tenant {TenantId} {Error}", tenantid, ex.Message); - AddModuleMessage(Localizer["Error Saving Tenant"], MessageType.Error); - } - } -} diff --git a/Oqtane.Client/Modules/Admin/Tenants/Index.razor b/Oqtane.Client/Modules/Admin/Tenants/Index.razor deleted file mode 100644 index 2aa70ecb..00000000 --- a/Oqtane.Client/Modules/Admin/Tenants/Index.razor +++ /dev/null @@ -1,68 +0,0 @@ -@namespace Oqtane.Modules.Admin.Tenants -@inherits ModuleBase -@inject ITenantService TenantService -@inject IAliasService AliasService -@inject IStringLocalizer Localizer - -@if (tenants == null) -{ -

@Localizer["Loading..."]

-} -else -{ - -
-   -   - @Localizer["Name"] -
- - - - @context.Name - -
- -} - -@code { - private List tenants; - - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - - protected override async Task OnParametersSetAsync() - { - tenants = await TenantService.GetTenantsAsync(); - } - - private async Task DeleteTenant(Tenant Tenant) - { - try - { - string message = string.Empty; - var aliases = await AliasService.GetAliasesAsync(); - foreach (var alias in aliases) - { - if (alias.TenantId == Tenant.TenantId) - { - message += ", " + alias.Name; - } - } - if (string.IsNullOrEmpty(message)) - { - await TenantService.DeleteTenantAsync(Tenant.TenantId); - await logger.LogInformation("Tenant Deleted {Tenant}", Tenant); - StateHasChanged(); - } - else - { - AddModuleMessage(Localizer["Tenant Cannot Be Deleted Until The Following Sites Are Deleted: {0}", message.Substring(2)], MessageType.Warning); - } - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Deleting Tenant {Tenant} {Error}", Tenant, ex.Message); - AddModuleMessage(Localizer["Error Deleting Tenant"], MessageType.Error); - } - } -} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Themes/Index.razor b/Oqtane.Client/Modules/Admin/Themes/Index.razor index 816bd06f..9e8677f7 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Index.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor @@ -49,7 +49,7 @@ else public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { try { @@ -101,7 +101,8 @@ else try { await ThemeService.DeleteThemeAsync(Theme.ThemeName); - AddModuleMessage(Localizer["Theme Deleted Successfully. You Must Restart Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success); + AddModuleMessage(Localizer["Theme Deleted Successfully"], MessageType.Success); + StateHasChanged(); } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor index d3212726..dcc96ff4 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor @@ -48,26 +48,12 @@ private async Task Send() { - var notification = new Notification(); try { var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); if (user != null) - { - notification.SiteId = PageState.Site.SiteId; - notification.FromUserId = PageState.User.UserId; - notification.FromDisplayName = PageState.User.DisplayName; - notification.FromEmail = PageState.User.Email; - notification.ToUserId = user.UserId; - notification.ToDisplayName = user.DisplayName; - notification.ToEmail = user.Email; - notification.Subject = subject; - notification.Body = body; - notification.ParentId = null; - notification.CreatedOn = DateTime.UtcNow; - notification.IsDelivered = false; - notification.DeliveredOn = null; - notification.SendOn = DateTime.UtcNow; + { + var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null); notification = await NotificationService.AddNotificationAsync(notification); await logger.LogInformation("Notification Created {Notification}", notification); NavigationManager.NavigateTo(NavigateUrl()); @@ -79,7 +65,7 @@ } catch (Exception ex) { - await logger.LogError(ex, "Error Adding Notification {Notification} {Error}", notification, ex.Message); + await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); AddModuleMessage(Localizer["Error Adding Notification"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Admin/UserProfile/View.razor b/Oqtane.Client/Modules/Admin/UserProfile/View.razor index fcd7340c..ff9f3937 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/View.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/View.razor @@ -176,26 +176,12 @@ private async Task Send() { - var notification = new Notification(); try { var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); if (user != null) - { - notification.SiteId = PageState.Site.SiteId; - notification.FromUserId = PageState.User.UserId; - notification.FromDisplayName = PageState.User.DisplayName; - notification.FromEmail = PageState.User.Email; - notification.ToUserId = user.UserId; - notification.ToDisplayName = user.DisplayName; - notification.ToEmail = user.Email; - notification.Subject = subject; - notification.Body = body; - notification.ParentId = notificationid; - notification.CreatedOn = DateTime.UtcNow; - notification.IsDelivered = false; - notification.DeliveredOn = null; - notification.SendOn = DateTime.UtcNow; + { + var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid); notification = await NotificationService.AddNotificationAsync(notification); await logger.LogInformation("Notification Created {Notification}", notification); NavigationManager.NavigateTo(NavigateUrl()); @@ -207,7 +193,7 @@ } catch (Exception ex) { - await logger.LogError(ex, "Error Adding Notification {Notification} {Error}", notification, ex.Message); + await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); AddModuleMessage(Localizer["Error Adding Notification"], MessageType.Error); } } diff --git a/Oqtane.Client/Modules/Controls/Pager.razor b/Oqtane.Client/Modules/Controls/Pager.razor index 5f3ae713..64f32728 100644 --- a/Oqtane.Client/Modules/Controls/Pager.razor +++ b/Oqtane.Client/Modules/Controls/Pager.razor @@ -3,6 +3,43 @@ @typeparam TableItem

+ @if (Toolbar == "Top") + { +

+ @if (_endPage > 1) + { + + } + @if (_page > _maxPages) + { + + } + @if (_endPage > 1) + { + + @for (int i = _startPage; i <= _endPage; i++) + { + var pager = i; + + } + + } + @if (_endPage < _pages) + { + + } + @if (_endPage > 1) + { + + } + @if (_endPage > 1) + { + Page @_page of @_pages + } +
+ } @if (Format == "Table") { @@ -35,32 +72,43 @@ } } -
- @if (_page > _maxPages) - { - - } - @if (_endPage > 1) - { - - @for (int i = _startPage; i <= _endPage; i++) + @if (Toolbar == "Bottom") + { +
+ @if (_endPage > 1) { - var pager = i; - + } - - } - @if (_endPage < _pages) - { - - } - @if (_endPage > 1) - { - Page @_page of @_pages - } -
+ @if (_page > _maxPages) + { + + } + @if (_endPage > 1) + { + + @for (int i = _startPage; i <= _endPage; i++) + { + var pager = i; + + } + + } + @if (_endPage < _pages) + { + + } + @if (_endPage > 1) + { + + } + @if (_endPage > 1) + { + Page @_page of @_pages + } +
+ }

@code { @@ -74,6 +122,9 @@ [Parameter] public string Format { get; set; } + [Parameter] + public string Toolbar { get; set; } + [Parameter] public RenderFragment Header { get; set; } @@ -104,6 +155,11 @@ Format = "Table"; } + if (string.IsNullOrEmpty(Toolbar)) + { + Toolbar = "Top"; + } + if (string.IsNullOrEmpty(Class)) { if (Format == "Table") diff --git a/Oqtane.Client/Modules/Controls/Section.razor b/Oqtane.Client/Modules/Controls/Section.razor index 027b0e85..7f253cc2 100644 --- a/Oqtane.Client/Modules/Controls/Section.razor +++ b/Oqtane.Client/Modules/Controls/Section.razor @@ -16,13 +16,14 @@

-
+
@ChildContent
@code { private string _heading = string.Empty; private string _expanded = string.Empty; + private string _show = string.Empty; [Parameter] public RenderFragment ChildContent { get; set; } @@ -40,6 +41,7 @@ { _heading = (!string.IsNullOrEmpty(Heading)) ? Heading : Name; _expanded = (!string.IsNullOrEmpty(Expanded)) ? Expanded : "false"; + if (_expanded == "true") { _show = "show"; } } protected override void OnParametersSet() diff --git a/Oqtane.Client/Modules/Controls/TabStrip.razor b/Oqtane.Client/Modules/Controls/TabStrip.razor index be82b9ff..d5186930 100644 --- a/Oqtane.Client/Modules/Controls/TabStrip.razor +++ b/Oqtane.Client/Modules/Controls/TabStrip.razor @@ -1,7 +1,7 @@ @namespace Oqtane.Modules.Controls @inherits ModuleControlBase - +