mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-09 15:51:29 +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:
62
src/app/updater/updater.component.ts
Normal file
62
src/app/updater/updater.component.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
import { CURRENT_VERSION } from 'app/consts';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { UpdateProgressDialogComponent } from 'app/dialogs/update-progress-dialog/update-progress-dialog.component';
|
||||
@Component({
|
||||
selector: 'app-updater',
|
||||
templateUrl: './updater.component.html',
|
||||
styleUrls: ['./updater.component.scss']
|
||||
})
|
||||
export class UpdaterComponent implements OnInit {
|
||||
|
||||
availableVersions = null;
|
||||
availableVersionsFiltered = [];
|
||||
versionsShowLimit = 5;
|
||||
latestStableRelease = null;
|
||||
selectedVersion = null;
|
||||
CURRENT_VERSION = CURRENT_VERSION;
|
||||
|
||||
constructor(private postsService: PostsService, private dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getAvailableVersions();
|
||||
}
|
||||
|
||||
updateServer() {
|
||||
this.postsService.updateServer(this.selectedVersion).subscribe(res => {
|
||||
if (res['success']) {
|
||||
this.openUpdateProgressDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getAvailableVersions() {
|
||||
this.availableVersionsFiltered = [];
|
||||
this.postsService.getAvailableRelease().subscribe(res => {
|
||||
this.availableVersions = res;
|
||||
for (let i = 0; i < this.availableVersions.length; i++) {
|
||||
const currentVersion = this.availableVersions[i];
|
||||
// if a stable release has not been found and the version is not "rc" (meaning it's stable) then set it as the stable release
|
||||
if (!this.latestStableRelease && !currentVersion.tag_name.includes('rc')) {
|
||||
this.latestStableRelease = currentVersion;
|
||||
this.selectedVersion = this.latestStableRelease.tag_name;
|
||||
}
|
||||
|
||||
if (this.latestStableRelease && i >= this.versionsShowLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.availableVersionsFiltered.push(currentVersion);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openUpdateProgressDialog() {
|
||||
this.dialog.open(UpdateProgressDialogComponent, {
|
||||
minWidth: '300px',
|
||||
minHeight: '200px'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user