mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-23 21:20:56 +03:00
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
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
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'
|
|
});
|
|
}
|
|
|
|
}
|