mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-14 08:40:57 +03:00
added the ability to create playlists in the gui through a new dialog reloading mp3s/mp4s doesn't cause an image refresh anymore when the list is unchanged fixed loading spinner of available formats so it now only shows when it is loading the current url file card images now don't show when errored or thumbnailurl doesn't exist
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import { Component, OnInit, Input, Output } from '@angular/core';
|
|
import {PostsService} from '../posts.services';
|
|
import {MatSnackBar} from '@angular/material';
|
|
import {EventEmitter} from '@angular/core';
|
|
import { MainComponent } from 'app/main/main.component';
|
|
import { Subject, Observable } from 'rxjs';
|
|
import 'rxjs/add/observable/merge';
|
|
|
|
@Component({
|
|
selector: 'app-file-card',
|
|
templateUrl: './file-card.component.html',
|
|
styleUrls: ['./file-card.component.css']
|
|
})
|
|
export class FileCardComponent implements OnInit {
|
|
|
|
@Input() title: string;
|
|
@Input() length: string;
|
|
@Input() name: string;
|
|
@Input() thumbnailURL: string;
|
|
@Input() isAudio = true;
|
|
@Output() removeFile: EventEmitter<string> = new EventEmitter<string>();
|
|
@Input() isPlaylist = false;
|
|
@Input() count = null;
|
|
type;
|
|
image_loaded = false;
|
|
image_errored = false;
|
|
|
|
scrollSubject;
|
|
scrollAndLoad;
|
|
|
|
constructor(private postsService: PostsService, public snackBar: MatSnackBar, public mainComponent: MainComponent) {
|
|
this.scrollSubject = new Subject();
|
|
this.scrollAndLoad = Observable.merge(
|
|
Observable.fromEvent(window, 'scroll'),
|
|
this.scrollSubject
|
|
);
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.type = this.isAudio ? 'audio' : 'video';
|
|
}
|
|
|
|
deleteFile() {
|
|
if (!this.isPlaylist) {
|
|
this.postsService.deleteFile(this.name, this.isAudio).subscribe(result => {
|
|
if (result === true) {
|
|
this.openSnackBar('Delete success!', 'OK.');
|
|
this.removeFile.emit(this.name);
|
|
} else {
|
|
this.openSnackBar('Delete failed!', 'OK.');
|
|
}
|
|
});
|
|
} else {
|
|
this.removeFile.emit(this.name);
|
|
}
|
|
|
|
}
|
|
|
|
onImgError(event) {
|
|
this.image_errored = true;
|
|
}
|
|
|
|
onHoverResponse() {
|
|
this.scrollSubject.next();
|
|
}
|
|
|
|
imageLoaded(loaded) {
|
|
this.image_loaded = true;
|
|
}
|
|
|
|
public openSnackBar(message: string, action: string) {
|
|
this.snackBar.open(message, action, {
|
|
duration: 2000,
|
|
});
|
|
}
|
|
|
|
}
|