From dd1898b5a659125c9b1c31e74cf1fd9989843ba6 Mon Sep 17 00:00:00 2001 From: Lupei Nicolae Date: Wed, 11 Mar 2020 16:52:14 +0200 Subject: [PATCH] feat: add menu initializer for reports module --- .../Helpers/DashboardRazorResources.cs | 4 +- ...ortsController.cs => ReportsController.cs} | 15 ++++-- .../Extensions/ServiceCollectionExtensions.cs | 14 +++-- .../GR.Report.Dynamic.Razor.csproj | 2 + .../Helpers/ReportRazorResources.cs | 14 +++++ .../Helpers/ReportsMenuInitializer.cs | 52 +++++++++++++++++++ .../CreateFolder.cshtml | 0 .../{DynamicReports => Reports}/Index.cshtml | 2 +- .../ManageDynamicReportFolders.cshtml | 8 +-- .../{DynamicReports => Reports}/Save.cshtml | 16 +++--- .../wwwroot/assets/ReportScripts/report.js | 2 - 11 files changed, 106 insertions(+), 23 deletions(-) rename src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/{DynamicReportsController.cs => ReportsController.cs} (96%) mode change 100755 => 100644 create mode 100644 src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportRazorResources.cs create mode 100644 src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportsMenuInitializer.cs rename src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/{DynamicReports => Reports}/CreateFolder.cshtml (100%) mode change 100755 => 100644 rename src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/{DynamicReports => Reports}/Index.cshtml (98%) mode change 100755 => 100644 rename src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/{DynamicReports => Reports}/ManageDynamicReportFolders.cshtml (96%) mode change 100755 => 100644 rename src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/{DynamicReports => Reports}/Save.cshtml (94%) mode change 100755 => 100644 diff --git a/src/GR.Extensions/GR.Dashboard.Extension/GR.Dashboard.Razor/Helpers/DashboardRazorResources.cs b/src/GR.Extensions/GR.Dashboard.Extension/GR.Dashboard.Razor/Helpers/DashboardRazorResources.cs index 021e67a2..b2133c7d 100644 --- a/src/GR.Extensions/GR.Dashboard.Extension/GR.Dashboard.Razor/Helpers/DashboardRazorResources.cs +++ b/src/GR.Extensions/GR.Dashboard.Extension/GR.Dashboard.Razor/Helpers/DashboardRazorResources.cs @@ -8,8 +8,8 @@ public static class Menu { public static Guid DashboardConfiguration = Guid.Parse("52a430e6-c41b-4b73-8a23-95b22769894e"); public static Guid AllDashboard = Guid.Parse("9448a77d-a90d-4461-9d78-1a4acd708dd3"); - public static Guid WidgetGroups = Guid.Parse(""); - public static Guid Widgets = Guid.Parse(""); + public static Guid WidgetGroups = Guid.Parse("4d18d950-ac58-45c0-9b53-04a8533e287d"); + public static Guid Widgets = Guid.Parse("dd8daaf3-f23e-46fc-a851-66ebf1cb7bfc"); } } } diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/DynamicReportsController.cs b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/ReportsController.cs old mode 100755 new mode 100644 similarity index 96% rename from src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/DynamicReportsController.cs rename to src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/ReportsController.cs index 6cd477fd..0fcf6afa --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/DynamicReportsController.cs +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Controllers/ReportsController.cs @@ -12,21 +12,30 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using GR.Core.Razor.BaseControllers; +using Microsoft.AspNetCore.Authorization; namespace GR.Report.Dynamic.Razor.Controllers { - public class DynamicReportsController : Controller + [Authorize] + public class ReportsController : BaseGearController { + #region Injectable + + /// + /// Inject reports service + /// private readonly IDynamicReportsService _service; - public DynamicReportsController(IDynamicReportsService service) + #endregion + + public ReportsController(IDynamicReportsService service) { _service = service; } #region ReportFolders - [HttpGet] public IActionResult Index() { diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Extensions/ServiceCollectionExtensions.cs b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Extensions/ServiceCollectionExtensions.cs index 85922335..3107cc6b 100755 --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Extensions/ServiceCollectionExtensions.cs +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Extensions/ServiceCollectionExtensions.cs @@ -1,8 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; +using GR.Core; +using GR.Core.Extensions; using Microsoft.Extensions.DependencyInjection; using GR.Report.Dynamic.Razor.Helpers; +using GR.UI.Menu.Abstractions; +using GR.UI.Menu.Abstractions.Events; namespace GR.Report.Dynamic.Razor.Extensions { @@ -16,6 +17,13 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddReportUIModule(this IServiceCollection services) { services.ConfigureOptions(typeof(ReportFileConfiguration)); + MenuEvents.Menu.OnMenuSeed += (sender, args) => + { + GearApplication.BackgroundTaskQueue.PushBackgroundWorkItemInQueue(async x => + { + await x.InjectService().AppendMenuItemsAsync(new ReportsMenuInitializer()); + }); + }; return services; } } diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/GR.Report.Dynamic.Razor.csproj b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/GR.Report.Dynamic.Razor.csproj index e3b7a034..f9b4b5d5 100644 --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/GR.Report.Dynamic.Razor.csproj +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/GR.Report.Dynamic.Razor.csproj @@ -22,6 +22,8 @@ + + diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportRazorResources.cs b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportRazorResources.cs new file mode 100644 index 00000000..1b90c1f2 --- /dev/null +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportRazorResources.cs @@ -0,0 +1,14 @@ +using System; + +namespace GR.Report.Dynamic.Razor.Helpers +{ + public static class ReportRazorResources + { + public class Menu + { + public static Guid ReportsSection = Guid.Parse("379adac1-351c-41a9-a9fa-1b5275bc362f"); + public static Guid Reports = Guid.Parse("0bf2560c-8ef2-4686-9f2e-1961d45ac4ea"); + public static Guid Folders = Guid.Parse("d4d004ac-c065-4fd1-87ee-bfda1832d4d5"); + } + } +} \ No newline at end of file diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportsMenuInitializer.cs b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportsMenuInitializer.cs new file mode 100644 index 00000000..f8e3138b --- /dev/null +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Helpers/ReportsMenuInitializer.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using GR.Core; +using GR.Core.Attributes.Documentation; +using GR.Core.Helpers.Global; +using GR.UI.Menu.Abstractions.Helpers; + +namespace GR.Report.Dynamic.Razor.Helpers +{ + [Author(Authors.LUPEI_NICOLAE)] + public class ReportsMenuInitializer : BaseMenuInitializer + { + public override MenuInitBuilder Builder => new MenuInitBuilder + { + MenuGroup = MenuResources.AppMenuId, + Configs = new List + { + new MenuItemConfig(ReportRazorResources.Menu.ReportsSection) + { + Name = "Reports", + ParentMenuItemId = MenuResources.MenuItems.AdministrationItem, + Href = MenuResources.MenuItems.None, + Translate = "reports", + AllowedRoles = new List + { + GlobalResources.Roles.ADMINISTRATOR + } + }, + new MenuItemConfig(ReportRazorResources.Menu.Reports) + { + Name = "Reports", + ParentMenuItemId = ReportRazorResources.Menu.ReportsSection, + Href = "/Reports", + Translate = "reports", + AllowedRoles = new List + { + GlobalResources.Roles.ADMINISTRATOR + } + }, + new MenuItemConfig(ReportRazorResources.Menu.Folders) + { + Name = "Report folders", + ParentMenuItemId = ReportRazorResources.Menu.ReportsSection, + Href = "/Reports/ManageDynamicReportFolders", + AllowedRoles = new List + { + GlobalResources.Roles.ADMINISTRATOR + } + } + } + }; + } +} \ No newline at end of file diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/CreateFolder.cshtml b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/CreateFolder.cshtml old mode 100755 new mode 100644 similarity index 100% rename from src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/CreateFolder.cshtml rename to src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/CreateFolder.cshtml diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Index.cshtml b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Index.cshtml old mode 100755 new mode 100644 similarity index 98% rename from src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Index.cshtml rename to src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Index.cshtml index 481f89c6..05a96c75 --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Index.cshtml +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Index.cshtml @@ -119,7 +119,7 @@ return ``; } } diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/ManageDynamicReportFolders.cshtml b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/ManageDynamicReportFolders.cshtml old mode 100755 new mode 100644 similarity index 96% rename from src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/ManageDynamicReportFolders.cshtml rename to src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/ManageDynamicReportFolders.cshtml index b28c9190..9b3dfe6f --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/ManageDynamicReportFolders.cshtml +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/ManageDynamicReportFolders.cshtml @@ -1,6 +1,6 @@ @model Microsoft.EntityFrameworkCore.Query.IIncludableQueryable> @{ - ViewData["Title"] = "Manage Dynamic Report Folders"; + ViewData["Title"] = "Manage Report Folders"; }
@@ -8,7 +8,7 @@

Folder Management - Add + Add

@@ -165,10 +165,10 @@ } diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Save.cshtml b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Save.cshtml old mode 100755 new mode 100644 similarity index 94% rename from src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Save.cshtml rename to src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Save.cshtml index 02bf8725..ac40dddf --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/DynamicReports/Save.cshtml +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/Views/Reports/Save.cshtml @@ -68,7 +68,7 @@
- +
@@ -89,7 +89,7 @@
-
+
@@ -112,7 +112,7 @@
-
+
@@ -132,7 +132,7 @@
-
+
@@ -148,12 +148,12 @@
-
+
-
@@ -178,7 +178,7 @@ save @Localizer["save"] -
diff --git a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/wwwroot/assets/ReportScripts/report.js b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/wwwroot/assets/ReportScripts/report.js index 2b4e2484..bc63ff9b 100644 --- a/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/wwwroot/assets/ReportScripts/report.js +++ b/src/GR.Extensions/GR.Report.Extension/GR.Report.Dynamic.Razor/wwwroot/assets/ReportScripts/report.js @@ -441,7 +441,6 @@ function AddChart(chartType) { return dfd.promise(); } - function SetRelValues() { $('#pnlRelationships > .row').each(function () { @@ -499,7 +498,6 @@ function prepareFields($n, option) { return dfd.promise(); } - function SetFieldValues(data) { if (data.length > 0) { $('#pnlFields > .row').each(function () {