]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/system/logs/logs.component.ts
Serve audit logs to client
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / system / logs / logs.component.ts
index 17abb8409365ec08f1c0cc242a8b0b242b123e5a..b63f1195310fb09cc9b7a22e000bc864b14d696a 100644 (file)
@@ -10,16 +10,18 @@ import { LogLevel } from '@shared/models/server/log-level.type'
   styleUrls: [ './logs.component.scss' ]
 })
 export class LogsComponent implements OnInit {
-  @ViewChild('logsElement') logsElement: ElementRef<HTMLElement>
+  @ViewChild('logsElement', { static: true }) logsElement: ElementRef<HTMLElement>
 
   loading = false
 
   logs: LogRow[] = []
   timeChoices: { id: string, label: string }[] = []
   levelChoices: { id: LogLevel, label: string }[] = []
+  logTypeChoices: { id: 'audit' | 'standard', label: string }[] = []
 
   startDate: string
   level: LogLevel
+  logType: 'audit' | 'standard'
 
   constructor (
     private logsService: LogsService,
@@ -30,6 +32,7 @@ export class LogsComponent implements OnInit {
   ngOnInit (): void {
     this.buildTimeChoices()
     this.buildLevelChoices()
+    this.buildLogTypeChoices()
 
     this.load()
   }
@@ -42,7 +45,7 @@ export class LogsComponent implements OnInit {
   load () {
     this.loading = true
 
-    this.logsService.getLogs(this.level, this.startDate)
+    this.logsService.getLogs({ isAuditLog: this.isAuditLog(), level: this.level, startDate: this.startDate })
         .subscribe(
           logs => {
             this.logs = logs
@@ -58,6 +61,10 @@ export class LogsComponent implements OnInit {
         )
   }
 
+  isAuditLog () {
+    return this.logType === 'audit'
+  }
+
   buildTimeChoices () {
     const lastHour = new Date()
     lastHour.setHours(lastHour.getHours() - 1)
@@ -106,6 +113,21 @@ export class LogsComponent implements OnInit {
       }
     ]
 
-    this.level = 'info'
+    this.level = 'warn'
+  }
+
+  buildLogTypeChoices () {
+    this.logTypeChoices = [
+      {
+        id: 'standard',
+        label: this.i18n('Standard logs')
+      },
+      {
+        id: 'audit',
+        label: this.i18n('Audit logs')
+      }
+    ]
+
+    this.logType = 'audit'
   }
 }