]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnInit } from '@angular/core' | |
2 | ||
3 | import { NotificationsService } from 'angular2-notifications' | |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | |
5 | ||
6 | import { RestTable, RestPagination, VideoAbuseService } from '../../../shared' | |
7 | import { VideoAbuse } from '../../../../../../shared' | |
8 | ||
9 | @Component({ | |
10 | selector: 'my-video-abuse-list', | |
11 | templateUrl: './video-abuse-list.component.html', | |
12 | styleUrls: [ './video-abuse-list.component.scss'] | |
13 | }) | |
14 | export class VideoAbuseListComponent extends RestTable implements OnInit { | |
15 | videoAbuses: VideoAbuse[] = [] | |
16 | totalRecords = 0 | |
17 | rowsPerPage = 10 | |
18 | sort: SortMeta = { field: 'id', order: 1 } | |
19 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | |
20 | ||
21 | constructor ( | |
22 | private notificationsService: NotificationsService, | |
23 | private videoAbuseService: VideoAbuseService | |
24 | ) { | |
25 | super() | |
26 | } | |
27 | ||
28 | ngOnInit () { | |
29 | this.loadData() | |
30 | } | |
31 | ||
32 | getRouterVideoLink (videoId: number) { | |
33 | return [ '/videos', videoId ] | |
34 | } | |
35 | ||
36 | protected loadData () { | |
37 | return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort) | |
38 | .subscribe( | |
39 | resultList => { | |
40 | this.videoAbuses = resultList.data | |
41 | this.totalRecords = resultList.total | |
42 | }, | |
43 | ||
44 | err => this.notificationsService.error('Error', err.message) | |
45 | ) | |
46 | } | |
47 | } |