Skip to content

Commit c119bea

Browse files
committed
add owner recert parameters + fixes
1 parent 28add3d commit c119bea

File tree

17 files changed

+308
-128
lines changed

17 files changed

+308
-128
lines changed

roles/database/files/sql/idempotent/fworch-texts.sql

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ INSERT INTO txt VALUES ('missing_objects', 'German', 'Fehlende Objekte auf Dev
778778
INSERT INTO txt VALUES ('missing_objects', 'English', 'Missing Objects on Device');
779779
INSERT INTO txt VALUES ('fully_modelled', 'German', 'Vollständig Modelliert');
780780
INSERT INTO txt VALUES ('fully_modelled', 'English', 'Fully Modelled');
781+
INSERT INTO txt VALUES ('show_all_owners', 'German', 'Alle Eigentümer zeigen');
782+
INSERT INTO txt VALUES ('show_all_owners', 'English', 'Show all owners');
781783

782784
-- schedule
783785
INSERT INTO txt VALUES ('schedule', 'German', 'Terminplan');
@@ -2861,8 +2863,16 @@ INSERT INTO txt VALUES ('U4001', 'German', 'Sind sie sicher, dass sie folgende
28612863
INSERT INTO txt VALUES ('U4001', 'English', 'Do you really want to delete notification ');
28622864
INSERT INTO txt VALUES ('U4002', 'German', 'Die App @@APPNAME@@ mit @@RULE_NUMBER@@ Regeln wurde erfolgreich rezertifiziert.');
28632865
INSERT INTO txt VALUES ('U4002', 'English', 'Recertified @@APPNAME@@ with @@RULE_NUMBER@@ rules successfully.');
2864-
INSERT INTO txt VALUES ('U4003', 'German', 'Die Rezertifizierung folgender Apps ist überfällig:');
2865-
INSERT INTO txt VALUES ('U4003', 'English', 'Following apps are overdue to be recertified:');
2866+
INSERT INTO txt VALUES ('U4003', 'German', 'Rezertifizierung überfällig');
2867+
INSERT INTO txt VALUES ('U4003', 'English', 'Overdue to be recertified');
2868+
INSERT INTO txt VALUES ('U4004', 'German', 'Es wurden keine überfälligen Apps gefunden.');
2869+
INSERT INTO txt VALUES ('U4004', 'English', 'No overdue apps found.');
2870+
INSERT INTO txt VALUES ('U4005', 'German', 'Anstehende Rezertifizierungen in den nächsten @@DAYS@@ Tagen');
2871+
INSERT INTO txt VALUES ('U4005', 'English', 'Upcoming recertifications in the next @@DAYS@@ days');
2872+
INSERT INTO txt VALUES ('U4006', 'German', 'Es wurden keine anstehenden Rezertifizierungen in den nächsten @@DAYS@@ Tagen gefunden.');
2873+
INSERT INTO txt VALUES ('U4006', 'English', 'No upcoming recertifications found in the next @@DAYS@@ days.');
2874+
INSERT INTO txt VALUES ('U4007', 'German', 'Weitere rezertifizierte Apps');
2875+
INSERT INTO txt VALUES ('U4007', 'English', 'Further recertified apps');
28662876

28672877
INSERT INTO txt VALUES ('U5001', 'German', 'Setup und Verwaltung des Firewall Orchestrator. Bitte eine Einstellung in der linken Randleiste auswählen.');
28682878
INSERT INTO txt VALUES ('U5001', 'English', 'Setup and administration of Firewall Orchestrator. Please choose a setting in the left sidebar.');
@@ -3526,6 +3536,8 @@ INSERT INTO txt VALUES ('T0107', 'German', 'Aktuell aktive Regeln, die zur Reze
35263536
INSERT INTO txt VALUES ('T0107', 'English', 'Currently active rules with upcoming recertification');
35273537

35283538
-- Contextual Info (Tooltips)
3539+
INSERT INTO txt VALUES ('C1000', 'German', 'Zeige alle Eigentüer inklusive der rezertifizierten');
3540+
INSERT INTO txt VALUES ('C1000', 'English', 'show all owners including recertified');
35293541
INSERT INTO txt VALUES ('C9000', 'German', 'Dieses Objekt wurde deaktiviert und sollte von der App Rolle entfernt werden.');
35303542
INSERT INTO txt VALUES ('C9000', 'English', 'This object was deactivated and should be removed from App Role.');
35313543
INSERT INTO txt VALUES ('C9001', 'German', 'Dieses Objekt wurde deaktiviert und sollte von der Verbindung entfernt werden.');

roles/lib/files/FWO.Basics/GlobalConstants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public struct Placeholder
124124
public const string ACTION = "@@ACTION@@";
125125
public const string CHANGEACTION = "@@CHANGEACTION@@";
126126
public const string COMMENT = "@@COMMENT@@";
127+
public const string DAYS = "@@DAYS@@";
127128
public const string DESTINATIONS = "@@DESTINATIONS@@";
128129
public const string FAIL_NUMBER = "@@FAIL_NUMBER@@";
129130
public const string GROUPNAME = "@@GROUPNAME@@";
@@ -155,6 +156,6 @@ public struct Placeholder
155156
public const string TASKS = "@@TASKS@@";
156157
public const string TICKET_SUBJECT = "@@TICKET_SUBJECT@@";
157158
public const string TYPE = "@@TYPE@@";
158-
public const string USER_NAME = "@@USER_NAME@@";
159+
public const string USER_NAME = "@@USER_NAME@@";
159160
}
160161
}

roles/lib/files/FWO.Basics/ReportType.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ReportType.NatRules or
3333
ReportType.Recertification or
3434
ReportType.UnusedRules or
3535
ReportType.AppRules => true,
36-
_ => false,
36+
_ => false
3737
};
3838
}
3939

