mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-13 22:01: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:
18
src/app/updater/updater.component.html
Normal file
18
src/app/updater/updater.component.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div style="display: block">
|
||||
<div style="display: inline-block">
|
||||
<ng-container i18n="Select a version">Select a version:</ng-container>
|
||||
</div>
|
||||
<div *ngIf="availableVersions" style="display: inline-block; margin-left: 15px;">
|
||||
<mat-form-field>
|
||||
<mat-select [(ngModel)]="selectedVersion">
|
||||
<mat-option *ngFor="let version of availableVersionsFiltered" [value]="version['tag_name']">
|
||||
{{version['tag_name'] + (version === latestStableRelease ? ' - Latest Stable' : '') + (version['tag_name'] === CURRENT_VERSION ? ' - Current Version' : '')}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div *ngIf="selectedVersion && selectedVersion !== CURRENT_VERSION" style="display: inline-block; margin-left: 15px;">
|
||||
<button (click)="updateServer()" color="accent" mat-raised-button><mat-icon>update</mat-icon>
|
||||
<ng-container *ngIf="selectedVersion > CURRENT_VERSION">Upgrade to</ng-container><ng-container *ngIf="selectedVersion < CURRENT_VERSION">Downgrade to</ng-container> {{selectedVersion}}</button>
|
||||
</div>
|
||||
</div>
|
||||
0
src/app/updater/updater.component.scss
Normal file
0
src/app/updater/updater.component.scss
Normal file
25
src/app/updater/updater.component.spec.ts
Normal file
25
src/app/updater/updater.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UpdaterComponent } from './updater.component';
|
||||
|
||||
describe('UpdaterComponent', () => {
|
||||
let component: UpdaterComponent;
|
||||
let fixture: ComponentFixture<UpdaterComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ UpdaterComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UpdaterComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
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