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'
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
constructor (
private logsService: LogsService,
- private notifier: Notifier
+ private notifier: Notifier,
+ private localStorage: LocalStorageService
) { }
ngOnInit (): void {
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()
}
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'
}
}
return StorageService.storageSub.asObservable().pipe(filter(val => keys ? keys.includes(val) : true))
}
- getItem (key: string) {
- return this.instance.getItem(key)
+ getItem <T extends string> (key: string) {
+ return this.instance.getItem(key) as T
}
setItem (key: string, data: any, notifyOfUpdate = true) {