@@ -44,7 +44,7 @@ public static bool IsChangeReport(this ReportType reportType)
4444
ReportType.Changes or
4545
ReportType.ResolvedChanges or
4646
ReportType.ResolvedChangesTech => true,
47-
_ => false,
47+
_ => false
4848
};
4949
}
5050

@@ -56,7 +56,7 @@ ReportType.ResolvedRules or
5656
ReportType.ResolvedRulesTech or
5757
ReportType.ResolvedChanges or
5858
ReportType.ResolvedChangesTech => true,
59-
_ => false,
59+
_ => false
6060
};
6161
}
6262

@@ -66,7 +66,7 @@ public static bool IsTechReport(this ReportType reportType)
6666
{
6767
ReportType.ResolvedRulesTech or
6868
ReportType.ResolvedChangesTech => true,
69-
_ => false,
69+
_ => false
7070
};
7171
}
7272

@@ -81,7 +81,7 @@ public static bool IsConnectionRelatedReport(this ReportType reportType)
8181
{
8282
ReportType.Connections or
8383
ReportType.VarianceAnalysis => true,
84-
_ => false,
84+
_ => false
8585
};
8686
}
8787

@@ -93,7 +93,23 @@ ReportType.Connections or
9393
ReportType.AppRules or
9494
ReportType.VarianceAnalysis or
9595
ReportType.OwnerRecertification => true,
96-
_ => false,
96+
_ => false
97+
};
98+
}
99+
100+
public static bool HasTimeFilter(this ReportType reportType)
101+
{
102+
return reportType switch
103+
{
104+
ReportType.Rules or
105+
ReportType.ResolvedRules or
106+
ReportType.ResolvedRulesTech or
107+
ReportType.NatRules or
108+
ReportType.Statistics or
109+
ReportType.Changes or
110+
ReportType.ResolvedChanges or
111+
ReportType.ResolvedChangesTech => true,
112+
_ => false
97113
};
98114
}
99115

roles/lib/files/FWO.Data/FwoOwner.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class FwoOwner : FwoOwnerBase
4141
[JsonProperty("next_recert_date"), JsonPropertyName("next_recert_date")]
4242
public DateTime? NextRecertDate { get; set; }
4343

44+
public bool RecertOverdue { get; set; } = false;
45+
public bool RecertUpcoming { get; set; } = false;
4446

