mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	log filtering
This commit is contained in:
		
							parent
							
								
									d15405ef56
								
							
						
					
					
						commit
						a2627aa520
					
				@ -1,4 +1,18 @@
 | 
				
			|||||||
<app-page-header title="Logs">
 | 
					<app-page-header title="Logs">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <div ngbDropdown class="btn-group">
 | 
				
			||||||
 | 
					    <button class="btn btn-outline-secondary btn-sm" id="dropdownBasic1" ngbDropdownToggle>
 | 
				
			||||||
 | 
					      <svg class="toolbaricon" fill="currentColor">
 | 
				
			||||||
 | 
					        <use xlink:href="assets/bootstrap-icons.svg#funnel" />
 | 
				
			||||||
 | 
					      </svg>
 | 
				
			||||||
 | 
					      Filter
 | 
				
			||||||
 | 
					    </button>
 | 
				
			||||||
 | 
					    <div ngbDropdownMenu aria-labelledby="dropdownBasic1">
 | 
				
			||||||
 | 
					      <button *ngFor="let f of getLevels()" ngbDropdownItem (click)="setLevel(f.id)"
 | 
				
			||||||
 | 
					        [class.active]="level == f.id">{{f.name}}</button>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</app-page-header>
 | 
					</app-page-header>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="bg-dark p-3 mb-3" infiniteScroll (scrolled)="onScroll()">
 | 
					<div class="bg-dark p-3 mb-3" infiniteScroll (scrolled)="onScroll()">
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { Component, OnInit } from '@angular/core';
 | 
					import { Component, OnInit } from '@angular/core';
 | 
				
			||||||
import { kMaxLength } from 'buffer';
 | 
					import { kMaxLength } from 'buffer';
 | 
				
			||||||
import { LOG_LEVELS, PaperlessLog } from 'src/app/data/paperless-log';
 | 
					import { LOG_LEVELS, LOG_LEVEL_INFO, PaperlessLog } from 'src/app/data/paperless-log';
 | 
				
			||||||
import { LogService } from 'src/app/services/rest/log.service';
 | 
					import { LogService } from 'src/app/services/rest/log.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
@ -13,9 +13,14 @@ export class LogsComponent implements OnInit {
 | 
				
			|||||||
  constructor(private logService: LogService) { }
 | 
					  constructor(private logService: LogService) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logs: PaperlessLog[] = []
 | 
					  logs: PaperlessLog[] = []
 | 
				
			||||||
 | 
					  level: number = LOG_LEVEL_INFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnInit(): void {
 | 
					  ngOnInit(): void {
 | 
				
			||||||
    this.logService.list(1, 50).subscribe(result => this.logs = result.results)
 | 
					    this.reload()
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  reload() {
 | 
				
			||||||
 | 
					    this.logService.list(1, 50, null, {'level__gte': this.level}).subscribe(result => this.logs = result.results)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getLevelText(level: number) {
 | 
					  getLevelText(level: number) {
 | 
				
			||||||
@ -27,9 +32,18 @@ export class LogsComponent implements OnInit {
 | 
				
			|||||||
    if (this.logs.length > 0) {
 | 
					    if (this.logs.length > 0) {
 | 
				
			||||||
      lastCreated = this.logs[this.logs.length-1].created
 | 
					      lastCreated = this.logs[this.logs.length-1].created
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    this.logService.list(1, 25, null, {'created__lt': lastCreated}).subscribe(result => {
 | 
					    this.logService.list(1, 25, null, {'created__lt': lastCreated, 'level__gte': this.level}).subscribe(result => {
 | 
				
			||||||
      this.logs.push(...result.results)
 | 
					      this.logs.push(...result.results)
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getLevels() {
 | 
				
			||||||
 | 
					    return LOG_LEVELS
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setLevel(id) {
 | 
				
			||||||
 | 
					    this.level = id
 | 
				
			||||||
 | 
					    this.reload()
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,15 +1,15 @@
 | 
				
			|||||||
export const DEBUG = 10
 | 
					export const LOG_LEVEL_DEBUG = 10
 | 
				
			||||||
export const INFO = 20
 | 
					export const LOG_LEVEL_INFO = 20
 | 
				
			||||||
export const WARNING = 30
 | 
					export const LOG_LEVEL_WARNING = 30
 | 
				
			||||||
export const ERROR = 40
 | 
					export const LOG_LEVEL_ERROR = 40
 | 
				
			||||||
export const CRITICAL = 50
 | 
					export const LOG_LEVEL_CRITICAL = 50
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const LOG_LEVELS = [
 | 
					export const LOG_LEVELS = [
 | 
				
			||||||
  {id: DEBUG, name: "DEBUG"},
 | 
					  {id: LOG_LEVEL_DEBUG, name: "DEBUG"},
 | 
				
			||||||
  {id: INFO, name: "INFO"},
 | 
					  {id: LOG_LEVEL_INFO, name: "INFO"},
 | 
				
			||||||
  {id: WARNING, name: "WARNING"},
 | 
					  {id: LOG_LEVEL_WARNING, name: "WARNING"},
 | 
				
			||||||
  {id: ERROR, name: "ERROR"},
 | 
					  {id: LOG_LEVEL_ERROR, name: "ERROR"},
 | 
				
			||||||
  {id: CRITICAL, name: "CRITICAL"}
 | 
					  {id: LOG_LEVEL_CRITICAL, name: "CRITICAL"}
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface PaperlessLog {
 | 
					export interface PaperlessLog {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user