From 28798b5d949826551740fc893d06e6424b77aa6a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Jan 2017 22:41:14 +0100 Subject: Client: replace simple tables by ng2 smart table component --- .../video-abuse-list/video-abuse-list.component.ts | 75 ++++++++++++++++------ 1 file changed, 56 insertions(+), 19 deletions(-) (limited to 'client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts') 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 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { NotificationsService } from 'angular2-notifications'; -import { VideoAbuseService, VideoAbuse} from '../../../shared'; +import { Utils, VideoAbuseService, VideoAbuse} from '../../../shared'; @Component({ selector: 'my-video-abuse-list', templateUrl: './video-abuse-list.component.html', styleUrls: [ './video-abuse-list.component.scss' ] }) -export class VideoAbuseListComponent implements OnInit { - videoAbuses: VideoAbuse[]; +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 - ) { } - - ngOnInit() { - this.getVideoAbuses(); - } - - buildVideoLink(videoAbuse: VideoAbuse) { - return `/videos/${videoAbuse.videoId}`; - } - - private getVideoAbuses() { - this.videoAbuseService.getVideoAbuses().subscribe( - res => this.videoAbuses = res.videoAbuses, + ) { + this.videoAbusesSource = this.videoAbuseService.getDataSource(); + } - err => this.notificationsService.error('Error', err.text) - ); + buildVideoLink(videoId: string) { + // TODO: transform to routerLink + // https://github.com/akveo/ng2-smart-table/issues/57 + return `${videoId}`; } } -- cgit v1.2.3