aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
blob: 55d82f79046efc32dd0770b8f27bbe4fe5b0f905 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Component } from '@angular/core';

import { NotificationsService } from 'angular2-notifications';

import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared';

@Component({
	selector: 'my-video-abuse-list',
	templateUrl: './video-abuse-list.component.html'
})
export class VideoAbuseListComponent {
  videoAbusesSource = null;
  tableSettings = {
    mode: 'external',
    attr: {
      class: 'table-hover'
    },
    hideSubHeader: true,
    actions: {
      position: 'right',
      add: false,
      edit: false,
      delete: false
    },
    pager: {
      display: true,
      perPage: 10
    },
    columns: {
      id: {
        title: 'ID',
        sortDirection: 'asc'
      },
      reason: {
        title: 'Reason',
        sort: false
      },
      reporterPodHost: {
        title: 'Reporter pod host',
        sort: false
      },
      reporterUsername: {
        title: 'Reporter username',
        sort: false
      },
      videoId: {
        title: 'Video',
        type: 'html',
        sort: false,
        valuePrepareFunction: this.buildVideoLink
      },
      createdAt: {
        title: 'Created Date',
        valuePrepareFunction: Utils.dateToHuman
      }
    }
  };

  constructor(
    private notificationsService: NotificationsService,
    private videoAbuseService: VideoAbuseService
  ) {
    this.videoAbusesSource = this.videoAbuseService.getDataSource();
   }

  buildVideoLink(videoId: string) {
    // TODO: transform to routerLink
    // https://github.com/akveo/ng2-smart-table/issues/57
    return `<a href="/videos/${videoId}" title="Go to the video">${videoId}</a>`;
  }
}