Remember last log type
This commit is contained in:
parent
53c06121a4
commit
288bcd7a60
|
@ -1,5 +1,5 @@
|
||||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
|
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 { LogLevel } from '@shared/models'
|
||||||
import { LogRow } from './log-row.model'
|
import { LogRow } from './log-row.model'
|
||||||
import { LogsService } from './logs.service'
|
import { LogsService } from './logs.service'
|
||||||
|
@ -9,6 +9,8 @@ import { LogsService } from './logs.service'
|
||||||
styleUrls: [ './logs.component.scss' ]
|
styleUrls: [ './logs.component.scss' ]
|
||||||
})
|
})
|
||||||
export class LogsComponent implements OnInit {
|
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>
|
@ViewChild('logsElement', { static: true }) logsElement: ElementRef<HTMLElement>
|
||||||
|
|
||||||
loading = false
|
loading = false
|
||||||
|
@ -24,7 +26,8 @@ export class LogsComponent implements OnInit {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private logsService: LogsService,
|
private logsService: LogsService,
|
||||||
private notifier: Notifier
|
private notifier: Notifier,
|
||||||
|
private localStorage: LocalStorageService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit (): void {
|
ngOnInit (): void {
|
||||||
|
@ -32,11 +35,16 @@ export class LogsComponent implements OnInit {
|
||||||
this.buildLevelChoices()
|
this.buildLevelChoices()
|
||||||
this.buildLogTypeChoices()
|
this.buildLogTypeChoices()
|
||||||
|
|
||||||
|
this.loadPreviousChoices()
|
||||||
|
|
||||||
this.load()
|
this.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh () {
|
refresh () {
|
||||||
this.logs = []
|
this.logs = []
|
||||||
|
|
||||||
|
this.localStorage.setItem(LogsComponent.LOCAL_STORAGE_LOG_TYPE_CHOICE_KEY, this.logType)
|
||||||
|
|
||||||
this.load()
|
this.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +136,11 @@ export class LogsComponent implements OnInit {
|
||||||
label: $localize`Audit logs`
|
label: $localize`Audit logs`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
|
||||||
this.logType = 'audit'
|
private loadPreviousChoices () {
|
||||||
|
this.logType = this.localStorage.getItem(LogsComponent.LOCAL_STORAGE_LOG_TYPE_CHOICE_KEY)
|
||||||
|
|
||||||
|
if (this.logType !== 'standard' && this.logType !== 'audit') this.logType = 'audit'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ abstract class StorageService {
|
||||||
return StorageService.storageSub.asObservable().pipe(filter(val => keys ? keys.includes(val) : true))
|
return StorageService.storageSub.asObservable().pipe(filter(val => keys ? keys.includes(val) : true))
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem (key: string) {
|
getItem <T extends string> (key: string) {
|
||||||
return this.instance.getItem(key)
|
return this.instance.getItem(key) as T
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem (key: string, data: any, notifyOfUpdate = true) {
|
setItem (key: string, data: any, notifyOfUpdate = true) {
|
||||||
|
|
Loading…
Reference in New Issue