From 7d705b57938d66901f503da24987932749ea3841 Mon Sep 17 00:00:00 2001 From: abarz722 Date: Mon, 26 Feb 2024 17:19:51 +0100 Subject: [PATCH 01/24] new component recert param selection --- .../files/FWO.Api.Client/Data/RecertFilter.cs | 12 +- .../files/FWO.UI/Pages/Reporting/Report.razor | 109 ++++-------------- .../ReportRecertParamSelection.razor | 99 ++++++++++++++++ 3 files changed, 134 insertions(+), 86 deletions(-) create mode 100644 roles/ui/files/FWO.UI/Pages/Reporting/ReportRecertParamSelection.razor diff --git a/roles/lib/files/FWO.Api.Client/Data/RecertFilter.cs b/roles/lib/files/FWO.Api.Client/Data/RecertFilter.cs index 09305a48a..e985d21cd 100644 --- a/roles/lib/files/FWO.Api.Client/Data/RecertFilter.cs +++ b/roles/lib/files/FWO.Api.Client/Data/RecertFilter.cs @@ -2,9 +2,19 @@ namespace FWO.Api.Data { public class RecertFilter { - public List RecertOwnerList {get; set;} = new List(); + public List RecertOwnerList {get; set;} = new (); public bool RecertShowAnyMatch {get; set;} = false; public int RecertificationDisplayPeriod = 0; + public RecertFilter() + {} + + public RecertFilter(RecertFilter recertFilter) + { + RecertOwnerList = new(recertFilter.RecertOwnerList); + RecertShowAnyMatch = recertFilter.RecertShowAnyMatch; + RecertificationDisplayPeriod = recertFilter.RecertificationDisplayPeriod; + + } } } diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor b/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor index e39a85740..78b946eb9 100644 --- a/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor +++ b/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor @@ -13,7 +13,7 @@ @page "/report/generation" @attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Auditor}")] -@inject ApiConnection Connection +@inject ApiConnection apiConnection @inject UserConfig userConfig @* ==== LEFT SIDEBAR ==== *@ @@ -29,43 +29,7 @@ @if (selectedReportType==ReportType.Recertification) { -
-
@(userConfig.GetText("recert_parameter"))
- @(userConfig.GetText("due_within")): - - @(userConfig.GetText("owner")) - - - @owner.Name - - -
-
- - -
-
+ } else if(selectedReportType==ReportType.UnusedRules) { @@ -86,21 +50,18 @@ } @if (selectedReportType != ReportType.Statistics && tenantList.Count > 1) { - if (tenantFilteringAllowed) - { -
-
@(userConfig.GetText("tenant_view"))
- - - @tenant.Name - - -
- } +
+
@(userConfig.GetText("tenant_view"))
+ + + @tenant.Name + + +
} else { @@ -252,8 +213,6 @@ private Management? globalStats = null; private ReportType selectedReportType = ReportType.Rules; - private FwoOwner? selectedOwner = null; - private List ownerList = new List(); private Tenant? selectedTenantView = null; private List tenantList = new List(); @@ -268,8 +227,7 @@ private TimeFilter savedTimeFilter = new TimeFilter(); private string displayedTimeSelection = ""; private bool ShowSelectTimeDialog = false; - private bool recertShowAnyMatch = true; - private int recertLookAheadDays = 0; + private RecertFilter actRecertFilter = new(); private int unusedDays = 0; private bool ShowCreateTicketDialog = false; @@ -302,11 +260,10 @@ { displayedTimeSelection = userConfig.GetText("now"); unusedDays = userConfig.UnusedTolerance; - deviceFilter.Managements = await Connection.SendQueryAsync>(DeviceQueries.getDevicesByManagement); - ownerList = await Connection.SendQueryAsync>(FWO.Api.Client.Queries.OwnerQueries.getOwners); + deviceFilter.Managements = await apiConnection.SendQueryAsync>(DeviceQueries.getDevicesByManagement); if (tenantFilteringAllowed) { - tenantList = await Connection.SendQueryAsync>(FWO.Api.Client.Queries.AuthQueries.getTenants); + tenantList = await apiConnection.SendQueryAsync>(FWO.Api.Client.Queries.AuthQueries.getTenants); tenantList?.Sort((a, b) => a.Name?.CompareTo(b.Name) ?? -1); // sort list of tenants } @@ -314,8 +271,6 @@ { collapseDevices = true; } - - recertLookAheadDays = Convert.ToInt32(userConfig.RecertificationDisplayPeriod); await InvokeAsync(StateHasChanged); } catch (Exception exception) @@ -353,7 +308,7 @@ private async Task SetDeviceVisibility(List mgms, Tenant tenantView) { // TODO: not used yet - List visibleDevices = await Connection.SendQueryAsync>(DeviceQueries.getDevicesByManagement); + // List visibleDevices = await apiConnection.SendQueryAsync>(DeviceQueries.getDevicesByManagement); // List tenantGatewayList = new List(selectedTenantView.TenantVisibleGateways); // List tenantGatewayList = new List(); @@ -447,7 +402,7 @@ if (template.ReportParams.TenantFilter.IsActive) { - Tenant tenantFromTemplate = await Tenant.getSingleTenant(Connection, template.ReportParams.TenantFilter.TenantId); + Tenant tenantFromTemplate = await Tenant.getSingleTenant(apiConnection, template.ReportParams.TenantFilter.TenantId); await tenantSelector.SelectElement(tenantFromTemplate); await TenantViewChanged(tenantFromTemplate); } @@ -470,12 +425,7 @@ actTimeFilter = template.ReportParams.TimeFilter; } DisplaySelectedTime(); - if(template.ReportParams.RecertFilter.RecertOwnerList.Count > 0) - { - selectedOwner = ownerList.FirstOrDefault(o => o.Id == template.ReportParams.RecertFilter.RecertOwnerList.First()); - } - recertShowAnyMatch = template.ReportParams.RecertFilter.RecertShowAnyMatch; - recertLookAheadDays = template.ReportParams.RecertFilter.RecertificationDisplayPeriod; + actRecertFilter = new(template.ReportParams.RecertFilter); unusedDays = template.ReportParams.UnusedFilter.UnusedForDays; } @@ -569,7 +519,7 @@ if(currentReport!.ReportType == ReportType.Statistics) { globalStats = new Management(); - await currentReport.Generate(0, Connection, + await currentReport.Generate(0, apiConnection, managementsReportIntermediate => { managementsReport = managementsReportIntermediate; @@ -589,7 +539,7 @@ } else { - await currentReport.Generate(userConfig.ElementsPerFetch, Connection, + await currentReport.Generate(userConfig.ElementsPerFetch, apiConnection, managementsReportIntermediate => { managementsReport = managementsReportIntermediate; @@ -644,7 +594,7 @@ // check for unsupported devices if(selectedReportType == ReportType.UnusedRules) { - var result = await ReportBase.GetUsageDataUnsupportedDevices(Connection, deviceFilter); + var result = await ReportBase.GetUsageDataUnsupportedDevices(apiConnection, deviceFilter); reducedDeviceFilter = result.reducedDeviceFilter; unsupportedList = result.unsupportedList; if(unsupportedList.Count > 0) @@ -687,12 +637,6 @@ private ReportTemplate ConstructReportTemplate() { - List ownerList = new List(); - if (selectedOwner != null) - { - ownerList.Add(selectedOwner.Id); - } - ReportParams reportParams = new ReportParams((int)selectedReportType, selectedReportType == ReportType.UnusedRules ? reducedDeviceFilter : deviceFilter); reportParams.TimeFilter = savedTimeFilter; if (selectedReportType != ReportType.Statistics) @@ -707,12 +651,7 @@ reportParams.TenantFilter = new TenantFilter(selectedTenantView); } - reportParams.RecertFilter = new RecertFilter() - { - RecertOwnerList = ownerList, - RecertShowAnyMatch = recertShowAnyMatch, - RecertificationDisplayPeriod = recertLookAheadDays - }; + reportParams.RecertFilter = new RecertFilter(actRecertFilter); reportParams.UnusedFilter = new UnusedFilter() { UnusedForDays = unusedDays, diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/ReportRecertParamSelection.razor b/roles/ui/files/FWO.UI/Pages/Reporting/ReportRecertParamSelection.razor new file mode 100644 index 000000000..019ce6181 --- /dev/null +++ b/roles/ui/files/FWO.UI/Pages/Reporting/ReportRecertParamSelection.razor @@ -0,0 +1,99 @@ +@using FWO.Config.Api + +@inject ApiConnection apiConnection +@inject UserConfig userConfig + + +
+
@(userConfig.GetText("recert_parameter"))
+ @(userConfig.GetText("due_within")): + + @(userConfig.GetText("owner")) + + + @owner.Name + + +
+
+ + +
+
+ + +@code +{ + [CascadingParameter] + Action DisplayMessageInUi { get; set; } = DefaultInit.DoNothing; + + [Parameter] + public string FilterInput { get; set; } = ""; + + [Parameter] + public EventCallback FilterInputChanged { get; set; } + + [Parameter] + public RecertFilter RecertFilter { get; set; } = new(); + + [Parameter] + public EventCallback RecertFilterChanged { get; set; } + + private List ownerList = new List(); + private FwoOwner? selectedOwner = null; + + + protected override async Task OnInitializedAsync() + { + try + { + ownerList = await apiConnection.SendQueryAsync>(FWO.Api.Client.Queries.OwnerQueries.getOwners); + RecertFilter.RecertificationDisplayPeriod = Convert.ToInt32(userConfig.RecertificationDisplayPeriod); + } + catch (Exception exception) + { + DisplayMessageInUi(exception, userConfig.GetText("object_fetch"), "", true); + } + } + + protected override void OnParametersSet() + { + if(RecertFilter.RecertOwnerList.Count > 0) + { + selectedOwner = ownerList.FirstOrDefault(o => o.Id == RecertFilter.RecertOwnerList.First()); + } + } + + private void SelectedOwnerChanged(FwoOwner newOwner) + { + selectedOwner = newOwner; + RecertFilter.RecertOwnerList = new(); + if(newOwner != null) + { + RecertFilter.RecertOwnerList.Add(newOwner.Id); + } + } +} From c0f68f7fc9ac06e861d472103d12708680062905 Mon Sep 17 00:00:00 2001 From: abarz722 Date: Tue, 27 Feb 2024 16:33:32 +0100 Subject: [PATCH 02/24] first steps modelling reports --- roles/api/files/replace_metadata.json | 302 ++++++++++++++++++ .../files/sql/idempotent/fworch-texts.sql | 2 + .../FilterTypes/ReportType.cs | 20 +- .../FWO.UI/Pages/Reporting/Archive.razor | 4 +- .../files/FWO.UI/Pages/Reporting/Report.razor | 127 ++++---- .../Reporting/ReportTemplateComponent.razor | 26 +- .../Reporting/Reports/StatisticsReport.razor | 43 +++ .../FWO.UI/Pages/Reporting/Schedule.razor | 30 +- .../files/FWO.UI/Shared/NavigationMenu.razor | 2 +- 9 files changed, 471 insertions(+), 85 deletions(-) create mode 100644 roles/ui/files/FWO.UI/Pages/Reporting/Reports/StatisticsReport.razor diff --git a/roles/api/files/replace_metadata.json b/roles/api/files/replace_metadata.json index 85bedf791..6841c208b 100644 --- a/roles/api/files/replace_metadata.json +++ b/roles/api/files/replace_metadata.json @@ -10155,6 +10155,28 @@ ] } }, + { + "role": "modeller", + "permission": { + "check": {}, + "columns": [ + "report_id", + "description", + "report_name", + "report_owner_id", + "report_template_id", + "report_type", + "tenant_wide_visible", + "report_json", + "report_csv", + "report_html", + "report_pdf", + "report_end_time", + "report_start_time" + ] + }, + "comment": "" + }, { "role": "recertifier", "permission": { @@ -10267,6 +10289,32 @@ "allow_aggregations": true } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_id", + "description", + "report_name", + "report_owner_id", + "report_template_id", + "report_type", + "tenant_wide_visible", + "report_json", + "report_csv", + "report_html", + "report_pdf", + "report_end_time", + "report_start_time" + ], + "filter": { + "report_owner_id": { + "_eq": "X-Hasura-User-Id" + } + }, + "allow_aggregations": true + } + }, { "role": "recertifier", "permission": { @@ -10399,6 +10447,32 @@ "check": null } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_pdf", + "report_owner_id", + "report_template_id", + "report_type", + "description", + "tenant_wide_visible", + "report_id", + "report_json", + "report_csv", + "report_html", + "report_end_time", + "report_start_time", + "report_name" + ], + "filter": { + "report_owner_id": { + "_eq": "X-Hasura-User-Id" + } + }, + "check": null + } + }, { "role": "recertifier", "permission": { @@ -10499,6 +10573,16 @@ } } }, + { + "role": "modeller", + "permission": { + "filter": { + "report_owner_id": { + "_eq": "X-Hasura-User-Id" + } + } + } + }, { "role": "recertifier", "permission": { @@ -10676,6 +10760,25 @@ ] } }, + { + "role": "modeller", + "permission": { + "check": {}, + "columns": [ + "report_schedule_id", + "report_schedule_active", + "report_schedule_name", + "report_schedule_counter", + "report_schedule_every", + "report_schedule_owner", + "report_schedule_repeat", + "report_schedule_repetitions", + "report_template_id", + "report_schedule_start_time" + ] + }, + "comment": "" + }, { "role": "recertifier", "permission": { @@ -10808,6 +10911,28 @@ "allow_aggregations": true } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_schedule_active", + "report_schedule_every", + "report_schedule_id", + "report_schedule_name", + "report_schedule_owner", + "report_schedule_repeat", + "report_schedule_repetitions", + "report_schedule_start_time", + "report_schedule_counter", + "report_template_id" + ], + "filter": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + }, { "role": "recertifier", "permission": { @@ -10938,6 +11063,29 @@ "check": null } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_schedule_active", + "report_schedule_every", + "report_schedule_id", + "report_schedule_name", + "report_schedule_owner", + "report_schedule_repeat", + "report_schedule_repetitions", + "report_schedule_start_time", + "report_schedule_counter", + "report_template_id" + ], + "filter": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + }, + "check": null + } + }, { "role": "recertifier", "permission": { @@ -11029,6 +11177,16 @@ } } }, + { + "role": "modeller", + "permission": { + "filter": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + }, { "role": "recertifier", "permission": { @@ -11113,6 +11271,22 @@ ] } }, + { + "role": "modeller", + "permission": { + "check": { + "report_schedule": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + }, + "columns": [ + "report_schedule_format_name", + "report_schedule_id" + ] + } + }, { "role": "recertifier", "permission": { @@ -11199,6 +11373,22 @@ "filter": {} } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_schedule_format_name", + "report_schedule_id" + ], + "filter": { + "report_schedule": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + } + }, { "role": "recertifier", "permission": { @@ -11289,6 +11479,29 @@ } } }, + { + "role": "modeller", + "permission": { + "columns": [ + "report_schedule_format_name", + "report_schedule_id" + ], + "filter": { + "report_schedule": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + }, + "check": { + "report_schedule": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + } + }, { "role": "recertifier", "permission": { @@ -11384,6 +11597,18 @@ } } }, + { + "role": "modeller", + "permission": { + "filter": { + "report_schedule": { + "report_schedule_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + } + }, { "role": "recertifier", "permission": { @@ -11506,6 +11731,23 @@ ] } }, + { + "role": "modeller", + "permission": { + "check": {}, + "columns": [ + "filterline_history", + "report_filter", + "report_template_name", + "report_template_id", + "report_template_owner", + "report_parameters", + "report_template_comment", + "report_template_create" + ] + }, + "comment": "" + }, { "role": "recertifier", "permission": { @@ -11618,6 +11860,35 @@ "allow_aggregations": true } }, + { + "role": "modeller", + "permission": { + "columns": [ + "filterline_history", + "report_filter", + "report_parameters", + "report_template_comment", + "report_template_create", + "report_template_id", + "report_template_name", + "report_template_owner" + ], + "filter": { + "_or": [ + { + "report_template_owner": { + "_eq": 0 + } + }, + { + "report_template_owner": { + "_eq": "X-Hasura-User-Id" + } + } + ] + } + } + }, { "role": "recertifier", "permission": { @@ -11749,6 +12020,27 @@ "check": null } }, + { + "role": "modeller", + "permission": { + "columns": [ + "filterline_history", + "report_filter", + "report_parameters", + "report_template_comment", + "report_template_create", + "report_template_id", + "report_template_name", + "report_template_owner" + ], + "filter": { + "report_template_owner": { + "_eq": "X-Hasura-User-Id" + } + }, + "check": null + } + }, { "role": "recertifier", "permission": { @@ -11834,6 +12126,16 @@ } } }, + { + "role": "modeller", + "permission": { + "filter": { + "report_template_owner": { + "_eq": "X-Hasura-User-Id" + } + } + } + }, { "role": "recertifier", "permission": { diff --git a/roles/database/files/sql/idempotent/fworch-texts.sql b/roles/database/files/sql/idempotent/fworch-texts.sql index 2949e68a6..7558d58f6 100644 --- a/roles/database/files/sql/idempotent/fworch-texts.sql +++ b/roles/database/files/sql/idempotent/fworch-texts.sql @@ -105,6 +105,8 @@ INSERT INTO txt VALUES ('ResolvedChangesTech', 'German', 'Changes-Report (tech INSERT INTO txt VALUES ('ResolvedChangesTech', 'English', 'Changes Report (technical)'); INSERT INTO txt VALUES ('UnusedRules', 'German', 'Unbenutzte-Regel-Report'); INSERT INTO txt VALUES ('UnusedRules', 'English', 'Unused Rules Report'); +INSERT INTO txt VALUES ('Connections', 'German', 'Verbindungs-Report'); +INSERT INTO txt VALUES ('Connections', 'English', 'Connections Report'); INSERT INTO txt VALUES ('mixed', 'German', 'Gemischt'); INSERT INTO txt VALUES ('mixed', 'English', 'Mixed'); INSERT INTO txt VALUES ('exclusive', 'German', 'Exklusiv'); diff --git a/roles/lib/files/FWO.Report.Filter/FilterTypes/ReportType.cs b/roles/lib/files/FWO.Report.Filter/FilterTypes/ReportType.cs index d4d650809..a6c464961 100644 --- a/roles/lib/files/FWO.Report.Filter/FilterTypes/ReportType.cs +++ b/roles/lib/files/FWO.Report.Filter/FilterTypes/ReportType.cs @@ -11,7 +11,9 @@ public enum ReportType Recertification = 7, ResolvedChanges = 8, ResolvedChangesTech = 9, - UnusedRules = 10 + UnusedRules = 10, + + Connections = 21 } public static class ReportTypeGroups @@ -70,5 +72,21 @@ public static bool IsTechReport(this ReportType reportType) return false; } } + + public static bool IsRuleRelatedReport(this ReportType reportType) + { + return reportType.IsRuleReport() || reportType.IsChangeReport() || reportType == ReportType.Statistics; + } + + public static bool IsModellingReport(this ReportType reportType) + { + switch(reportType) + { + case ReportType.Connections: + return true; + default: + return false; + } + } } } diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/Archive.razor b/roles/ui/files/FWO.UI/Pages/Reporting/Archive.razor index 253d30bf6..c9ec3ca2b 100644 --- a/roles/ui/files/FWO.UI/Pages/Reporting/Archive.razor +++ b/roles/ui/files/FWO.UI/Pages/Reporting/Archive.razor @@ -7,9 +7,9 @@ @inject UserConfig userConfig @page "/report/archive" -@attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Auditor}")] +@attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Auditor}, {Roles.Modeller}")] - +
diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor b/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor index 78b946eb9..34da2a8aa 100644 --- a/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor +++ b/roles/ui/files/FWO.UI/Pages/Reporting/Report.razor @@ -3,15 +3,12 @@ @using FWO.Report.Filter @using FWO.Report.Filter.Exceptions @using FWO.Api.Data -@using System -@using System.Threading -@using System.Text.RegularExpressions @using FWO.Ui.Data @using FWO.Ui.Pages.Reporting.Reports @using System.Diagnostics @page "/report/generation" -@attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Auditor}")] +@attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Auditor}, {Roles.Modeller}")] @inject ApiConnection apiConnection @inject UserConfig userConfig @@ -70,7 +67,10 @@ } - + @if (selectedReportType.IsRuleRelatedReport()) + { + + } @* ==== Middle div ==== *@ @@ -134,34 +134,7 @@ break; case ReportType.Statistics: - @if (globalStats != null) - { -
@(userConfig.GetText("glob_no_obj"))
-
- - - - -
- } - @foreach (Management management in managementsReport.Where(mgt => !mgt.Ignore)) - { - -
@(userConfig.GetText("total_no_obj_mgt"))
- - - - - -
- -
@(userConfig.GetText("no_rules_gtw"))
- - - -
-
- } + break; default: @@ -187,13 +160,17 @@
@* ==== RIGHT SIDEBAR ==== *@ - - +@if (selectedReportType.IsRuleRelatedReport()) +{ + + +} @* ==== POPUPS ==== *@ + @code { [CascadingParameter] @@ -210,6 +187,7 @@ private List selectedItemsChangeReportTable = new List(); private Management[] managementsReport = new Management[0]; + List relevantManagementIds = new(); private Management? globalStats = null; private ReportType selectedReportType = ReportType.Rules; @@ -223,8 +201,8 @@ private Dropdown tenantSelector; - private TimeFilter actTimeFilter = new TimeFilter(); - private TimeFilter savedTimeFilter = new TimeFilter(); + private TimeFilter actTimeFilter = new(); + private TimeFilter savedTimeFilter = new(); private string displayedTimeSelection = ""; private bool ShowSelectTimeDialog = false; private RecertFilter actRecertFilter = new(); @@ -254,10 +232,21 @@ private bool tenantFilteringAllowed => authenticationStateTask!.Result.User.IsInRole(Roles.ReporterViewAll) || authenticationStateTask!.Result.User.IsInRole(Roles.Admin) || authenticationStateTask!.Result.User.IsInRole(Roles.FwAdmin) || authenticationStateTask!.Result.User.IsInRole(Roles.Auditor); + private bool showRuleRelatedReports => authenticationStateTask!.Result.User.IsInRole(Roles.Reporter) + || authenticationStateTask!.Result.User.IsInRole(Roles.ReporterViewAll) + || authenticationStateTask!.Result.User.IsInRole(Roles.FwAdmin) + || authenticationStateTask!.Result.User.IsInRole(Roles.Admin) + || authenticationStateTask!.Result.User.IsInRole(Roles.Auditor); + private bool showModellingReports => authenticationStateTask!.Result.User.IsInRole(Roles.Modeller) + || authenticationStateTask!.Result.User.IsInRole(Roles.Admin) + || authenticationStateTask!.Result.User.IsInRole(Roles.Auditor); + + protected override async Task OnInitializedAsync() { try { + selectedReportType = showRuleRelatedReports ? ReportType.Rules : ReportType.Connections; displayedTimeSelection = userConfig.GetText("now"); unusedDays = userConfig.UnusedTolerance; deviceFilter.Managements = await apiConnection.SendQueryAsync>(DeviceQueries.getDevicesByManagement); @@ -499,7 +488,7 @@ Management[] managementsReportOrig = managementsReport; try { - if (!deviceFilter.isAnyDeviceFilterSet()) // display warning + if (selectedReportType.IsRuleRelatedReport() && !deviceFilter.isAnyDeviceFilterSet()) // display warning { DisplayMessageInUi(null, userConfig.GetText("no_device_selected"), userConfig.GetText("E1001"), true); return; @@ -509,33 +498,16 @@ await PrepareReportGeneration(); // save selected managements before resetting - List relevantManagements = deviceFilter.getSelectedManagements(); + relevantManagementIds = deviceFilter.getSelectedManagements(); DateTime startTime = DateTime.Now; managementsReport = new Management[0]; // reset management data when switching between reports try { - if(currentReport!.ReportType == ReportType.Statistics) + if(currentReport.ReportType == ReportType.Statistics) { - globalStats = new Management(); - await currentReport.Generate(0, apiConnection, - managementsReportIntermediate => - { - managementsReport = managementsReportIntermediate; - setRelevantManagements(relevantManagements); - return InvokeAsync(() => - { - foreach (Management mgm in managementsReport.Where(mgt => !mgt.Ignore)) - { - globalStats.RuleStatistics.ObjectAggregate.ObjectCount += mgm.RuleStatistics.ObjectAggregate.ObjectCount; - globalStats.NetworkObjectStatistics.ObjectAggregate.ObjectCount += mgm.NetworkObjectStatistics.ObjectAggregate.ObjectCount; - globalStats.ServiceObjectStatistics.ObjectAggregate.ObjectCount += mgm.ServiceObjectStatistics.ObjectAggregate.ObjectCount; - globalStats.UserObjectStatistics.ObjectAggregate.ObjectCount += mgm.UserObjectStatistics.ObjectAggregate.ObjectCount; - } - StateHasChanged(); - }); - }, token); + await GenerateStatisticsReport(token); } else { @@ -543,7 +515,7 @@ managementsReportIntermediate => { managementsReport = managementsReportIntermediate; - setRelevantManagements(relevantManagements); + setRelevantManagements(); return InvokeAsync(StateHasChanged); }, token); if (currentReport.ReportType == ReportType.Recertification) @@ -605,6 +577,28 @@ currentReport = ReportBase.ConstructReport(ConstructReportTemplate(), userConfig); } + private async Task GenerateStatisticsReport(CancellationToken token) + { + globalStats = new Management(); + await currentReport.Generate(0, apiConnection, + managementsReportIntermediate => + { + managementsReport = managementsReportIntermediate; + setRelevantManagements(); + return InvokeAsync(() => + { + foreach (Management mgm in managementsReport.Where(mgt => !mgt.Ignore)) + { + globalStats.RuleStatistics.ObjectAggregate.ObjectCount += mgm.RuleStatistics.ObjectAggregate.ObjectCount; + globalStats.NetworkObjectStatistics.ObjectAggregate.ObjectCount += mgm.NetworkObjectStatistics.ObjectAggregate.ObjectCount; + globalStats.ServiceObjectStatistics.ObjectAggregate.ObjectCount += mgm.ServiceObjectStatistics.ObjectAggregate.ObjectCount; + globalStats.UserObjectStatistics.ObjectAggregate.ObjectCount += mgm.UserObjectStatistics.ObjectAggregate.ObjectCount; + } + StateHasChanged(); + }); + }, token); + } + private bool PrepareMetadata(Management[] Managements) { bool rulesFound = false; @@ -627,11 +621,11 @@ DisplayMessageInUi(null, userConfig.GetText("report_data_fetch"), userConfig.GetText("E1003"), true); } - private void setRelevantManagements(List relevantManagements) + private void setRelevantManagements() { foreach (Management mgm in managementsReport) { - mgm.Ignore = !relevantManagements.Contains(mgm.Id); + mgm.Ignore = !relevantManagementIds.Contains(mgm.Id); } } @@ -646,10 +640,8 @@ { selectedTenantView = userConfig.User.Tenant; // TODO: when admin selects a tenant filter, add the corresponding device filter to make sure only those devices are reported that the tenant is allowed to see - } reportParams.TenantFilter = new TenantFilter(selectedTenantView); - } reportParams.RecertFilter = new RecertFilter(actRecertFilter); reportParams.UnusedFilter = new UnusedFilter() @@ -657,7 +649,6 @@ UnusedForDays = unusedDays, CreationTolerance = userConfig.CreationTolerance }; - return new ReportTemplate(filterInput, reportParams); } @@ -719,14 +710,18 @@ ReportType.Rules, ReportType.ResolvedRules, ReportType.ResolvedRulesTech, ReportType.UnusedRules, ReportType.NatRules, ReportType.Recertification, ReportType.Changes, ReportType.ResolvedChanges, ReportType.ResolvedChangesTech, - ReportType.Statistics + ReportType.Statistics, + ReportType.Connections }; foreach (ReportType reportType in orderedReportTypeList) { ReportType? foundType = ListIn.Find(x => x == reportType); if (foundType != null) { - ListOut.Add(reportType); + if(showRuleRelatedReports && reportType.IsRuleRelatedReport() || showModellingReports && reportType.IsModellingReport()) + { + ListOut.Add(reportType); + } ListIn.Remove(reportType); } } diff --git a/roles/ui/files/FWO.UI/Pages/Reporting/ReportTemplateComponent.razor b/roles/ui/files/FWO.UI/Pages/Reporting/ReportTemplateComponent.razor index 1eeec060a..166aedc18 100644 --- a/roles/ui/files/FWO.UI/Pages/Reporting/ReportTemplateComponent.razor +++ b/roles/ui/files/FWO.UI/Pages/Reporting/ReportTemplateComponent.razor @@ -104,13 +104,16 @@ } -
- -
- - + @if(reportTypeInEdit.IsRuleRelatedReport()) + { +
+ +
+ + +
-
+ }