From bc73e5e3d03c1e67048dadc1d5cd5d445142b08a Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Fri, 17 Jul 2020 15:09:05 -0400 Subject: [PATCH] modifications to ActionLink and ActionDialog controls, added logic to prevent IHostedService from blocking startup, made controller route prefix consistent in module template --- Oqtane.Client/Modules/Controls/ActionDialog.razor | 7 ++++--- Oqtane.Client/Modules/Controls/ActionLink.razor | 6 +++--- Oqtane.Client/Modules/HtmlText/Index.razor | 4 ++-- Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs | 4 +++- .../External/Server/Controllers/[Module]Controller.cs | 2 +- .../[Owner].[Module]s/Controllers/[Module]Controller.cs | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Oqtane.Client/Modules/Controls/ActionDialog.razor b/Oqtane.Client/Modules/Controls/ActionDialog.razor index 020b004c..0182fe03 100644 --- a/Oqtane.Client/Modules/Controls/ActionDialog.razor +++ b/Oqtane.Client/Modules/Controls/ActionDialog.razor @@ -40,7 +40,7 @@ @code { private bool _visible = false; - private bool _editmode = true; + private bool _editmode = false; private bool _authorized = false; private string _iconSpan = string.Empty; @@ -66,7 +66,7 @@ public bool Disabled { get; set; } // optional [Parameter] - public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true + public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false [Parameter] public Action OnClick { get; set; } // required if an Action is specified - executes a method in the calling component @@ -84,6 +84,7 @@ { Class = "btn btn-success"; } + if (!string.IsNullOrEmpty(EditMode)) { _editmode = bool.Parse(EditMode); @@ -100,7 +101,7 @@ private bool IsAuthorized() { bool authorized = false; - if (PageState.EditMode || _editmode) + if (PageState.EditMode || !_editmode) { SecurityAccessLevel security = SecurityAccessLevel.Host; if (Security == null) diff --git a/Oqtane.Client/Modules/Controls/ActionLink.razor b/Oqtane.Client/Modules/Controls/ActionLink.razor index 383fb114..7de2331a 100644 --- a/Oqtane.Client/Modules/Controls/ActionLink.razor +++ b/Oqtane.Client/Modules/Controls/ActionLink.razor @@ -20,7 +20,7 @@ private string _parameters = string.Empty; private string _classname = "btn btn-primary"; private string _style = string.Empty; - private bool _editmode = true; + private bool _editmode = false; private bool _authorized = false; private string _iconSpan = string.Empty; @@ -46,7 +46,7 @@ public bool Disabled { get; set; } // optional [Parameter] - public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true + public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false. [Parameter] public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon @@ -100,7 +100,7 @@ private bool IsAuthorized() { var authorized = false; - if (PageState.EditMode || _editmode) + if (PageState.EditMode || !_editmode) { var security = SecurityAccessLevel.Host; if (Security == null) diff --git a/Oqtane.Client/Modules/HtmlText/Index.razor b/Oqtane.Client/Modules/HtmlText/Index.razor index c237402d..36e7c35c 100644 --- a/Oqtane.Client/Modules/HtmlText/Index.razor +++ b/Oqtane.Client/Modules/HtmlText/Index.razor @@ -7,12 +7,12 @@ @if (PageState.EditMode) { -


+


} @code { public override List Resources => new List() -{ + { new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } }; diff --git a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs index 35b8b0a9..b47cd130 100644 --- a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs +++ b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs @@ -27,8 +27,10 @@ namespace Oqtane.Infrastructure protected async Task ExecuteAsync(CancellationToken stoppingToken) { + await Task.Yield(); // required so that this method does not block startup + try - { + { while (!stoppingToken.IsCancellationRequested) { using (var scope = _serviceScopeFactory.CreateScope()) diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs index b8e19abc..6045fddf 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs @@ -10,7 +10,7 @@ using [Owner].[Module]s.Repository; namespace [Owner].[Module]s.Controllers { - [Route("{site}/api/[controller]")] + [Route("{alias}/api/[controller]")] public class [Module]Controller : Controller { private readonly I[Module]Repository _[Module]s; diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs index b8e19abc..6045fddf 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs +++ b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]s/Controllers/[Module]Controller.cs @@ -10,7 +10,7 @@ using [Owner].[Module]s.Repository; namespace [Owner].[Module]s.Controllers { - [Route("{site}/api/[controller]")] + [Route("{alias}/api/[controller]")] public class [Module]Controller : Controller { private readonly I[Module]Repository _[Module]s;