]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/system/logs/logs.component.ts
paginate response for abuse list in openapi spec
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / system / logs / logs.component.ts
index 62b8bc0b9bfe8dbf4efb110024d2a600b35695b8..48318f07baaa55b827e9df2ee4f243d5f1590ed4 100644 (file)
@@ -1,5 +1,5 @@
 import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
-import { Notifier } from '@app/core'
+import { LocalStorageService, Notifier } from '@app/core'
 import { LogLevel } from '@shared/models'
 import { LogRow } from './log-row.model'
 import { LogsService } from './logs.service'
@@ -9,6 +9,8 @@ import { LogsService } from './logs.service'
   styleUrls: [ './logs.component.scss' ]
 })
 export class LogsComponent implements OnInit {
+  private static LOCAL_STORAGE_LOG_TYPE_CHOICE_KEY = 'admin-logs-log-type-choice'
+
   @ViewChild('logsElement', { static: true }) logsElement: ElementRef<HTMLElement>
 
   loading = false
@@ -24,19 +26,25 @@ export class LogsComponent implements OnInit {
 
   constructor (
     private logsService: LogsService,
-    private notifier: Notifier
-    ) { }
+    private notifier: Notifier,
+    private localStorage: LocalStorageService
+  ) { }
 
   ngOnInit (): void {
     this.buildTimeChoices()
     this.buildLevelChoices()
     this.buildLogTypeChoices()
 
+    this.loadPreviousChoices()
+
     this.load()
   }
 
   refresh () {
     this.logs = []
+
+    this.localStorage.setItem(LogsComponent.LOCAL_STORAGE_LOG_TYPE_CHOICE_KEY, this.logType)
+
     this.load()
   }
 
@@ -128,7 +136,11 @@ export class LogsComponent implements OnInit {
         label: $localize`Audit logs`
       }
     ]
+  }
+
+  private loadPreviousChoices () {
+    this.logType = this.localStorage.getItem(LogsComponent.LOCAL_STORAGE_LOG_TYPE_CHOICE_KEY)
 
-    this.logType = 'audit'
+    if (this.logType !== 'standard' && this.logType !== 'audit') this.logType = 'audit'
   }
 }