mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #778 from shamoon/fix/issue-774-775
Fix extra scrollbar on log container, auto scroll logs to bottom
This commit is contained in:
		| @@ -11,7 +11,7 @@ | ||||
|  | ||||
| <div [ngbNavOutlet]="nav" class="mt-2"></div> | ||||
|  | ||||
| <div class="bg-dark p-3 mb-3 text-light text-monospace log-container"> | ||||
| <div class="bg-dark p-3 text-light text-monospace log-container" #logContainer> | ||||
|   <p | ||||
|     class="m-0 p-0 log-entry-{{getLogLevel(log)}}" | ||||
|     *ngFor="let log of logs">{{log}}</p> | ||||
|   | ||||
| @@ -17,7 +17,7 @@ | ||||
|  | ||||
| .log-container { | ||||
|   overflow-y: scroll; | ||||
|   height: calc(100vh - 190px); | ||||
|   height: calc(100vh - 200px); | ||||
|   top: 70px; | ||||
|  | ||||
|   p { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; | ||||
| import { Component, ElementRef, OnInit, AfterViewChecked, ViewChild } from '@angular/core'; | ||||
| import { LogService } from 'src/app/services/rest/log.service'; | ||||
|  | ||||
| @Component({ | ||||
| @@ -6,7 +6,7 @@ import { LogService } from 'src/app/services/rest/log.service'; | ||||
|   templateUrl: './logs.component.html', | ||||
|   styleUrls: ['./logs.component.scss'] | ||||
| }) | ||||
| export class LogsComponent implements OnInit { | ||||
| export class LogsComponent implements OnInit, AfterViewChecked { | ||||
|  | ||||
|   constructor(private logService: LogService) { } | ||||
|  | ||||
| @@ -16,6 +16,8 @@ export class LogsComponent implements OnInit { | ||||
|  | ||||
|   activeLog: string | ||||
|  | ||||
|   @ViewChild('logContainer') logContainer: ElementRef | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|     this.logService.list().subscribe(result => { | ||||
|       this.logFiles = result | ||||
| @@ -26,6 +28,10 @@ export class LogsComponent implements OnInit { | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   ngAfterViewChecked() { | ||||
|     this.scrollToBottom(); | ||||
|   } | ||||
|  | ||||
|   reloadLogs() { | ||||
|     this.logService.get(this.activeLog).subscribe(result => { | ||||
|       this.logs = result | ||||
| @@ -48,4 +54,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
	 Jonas Winkler
					Jonas Winkler