Added the ability to view logs from the settings menu

This commit is contained in:
Isaac Grynsztein
2020-06-22 23:15:21 -04:00
parent 09d8ce04d7
commit 2998562655
14 changed files with 94 additions and 6 deletions

View File

@@ -0,0 +1,3 @@
<div style="height: 100%">
<textarea style="height: 100%" matInput readonly [(ngModel)]="logs" placeholder="Logs will appear here" i18n-placeholder="Logs placeholder"></textarea>
</div>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LogsViewerComponent } from './logs-viewer.component';
describe('LogsViewerComponent', () => {
let component: LogsViewerComponent;
let fixture: ComponentFixture<LogsViewerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LogsViewerComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LogsViewerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,32 @@
import { Component, OnInit } from '@angular/core';
import { PostsService } from '../../posts.services';
@Component({
selector: 'app-logs-viewer',
templateUrl: './logs-viewer.component.html',
styleUrls: ['./logs-viewer.component.scss']
})
export class LogsViewerComponent implements OnInit {
logs: string = null;
constructor(private postsService: PostsService) { }
ngOnInit(): void {
this.getLogs();
}
getLogs() {
this.postsService.getLogs().subscribe(res => {
if (res['logs']) {
this.logs = res['logs'];
} else {
this.postsService.openSnackBar('Failed to retrieve logs!');
}
}, err => {
console.error(err);
this.postsService.openSnackBar('Failed to retrieve logs!');
});
}
}