diff --git a/Oqtane.Client/Modules/Admin/Files/Index.razor b/Oqtane.Client/Modules/Admin/Files/Index.razor index f31aa809..bbec39f9 100644 --- a/Oqtane.Client/Modules/Admin/Files/Index.razor +++ b/Oqtane.Client/Modules/Admin/Files/Index.razor @@ -17,7 +17,7 @@ else Name - + @context diff --git a/Oqtane.Client/Modules/Admin/Profiles/Index.razor b/Oqtane.Client/Modules/Admin/Profiles/Index.razor index f65bded6..b362895a 100644 --- a/Oqtane.Client/Modules/Admin/Profiles/Index.razor +++ b/Oqtane.Client/Modules/Admin/Profiles/Index.razor @@ -8,7 +8,7 @@ } else { - +
@@ -18,7 +18,7 @@ else
- + @context.Name
diff --git a/Oqtane.Client/Modules/Controls/ActionDialog.razor b/Oqtane.Client/Modules/Controls/ActionDialog.razor new file mode 100644 index 00000000..62077ee5 --- /dev/null +++ b/Oqtane.Client/Modules/Controls/ActionDialog.razor @@ -0,0 +1,123 @@ +@namespace Oqtane.Modules.Controls +@inherits ModuleBase + +@if (visible) +{ +
+ +
+} +@if (authorized) +{ + +} + +@code { + [Parameter] + public string Header { get; set; } // required + + [Parameter] + public string Message { get; set; } // required + + [Parameter] + public string Action { get; set; } // defaults to Ok if not specified + + [Parameter] + public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel + + [Parameter] + public string Class { get; set; } // optional + + [Parameter] + public Action OnClick { get; set; } // required - executes a method in the calling component + + bool visible = false; + bool authorized = false; + + protected override void OnParametersSet() + { + if (string.IsNullOrEmpty(Action)) + { + Action = "Ok"; + } + if (string.IsNullOrEmpty(Class)) + { + Class = "btn btn-success"; + } + authorized = IsAuthorized(); + } + + private bool IsAuthorized() + { + bool authorized = false; + if (PageState.EditMode) + { + SecurityAccessLevel security = SecurityAccessLevel.Host; + if (Security == null) + { + string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ","); + Type moduleType = Type.GetType(typename); + if (moduleType != null) + { + var moduleobject = Activator.CreateInstance(moduleType); + security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null); + } + else + { + security = SecurityAccessLevel.Anonymous; // occurs when an action does not have a corresponding module control + } + } + else + { + security = Security.Value; + } + switch (security) + { + case SecurityAccessLevel.Anonymous: + authorized = true; + break; + case SecurityAccessLevel.View: + authorized = UserSecurity.IsAuthorized(PageState.User, "View", ModuleState.Permissions); + break; + case SecurityAccessLevel.Edit: + authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions); + break; + case SecurityAccessLevel.Admin: + authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole); + break; + case SecurityAccessLevel.Host: + authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole); + break; + } + } + return authorized; + } + + private void DisplayModal() + { + visible = !visible; + StateHasChanged(); + } + + private void Confirm() + { + DisplayModal(); + OnClick(); + } +} diff --git a/Oqtane.Client/Modules/Controls/ActionLink.razor b/Oqtane.Client/Modules/Controls/ActionLink.razor index aebbcb0d..c3b1f7cf 100644 --- a/Oqtane.Client/Modules/Controls/ActionLink.razor +++ b/Oqtane.Client/Modules/Controls/ActionLink.razor @@ -9,7 +9,10 @@ @code { [Parameter] - public string Action { get; set; } + public string Action { get; set; } // required + + [Parameter] + public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel [Parameter] public string Text { get; set; } // optional - defaults to Action if not specified @@ -23,9 +26,6 @@ [Parameter] public string Style { get; set; } // optional - [Parameter] - public string Control { get; set; } // optional - can be used to explicitly link an Action to a Module Control - string text = ""; string url = ""; string parameters = ""; @@ -57,51 +57,53 @@ } url = EditUrl(Action, parameters); + authorized = IsAuthorized(); + } + private bool IsAuthorized() + { + bool authorized = false; if (PageState.EditMode) { - string typename; - if (string.IsNullOrEmpty(Control)) + SecurityAccessLevel security = SecurityAccessLevel.Host; + if (Security == null) { - typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ","); - } - else - { - typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Control + ","); - } - Type moduleType = Type.GetType(typename); - if (moduleType != null) - { - var moduleobject = Activator.CreateInstance(moduleType); - SecurityAccessLevel SecurityAccessLevel = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null); - switch (SecurityAccessLevel) + string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ","); + Type moduleType = Type.GetType(typename); + if (moduleType != null) { - case SecurityAccessLevel.Anonymous: - authorized = true; - break; - case SecurityAccessLevel.View: - authorized = UserSecurity.IsAuthorized(PageState.User, "View", ModuleState.Permissions); - break; - case SecurityAccessLevel.Edit: - authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions); - break; - case SecurityAccessLevel.Admin: - authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole); - break; - case SecurityAccessLevel.Host: - authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole); - break; + var moduleobject = Activator.CreateInstance(moduleType); + security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null); + } + else + { + security = SecurityAccessLevel.Anonymous; // occurs when an action does not have a corresponding module control + Class = "btn btn-warning"; // alert developer of missing module comtrol } } else { - authorized = true; // occurs when an action does not have a corresponding module control - classname = "btn btn-warning"; // alert developer of missing module comtrol + security = Security.Value; + } + switch (security) + { + case SecurityAccessLevel.Anonymous: + authorized = true; + break; + case SecurityAccessLevel.View: + authorized = UserSecurity.IsAuthorized(PageState.User, "View", ModuleState.Permissions); + break; + case SecurityAccessLevel.Edit: + authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions); + break; + case SecurityAccessLevel.Admin: + authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole); + break; + case SecurityAccessLevel.Host: + authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole); + break; } } - else - { - authorized = false; - } + return authorized; } } diff --git a/Oqtane.Client/Modules/Controls/ConfirmationDialog.razor b/Oqtane.Client/Modules/Controls/ConfirmationDialog.razor deleted file mode 100644 index 00e5cdd4..00000000 --- a/Oqtane.Client/Modules/Controls/ConfirmationDialog.razor +++ /dev/null @@ -1,69 +0,0 @@ -@namespace Oqtane.Modules.Controls -@inherits ModuleBase - -@if (visible) -{ -
- -
-} - - -@code { - [Parameter] - public string Header { get; set; } - - [Parameter] - public string Message { get; set; } - - [Parameter] - public string Action { get; set; } - - [Parameter] - public string Class { get; set; } - - [Parameter] - public Action OnClick { get; set; } - - bool visible = false; - - protected override void OnParametersSet() - { - if (string.IsNullOrEmpty(Action)) - { - Action = "Ok"; - } - if (string.IsNullOrEmpty(Class)) - { - Class = "btn btn-success"; - } - } - - private void DisplayModal() - { - visible = !visible; - StateHasChanged(); - } - - private void Confirm() - { - DisplayModal(); - OnClick(); - } -} diff --git a/Oqtane.Client/Modules/Controls/Pager.razor b/Oqtane.Client/Modules/Controls/Pager.razor index bb8e67b9..57d4eeb1 100644 --- a/Oqtane.Client/Modules/Controls/Pager.razor +++ b/Oqtane.Client/Modules/Controls/Pager.razor @@ -2,7 +2,9 @@ @inherits ModuleBase @typeparam TableItem -

+

+ @if(Format == "Table") + { @Header @@ -14,7 +16,18 @@ }
-

+ } + @if(Format == "Grid") + { +
+
@Header
+ @foreach (var item in ItemList) + { +
@Row(item)
+ } +
+ } +
@if (Page > MaxPages) { @@ -50,6 +63,9 @@ int StartPage; int EndPage; + [Parameter] + public string Format { get; set; } + [Parameter] public RenderFragment Header { get; set; } @@ -69,6 +85,10 @@ protected override void OnParametersSet() { + if (string.IsNullOrEmpty(Format)) + { + Format = "Table"; + } if (string.IsNullOrEmpty(PageSize)) { MaxItems = 10; diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index b7bffd27..87ad57f5 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -50,7 +50,6 @@ namespace Oqtane.Infrastructure case ".dll": entry.ExtractToFile(Path.Combine(binfolder, filename), true); break; - case ".nuspec": case ".png": case ".jpg": case ".jpeg":