From d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Sep 2017 11:57:49 +0200 Subject: Move to HttpClient and PrimeNG data table --- .../video-abuse-list.component.html | 18 ++++- .../video-abuse-list/video-abuse-list.component.ts | 84 ++++++++-------------- 2 files changed, 44 insertions(+), 58 deletions(-) (limited to 'client/src/app/+admin/video-abuses') 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 c6723a734..e73f38112 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 @@ -3,9 +3,21 @@

Video abuses list

- + + + + + + + + {{ videoAbuse.videoId }} + + + + 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 @@ -import { Component } from '@angular/core' +import { Component, OnInit } from '@angular/core' import { NotificationsService } from 'angular2-notifications' +import { SortMeta } from 'primeng/primeng' -import { Utils, VideoAbuseService } from '../../../shared' -import { VideoAbuse } from '../../../../../shared' +import { RestTable, RestPagination, VideoAbuseService } from '../../../shared' +import { 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 - } - } - } +export class VideoAbuseListComponent extends RestTable implements OnInit { + videoAbuses: VideoAbuse[] = [] + totalRecords = 0 + rowsPerPage = 1 + sort: SortMeta = { field: 'id', order: 1 } + pagination: RestPagination = { count: this.rowsPerPage, start: 0 } constructor ( private notificationsService: NotificationsService, private videoAbuseService: VideoAbuseService ) { - this.videoAbusesSource = this.videoAbuseService.getDataSource() + super() + } + + ngOnInit () { + this.loadData() } - buildVideoLink (videoId: string) { - // TODO: transform to routerLink - // https://github.com/akveo/ng2-smart-table/issues/57 - return `${videoId}` + getRouterVideoLink (videoId: number) { + return [ '/videos', videoId ] + } + + protected loadData () { + return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort) + .subscribe( + resultList => { + this.videoAbuses = resultList.data + this.totalRecords = resultList.total + }, + + err => this.notificationsService.error('Error', err) + ) } } -- cgit v1.2.3