diff options
Diffstat (limited to 'client/src/app/+admin/users')
-rw-r--r-- | client/src/app/+admin/users/shared/user.service.ts | 31 | ||||
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-update.component.ts | 13 |
2 files changed, 22 insertions, 22 deletions
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts index 6536546fb..578cd98c3 100644 --- a/client/src/app/+admin/users/shared/user.service.ts +++ b/client/src/app/+admin/users/shared/user.service.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
1 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import { BytesPipe } from 'ngx-pipes' | 4 | import { BytesPipe } from 'ngx-pipes' |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | 5 | import { SortMeta } from 'primeng/components/common/sortmeta' |
5 | import 'rxjs/add/operator/catch' | 6 | import { Observable } from 'rxjs' |
6 | import 'rxjs/add/operator/map' | ||
7 | import { Observable } from 'rxjs/Observable' | ||
8 | import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared' | 7 | import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared' |
9 | import { environment } from '../../../../environments/environment' | 8 | import { environment } from '../../../../environments/environment' |
10 | import { RestExtractor, RestPagination, RestService, User } from '../../../shared' | 9 | import { RestExtractor, RestPagination, RestService, User } from '../../../shared' |
@@ -18,23 +17,28 @@ export class UserService { | |||
18 | private authHttp: HttpClient, | 17 | private authHttp: HttpClient, |
19 | private restService: RestService, | 18 | private restService: RestService, |
20 | private restExtractor: RestExtractor | 19 | private restExtractor: RestExtractor |
21 | ) {} | 20 | ) { |
21 | } | ||
22 | 22 | ||
23 | addUser (userCreate: UserCreate) { | 23 | addUser (userCreate: UserCreate) { |
24 | return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) | 24 | return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) |
25 | .map(this.restExtractor.extractDataBool) | 25 | .pipe( |
26 | .catch(err => this.restExtractor.handleError(err)) | 26 | map(this.restExtractor.extractDataBool), |
27 | catchError(err => this.restExtractor.handleError(err)) | ||
28 | ) | ||
27 | } | 29 | } |
28 | 30 | ||
29 | updateUser (userId: number, userUpdate: UserUpdate) { | 31 | updateUser (userId: number, userUpdate: UserUpdate) { |
30 | return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate) | 32 | return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate) |
31 | .map(this.restExtractor.extractDataBool) | 33 | .pipe( |
32 | .catch(err => this.restExtractor.handleError(err)) | 34 | map(this.restExtractor.extractDataBool), |
35 | catchError(err => this.restExtractor.handleError(err)) | ||
36 | ) | ||
33 | } | 37 | } |
34 | 38 | ||
35 | getUser (userId: number) { | 39 | getUser (userId: number) { |
36 | return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId) | 40 | return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId) |
37 | .catch(err => this.restExtractor.handleError(err)) | 41 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
38 | } | 42 | } |
39 | 43 | ||
40 | getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> { | 44 | getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> { |
@@ -42,13 +46,16 @@ export class UserService { | |||
42 | params = this.restService.addRestGetParams(params, pagination, sort) | 46 | params = this.restService.addRestGetParams(params, pagination, sort) |
43 | 47 | ||
44 | return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params }) | 48 | return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params }) |
45 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 49 | .pipe( |
46 | .map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this))) | 50 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
47 | .catch(err => this.restExtractor.handleError(err)) | 51 | map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this))), |
52 | catchError(err => this.restExtractor.handleError(err)) | ||
53 | ) | ||
48 | } | 54 | } |
49 | 55 | ||
50 | removeUser (user: User) { | 56 | removeUser (user: User) { |
51 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) | 57 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) |
58 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
52 | } | 59 | } |
53 | 60 | ||
54 | private formatUser (user: User) { | 61 | private formatUser (user: User) { |
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index 23e44ac1f..3cde07c65 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -1,20 +1,13 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { FormBuilder, FormGroup } from '@angular/forms' | 2 | import { FormBuilder, FormGroup } from '@angular/forms' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { Subscription } from 'rxjs/Subscription' | 4 | import { Subscription } from 'rxjs' |
5 | |||
6 | import { NotificationsService } from 'angular2-notifications' | 5 | import { NotificationsService } from 'angular2-notifications' |
7 | |||
8 | import { UserService } from '../shared' | 6 | import { UserService } from '../shared' |
9 | import { | 7 | import { User, USER_EMAIL, USER_ROLE, USER_VIDEO_QUOTA } from '../../../shared' |
10 | USER_EMAIL, | ||
11 | USER_VIDEO_QUOTA, | ||
12 | USER_ROLE, | ||
13 | User | ||
14 | } from '../../../shared' | ||
15 | import { ServerService } from '../../../core' | 8 | import { ServerService } from '../../../core' |
16 | import { UserEdit } from './user-edit' | 9 | import { UserEdit } from './user-edit' |
17 | import { UserUpdate, UserRole } from '../../../../../../shared' | 10 | import { UserUpdate } from '../../../../../../shared' |
18 | 11 | ||
19 | @Component({ | 12 | @Component({ |
20 | selector: 'my-user-update', | 13 | selector: 'my-user-update', |