mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { LogsComponent } from './logs.component';
|
||||
import { LogsComponent } from './logs.component'
|
||||
|
||||
describe('LogsComponent', () => {
|
||||
let component: LogsComponent;
|
||||
let fixture: ComponentFixture<LogsComponent>;
|
||||
let component: LogsComponent
|
||||
let fixture: ComponentFixture<LogsComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ LogsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [LogsComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LogsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(LogsComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,14 +1,19 @@
|
||||
import { Component, ElementRef, OnInit, AfterViewChecked, ViewChild } from '@angular/core';
|
||||
import { LogService } from 'src/app/services/rest/log.service';
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
OnInit,
|
||||
AfterViewChecked,
|
||||
ViewChild,
|
||||
} from '@angular/core'
|
||||
import { LogService } from 'src/app/services/rest/log.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-logs',
|
||||
templateUrl: './logs.component.html',
|
||||
styleUrls: ['./logs.component.scss']
|
||||
styleUrls: ['./logs.component.scss'],
|
||||
})
|
||||
export class LogsComponent implements OnInit, AfterViewChecked {
|
||||
|
||||
constructor(private logService: LogService) { }
|
||||
constructor(private logService: LogService) {}
|
||||
|
||||
logs: string[] = []
|
||||
|
||||
@@ -19,7 +24,7 @@ export class LogsComponent implements OnInit, AfterViewChecked {
|
||||
@ViewChild('logContainer') logContainer: ElementRef
|
||||
|
||||
ngOnInit(): void {
|
||||
this.logService.list().subscribe(result => {
|
||||
this.logService.list().subscribe((result) => {
|
||||
this.logFiles = result
|
||||
if (this.logFiles.length > 0) {
|
||||
this.activeLog = this.logFiles[0]
|
||||
@@ -29,25 +34,28 @@ export class LogsComponent implements OnInit, AfterViewChecked {
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
this.scrollToBottom()
|
||||
}
|
||||
|
||||
reloadLogs() {
|
||||
this.logService.get(this.activeLog).subscribe(result => {
|
||||
this.logs = result
|
||||
}, error => {
|
||||
this.logs = []
|
||||
})
|
||||
this.logService.get(this.activeLog).subscribe(
|
||||
(result) => {
|
||||
this.logs = result
|
||||
},
|
||||
(error) => {
|
||||
this.logs = []
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
getLogLevel(log: string) {
|
||||
if (log.indexOf("[DEBUG]") != -1) {
|
||||
if (log.indexOf('[DEBUG]') != -1) {
|
||||
return 10
|
||||
} else if (log.indexOf("[WARNING]") != -1) {
|
||||
} else if (log.indexOf('[WARNING]') != -1) {
|
||||
return 30
|
||||
} else if (log.indexOf("[ERROR]") != -1) {
|
||||
} else if (log.indexOf('[ERROR]') != -1) {
|
||||
return 40
|
||||
} else if (log.indexOf("[CRITICAL]") != -1) {
|
||||
} else if (log.indexOf('[CRITICAL]') != -1) {
|
||||
return 50
|
||||
} else {
|
||||
return 20
|
||||
@@ -58,8 +66,7 @@ export class LogsComponent implements OnInit, AfterViewChecked {
|
||||
this.logContainer?.nativeElement.scroll({
|
||||
top: this.logContainer.nativeElement.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'auto'
|
||||
});
|
||||
behavior: 'auto',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user