mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Automatically scroll log ouput
This commit is contained in:
		| @@ -11,7 +11,7 @@ | |||||||
|  |  | ||||||
| <div [ngbNavOutlet]="nav" class="mt-2"></div> | <div [ngbNavOutlet]="nav" class="mt-2"></div> | ||||||
|  |  | ||||||
| <div class="bg-dark p-3 text-light text-monospace log-container"> | <div class="bg-dark p-3 text-light text-monospace log-container" #logContainer> | ||||||
|   <p |   <p | ||||||
|     class="m-0 p-0 log-entry-{{getLogLevel(log)}}" |     class="m-0 p-0 log-entry-{{getLogLevel(log)}}" | ||||||
|     *ngFor="let log of logs">{{log}}</p> |     *ngFor="let log of logs">{{log}}</p> | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; | import { Component, ElementRef, AfterViewChecked, ViewChild } from '@angular/core'; | ||||||
| import { LogService } from 'src/app/services/rest/log.service'; | import { LogService } from 'src/app/services/rest/log.service'; | ||||||
|  |  | ||||||
| @Component({ | @Component({ | ||||||
| @@ -6,7 +6,7 @@ import { LogService } from 'src/app/services/rest/log.service'; | |||||||
|   templateUrl: './logs.component.html', |   templateUrl: './logs.component.html', | ||||||
|   styleUrls: ['./logs.component.scss'] |   styleUrls: ['./logs.component.scss'] | ||||||
| }) | }) | ||||||
| export class LogsComponent implements OnInit { | export class LogsComponent implements AfterViewChecked { | ||||||
|  |  | ||||||
|   constructor(private logService: LogService) { } |   constructor(private logService: LogService) { } | ||||||
|  |  | ||||||
| @@ -16,6 +16,8 @@ export class LogsComponent implements OnInit { | |||||||
|  |  | ||||||
|   activeLog: string |   activeLog: string | ||||||
|  |  | ||||||
|  |   @ViewChild('logContainer') logContainer: ElementRef | ||||||
|  |  | ||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|     this.logService.list().subscribe(result => { |     this.logService.list().subscribe(result => { | ||||||
|       this.logFiles = result |       this.logFiles = result | ||||||
| @@ -26,9 +28,14 @@ export class LogsComponent implements OnInit { | |||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   ngAfterViewChecked() { | ||||||
|  |     this.scrollToBottom(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   reloadLogs() { |   reloadLogs() { | ||||||
|     this.logService.get(this.activeLog).subscribe(result => { |     this.logService.get(this.activeLog).subscribe(result => { | ||||||
|       this.logs = result |       this.logs = result | ||||||
|  |       this.scrollToBottom() | ||||||
|     }, error => { |     }, error => { | ||||||
|       this.logs = [] |       this.logs = [] | ||||||
|     }) |     }) | ||||||
| @@ -48,4 +55,12 @@ export class LogsComponent implements OnInit { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   scrollToBottom(): void { | ||||||
|  |     this.logContainer?.nativeElement.scroll({ | ||||||
|  |       top: this.logContainer.nativeElement.scrollHeight, | ||||||
|  |       left: 0, | ||||||
|  |       behavior: 'auto' | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon