You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
YoutubeDL-Material/src/app/dialogs/update-progress-dialog/update-progress-dialog.comp...

43 lines
1.1 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { PostsService } from 'app/posts.services';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-update-progress-dialog',
templateUrl: './update-progress-dialog.component.html',
styleUrls: ['./update-progress-dialog.component.scss']
})
export class UpdateProgressDialogComponent implements OnInit {
updateStatus = null;
updateInterval = 250;
errored = false;
constructor(private postsService: PostsService, private snackBar: MatSnackBar) { }
ngOnInit(): void {
this.getUpdateProgress();
setInterval(() => {
if (this.updateStatus['updating']) { this.getUpdateProgress(); }
}, 250);
}
getUpdateProgress() {
this.postsService.getUpdaterStatus().subscribe(res => {
if (res) {
this.updateStatus = res;
if (this.updateStatus && this.updateStatus['error']) {
this.openSnackBar('Update failed. Check logs for more details.');
}
}
});
}
public openSnackBar(message: string, action: string = '') {
this.snackBar.open(message, action, {
duration: 2000,
});
}
}