]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
Optimize imports
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / video-abuses / video-abuse-list / video-abuse-list.component.ts
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 })
13 export class VideoAbuseListComponent extends RestTable implements OnInit {
14 videoAbuses: VideoAbuse[] = []
15 totalRecords = 0
16 rowsPerPage = 10
17 sort: SortMeta = { field: 'id', order: 1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
21 private notificationsService: NotificationsService,
22 private videoAbuseService: VideoAbuseService
23 ) {
24 super()
25 }
26
27 ngOnInit () {
28 this.loadData()
29 }
30
31 getRouterVideoLink (videoId: number) {
32 return [ '/videos', videoId ]
33 }
34
35 protected loadData () {
36 return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort)
37 .subscribe(
38 resultList => {
39 this.videoAbuses = resultList.data
40 this.totalRecords = resultList.total
41 },
42
43 err => this.notificationsService.error('Error', err.message)
44 )
45 }
46 }