mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-29 16:10:56 +03:00
Added progress bar to file downloads
Added two new API calls, to update the server to a particular version and to get the updater status You can now update through the UI, and a status dialog displays after
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<h4 i18n="Update progress dialog title" mat-dialog-title>Updater</h4>
|
||||
|
||||
<mat-dialog-content>
|
||||
<div *ngIf="updateStatus">
|
||||
<div style="margin-bottom: 8px;">
|
||||
<h6 *ngIf="updateStatus['updating']">Update in progress</h6>
|
||||
<h6 *ngIf="!updateStatus['updating'] && updateStatus['error']">Update failed</h6>
|
||||
<h6 *ngIf="!updateStatus['updating'] && !updateStatus['error']">Update succeeded!</h6>
|
||||
</div>
|
||||
<mat-progress-bar *ngIf="updateStatus['updating']" mode="indeterminate"></mat-progress-bar>
|
||||
<mat-progress-bar *ngIf="!updateStatus['updating']" mode="determinate" value="100"></mat-progress-bar>
|
||||
<p style="margin-top: 4px; font-size: 13px;" *ngIf="updateStatus['details']">{{updateStatus['details']}}</p>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions>
|
||||
<button mat-button mat-dialog-close><ng-container i18n="Close update progress dialog">Close</ng-container></button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UpdateProgressDialogComponent } from './update-progress-dialog.component';
|
||||
|
||||
describe('UpdateProgressDialogComponent', () => {
|
||||
let component: UpdateProgressDialogComponent;
|
||||
let fixture: ComponentFixture<UpdateProgressDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ UpdateProgressDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UpdateProgressDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
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(() => {
|
||||
this.getUpdateProgress();
|
||||
}, 250);
|
||||
}
|
||||
|
||||
getUpdateProgress() {
|
||||
this.postsService.getUpdaterStatus().subscribe(res => {
|
||||
this.updateStatus = res;
|
||||
if (!this.updateStatus) {
|
||||
// update complete?
|
||||
console.log('Update complete? or not started');
|
||||
}
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user