aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-19 09:43:01 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-19 09:43:01 +0200
commit8a02bd0433b7101c5ea36e87a4edb63204d2adec (patch)
treed7ab4b6164aef752c216bd2f22f8b3b270a724b8 /client/src/app/+admin
parent9fd540562c356cb54b98861d2d9e7d4fbfcd00e0 (diff)
downloadPeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.tar.gz
PeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.tar.zst
PeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.zip
Add pod list endpoint with pagination, sort...
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.html13
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.ts19
-rw-r--r--client/src/app/+admin/friends/shared/friend.service.ts15
3 files changed, 33 insertions, 14 deletions
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 7887bc5e3..7e92ced54 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,12 +2,15 @@
2 <div class="content-padding"> 2 <div class="content-padding">
3 <h3>Friends list</h3> 3 <h3>Friends list</h3>
4 4
5 <p-dataTable [value]="friends"> 5 <p-dataTable
6 <p-column field="id" header="ID"></p-column> 6 [value]="friends" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
7 <p-column field="host" header="Host"></p-column> 7 sortField="id" (onLazyLoad)="loadLazy($event)"
8 >
9 <p-column field="id" header="ID" [sortable]="true"></p-column>
10 <p-column field="host" header="Host" [sortable]="true"></p-column>
8 <p-column field="email" header="Email"></p-column> 11 <p-column field="email" header="Email"></p-column>
9 <p-column field="score" header="Score"></p-column> 12 <p-column field="score" header="Score" [sortable]="true"></p-column>
10 <p-column field="createdAt" header="Created date"></p-column> 13 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
11 <p-column header="Delete" styleClass="action-cell"> 14 <p-column header="Delete" styleClass="action-cell">
12 <ng-template pTemplate="body" let-pod="rowData"> 15 <ng-template pTemplate="body" let-pod="rowData">
13 <span (click)="removeFriend(pod)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this pod"></span> 16 <span (click)="removeFriend(pod)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this pod"></span>
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 4af39c47e..5a1ecd280 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,24 +1,32 @@
1import { Component, OnInit } 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 { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
6import { FriendService } from '../shared' 7import { RestTable, RestPagination } from '../../../shared'
7import { Pod } from '../../../../../../shared' 8import { Pod } from '../../../../../../shared'
9import { FriendService } from '../shared'
8 10
9@Component({ 11@Component({
10 selector: 'my-friend-list', 12 selector: 'my-friend-list',
11 templateUrl: './friend-list.component.html', 13 templateUrl: './friend-list.component.html',
12 styleUrls: ['./friend-list.component.scss'] 14 styleUrls: ['./friend-list.component.scss']
13}) 15})
14export class FriendListComponent implements OnInit { 16export class FriendListComponent extends RestTable implements OnInit {
15 friends: Pod[] = [] 17 friends: Pod[] = []
18 totalRecords = 0
19 rowsPerPage = 10
20 sort: SortMeta = { field: 'id', order: 1 }
21 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
16 22
17 constructor ( 23 constructor (
18 private notificationsService: NotificationsService, 24 private notificationsService: NotificationsService,
19 private confirmService: ConfirmService, 25 private confirmService: ConfirmService,
20 private friendService: FriendService 26 private friendService: FriendService
21 ) {} 27 ) {
28 super()
29 }
22 30
23 ngOnInit () { 31 ngOnInit () {
24 this.loadData() 32 this.loadData()
@@ -65,11 +73,12 @@ export class FriendListComponent implements OnInit {
65 ) 73 )
66 } 74 }
67 75
68 private loadData () { 76 protected loadData () {
69 this.friendService.getFriends() 77 this.friendService.getFriends(this.pagination, this.sort)
70 .subscribe( 78 .subscribe(
71 resultList => { 79 resultList => {
72 this.friends = resultList.data 80 this.friends = resultList.data
81 this.totalRecords = resultList.total
73 }, 82 },
74 83
75 err => this.notificationsService.error('Error', err.message) 84 err => this.notificationsService.error('Error', err.message)
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts
index 274373e3b..a32cdcc88 100644
--- a/client/src/app/+admin/friends/shared/friend.service.ts
+++ b/client/src/app/+admin/friends/shared/friend.service.ts
@@ -1,9 +1,12 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient, HttpParams } from '@angular/common/http'
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 { RestExtractor } from '../../../shared' 7import { SortMeta } from 'primeng/primeng'
8
9import { RestExtractor, RestPagination, RestService } from '../../../shared'
7import { Pod, ResultList } from '../../../../../../shared' 10import { Pod, ResultList } from '../../../../../../shared'
8 11
9@Injectable() 12@Injectable()
@@ -12,11 +15,15 @@ export class FriendService {
12 15
13 constructor ( 16 constructor (
14 private authHttp: HttpClient, 17 private authHttp: HttpClient,
18 private restService: RestService,
15 private restExtractor: RestExtractor 19 private restExtractor: RestExtractor
16 ) {} 20 ) {}
17 21
18 getFriends () { 22 getFriends (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> {
19 return this.authHttp.get<ResultList<Pod>>(FriendService.BASE_FRIEND_URL) 23 let params = new HttpParams()
24 params = this.restService.addRestGetParams(params, pagination, sort)
25
26 return this.authHttp.get<ResultList<Pod>>(FriendService.BASE_FRIEND_URL, { params })
20 .map(res => this.restExtractor.convertResultListDateToHuman(res)) 27 .map(res => this.restExtractor.convertResultListDateToHuman(res))
21 .catch(res => this.restExtractor.handleError(res)) 28 .catch(res => this.restExtractor.handleError(res))
22 } 29 }