aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/system/logs/log-row.model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-11 14:14:01 +0100
committerChocobozzz <me@florianbigard.com>2019-12-11 14:14:01 +0100
commit566c125d6eee3bd907404523d94e1e0b5e403a46 (patch)
treec477cdd2ba745015d80052968c37927b1bca1254 /client/src/app/+admin/system/logs/log-row.model.ts
parent92e0f42e8ce5f1ab5e4023900b8194627231a11b (diff)
downloadPeerTube-566c125d6eee3bd907404523d94e1e0b5e403a46.tar.gz
PeerTube-566c125d6eee3bd907404523d94e1e0b5e403a46.tar.zst
PeerTube-566c125d6eee3bd907404523d94e1e0b5e403a46.zip
Serve audit logs to client
Diffstat (limited to 'client/src/app/+admin/system/logs/log-row.model.ts')
-rw-r--r--client/src/app/+admin/system/logs/log-row.model.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/client/src/app/+admin/system/logs/log-row.model.ts b/client/src/app/+admin/system/logs/log-row.model.ts
index 9bc7dafdd..b22581b5a 100644
--- a/client/src/app/+admin/system/logs/log-row.model.ts
+++ b/client/src/app/+admin/system/logs/log-row.model.ts
@@ -8,6 +8,10 @@ export class LogRow {
8 message: string 8 message: string
9 meta: string 9 meta: string
10 10
11 by: string
12 domain: string
13 action: string
14
11 constructor (row: any) { 15 constructor (row: any) {
12 this.date = new Date(row.timestamp) 16 this.date = new Date(row.timestamp)
13 this.localeDate = this.date.toLocaleString() 17 this.localeDate = this.date.toLocaleString()
@@ -17,5 +21,20 @@ export class LogRow {
17 const metaObj = omit(row, 'timestamp', 'level', 'message', 'label') 21 const metaObj = omit(row, 'timestamp', 'level', 'message', 'label')
18 22
19 if (Object.keys(metaObj).length !== 0) this.meta = JSON.stringify(metaObj, undefined, 2) 23 if (Object.keys(metaObj).length !== 0) this.meta = JSON.stringify(metaObj, undefined, 2)
24
25 if (row.level === 'audit') {
26 try {
27 const message = JSON.parse(row.message)
28
29 this.by = message.user
30 this.domain = message.domain
31 this.action = message.action
32
33 this.meta = JSON.stringify(message, null, 2)
34 this.message = ''
35 } catch (err) {
36 console.error('Cannot parse audit message.', err)
37 }
38 }
20 } 39 }
21} 40}