39 lines
1 KiB
TypeScript
39 lines
1 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { Torrent } from '../models/torrent.model';
|
|
import { TorrentService } from '../torrent.service';
|
|
|
|
@Component({
|
|
selector: 'app-torrent-table',
|
|
templateUrl: './torrent-table.component.html',
|
|
styleUrls: ['./torrent-table.component.scss'],
|
|
})
|
|
export class TorrentTableComponent implements OnInit {
|
|
public torrents: Torrent[] = [];
|
|
public error: string;
|
|
|
|
constructor(private router: Router, private torrentService: TorrentService) {}
|
|
|
|
ngOnInit(): void {
|
|
this.torrentService.getList().subscribe(
|
|
(result) => {
|
|
this.torrents = result;
|
|
|
|
this.torrentService.update$.subscribe((result2) => {
|
|
this.torrents = result2;
|
|
});
|
|
},
|
|
(err) => {
|
|
this.error = err.error;
|
|
}
|
|
);
|
|
}
|
|
|
|
public selectTorrent(torrentId: string): void {
|
|
this.router.navigate([`/torrent/${torrentId}`]);
|
|
}
|
|
|
|
public trackByMethod(index: number, el: Torrent): string {
|
|
return el.torrentId;
|
|
}
|
|
}
|