aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts')
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts84
1 files changed, 29 insertions, 55 deletions
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
index 7c838fbf0..cc9c1bdf4 100644
--- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
+++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
@@ -1,72 +1,46 @@
1import { Component } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2 2
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { SortMeta } from 'primeng/primeng'
4 5
5import { Utils, VideoAbuseService } from '../../../shared' 6import { RestTable, RestPagination, VideoAbuseService } from '../../../shared'
6import { VideoAbuse } from '../../../../../shared' 7import { VideoAbuse } from '../../../../../../shared'
7 8
8@Component({ 9@Component({
9 selector: 'my-video-abuse-list', 10 selector: 'my-video-abuse-list',
10 templateUrl: './video-abuse-list.component.html' 11 templateUrl: './video-abuse-list.component.html'
11}) 12})
12export class VideoAbuseListComponent { 13export class VideoAbuseListComponent extends RestTable implements OnInit {
13 videoAbusesSource = null 14 videoAbuses: VideoAbuse[] = []
14 tableSettings = { 15 totalRecords = 0
15 mode: 'external', 16 rowsPerPage = 1
16 attr: { 17 sort: SortMeta = { field: 'id', order: 1 }
17 class: 'table-hover' 18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18 },
19 hideSubHeader: true,
20 actions: {
21 position: 'right',
22 add: false,
23 edit: false,
24 delete: false
25 },
26 pager: {
27 display: true,
28 perPage: 10
29 },
30 columns: {
31 id: {
32 title: 'ID',
33 sortDirection: 'asc'
34 },
35 reason: {
36 title: 'Reason',
37 sort: false
38 },
39 reporterPodHost: {
40 title: 'Reporter pod host',
41 sort: false
42 },
43 reporterUsername: {
44 title: 'Reporter username',
45 sort: false
46 },
47 videoId: {
48 title: 'Video',
49 type: 'html',
50 sort: false,
51 valuePrepareFunction: this.buildVideoLink
52 },
53 createdAt: {
54 title: 'Created Date',
55 valuePrepareFunction: Utils.dateToHuman
56 }
57 }
58 }
59 19
60 constructor ( 20 constructor (
61 private notificationsService: NotificationsService, 21 private notificationsService: NotificationsService,
62 private videoAbuseService: VideoAbuseService 22 private videoAbuseService: VideoAbuseService
63 ) { 23 ) {
64 this.videoAbusesSource = this.videoAbuseService.getDataSource() 24 super()
25 }
26
27 ngOnInit () {
28 this.loadData()
65 } 29 }
66 30
67 buildVideoLink (videoId: string) { 31 getRouterVideoLink (videoId: number) {
68 // TODO: transform to routerLink 32 return [ '/videos', videoId ]
69 // https://github.com/akveo/ng2-smart-table/issues/57 33 }
70 return `<a href="/videos/${videoId}" title="Go to the video">${videoId}</a>` 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)
44 )
71 } 45 }
72} 46}