@@ -10,11 +10,10 @@ import { Map, Marker } from "pigeon-maps"
10
10
import Tree from "antd/es/tree" ;
11
11
import Empty from "antd/es/empty" ;
12
12
import { ReactNode , useEffect , useMemo , useState } from "react" ;
13
- import { getAuditLogs , getMeta } from "@lowcoder-ee/api/enterpriseApi" ;
13
+ import { getAuditLogs , getEnvironmentsByIds , getMeta } from "@lowcoder-ee/api/enterpriseApi" ;
14
14
import { isEmpty } from "lodash" ;
15
15
import { getEventColor , getEventLabel } from "./dashboard" ;
16
16
import Tag from "antd/es/tag" ;
17
- import { geoLocation } from "./auditContants" ;
18
17
19
18
const StyleThemeSettingsCover = styled . div `
20
19
display: flex;
@@ -31,7 +30,28 @@ const StyledTree = styled(Tree)`
31
30
}
32
31
33
32
.ant-tree-treenode {
34
- margin-bottom: 24px;
33
+ margin-bottom: 12px;
34
+ }
35
+
36
+ .ant-tree-node-content-wrapper {
37
+ padding: 8px;
38
+ }
39
+
40
+ .ant-tree-switcher {
41
+ padding-top: 8px;
42
+ &::before {
43
+ top: 8px;
44
+ }
45
+ }
46
+
47
+ .ant-tree-switcher_open::after {
48
+ content: "";
49
+ width: 1px;
50
+ height: 100%;
51
+ position: absolute;
52
+ left: 46%;
53
+ top: 26px;
54
+ background: #d9d9d9;
35
55
}
36
56
37
57
.ant-descriptions-header {
@@ -63,8 +83,6 @@ const getResourceData = (eventType: string, eventDetail: any) => {
63
83
return {
64
84
ID : eventDetail . id , Name : eventDetail . name ,
65
85
}
66
-
67
- return undefined ;
68
86
}
69
87
70
88
const EventTreeNode = ( props : {
@@ -80,14 +98,16 @@ const EventTreeNode = (props: {
80
98
title = { < span > { props . icon } { props . title } </ span > }
81
99
>
82
100
{ Object . keys ( props . data ) . map ( dataKey => (
83
- < Descriptions . Item label = { dataKey } > { props . data [ dataKey ] || '-' } </ Descriptions . Item >
101
+ < Descriptions . Item key = { dataKey } label = { dataKey } > { props . data [ dataKey ] || '-' } </ Descriptions . Item >
84
102
) ) }
85
103
</ Descriptions >
86
104
)
87
105
}
88
106
export function AuditLogDetail ( ) {
89
107
const { eventId } = useParams < { eventId : string } > ( ) ;
90
108
const [ event , setEvent ] = useState < any > ( { } ) ;
109
+ const [ meta , setMeta ] = useState < any > ( { } ) ;
110
+ const [ environment , setEnvironment ] = useState < any > ( { } ) ;
91
111
92
112
const fetchEventData = async ( ) => {
93
113
const response = await getAuditLogs ( { eventId } ) ;
@@ -107,8 +127,14 @@ export function AuditLogDetail() {
107
127
folderIds : [ ] ,
108
128
libraryQueryIds : [ ]
109
129
} ) ;
110
- console . log ( response ) ;
111
- // setEvent(response?.data?.[0]);
130
+ setMeta ( response . data ) ;
131
+ }
132
+
133
+ const fetchEnvironmentData = async ( ) => {
134
+ if ( isEmpty ( event ) ) return ;
135
+
136
+ const response = await getEnvironmentsByIds ( [ event . environmentId ] ) ;
137
+ setEnvironment ( response . data ?. [ 0 ] || { } ) ;
112
138
}
113
139
114
140
useEffect ( ( ) => {
@@ -117,7 +143,8 @@ export function AuditLogDetail() {
117
143
118
144
useEffect ( ( ) => {
119
145
fetchEventMeta ( ) ;
120
- } , [ event ] ) ;
146
+ fetchEnvironmentData ( ) ;
147
+ } , [ JSON . stringify ( event ) ] ) ;
121
148
122
149
const eventHierarchy = useMemo ( ( ) => {
123
150
if ( isEmpty ( event ) ) return [ ] ;
@@ -175,7 +202,10 @@ export function AuditLogDetail() {
175
202
< EventTreeNode
176
203
icon = { < EnvironmentOutlined /> }
177
204
title = "Environment"
178
- data = { { ID : event ?. environmentId , Name : event ?. environmentName } }
205
+ data = { {
206
+ ID : event ?. environmentId ,
207
+ Name : environment ?. environmentType || '-'
208
+ } }
179
209
/>
180
210
) ,
181
211
key : "0" ,
@@ -185,7 +215,10 @@ export function AuditLogDetail() {
185
215
< EventTreeNode
186
216
icon = { < TeamOutlined /> }
187
217
title = "Workspace"
188
- data = { { ID : event ?. orgId , Name : event ?. orgName } }
218
+ data = { {
219
+ ID : event ?. orgId ,
220
+ Name : meta ?. orgs ?. [ 0 ] ?. name || '-' ,
221
+ } }
189
222
/>
190
223
) ,
191
224
key : "0-0" ,
@@ -195,7 +228,10 @@ export function AuditLogDetail() {
195
228
< EventTreeNode
196
229
icon = { < UserOutlined /> }
197
230
title = "User"
198
- data = { { ID : event ?. userId , Name : event ?. userName } }
231
+ data = { {
232
+ ID : event ?. userId ,
233
+ Name : meta ?. users ?. [ 0 ] ?. name || '-' ,
234
+ } }
199
235
/>
200
236
) ,
201
237
key : "0-0-0" ,
@@ -206,7 +242,7 @@ export function AuditLogDetail() {
206
242
] ,
207
243
} ,
208
244
] ;
209
- } , [ event ] ) ;
245
+ } , [ event , meta , environment ] ) ;
210
246
211
247
if ( ! Boolean ( event ) ) {
212
248
return (
@@ -254,7 +290,7 @@ export function AuditLogDetail() {
254
290
< h2 style = { { color : "#ffffff" , marginTop : "8px" } } > Browser / System Metadata</ h2 >
255
291
</ StyleThemeSettingsCover >
256
292
< Card size = "small" style = { { marginBottom : "20px" , borderTopLeftRadius : 0 , borderTopRightRadius : 0 } } >
257
- < Descriptions bordered column = { 1 } >
293
+ < Descriptions bordered column = { 1 } size = "small" >
258
294
< Descriptions . Item label = { < span > < ChromeOutlined className = "text-lg mr-2" /> Browser</ span > } > { event ?. agentName } </ Descriptions . Item >
259
295
< Descriptions . Item label = { < span > < AppleOutlined className = "text-lg mr-2" /> OS</ span > } > { event ?. operatingSystemName } ({ event ?. operatingSystemVersion } )</ Descriptions . Item >
260
296
< Descriptions . Item label = { < span > < DesktopOutlined className = "text-lg mr-2" /> Device</ span > } > { event ?. deviceName } </ Descriptions . Item >
0 commit comments