4547
public FwoOwner()
4648
{ }
@@ -59,6 +61,8 @@ public FwoOwner(FwoOwner owner) : base(owner)
5961
LastRecertifierId = owner.LastRecertifierId;
6062
LastRecertifierDn = owner.LastRecertifierDn;
6163
NextRecertDate = owner.NextRecertDate;
64+
RecertOverdue = owner.RecertOverdue;
65+
RecertUpcoming = owner.RecertUpcoming;
6266
}
6367

6468
public string Display(string comSvcTxt)

roles/lib/files/FWO.Data/Report/ModellingFilter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public FwoOwner SelectedOwner
1616
public bool ShowFullRules {get; set;} = false;
1717
public bool ShowDropRules {get; set;} = false;
1818

19-
public bool AnalyseRemainingRules {get; set;} = false;
19+
public bool AnalyseRemainingRules { get; set; } = false;
20+
21+
public bool ShowAllOwners { get; set; } = false;
2022

2123

2224
public ModellingFilter()
@@ -31,6 +33,7 @@ public ModellingFilter(ModellingFilter modellingFilter)
3133
ShowFullRules = modellingFilter.ShowFullRules;
3234
ShowDropRules = modellingFilter.ShowDropRules;
3335
AnalyseRemainingRules = modellingFilter.AnalyseRemainingRules;
36+
ShowAllOwners = modellingFilter.ShowAllOwners;
3437
}
3538
}
3639
}

roles/lib/files/FWO.Data/Report/ReportData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class ReportData
66
public List<OwnerConnectionReport> OwnerData { get; set; } = [];
77
public List<GlobalCommonSvcReport> GlobalComSvc { get; set; } = [];
88
public ManagementReport GlobalStats { get; set; } = new();
9-
9+
public int RecertificationDisplayPeriod { get; set; } = 0;
1010

1111
public ReportData()
1212
{}

roles/lib/files/FWO.Report.Filter/DynGraphqlQuery.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private static void SetFixedFilters(ref DynGraphqlQuery query, ReportTemplate re
348348
}
349349
if ((ReportType)reportParams.ReportParams.ReportType == ReportType.OwnerRecertification)
350350
{
351-
SetOwnerRecertFilter(ref query, reportParams.ReportParams.ModellingFilter);
351+
SetOwnerRecertFilter(ref query, reportParams.ReportParams.ModellingFilter, reportParams.ReportParams.RecertFilter);
352352
}
353353
if ((ReportType)reportParams.ReportParams.ReportType == ReportType.UnusedRules)
354354
{
@@ -544,17 +544,20 @@ private static void SetRecertFilter(ref DynGraphqlQuery query, RecertFilter? rec
544544
}
545545
}
546546

547-
private static void SetOwnerRecertFilter(ref DynGraphqlQuery query, ModellingFilter? modellingFilter)
547+
private static void SetOwnerRecertFilter(ref DynGraphqlQuery query, ModellingFilter? modellingFilter, RecertFilter? recertFilter)
548548
{
549549
if (modellingFilter != null)
550550
{
551551
query.QueryParameters.Add("$selectedOwners: [Int!]");
552552
query.QueryVariables["selectedOwners"] = new List<int> (modellingFilter.SelectedOwners.Select(o => o.Id)).ToArray();
553553
query.OwnerWhereStatement += $@"{{ id: {{ _in: $selectedOwners }} }}";
554554

555-
query.QueryParameters.Add("$refDate: timestamp");
556-
query.QueryVariables["refDate"] = DateTime.Now;
557-
query.OwnerWhereStatement += $@"{{ next_recert_date: {{ _lte: $refDate }} }}";
555+
if (!modellingFilter.ShowAllOwners)
556+
{
557+
query.QueryParameters.Add("$refDate: timestamp");
558+
query.QueryVariables["refDate"] = DateTime.Now.AddDays(recertFilter?.RecertificationDisplayPeriod ?? 0);
559+
query.OwnerWhereStatement += $@"{{ next_recert_date: {{ _lte: $refDate }} }}";
560+
}
558561
}
559562
}
560563

