aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/video-abuses
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-30 22:41:14 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-30 22:41:14 +0100
commit28798b5d949826551740fc893d06e6424b77aa6a (patch)
treee235a7f49164a06c4b76df49ca61b89998d4ed81 /client/src/app/+admin/video-abuses
parent13fc89f4a4b91b3da10493517de556240fb65463 (diff)
downloadPeerTube-28798b5d949826551740fc893d06e6424b77aa6a.tar.gz
PeerTube-28798b5d949826551740fc893d06e6424b77aa6a.tar.zst
PeerTube-28798b5d949826551740fc893d06e6424b77aa6a.zip
Client: replace simple tables by ng2 smart table component
Diffstat (limited to 'client/src/app/+admin/video-abuses')
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html28
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts75
2 files changed, 59 insertions, 44 deletions
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html
index 46043577c..b2fd17bf0 100644
--- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html
+++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html
@@ -1,27 +1,5 @@
1<h3>Video abuses list</h3> 1<h3>Video abuses list</h3>
2 2
3<table class="table table-hover"> 3<ng2-smart-table
4 <thead> 4 [settings]="tableSettings" [source]="videoAbusesSource"
5 <tr> 5></ng2-smart-table>
6 <th class="cell-id">ID</th>
7 <th class="cell-reason">Reason</th>
8 <th>Reporter pod host</th>
9 <th>Reporter username</th>
10 <th>Video</th>
11 <th>Created at</th>
12 </tr>
13 </thead>
14
15 <tbody>
16 <tr *ngFor="let videoAbuse of videoAbuses">
17 <td>{{ videoAbuse.id }}</td>
18 <td>{{ videoAbuse.reason }}</td>
19 <td>{{ videoAbuse.reporterPodHost }}</td>
20 <td>{{ videoAbuse.reporterUsername }}</td>
21 <td>
22 <a [routerLink]="buildVideoLink(videoAbuse)" title="Go to video">{{ videoAbuse.videoId }}</a>
23 </td>
24 <td>{{ videoAbuse.createdAt | date: 'medium' }}</td>
25 </tr>
26 </tbody>
27</table>
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 cfd9151b0..2f22a4ab0 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,35 +1,72 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component } from '@angular/core';
2 2
3import { NotificationsService } from 'angular2-notifications'; 3import { NotificationsService } from 'angular2-notifications';
4 4
5import { VideoAbuseService, VideoAbuse} from '../../../shared'; 5import { Utils, VideoAbuseService, VideoAbuse} from '../../../shared';
6 6
7@Component({ 7@Component({
8 selector: 'my-video-abuse-list', 8 selector: 'my-video-abuse-list',
9 templateUrl: './video-abuse-list.component.html', 9 templateUrl: './video-abuse-list.component.html',
10 styleUrls: [ './video-abuse-list.component.scss' ] 10 styleUrls: [ './video-abuse-list.component.scss' ]
11}) 11})
12export class VideoAbuseListComponent implements OnInit { 12export class VideoAbuseListComponent {
13 videoAbuses: VideoAbuse[]; 13 videoAbusesSource = null;
14 tableSettings = {
15 mode: 'external',
16 attr: {
17 class: 'table-hover'
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 }
14 59
15 constructor( 60 constructor(
16 private notificationsService: NotificationsService, 61 private notificationsService: NotificationsService,
17 private videoAbuseService: VideoAbuseService 62 private videoAbuseService: VideoAbuseService
18 ) { } 63 ) {
19 64 this.videoAbusesSource = this.videoAbuseService.getDataSource();
20 ngOnInit() { 65 }
21 this.getVideoAbuses();
22 }
23
24 buildVideoLink(videoAbuse: VideoAbuse) {
25 return `/videos/${videoAbuse.videoId}`;
26 }
27
28 private getVideoAbuses() {
29 this.videoAbuseService.getVideoAbuses().subscribe(
30 res => this.videoAbuses = res.videoAbuses,
31 66
32 err => this.notificationsService.error('Error', err.text) 67 buildVideoLink(videoId: string) {
33 ); 68 // TODO: transform to routerLink
69 // https://github.com/akveo/ng2-smart-table/issues/57
70 return `<a href="/videos/${videoId}" title="Go to the video">${videoId}</a>`;
34 } 71 }
35} 72}