You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
YoutubeDL-Material/src/app/file-card/file-card.component.ts

44 lines
1.2 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';
@Component({
selector: 'app-file-card',
templateUrl: './file-card.component.html',
styleUrls: ['./file-card.component.css']
})
export class FileCardComponent implements OnInit {
6 years ago
@Input() title: string;
@Input() length: string;
@Input() name: string;
@Input() thumbnailURL: string;
6 years ago
@Input() isAudio = true;
@Output() removeFile: EventEmitter<string> = new EventEmitter<string>();
constructor(private postsService: PostsService, public snackBar: MatSnackBar, public mainComponent: MainComponent) { }
ngOnInit() {
}
6 years ago
deleteFile() {
this.postsService.deleteFile(this.name, this.isAudio).subscribe(result => {
6 years ago
if (result === true) {
this.openSnackBar('Delete success!', 'OK.');
this.removeFile.emit(this.name);
6 years ago
} else {
this.openSnackBar('Delete failed!', 'OK.');
}
});
}
public openSnackBar(message: string, action: string) {
this.snackBar.open(message, action, {
duration: 2000,
});
}
}