roles/lib/files/FWO.Report/ReportBase.cs

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static ReportBase ConstructReport(ReportTemplate reportFilter, UserConfig
159159
ReportType.Connections => new ReportConnections(query, userConfig, repType),
160160
ReportType.AppRules => new ReportAppRules(query, userConfig, repType, reportFilter.ReportParams.ModellingFilter),
161161
ReportType.VarianceAnalysis => new ReportVariances(query, userConfig, repType),
162-
ReportType.OwnerRecertification => new ReportOwnerRecerts(query, userConfig, repType),
162+
ReportType.OwnerRecertification => new ReportOwnerRecerts(query, userConfig, repType),
163163
_ => throw new NotSupportedException("Report Type is not supported."),
164164
};
165165
}
@@ -189,51 +189,12 @@ protected string GenerateHtmlFrameBase(string title, string filter, DateTime dat
189189
if(string.IsNullOrEmpty(htmlExport))
190190
{
191191
HtmlTemplate = HtmlTemplate.Replace("##Title##", title);
192-
if(filter != "")
193-
{
194-
HtmlTemplate = HtmlTemplate.Replace("##Filter##", userConfig.GetText("filter") + ": " + filter);
195-
}
196-
else
197-
{
198-
HtmlTemplate = HtmlTemplate.Replace("<p>##Filter##</p>", "");
199-
}
192+
ReplaceFilter(filter);
200193
HtmlTemplate = HtmlTemplate.Replace("##GeneratedOn##", userConfig.GetText("generated_on"));
201194
HtmlTemplate = HtmlTemplate.Replace("##Date##", date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK"));
202-
if(ReportType.IsChangeReport())
203-
{
204-
(string startTime, string stopTime) = DynGraphqlQuery.ResolveTimeRange(timeFilter!);
205-
string timeRange = $"{userConfig.GetText("change_time")}: " +
206-
$"{userConfig.GetText("from")}: {ToUtcString(startTime)}, " +
207-
$"{userConfig.GetText("until")}: {ToUtcString(stopTime)}";
208-
HtmlTemplate = HtmlTemplate.Replace("##Date-of-Config##: ##GeneratedFor##", timeRange);
209-
}
210-
else if(ReportType.IsRuleReport() || ReportType == ReportType.Statistics)
211-
{
212-
HtmlTemplate = HtmlTemplate.Replace("##Date-of-Config##", userConfig.GetText("date_of_config"));
213-
HtmlTemplate = HtmlTemplate.Replace("##GeneratedFor##", ToUtcString(Query.ReportTimeString));
214-
}
215-
else
216-
{
217-
HtmlTemplate = HtmlTemplate.Replace("<p>##Date-of-Config##: ##GeneratedFor## (UTC)</p>", "");
218-
}
219-
220-
if(ownerFilter != null && ownerFilter != "")
221-
{
222-
HtmlTemplate = HtmlTemplate.Replace("##OwnerFilters##", userConfig.GetText("owners") + ": " + ownerFilter);
223-
}
224-
else
225-
{
226-
HtmlTemplate = HtmlTemplate.Replace("<p>##OwnerFilters##</p>", "");
227-
}
228-
229-
if(deviceFilter != null)
230-
{
231-
HtmlTemplate = HtmlTemplate.Replace("##OtherFilters##", userConfig.GetText("devices") + ": " + deviceFilter);
232-
}
233-
else
234-
{
235-
HtmlTemplate = HtmlTemplate.Replace("<p>##OtherFilters##</p>", "");
236-
}
195+
ReplaceDateOfConfig(timeFilter);
196+
ReplaceOwnerFilter(ownerFilter);
197+
ReplaceOtherFilter(deviceFilter);
237198

238199
string htmlToC = BuildHTMLToC(htmlReport.ToString());
239200

@@ -244,13 +205,70 @@ protected string GenerateHtmlFrameBase(string title, string filter, DateTime dat
244205
return htmlExport;
245206
}
246207

247-
public static string ToUtcString(string? timestring)
208+
private void ReplaceFilter(string filter)
209+
{
210+
if(filter != "")
211+
{
212+
HtmlTemplate = HtmlTemplate.Replace("##Filter##", userConfig.GetText("filter") + ": " + filter);
213+
}
214+
else
215+
{
216+
HtmlTemplate = HtmlTemplate.Replace("<p>##Filter##</p>", "");
217+
}
218+
}
219+
220+
private void ReplaceDateOfConfig(TimeFilter? timeFilter)
221+
{
222+
if (ReportType.IsChangeReport())
223+
{
224+
(string startTime, string stopTime) = DynGraphqlQuery.ResolveTimeRange(timeFilter ?? new());
225+
string timeRange = $"{userConfig.GetText("change_time")}: " +
226+
$"{userConfig.GetText("from")}: {ToUtcString(startTime)}, " +
227+
$"{userConfig.GetText("until")}: {ToUtcString(stopTime)}";
228+
HtmlTemplate = HtmlTemplate.Replace("##Date-of-Config##: ##GeneratedFor##", timeRange);
229+
}
230+
else if (ReportType.IsRuleReport() || ReportType == ReportType.Statistics)
231+
{
232+
HtmlTemplate = HtmlTemplate.Replace("##Date-of-Config##", userConfig.GetText("date_of_config"));
233+
HtmlTemplate = HtmlTemplate.Replace("##GeneratedFor##", ToUtcString(Query.ReportTimeString));
234+
}
235+
else
236+
{
237+
HtmlTemplate = HtmlTemplate.Replace("<p>##Date-of-Config##: ##GeneratedFor## (UTC)</p>", "");
238+
}
239+
}
240+
241+
private void ReplaceOwnerFilter(string? ownerFilter)
242+
{
243+
if(ownerFilter != null && ownerFilter != "")
244+
{
245+
HtmlTemplate = HtmlTemplate.Replace("##OwnerFilters##", userConfig.GetText("owners") + ": " + ownerFilter);
246+
}
247+
else
248+
{
249+
HtmlTemplate = HtmlTemplate.Replace("<p>##OwnerFilters##</p>", "");
250+
}
251+
}
252+
253+
private void ReplaceOtherFilter(string? deviceFilter)
254+
{
255+
if(deviceFilter != null)
256+
{
257+
HtmlTemplate = HtmlTemplate.Replace("##OtherFilters##", userConfig.GetText("devices") + ": " + deviceFilter);
258+
}
259+
else
260+
{
261+
HtmlTemplate = HtmlTemplate.Replace("<p>##OtherFilters##</p>", "");
262+
}
263+
}
264+
265+
private static string ToUtcString(string? timestring)
248266
{
249267
try
250268
{
251269
return timestring != null ? DateTime.Parse(timestring).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK") : "";
252270
}
253-
catch(Exception)
271+
catch (Exception)
254272
{
255273
return timestring ?? "";
256274
}

roles/lib/files/FWO.Report/ReportGenerator.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,22 @@ private static async Task GenerateOwnerReport(ReportBase report, ReportTemplate
7070
await report.Generate(0, apiConnection,
7171
rep =>
7272
{
73-
report.ReportData.OwnerData.Add(new() { Owner = rep.OwnerData[0].Owner });
73+
report.ReportData.OwnerData.AddRange(rep.OwnerData);
7474
return Task.CompletedTask;
7575
}, token);
76-
}
76+
report.ReportData.RecertificationDisplayPeriod = reportTemplate.ReportParams.RecertFilter.RecertificationDisplayPeriod;
77+
foreach (var owner in report.ReportData.OwnerData.Select(o => o.Owner))
78+
{
79+
if (owner.NextRecertDate < DateTime.Now)
80+
{
81+
owner.RecertOverdue = true;
82+
}
83+
else if (owner.NextRecertDate < DateTime.Now.AddDays(reportTemplate.ReportParams.RecertFilter.RecertificationDisplayPeriod))
84+
{
85+
owner.RecertUpcoming = true;
86+
}
87+
}
88+
}
7789

7890
private static async Task GenerateConnectionRelatedReport(ReportBase report, ReportTemplate reportTemplate, ApiConnection apiConnection, UserConfig userConfig, Action<Exception?, string, string, bool> displayMessageInUi, CancellationToken token)
7991
{

0 commit comments

Comments
 (0)