mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-28 07:30:56 +03:00
Updated logs viewer component
- now by default last 50 lines are showed
- added copy to clipboard button
- added loading spinner to indicate to users when the logs are loading
app.get('/api/logs') is now app.post to allow for additional parameters (such as lines to retrieve)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, AfterViewInit } from '@angular/core';
|
||||
import { PostsService } from '../../posts.services';
|
||||
|
||||
@Component({
|
||||
@@ -9,7 +9,8 @@ import { PostsService } from '../../posts.services';
|
||||
export class LogsViewerComponent implements OnInit {
|
||||
|
||||
logs: string = null;
|
||||
|
||||
requested_lines = 50;
|
||||
logs_loading = false;
|
||||
constructor(private postsService: PostsService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -17,16 +18,23 @@ export class LogsViewerComponent implements OnInit {
|
||||
}
|
||||
|
||||
getLogs() {
|
||||
this.postsService.getLogs().subscribe(res => {
|
||||
if (!this.logs) { this.logs_loading = true; } // only show loading spinner at the first load
|
||||
this.postsService.getLogs(this.requested_lines !== 0 ? this.requested_lines : null).subscribe(res => {
|
||||
this.logs_loading = false;
|
||||
if (res['logs']) {
|
||||
this.logs = res['logs'];
|
||||
} else {
|
||||
this.postsService.openSnackBar('Failed to retrieve logs!');
|
||||
}
|
||||
}, err => {
|
||||
this.logs_loading = false;
|
||||
console.error(err);
|
||||
this.postsService.openSnackBar('Failed to retrieve logs!');
|
||||
});
|
||||
}
|
||||
|
||||
copiedLogsToClipboard() {
|
||||
this.postsService.openSnackBar('Logs copied to clipboard!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user