aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-08 15:15:11 +0200
committerChocobozzz <me@florianbigard.com>2018-10-08 15:55:32 +0200
commit791645e620fb98c6e7c32271d91d91ff7e41b892 (patch)
treeb9554ae53c93c1e699d8cc2e137128e599a4c045 /client/src/app/shared/users
parent80c7336a896d9eb1e71b7c89a72285f914259457 (diff)
downloadPeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.tar.gz
PeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.tar.zst
PeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.zip
Add bulk actions in users table
Diffstat (limited to 'client/src/app/shared/users')
-rw-r--r--client/src/app/shared/users/user.service.ts39
1 files changed, 28 insertions, 11 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index d9b81c181..0eb3870b0 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -1,5 +1,5 @@
1import { Observable } from 'rxjs' 1import { from, Observable } from 'rxjs'
2import { catchError, map } from 'rxjs/operators' 2import { catchError, concatMap, map, toArray } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { ResultList, User, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' 5import { ResultList, User, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
@@ -170,21 +170,38 @@ export class UserService {
170 ) 170 )
171 } 171 }
172 172
173 removeUser (user: { id: number }) { 173 removeUser (usersArg: User | User[]) {
174 return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) 174 const users = Array.isArray(usersArg) ? usersArg : [ usersArg ]
175 .pipe(catchError(err => this.restExtractor.handleError(err))) 175
176 return from(users)
177 .pipe(
178 concatMap(u => this.authHttp.delete(UserService.BASE_USERS_URL + u.id)),
179 toArray(),
180 catchError(err => this.restExtractor.handleError(err))
181 )
176 } 182 }
177 183
178 banUser (user: { id: number }, reason?: string) { 184 banUsers (usersArg: User | User[], reason?: string) {
179 const body = reason ? { reason } : {} 185 const body = reason ? { reason } : {}
186 const users = Array.isArray(usersArg) ? usersArg : [ usersArg ]
180 187
181 return this.authHttp.post(UserService.BASE_USERS_URL + user.id + '/block', body) 188 return from(users)
182 .pipe(catchError(err => this.restExtractor.handleError(err))) 189 .pipe(
190 concatMap(u => this.authHttp.post(UserService.BASE_USERS_URL + u.id + '/block', body)),
191 toArray(),
192 catchError(err => this.restExtractor.handleError(err))
193 )
183 } 194 }
184 195
185 unbanUser (user: { id: number }) { 196 unbanUsers (usersArg: User | User[]) {
186 return this.authHttp.post(UserService.BASE_USERS_URL + user.id + '/unblock', {}) 197 const users = Array.isArray(usersArg) ? usersArg : [ usersArg ]
187 .pipe(catchError(err => this.restExtractor.handleError(err))) 198
199 return from(users)
200 .pipe(
201 concatMap(u => this.authHttp.post(UserService.BASE_USERS_URL + u.id + '/unblock', {})),
202 toArray(),
203 catchError(err => this.restExtractor.handleError(err))
204 )
188 } 205 }
189 206
190 private formatUser (user: User) { 207 private formatUser (user: User) {