]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
Change video abuse API response
[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 import { Account } from '@app/shared/account/account.model'
3 import { NotificationsService } from 'angular2-notifications'
4 import { SortMeta } from 'primeng/components/common/sortmeta'
5 import { VideoAbuse } from '../../../../../../shared'
6
7 import { RestPagination, RestTable, VideoAbuseService } 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: 'createdAt', 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.loadSort()
30 }
31
32 createByString (account: Account) {
33 return Account.CREATE_BY_STRING(account.name, account.host)
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 }