diff --git a/Oqtane.Client/Modules/Admin/Login/Index.razor b/Oqtane.Client/Modules/Admin/Login/Index.razor index 106ee57f..91248ec7 100644 --- a/Oqtane.Client/Modules/Admin/Login/Index.razor +++ b/Oqtane.Client/Modules/Admin/Login/Index.razor @@ -1,7 +1,6 @@ @namespace Oqtane.Modules.Admin.Login @inherits ModuleBase @inject NavigationManager NavigationManager -@inject IJSRuntime JsRuntime @inject IUserService UserService @inject IServiceProvider ServiceProvider @@ -96,7 +95,7 @@ { await logger.LogInformation("Login Successful For Username {Username}", _username); // complete the login on the server so that the cookies are set correctly on SignalR - var interop = new Interop(JsRuntime); + var interop = new Interop(JSRuntime); string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken"); var fields = new { __RequestVerificationToken = antiforgerytoken, username = _username, password = _password, remember = _remember, returnurl = _returnUrl }; await interop.SubmitForm($"/{PageState.Alias.AliasId}/pages/login/", fields); diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor index db9186bd..4d13338e 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor @@ -10,23 +10,23 @@ @if (_packages.Count > 0) { - - - -
- Name - Version - -
- - @context.Name - @context.Version - - - - -
-
+ + + +
+ Name + Version + +
+ + @context.Name + @context.Version + + + + +
+
} @@ -77,8 +77,10 @@ { try { + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); await ModuleDefinitionService.InstallModuleDefinitionsAsync(); - NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor index d348ddb4..88590d5e 100644 --- a/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor +++ b/Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor @@ -24,17 +24,17 @@ else @@ -55,20 +55,26 @@ else } catch (Exception ex) { - await logger.LogError(ex, "Error Loading Modules {Error}", ex.Message); - AddModuleMessage("Error Loading Modules", MessageType.Error); + if (_moduleDefinitions == null) + { + await logger.LogError(ex, "Error Loading Modules {Error}", ex.Message); + AddModuleMessage("Error Loading Modules", MessageType.Error); + } } } private bool UpgradeAvailable(string moduledefinitionname, string version) { var upgradeavailable = false; - var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault(); - if (package != null) + if (_packages != null) { - upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); + var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault(); + if (package != null) + { + upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); + } + } - return upgradeavailable; } @@ -77,24 +83,27 @@ else try { await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules"); - await ModuleDefinitionService.InstallModuleDefinitionsAsync(); await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", moduledefinitionname, version); - NavigationManager.NavigateTo(NavigateUrl()); + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); + await ModuleDefinitionService.InstallModuleDefinitionsAsync(); } catch (Exception ex) { await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version} {Error}", moduledefinitionname, version, ex.Message); AddModuleMessage("Error Downloading Module", MessageType.Error); } - } + } private async Task DeleteModule(ModuleDefinition moduleDefinition) { try { + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduleDefinition.ModuleDefinitionId, moduleDefinition.SiteId); - await logger.LogInformation("Module Deleted {ModuleDefinition}", moduleDefinition); - NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/Modules/Settings.razor b/Oqtane.Client/Modules/Admin/Modules/Settings.razor index 98e78bdf..31cedb01 100644 --- a/Oqtane.Client/Modules/Admin/Modules/Settings.razor +++ b/Oqtane.Client/Modules/Admin/Modules/Settings.razor @@ -25,9 +25,9 @@ @@ -63,7 +63,7 @@ } - @if (_containers != null) + @if (_permissions != null) {
@if (context.AssemblyName != "Oqtane.Client") - { + { - } + } @context.Name @context.Version @if (UpgradeAvailable(context.ModuleDefinitionName, context.Version)) - { + { - } + }
@@ -85,12 +85,12 @@ Cancel @code { - private Dictionary _containers; + private List _containers = new List(); private string _title; private string _containerType; private string _allPages = "false"; private string _permissionNames = ""; - private string _permissions; + private string _permissions = null; private string _pageId; private PermissionGrid _permissionGrid; private Type _settingsModuleType; @@ -105,7 +105,7 @@ protected override async Task OnInitializedAsync() { _title = ModuleState.Title; - _containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync()); + _containers = ThemeService.GetContainerControls(await ThemeService.GetThemesAsync(), PageState.Page.ThemeType); _containerType = ModuleState.ContainerType; if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType) { diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 8761ff3a..2970d442 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -102,41 +102,44 @@ - - - + + - + + + + } @@ -199,10 +202,10 @@ Cancel @code { - private Dictionary _themes; - private Dictionary _panelayouts; - private Dictionary _containers = new Dictionary(); private List _themeList; + private List _themes = new List(); + private List _layouts = new List(); + private List _containers = new List(); private List _pageList; private string _name; private string _title; @@ -232,10 +235,7 @@ _pageList = PageState.Pages; _children = PageState.Pages.Where(item => item.ParentId == null).ToList(); - _themes = ThemeService.GetThemeTypes(_themeList); - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); - _containers = ThemeService.GetContainerTypes(_themeList); - + _themes = ThemeService.GetThemeControls(_themeList); _permissions = string.Empty; } catch (Exception ex) @@ -287,12 +287,16 @@ _themetype = (string)e.Value; if (_themetype != "-") { - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); + _containers = ThemeService.GetContainerControls(_themeList, _themetype); } else { - _panelayouts = new Dictionary(); + _layouts = new List(); + _containers = new List(); } + _layouttype = "-"; + _containertype = "-"; StateHasChanged(); } catch (Exception ex) @@ -307,7 +311,7 @@ Page page = null; try { - if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) + if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) { page = new Page(); page.SiteId = PageState.Page.SiteId; diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index b25f6b2e..7373d36a 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -113,41 +113,44 @@ - - - + + - + + + + } @@ -199,23 +202,26 @@ } -
- - -
+ + + -
@@ -144,9 +147,9 @@
- - -
+ + + -
@@ -155,9 +158,9 @@
- - - -
- -
+ @if (_permissions != null) + { + + + + +
+ +
+ }
Cancel @code { - private Dictionary _themes; - private Dictionary _panelayouts; - private Dictionary _containers = new Dictionary(); private List _themeList; + private List _themes = new List(); + private List _layouts = new List(); + private List _containers = new List(); private List _pageList; private int _pageId; private string _name; @@ -234,7 +240,7 @@ private string _layouttype = "-"; private string _containertype = "-"; private string _icon; - private string _permissions; + private string _permissions = null; private string _createdby; private DateTime _createdon; private string _modifiedby; @@ -252,12 +258,11 @@ { try { - _themeList = await ThemeService.GetThemesAsync(); _pageList = PageState.Pages; _children = PageState.Pages.Where(item => item.ParentId == null).ToList(); - _themes = ThemeService.GetThemeTypes(_themeList); - _containers = ThemeService.GetContainerTypes(_themeList); + _themeList = await ThemeService.GetThemesAsync(); + _themes = ThemeService.GetThemeControls(_themeList); _pageId = Int32.Parse(PageState.QueryString["id"]); var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); @@ -291,12 +296,13 @@ { _themetype = "-"; } - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, page.ThemeType); _layouttype = page.LayoutType; if (_layouttype == PageState.Site.DefaultLayoutType) { _layouttype = "-"; } + _containers = ThemeService.GetContainerControls(_themeList, page.ThemeType); _containertype = page.DefaultContainerType; if (string.IsNullOrEmpty(_containertype)) { @@ -369,12 +375,16 @@ _themetype = (string)e.Value; if (_themetype != "-") { - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); + _containers = ThemeService.GetContainerControls(_themeList, _themetype); } else { - _panelayouts = new Dictionary(); + _layouts = new List(); + _containers = new List(); } + _layouttype = "-"; + _containertype = "-"; StateHasChanged(); } catch (Exception ex) diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 3f3425f6..9d4e4611 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -56,45 +56,48 @@ - - - - - - - - + @if (_layouts.Count > 0) + { + + + + + + + + + } @@ -208,10 +211,10 @@ } @code { - private Dictionary _themes; - private Dictionary _panelayouts; - private Dictionary _containers; private List _themeList; + private List _themes = new List(); + private List _layouts = new List(); + private List _containers = new List(); private string _name = string.Empty; private List _tenantList; private string _tenant = string.Empty; @@ -221,9 +224,9 @@ private FileManager _logofilemanager; private int _faviconfileid = -1; private FileManager _faviconfilemanager; - private string _themetype; - private string _layouttype; - private string _containertype; + private string _themetype = "-"; + private string _layouttype = "-"; + private string _containertype = "-"; private string _allowregistration; private string _smtphost = string.Empty; private string _smtpport = string.Empty; @@ -271,9 +274,11 @@ _faviconfileid = site.FaviconFileId.Value; } + _themes = ThemeService.GetThemeControls(_themeList); _themetype = site.DefaultThemeType; - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); _layouttype = site.DefaultLayoutType; + _containers = ThemeService.GetContainerControls(_themeList, _themetype); _containertype = site.DefaultContainerType; _allowregistration = site.AllowRegistration.ToString(); @@ -314,9 +319,6 @@ _deletedon = site.DeletedOn; _isdeleted = site.IsDeleted.ToString(); } - - _themes = ThemeService.GetThemeTypes(_themeList); - _containers = ThemeService.GetContainerTypes(_themeList); } catch (Exception ex) { @@ -330,14 +332,18 @@ try { _themetype = (string)e.Value; - if (_themetype != string.Empty) + if (_themetype != "-") { - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); + _containers = ThemeService.GetContainerControls(_themeList, _themetype); } else { - _panelayouts = new Dictionary(); + _layouts = new List(); + _containers = new List(); } + _layouttype = "-"; + _containertype = "-"; StateHasChanged(); } catch (Exception ex) @@ -351,7 +357,7 @@ { try { - if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) + if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-") { var unique = true; foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) @@ -376,7 +382,7 @@ } site.DefaultThemeType = _themetype; - site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype); + site.DefaultLayoutType = (_layouttype == "-" ? string.Empty : _layouttype); site.DefaultContainerType = _containertype; site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); diff --git a/Oqtane.Client/Modules/Admin/Sites/Add.razor b/Oqtane.Client/Modules/Admin/Sites/Add.razor index 40ac6f39..b2b9414d 100644 --- a/Oqtane.Client/Modules/Admin/Sites/Add.razor +++ b/Oqtane.Client/Modules/Admin/Sites/Add.razor @@ -38,38 +38,41 @@ else - - - - - - - - + @if (_layouts.Count > 0) + { + + + + + + + + + } @@ -80,7 +83,7 @@ else - - @foreach (KeyValuePair item in _themes) + + @foreach (var theme in _themes) { - if (item.Key == _themetype) + if (theme.TypeName == _themetype) { - + } else { - + } } - - - - - - - - + @if (_layouts.Count > 0) + { + + + + + + + + + } @@ -103,11 +106,11 @@ } @code { - private Dictionary _themes; - private Dictionary _panelayouts; - private Dictionary _containers; - private Alias _alias; private List _themeList; + private List _themes = new List(); + private List _layouts = new List(); + private List _containers = new List(); + private Alias _alias; private string _name = string.Empty; private List _tenantList; private string _tenant = string.Empty; @@ -147,9 +150,11 @@ _urls += alias.Name + "\n"; } + _themes = ThemeService.GetThemeControls(_themeList); _themetype = site.DefaultThemeType; - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); _layouttype = site.DefaultLayoutType; + _containers = ThemeService.GetContainerControls(_themeList, _themetype); _containertype = site.DefaultContainerType; _createdby = site.CreatedBy; _createdon = site.CreatedOn; @@ -159,9 +164,6 @@ _deletedon = site.DeletedOn; _isdeleted = site.IsDeleted.ToString(); } - - _themes = ThemeService.GetThemeTypes(_themeList); - _containers = ThemeService.GetContainerTypes(_themeList); } catch (Exception ex) { @@ -175,15 +177,18 @@ try { _themetype = (string)e.Value; - if (_themetype != string.Empty) + if (_themetype != "-") { - _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); + _layouts = ThemeService.GetLayoutControls(_themeList, _themetype); + _containers = ThemeService.GetContainerControls(_themeList, _themetype); } else { - _panelayouts = new Dictionary(); + _layouts = new List(); + _containers = new List(); } - + _layouttype = "-"; + _containertype = "-"; StateHasChanged(); } catch (Exception ex) @@ -197,7 +202,7 @@ { try { - if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) + if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-") { var unique = true; foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) diff --git a/Oqtane.Client/Modules/Admin/Themes/Add.razor b/Oqtane.Client/Modules/Admin/Themes/Add.razor index da47d8a9..327a7d3a 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Add.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Add.razor @@ -7,43 +7,43 @@ @if (_packages != null) { - - @if (_packages.Count > 0) - { - - - -
- Name - Version - -
- - @context.Name - @context.Version - - - - -
-
- } - - - - - - -
- - - -
-
-
+ + @if (_packages.Count > 0) + { + + + +
+ Name + Version + +
+ + @context.Name + @context.Version + + + + +
+
+ } + + + + + + +
+ + + +
+
+
- -Cancel + + Cancel } @code { @@ -77,8 +77,10 @@ { try { + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); await ThemeService.InstallThemesAsync(); - NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { @@ -101,4 +103,4 @@ AddModuleMessage("Error Downloading Theme", MessageType.Error); } } - } +} diff --git a/Oqtane.Client/Modules/Admin/Themes/Index.razor b/Oqtane.Client/Modules/Admin/Themes/Index.razor index 4a3113b6..d2e6b2e9 100644 --- a/Oqtane.Client/Modules/Admin/Themes/Index.razor +++ b/Oqtane.Client/Modules/Admin/Themes/Index.razor @@ -1,10 +1,11 @@ @namespace Oqtane.Modules.Admin.Themes +@using System.Net @inherits ModuleBase @inject NavigationManager NavigationManager @inject IThemeService ThemeService @inject IPackageService PackageService -@if (themes == null) +@if (_themes == null) {

Loading...

} @@ -12,68 +13,102 @@ else { - +
+     Name Version  
+ @if (context.AssemblyName != "Oqtane.Client") - { + { - } + } @context.Name @context.Version @if (UpgradeAvailable(context.ThemeName, context.Version)) - { + { - } + }
} @code { - private List themes; - private List packages; + private List _themes; + private List _packages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; protected override async Task OnInitializedAsync() { - themes = await ThemeService.GetThemesAsync(); - packages = await PackageService.GetPackagesAsync("module"); + try + { + _themes = await ThemeService.GetThemesAsync(); + _packages = await PackageService.GetPackagesAsync("theme"); + } + catch (Exception ex) + { + if (_themes == null) + { + await logger.LogError(ex, "Error Loading Themes {Error}", ex.Message); + AddModuleMessage("Error Loading Themes", MessageType.Error); + } + } } private bool UpgradeAvailable(string themename, string version) { var upgradeavailable = false; - var package = packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault(); - if (package != null) + if (_packages != null) { - upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); + var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault(); + if (package != null) + { + upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0); + } } - return upgradeavailable; } private async Task DownloadTheme(string themename, string version) { - await PackageService.DownloadPackageAsync(themename, version, "Themes"); - await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", themename, version); - await ThemeService.InstallThemesAsync(); - NavigationManager.NavigateTo(NavigateUrl()); + try + { + await PackageService.DownloadPackageAsync(themename, version, "Themes"); + await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", themename, version); + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); + await ThemeService.InstallThemesAsync(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading Theme {ThemeName} {Version} {Error}", themename, version, ex.Message); + AddModuleMessage("Error Downloading Theme", MessageType.Error); + } } private async Task DeleteTheme(Theme Theme) { - await ThemeService.DeleteThemeAsync(Theme.ThemeName); - await logger.LogInformation("Theme Deleted {Theme}", Theme); - NavigationManager.NavigateTo(NavigateUrl()); + try + { + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); + await ThemeService.DeleteThemeAsync(Theme.ThemeName); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Deleting Theme {Theme} {Error}", Theme, ex.Message); + AddModuleMessage("Error Deleting Theme", MessageType.Error); + } } } \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Themes/View.razor b/Oqtane.Client/Modules/Admin/Themes/View.razor new file mode 100644 index 00000000..eb655799 --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Themes/View.razor @@ -0,0 +1,101 @@ +@namespace Oqtane.Modules.Admin.Themes +@using System.Net +@inherits ModuleBase +@inject IThemeService ThemeService +@inject NavigationManager NavigationManager + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+Cancel + +@code { + private string _themeName = ""; + private string _name; + private string _version; + private string _owner = ""; + private string _url = ""; + private string _contact = ""; + private string _license = ""; + + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; + + protected override async Task OnInitializedAsync() + { + try + { + _themeName = WebUtility.UrlDecode(PageState.QueryString["name"]); + var themes = await ThemeService.GetThemesAsync(); + var theme = themes.FirstOrDefault(item => item.ThemeName == _themeName); + if (theme != null) + { + _name = theme.Name; + _version = theme.Version; + _owner = theme.Owner; + _url = theme.Url; + _contact = theme.Contact; + _license = theme.License; + } + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Loading Theme {ThemeName} {Error}", _themeName, ex.Message); + AddModuleMessage("Error Loading Theme", MessageType.Error); + } + } +} diff --git a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor index 7ee95e30..5eba7cbd 100644 --- a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor +++ b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor @@ -7,32 +7,32 @@ @if (_package != null) { - - - @if (_upgradeavailable) - { - - @("Framework") @_package.Version - } - else - { - - } - - - - - - - -
- - - -
- -
-
+ + + @if (_upgradeavailable) + { + + @("Framework") @_package.Version + } + else + { + + } + + + + + + + +
+ + + +
+ +
+
} @code { @@ -43,28 +43,58 @@ protected override async Task OnInitializedAsync() { - List packages = await PackageService.GetPackagesAsync("framework"); - _package = packages.FirstOrDefault(); - if (_package != null) + try { - _upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0); + List packages = await PackageService.GetPackagesAsync("framework"); + if (packages != null) + { + _package = packages.FirstOrDefault(); + if (_package != null) + { + _upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0); + } + else + { + _package = new Package { Name = Constants.PackageId, Version = Constants.Version }; + } + } } - else + catch { - _package = new Package { Name = Constants.PackageId, Version = Constants.Version }; + // can be caused by no network connection } } private async Task Upgrade() { - await InstallationService.Upgrade(); - NavigationManager.NavigateTo(NavigateUrl()); + try + { + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); + await InstallationService.Upgrade(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Executing Upgrade {Error}", ex.Message); + AddModuleMessage("Error Executing Upgrade", MessageType.Error); + } } private async Task Download(string packageid, string version) { - await PackageService.DownloadPackageAsync(packageid, version, "Framework"); - await InstallationService.Upgrade(); - NavigationManager.NavigateTo(NavigateUrl()); + try + { + await PackageService.DownloadPackageAsync(packageid, version, "Framework"); + ShowProgressIndicator(); + var interop = new Interop(JSRuntime); + await interop.RedirectBrowser(NavigateUrl(), 3); + await InstallationService.Upgrade(); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Downloading Framework {Error}", ex.Message); + AddModuleMessage("Error Downloading Framework", MessageType.Error); + } } } diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor index e6ae6b68..c413ec91 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor @@ -1,7 +1,7 @@ @namespace Oqtane.Modules.Admin.UserProfile @inherits ModuleBase @inject NavigationManager NavigationManager -@inject IUserRoleService UserRoleService +@inject IUserService UserService @inject INotificationService NotificationService @if (PageState.User != null) @@ -9,19 +9,10 @@ @@ -46,8 +37,7 @@ } @code { - private List userroles; - private string userid = "-1"; + private string username = ""; private string subject = ""; private string body = ""; @@ -55,41 +45,35 @@ public override string Title => "Send Notification"; - protected override async Task OnInitializedAsync() - { - try - { - userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId); - userroles = userroles.Where(item => item.Role.Name == Constants.RegisteredRole || item.Role.Name == Constants.HostRole) - .OrderBy(item => item.User.DisplayName).ToList(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Loading Users {Error}", ex.Message); - AddModuleMessage("Error Loading Users", MessageType.Error); - } - } - private async Task Send() { var notification = new Notification(); try { - notification.SiteId = PageState.Site.SiteId; - notification.FromUserId = PageState.User.UserId; - notification.ToUserId = int.Parse(userid); - notification.ToEmail = ""; - notification.Subject = subject; - notification.Body = body; - notification.ParentId = null; - notification.CreatedOn = DateTime.UtcNow; - notification.IsDelivered = false; - notification.DeliveredOn = null; - - notification = await NotificationService.AddNotificationAsync(notification); - - await logger.LogInformation("Notification Created {Notification}", notification); - NavigationManager.NavigateTo(NavigateUrl()); + 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 = await NotificationService.AddNotificationAsync(notification); + await logger.LogInformation("Notification Created {Notification}", notification); + NavigationManager.NavigateTo(NavigateUrl()); + } + else + { + AddModuleMessage("User Does Not Exist. Please Verify That The Username Provided Is Correct.", MessageType.Warning); + } } catch (Exception ex) { diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor index fec53f62..82ff8309 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor @@ -73,7 +73,7 @@ else } - @if (profiles != null) + @if (profiles != null && settings != null) {
- + - +
@foreach (Profile profile in profiles) @@ -120,13 +120,22 @@ else - + - + } @@ -143,13 +152,22 @@ else - + - + } diff --git a/Oqtane.Client/Modules/Admin/UserProfile/View.razor b/Oqtane.Client/Modules/Admin/UserProfile/View.razor index 07140f63..2e48fcb1 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/View.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/View.razor @@ -1,7 +1,7 @@ @namespace Oqtane.Modules.Admin.UserProfile @inherits ModuleBase @inject NavigationManager NavigationManager -@inject IUserRoleService UserRoleService +@inject IUserService UserService @inject INotificationService NotificationService @if (PageState.User != null) @@ -9,71 +9,99 @@
@(context.FromUser == null ? "System" : context.FromUser.DisplayName)@context.FromDisplayName @context.Subject @context.CreatedOn @(context.Body.Length > 100 ? context.Body.Substring(0, 100) : context.Body) + @{ + string input = "___"; + if (context.Body.Contains(input)){ + context.Body = context.Body.Split(input)[0]; + context.Body = context.Body.Replace("\n", ""); + context.Body = context.Body.Replace("\r", ""); + } } + @(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body) + @(context.ToUser == null ? context.ToEmail : context.ToUser.DisplayName)@context.ToDisplayName @context.Subject @context.CreatedOn @(context.Body.Length > 100 ? context.Body.Substring(0, 100) : context.Body) + @{ + string input = "___"; + if (context.Body.Contains(input)){ + context.Body = context.Body.Split(input)[0]; + context.Body = context.Body.Replace("\n", ""); + context.Body = context.Body.Replace("\r", ""); + } } + @(context.Body.Length > 100 ? (context.Body.Substring(0, 97) + "...") : context.Body) +
- + @if (title == "From") + { + + } + @if (title == "To") + { + + } - + @if (title == "From") + { + +} + @if (title == "To") + { + + } @if (title == "From") { - } - - -
- - - + + + + +
- - - + + + + +
- + - +
- - -