aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/friends/friend-add/friend-add.component.ts5
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.html15
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.ts88
-rw-r--r--client/src/app/+admin/friends/shared/friend.service.ts24
-rw-r--r--client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts16
-rw-r--r--client/src/app/+admin/users/shared/user.service.ts56
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.html27
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts91
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html18
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts84
10 files changed, 192 insertions, 232 deletions
diff --git a/client/src/app/+admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
index 0449d26a9..02543d393 100644
--- a/client/src/app/+admin/friends/friend-add/friend-add.component.ts
+++ b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
@@ -93,8 +93,9 @@ export class FriendAddComponent implements OnInit {
93 93
94 this.friendService.makeFriends(notEmptyHosts).subscribe( 94 this.friendService.makeFriends(notEmptyHosts).subscribe(
95 status => { 95 status => {
96 this.notificationsService.success('Sucess', 'Make friends request sent!') 96 this.notificationsService.success('Success', 'Make friends request sent!')
97 this.router.navigate([ '/admin/friends/list' ]) 97 // Wait requests between pods
98 setTimeout(() => this.router.navigate([ '/admin/friends/list' ]), 1000)
98 }, 99 },
99 100
100 err => this.notificationsService.error('Error', err.text) 101 err => this.notificationsService.error('Error', err.text)
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.html b/client/src/app/+admin/friends/friend-list/friend-list.component.html
index 7b9fff304..7887bc5e3 100644
--- a/client/src/app/+admin/friends/friend-list/friend-list.component.html
+++ b/client/src/app/+admin/friends/friend-list/friend-list.component.html
@@ -2,13 +2,24 @@
2 <div class="content-padding"> 2 <div class="content-padding">
3 <h3>Friends list</h3> 3 <h3>Friends list</h3>
4 4
5 <ng2-smart-table [settings]="tableSettings" [source]="friendsSource" (delete)="removeFriend($event)"></ng2-smart-table> 5 <p-dataTable [value]="friends">
6 <p-column field="id" header="ID"></p-column>
7 <p-column field="host" header="Host"></p-column>
8 <p-column field="email" header="Email"></p-column>
9 <p-column field="score" header="Score"></p-column>
10 <p-column field="createdAt" header="Created date"></p-column>
11 <p-column header="Delete" styleClass="action-cell">
12 <ng-template pTemplate="body" let-pod="rowData">
13 <span (click)="removeFriend(pod)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this pod"></span>
14 </ng-template>
15 </p-column>
16 </p-dataTable>
6 17
7 <a *ngIf="hasFriends()" class="btn btn-danger pull-left" (click)="quitFriends()"> 18 <a *ngIf="hasFriends()" class="btn btn-danger pull-left" (click)="quitFriends()">
8 Quit friends 19 Quit friends
9 </a> 20 </a>
10 21
11 <a *ngIf="!hasFriends()" class="btn btn-success pull-right" [routerLink]="['/admin/friends/add']"> 22 <a *ngIf="!hasFriends()" class="btn btn-success pull-right" [routerLink]="[ '/admin/friends/add' ]">
12 Make friends 23 Make friends
13 </a> 24 </a>
14 </div> 25 </div>
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
index 822a112cc..6a8bd492c 100644
--- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts
+++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
@@ -1,71 +1,31 @@
1import { Component } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2 2
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { ServerDataSource } from 'ng2-smart-table'
5 4
6import { ConfirmService } from '../../../core' 5import { ConfirmService } from '../../../core'
7import { Utils } from '../../../shared'
8import { FriendService } from '../shared' 6import { FriendService } from '../shared'
9import { Pod } from '../../../../../../shared' 7import { Pod } from '../../../../../../shared'
10 8
11@Component({ 9@Component({
12 selector: 'my-friend-list', 10 selector: 'my-friend-list',
13 templateUrl: './friend-list.component.html', 11 templateUrl: './friend-list.component.html',
14 styleUrls: [ './friend-list.component.scss' ] 12 styleUrls: ['./friend-list.component.scss']
15}) 13})
16export class FriendListComponent { 14export class FriendListComponent implements OnInit {
17 friendsSource = null 15 friends: Pod[] = []
18 tableSettings = {
19 mode: 'external',
20 attr: {
21 class: 'table-hover'
22 },
23 hideSubHeader: true,
24 actions: {
25 position: 'right',
26 add: false,
27 edit: false,
28 delete: true
29 },
30 delete: {
31 deleteButtonContent: Utils.getRowDeleteButton()
32 },
33 columns: {
34 id: {
35 title: 'ID',
36 sort: false,
37 sortDirection: 'asc'
38 },
39 host: {
40 title: 'Host',
41 sort: false
42 },
43 email: {
44 title: 'Email',
45 sort: false
46 },
47 score: {
48 title: 'Score',
49 sort: false
50 },
51 createdAt: {
52 title: 'Created Date',
53 sort: false,
54 valuePrepareFunction: Utils.dateToHuman
55 }
56 }
57 }
58 16
59 constructor ( 17 constructor (
60 private notificationsService: NotificationsService, 18 private notificationsService: NotificationsService,
61 private confirmService: ConfirmService, 19 private confirmService: ConfirmService,
62 private friendService: FriendService 20 private friendService: FriendService
63 ) { 21 ) {}
64 this.friendsSource = this.friendService.getDataSource() 22
23 ngOnInit () {
24 this.loadData()
65 } 25 }
66 26
67 hasFriends () { 27 hasFriends () {
68 return this.friendsSource.count() !== 0 28 return this.friends.length !== 0
69 } 29 }
70 30
71 quitFriends () { 31 quitFriends () {
@@ -77,32 +37,42 @@ export class FriendListComponent {
77 this.friendService.quitFriends().subscribe( 37 this.friendService.quitFriends().subscribe(
78 status => { 38 status => {
79 this.notificationsService.success('Success', 'Friends left!') 39 this.notificationsService.success('Success', 'Friends left!')
80 this.friendsSource.refresh() 40 this.loadData()
81 }, 41 },
82 42
83 err => this.notificationsService.error('Error', err.text) 43 err => this.notificationsService.error('Error', err)
84 ) 44 )
85 } 45 }
86 ) 46 )
87 } 47 }
88 48
89 removeFriend ({ data }) { 49 removeFriend (friend: Pod) {
90 const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.' 50 const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.'
91 const friend: Pod = data
92 51
93 this.confirmService.confirm(confirmMessage, 'Remove').subscribe( 52 this.confirmService.confirm(confirmMessage, 'Remove').subscribe(
94 res => { 53 res => {
95 if (res === false) return 54 if (res === false) return
96 55
97 this.friendService.removeFriend(friend).subscribe( 56 this.friendService.removeFriend(friend).subscribe(
98 status => { 57 status => {
99 this.notificationsService.success('Success', 'Friend removed') 58 this.notificationsService.success('Success', 'Friend removed')
100 this.friendsSource.refresh() 59 this.loadData()
101 }, 60 },
102 61
103 err => this.notificationsService.error('Error', err.text) 62 err => this.notificationsService.error('Error', err)
104 ) 63 )
105 } 64 }
106 ) 65 )
107 } 66 }
67
68 private loadData () {
69 this.friendService.getFriends()
70 .subscribe(
71 resultList => {
72 this.friends = resultList.data
73 },
74
75 err => this.notificationsService.error('Error', err)
76 )
77 }
108} 78}
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts
index 9b3ff04b1..45607e28d 100644
--- a/client/src/app/+admin/friends/shared/friend.service.ts
+++ b/client/src/app/+admin/friends/shared/friend.service.ts
@@ -1,24 +1,24 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { Observable } from 'rxjs/Observable' 2import { HttpClient } from '@angular/common/http'
3import 'rxjs/add/operator/catch' 3import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map' 4import 'rxjs/add/operator/map'
5 5
6import { ServerDataSource } from 'ng2-smart-table' 6import { RestExtractor, } from '../../../shared'
7 7import { Pod, ResultList } from '../../../../../../shared'
8import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared'
9import { Pod } from '../../../../../../shared'
10 8
11@Injectable() 9@Injectable()
12export class FriendService { 10export class FriendService {
13 private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/' 11 private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/'
14 12
15 constructor ( 13 constructor (
16 private authHttp: AuthHttp, 14 private authHttp: HttpClient,
17 private restExtractor: RestExtractor 15 private restExtractor: RestExtractor
18 ) {} 16 ) {}
19 17
20 getDataSource () { 18 getFriends () {
21 return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL) 19 return this.authHttp.get<ResultList<Pod>>(FriendService.BASE_FRIEND_URL)
20 .map(res => this.restExtractor.convertResultListDateToHuman(res))
21 .catch(res => this.restExtractor.handleError(res))
22 } 22 }
23 23
24 makeFriends (notEmptyHosts: String[]) { 24 makeFriends (notEmptyHosts: String[]) {
@@ -28,18 +28,18 @@ export class FriendService {
28 28
29 return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body) 29 return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body)
30 .map(this.restExtractor.extractDataBool) 30 .map(this.restExtractor.extractDataBool)
31 .catch((res) => this.restExtractor.handleError(res)) 31 .catch(res => this.restExtractor.handleError(res))
32 } 32 }
33 33
34 quitFriends () { 34 quitFriends () {
35 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quit-friends') 35 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quit-friends')
36 .map(res => res.status) 36 .map(this.restExtractor.extractDataBool)
37 .catch((res) => this.restExtractor.handleError(res)) 37 .catch(res => this.restExtractor.handleError(res))
38 } 38 }
39 39
40 removeFriend (friend: Pod) { 40 removeFriend (friend: Pod) {
41 return this.authHttp.delete(FriendService.BASE_FRIEND_URL + friend.id) 41 return this.authHttp.delete(FriendService.BASE_FRIEND_URL + friend.id)
42 .map(this.restExtractor.extractDataBool) 42 .map(this.restExtractor.extractDataBool)
43 .catch((res) => this.restExtractor.handleError(res)) 43 .catch(res => this.restExtractor.handleError(res))
44 } 44 }
45} 45}
diff --git a/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts b/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts
index e9b166f78..44d9cbc3e 100644
--- a/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts
+++ b/client/src/app/+admin/request-schedulers/shared/request-schedulers.service.ts
@@ -1,10 +1,11 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { HttpClient } from '@angular/common/http'
2import { Observable } from 'rxjs/Observable' 3import { Observable } from 'rxjs/Observable'
3import 'rxjs/add/operator/catch' 4import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map' 5import 'rxjs/add/operator/map'
5 6
6import { RequestSchedulerStats } from '../../../../../../shared' 7import { RequestSchedulerStats } from '../../../../../../shared'
7import { AuthHttp, RestExtractor } from '../../../shared' 8import { RestExtractor } from '../../../shared'
8import { RequestSchedulerStatsAttributes } from './request-schedulers-stats-attributes.model' 9import { RequestSchedulerStatsAttributes } from './request-schedulers-stats-attributes.model'
9 10
10@Injectable() 11@Injectable()
@@ -12,19 +13,18 @@ export class RequestSchedulersService {
12 private static BASE_REQUEST_URL = API_URL + '/api/v1/request-schedulers/' 13 private static BASE_REQUEST_URL = API_URL + '/api/v1/request-schedulers/'
13 14
14 constructor ( 15 constructor (
15 private authHttp: AuthHttp, 16 private authHttp: HttpClient,
16 private restExtractor: RestExtractor 17 private restExtractor: RestExtractor
17 ) {} 18 ) {}
18 19
19 getStats (): Observable<RequestSchedulerStats> { 20 getStats () {
20 return this.authHttp.get(RequestSchedulersService.BASE_REQUEST_URL + 'stats') 21 return this.authHttp.get<RequestSchedulerStats>(RequestSchedulersService.BASE_REQUEST_URL + 'stats')
21 .map(this.restExtractor.extractDataGet) 22 .map(res => this.buildRequestObjects(res))
22 .map(this.buildRequestObjects) 23 .catch(res => this.restExtractor.handleError(res))
23 .catch((res) => this.restExtractor.handleError(res))
24 } 24 }
25 25
26 private buildRequestObjects (data: RequestSchedulerStats) { 26 private buildRequestObjects (data: RequestSchedulerStats) {
27 const requestSchedulers = {} 27 const requestSchedulers: { [ id: string ]: RequestSchedulerStatsAttributes } = {}
28 28
29 Object.keys(data).forEach(requestSchedulerName => { 29 Object.keys(data).forEach(requestSchedulerName => {
30 requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName]) 30 requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName])
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts
index 999013bcc..a4b89bf1d 100644
--- a/client/src/app/+admin/users/shared/user.service.ts
+++ b/client/src/app/+admin/users/shared/user.service.ts
@@ -1,11 +1,14 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Observable } from 'rxjs/Observable'
2import 'rxjs/add/operator/catch' 4import 'rxjs/add/operator/catch'
3import 'rxjs/add/operator/map' 5import 'rxjs/add/operator/map'
4 6
7import { SortMeta } from 'primeng/primeng'
5import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe' 8import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'
6 9
7import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' 10import { RestExtractor, User, RestPagination, RestService } from '../../../shared'
8import { UserCreate, UserUpdate } from '../../../../../../shared' 11import { UserCreate, UserUpdate, ResultList } from '../../../../../../shared'
9 12
10@Injectable() 13@Injectable()
11export class UserService { 14export class UserService {
@@ -13,53 +16,52 @@ export class UserService {
13 private bytesPipe = new BytesPipe() 16 private bytesPipe = new BytesPipe()
14 17
15 constructor ( 18 constructor (
16 private authHttp: AuthHttp, 19 private authHttp: HttpClient,
20 private restService: RestService,
17 private restExtractor: RestExtractor 21 private restExtractor: RestExtractor
18 ) {} 22 ) {}
19 23
20 addUser (userCreate: UserCreate) { 24 addUser (userCreate: UserCreate) {
21 return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) 25 return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
22 .map(this.restExtractor.extractDataBool) 26 .map(this.restExtractor.extractDataBool)
23 .catch(this.restExtractor.handleError) 27 .catch(err => this.restExtractor.handleError(err))
24 } 28 }
25 29
26 updateUser (userId: number, userUpdate: UserUpdate) { 30 updateUser (userId: number, userUpdate: UserUpdate) {
27 return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate) 31 return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate)
28 .map(this.restExtractor.extractDataBool) 32 .map(this.restExtractor.extractDataBool)
29 .catch(this.restExtractor.handleError) 33 .catch(err => this.restExtractor.handleError(err))
30 } 34 }
31 35
32 getUser (userId: number) { 36 getUser (userId: number) {
33 return this.authHttp.get(UserService.BASE_USERS_URL + userId) 37 return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId)
34 .map(this.restExtractor.extractDataGet) 38 .catch(err => this.restExtractor.handleError(err))
35 .catch(this.restExtractor.handleError)
36 } 39 }
37 40
38 getDataSource () { 41 getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> {
39 return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL, this.formatDataSource.bind(this)) 42 let params = new HttpParams()
43 params = this.restService.addRestGetParams(params, pagination, sort)
44
45 return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params })
46 .map(res => this.restExtractor.convertResultListDateToHuman(res))
47 .map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this)))
48 .catch(err => this.restExtractor.handleError(err))
40 } 49 }
41 50
42 removeUser (user: User) { 51 removeUser (user: User) {
43 return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) 52 return this.authHttp.delete(UserService.BASE_USERS_URL + user.id)
44 } 53 }
45 54
46 private formatDataSource (users: User[]) { 55 private formatUser (user: User) {
47 const newUsers = [] 56 let videoQuota
57 if (user.videoQuota === -1) {
58 videoQuota = 'Unlimited'
59 } else {
60 videoQuota = this.bytesPipe.transform(user.videoQuota)
61 }
48 62
49 users.forEach(user => { 63 return Object.assign(user, {
50 let videoQuota 64 videoQuota
51 if (user.videoQuota === -1) {
52 videoQuota = 'Unlimited'
53 } else {
54 videoQuota = this.bytesPipe.transform(user.videoQuota)
55 }
56
57 const newUser = Object.assign(user, {
58 videoQuota
59 })
60 newUsers.push(newUser)
61 }) 65 })
62
63 return newUsers
64 } 66 }
65} 67}
diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html
index eb5bc9d4a..2944e3cbf 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.html
+++ b/client/src/app/+admin/users/user-list/user-list.component.html
@@ -3,10 +3,29 @@
3 3
4 <h3>Users list</h3> 4 <h3>Users list</h3>
5 5
6 <ng2-smart-table 6 <p-dataTable
7 [settings]="tableSettings" [source]="usersSource" 7 [value]="users" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
8 (delete)="removeUser($event)" (edit)="editUser($event)" 8 sortField="id" (onLazyLoad)="loadLazy($event)"
9 ></ng2-smart-table> 9 >
10 <p-column field="id" header="ID" [sortable]="true"></p-column>
11 <p-column field="username" header="Username" [sortable]="true"></p-column>
12 <p-column field="email" header="Email"></p-column>
13 <p-column field="videoQuota" header="Video quota"></p-column>
14 <p-column field="role" header="Role"></p-column>
15 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
16 <p-column header="Edit" styleClass="action-cell">
17 <ng-template pTemplate="body" let-user="rowData">
18 <a [routerLink]="getRouterUserEditLink(user)" title="Edit this user">
19 <span class="glyphicon glyphicon-pencil glyphicon-black"></span>
20 </a>
21 </ng-template>
22 </p-column>
23 <p-column header="Delete" styleClass="action-cell">
24 <ng-template pTemplate="body" let-user="rowData">
25 <span (click)="removeUser(user)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this user"></span>
26 </ng-template>
27 </p-column>
28 </p-dataTable>
10 29
11 <a class="add-user btn btn-success pull-right" [routerLink]="['/admin/users/add']"> 30 <a class="add-user btn btn-success pull-right" [routerLink]="['/admin/users/add']">
12 <span class="glyphicon glyphicon-plus"></span> 31 <span class="glyphicon glyphicon-plus"></span>
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts
index 7187a2008..c3fa55825 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/users/user-list/user-list.component.ts
@@ -1,82 +1,37 @@
1import { Component } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { SortMeta } from 'primeng/primeng'
2 3
3import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
4 5
5import { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
6import { RestDataSource, User, Utils } from '../../../shared' 7import { RestTable, RestPagination, User } from '../../../shared'
7import { UserService } from '../shared' 8import { UserService } from '../shared'
8import { Router } from '@angular/router'
9 9
10@Component({ 10@Component({
11 selector: 'my-user-list', 11 selector: 'my-user-list',
12 templateUrl: './user-list.component.html', 12 templateUrl: './user-list.component.html',
13 styleUrls: [ './user-list.component.scss' ] 13 styleUrls: [ './user-list.component.scss' ]
14}) 14})
15export class UserListComponent { 15export class UserListComponent extends RestTable implements OnInit {
16 usersSource: RestDataSource = null 16 users: User[] = []
17 tableSettings = { 17 totalRecords = 0
18 mode: 'external', 18 rowsPerPage = 10
19 attr: { 19 sort: SortMeta = { field: 'id', order: 1 }
20 class: 'table-hover' 20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 },
22 hideSubHeader: true,
23 actions: {
24 position: 'right',
25 add: false,
26 edit: true,
27 delete: true
28 },
29 delete: {
30 deleteButtonContent: Utils.getRowDeleteButton()
31 },
32 edit: {
33 editButtonContent: Utils.getRowEditButton()
34 },
35 pager: {
36 display: true,
37 perPage: 10
38 },
39 columns: {
40 id: {
41 title: 'ID',
42 sortDirection: 'asc'
43 },
44 username: {
45 title: 'Username'
46 },
47 email: {
48 title: 'Email'
49 },
50 videoQuota: {
51 title: 'Video quota'
52 },
53 role: {
54 title: 'Role',
55 sort: false
56 },
57 createdAt: {
58 title: 'Created Date',
59 valuePrepareFunction: Utils.dateToHuman
60 }
61 }
62 }
63 21
64 constructor ( 22 constructor (
65 private router: Router,
66 private notificationsService: NotificationsService, 23 private notificationsService: NotificationsService,
67 private confirmService: ConfirmService, 24 private confirmService: ConfirmService,
68 private userService: UserService 25 private userService: UserService
69 ) { 26 ) {
70 this.usersSource = this.userService.getDataSource() 27 super()
71 } 28 }
72 29
73 editUser ({ data }: { data: User }) { 30 ngOnInit () {
74 this.router.navigate([ '/admin', 'users', data.id, 'update' ]) 31 this.loadData()
75 } 32 }
76 33
77 removeUser ({ data }: { data: User }) { 34 removeUser (user: User) {
78 const user = data
79
80 if (user.username === 'root') { 35 if (user.username === 'root') {
81 this.notificationsService.error('Error', 'You cannot delete root.') 36 this.notificationsService.error('Error', 'You cannot delete root.')
82 return 37 return
@@ -89,12 +44,28 @@ export class UserListComponent {
89 this.userService.removeUser(user).subscribe( 44 this.userService.removeUser(user).subscribe(
90 () => { 45 () => {
91 this.notificationsService.success('Success', `User ${user.username} deleted.`) 46 this.notificationsService.success('Success', `User ${user.username} deleted.`)
92 this.usersSource.refresh() 47 this.loadData()
93 }, 48 },
94 49
95 err => this.notificationsService.error('Error', err.text) 50 err => this.notificationsService.error('Error', err)
96 ) 51 )
97 } 52 }
98 ) 53 )
99 } 54 }
55
56 getRouterUserEditLink (user: User) {
57 return [ '/admin', 'users', user.id, 'update' ]
58 }
59
60 protected loadData () {
61 this.userService.getUsers(this.pagination, this.sort)
62 .subscribe(
63 resultList => {
64 this.users = resultList.data
65 this.totalRecords = resultList.total
66 },
67
68 err => this.notificationsService.error('Error', err)
69 )
70 }
100} 71}
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 @@
3 3
4 <h3>Video abuses list</h3> 4 <h3>Video abuses list</h3>
5 5
6 <ng2-smart-table 6 <p-dataTable
7 [settings]="tableSettings" [source]="videoAbusesSource" 7 [value]="videoAbuses" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
8 ></ng2-smart-table> 8 sortField="id" (onLazyLoad)="loadLazy($event)"
9 >
10 <p-column field="id" header="ID" [sortable]="true"></p-column>
11 <p-column field="reason" header="Reason"></p-column>
12 <p-column field="reporterPodHost" header="Reporter pod host"></p-column>
13 <p-column field="reporterUsername" header="Reporter username"></p-column>
14 <p-column header="Video" styleClass="action-cell">
15 <ng-template pTemplate="body" let-videoAbuse="rowData">
16 <a [routerLink]="getRouterVideoLink(videoAbuse.videoId)" title="Go to the video">{{ videoAbuse.videoId }}</a>
17 </ng-template>
18 </p-column>
19 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
20 </p-dataTable>
9 21
10 </div> 22 </div>
11</div> 23</div>
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}