|
1 | 1 | @page "/audit" |
2 | 2 | @page "/audit/{ActiveTab}" |
3 | | -@using BLAZAM.Database.Models.Audit; |
4 | | -@using BLAZAM.Global.Data |
| 3 | + |
| 4 | + |
5 | 5 |
|
6 | 6 |
|
7 | 7 | @attribute [Authorize(Roles = UserRoles.SuperAdmin)] |
|
23 | 23 | <MudTabs @bind-ActivePanelIndex="@ActiveTab"> |
24 | 24 | <MudTabPanel> |
25 | 25 | <ChildContent> |
26 | | - <MudDataGrid Virtualize=true |
27 | | - Height="600px" |
28 | | - ColumnResizeMode="ResizeMode.Container" |
29 | | - FixedHeader=true |
30 | | - Hideable=true |
31 | | - Items="@auditEntries.Where(ae => ae.Action != "Login" && ae.Action != "Logout").OrderByDescending(ae => ae.Timestamp)" |
32 | | - Filterable="false" |
33 | | - SortMode="@SortMode.Multiple" |
34 | | - Groupable="false"> |
35 | | - <Columns> |
36 | | - <PropertyColumn Property="x=>x.Timestamp" Title=@AppLocalization[Lang.Timestamp] Sortable="true"> |
37 | | - <CellTemplate> |
38 | | - <MudText> |
39 | | - @context.Item.Timestamp.ToLocalTime() |
40 | | - </MudText> |
41 | | - </CellTemplate> |
42 | | - </PropertyColumn> |
43 | | - <PropertyColumn Property="x => x.Username" Filterable="true" Title="@AppLocalization[Lang.Username]" /> |
44 | | - @if (!ApplicationInfo.InDemoMode) |
45 | | - { |
46 | | - <PropertyColumn Property="x => x.IpAddress" Title=@AppLocalization[Lang.IP_Address] |
47 | | - Filterable="true"> |
48 | | - <CellTemplate> |
49 | | - <IPAddress> |
50 | | - @context.Item.IpAddress |
51 | | - </IPAddress> |
52 | | - </CellTemplate> |
53 | | - </PropertyColumn> |
54 | | - } |
55 | | - else |
56 | | - { |
57 | | - <TemplateColumn Title=@AppLocalization[Lang.IP_Address]> |
58 | | - <CellTemplate> |
59 | | - <IPAddress> |
60 | | - @context.Item.IpAddress |
61 | | - </IPAddress> |
62 | | - </CellTemplate> |
63 | | - </TemplateColumn> |
64 | | - } |
65 | | - <PropertyColumn Property="x => x.Action" |
66 | | - Filterable=true |
67 | | - Title="@AppLocalization[Lang.Action]"> |
68 | | - <CellTemplate> |
69 | | - <MudText>@AppLocalization[context.Item.Action]</MudText> |
70 | | - </CellTemplate> |
71 | | - </PropertyColumn> |
72 | | - |
73 | | - <PropertyColumn Property="x => x.Target" |
74 | | - Filterable=true |
75 | | - Title="@AppLocalization[Lang.Target]"> |
76 | | - <CellTemplate> |
77 | | - <MudLink Href="@("/view/" + context.Item.Target)">@context.Item.Target</MudLink> |
78 | | - </CellTemplate> |
79 | | - </PropertyColumn> |
80 | | - |
81 | | - <PropertyColumn Property="x => x.BeforeAction" |
82 | | - Filterable="true" |
83 | | - Title="@AppLocalization[Lang.Before_Action]" /> |
84 | | - |
85 | | - <PropertyColumn Property="x => x.AfterAction" |
86 | | - Filterable="true" |
87 | | - Title="@AppLocalization[Lang.After_Action]" /> |
88 | | - |
89 | | - </Columns> |
90 | | - </MudDataGrid> |
| 26 | + <MainAuditContent /> |
91 | 27 |
|
92 | 28 |
|
93 | 29 |
|
|
99 | 35 | </MudTabPanel> |
100 | 36 | <MudTabPanel> |
101 | 37 | <ChildContent> |
102 | | - <LoginHistoryChart /> |
103 | | - |
104 | | - |
105 | | - <MudDataGrid Virtualize=true |
106 | | - Height="600px" |
107 | | - FixedHeader=true |
108 | | - ColumnResizeMode="ResizeMode.Container" |
109 | | - Hideable=true |
110 | | - Items="@logonEntries.OrderByDescending(ae => ae.Timestamp)" |
111 | | - Filterable="false" |
112 | | - SortMode="@SortMode.Multiple" |
113 | | - Groupable="false"> |
114 | | - <Columns> |
115 | | - <TemplateColumn Title=@AppLocalization[Lang.Timestamp] Sortable="true"> |
116 | | - <CellTemplate> |
117 | | - <MudText> |
118 | | - @context.Item.Timestamp.ToLocalTime() |
119 | | - </MudText> |
120 | | - </CellTemplate> |
121 | | - </TemplateColumn> |
122 | | - |
123 | | - <PropertyColumn Property="x => x.Username" Title="@AppLocalization[Lang.Username]" /> |
124 | | - |
125 | | - <TemplateColumn Title=@AppLocalization[Lang.IP_Address] Filterable="true"> |
126 | | - <CellTemplate> |
127 | | - <IPAddress> |
128 | | - @context.Item.IpAddress |
129 | | - </IPAddress> |
130 | | - </CellTemplate> |
131 | | - </TemplateColumn> |
132 | | - |
133 | | - <PropertyColumn Property="x => x.Action" Title="@AppLocalization[Lang.Action]" /> |
134 | | - |
135 | | - </Columns> |
136 | | - </MudDataGrid> |
137 | | - |
138 | | - |
| 38 | + <LoginAuditContent /> |
139 | 39 |
|
140 | 40 |
|
141 | 41 | </ChildContent> |
|
145 | 45 | </MudTabPanel> |
146 | 46 | <MudTabPanel> |
147 | 47 | <ChildContent> |
148 | | - @if (ApplicationInfo.InDemoMode && CurrentUser.Username == "Demo") |
149 | | - { |
150 | | - <MudText>Disabled in demo</MudText> |
151 | | - } |
152 | | - else |
153 | | - { |
154 | | - <MudDataGrid Virtualize=true |
155 | | - Height="600px" |
156 | | - ColumnResizeMode="ResizeMode.Container" |
157 | | - FixedHeader=true |
158 | | - Hideable=true |
159 | | - Items="@systemAuditEntries.OrderByDescending(ae => ae.Timestamp)" |
160 | | - Filterable="false" |
161 | | - SortMode="@SortMode.Multiple" |
162 | | - Groupable="false"> |
163 | | - <Columns> |
164 | | - <TemplateColumn Title=@AppLocalization[Lang.Timestamp] Sortable="true"> |
165 | | - <CellTemplate> |
166 | | - <MudText> |
167 | | - @context.Item.Timestamp.ToLocalTime() |
168 | | - </MudText> |
169 | | - </CellTemplate> |
170 | | - </TemplateColumn> |
171 | | - <PropertyColumn Property="x => x.Username" Title="@AppLocalization[Lang.Username]" /> |
172 | | - <PropertyColumn Property="x => x.IpAddress" Title="@AppLocalization[Lang.IP_Address]" /> |
173 | | - <PropertyColumn Property="x => x.Target" Title="@AppLocalization[Lang.Target]" /> |
174 | | - <PropertyColumn Property="x => x.BeforeAction" Title="@AppLocalization[Lang.Before_Action]" /> |
175 | | - <PropertyColumn Property="x => x.AfterAction" Title="@AppLocalization[Lang.After_Action]" /> |
176 | | - |
177 | | - </Columns> |
178 | | - </MudDataGrid> |
179 | | - } |
180 | | - |
181 | | - |
182 | | - |
| 48 | + <SystemAuditContent /> |
183 | 49 |
|
184 | 50 | </ChildContent> |
185 | 51 | <TabContent> |
|
213 | 79 |
|
214 | 80 |
|
215 | 81 | @code { |
216 | | - List<LogonAuditLog> logonEntries = new(); |
217 | | - List<DirectoryEntryAuditLog> auditEntries = new(); |
218 | | - List<SystemAuditLog> systemAuditEntries = new(); |
219 | 82 | protected override async Task OnInitializedAsync() |
220 | 83 | { |
221 | 84 |
|
222 | 85 | await base.OnInitializedAsync(); |
223 | 86 | BaseUri = "/audit"; |
224 | | - using (var context = await DbFactory.CreateDbContextAsync()) |
225 | | - { |
226 | | - auditEntries = await context.DirectoryEntryAuditLogs.ToListAsync(); |
227 | | - logonEntries = await context.LogonAuditLog.ToListAsync(); |
228 | | - |
229 | | - systemAuditEntries = await context.SystemAuditLog.ToListAsync(); |
230 | | - |
231 | | - |
232 | | - |
233 | | - |
234 | | - } |
235 | | - |
236 | | - |
237 | 87 | } |
238 | 88 |
|
239 | 89 | } |
0 commit comments