diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-15 11:55:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-16 09:42:54 +0200 |
commit | db400f447a9f7aae1c56fa25396e93069744483f (patch) | |
tree | f45af832a5d3f4eebafd2f885b7413d9f84fa374 /client/src/app/+admin | |
parent | 54c3a22faa04bf13eea37f39be9149fc5eb95737 (diff) | |
download | PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.gz PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.zst PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.zip |
Upgrade to rxjs 6
Diffstat (limited to 'client/src/app/+admin')
5 files changed, 53 insertions, 43 deletions
diff --git a/client/src/app/+admin/config/shared/config.service.ts b/client/src/app/+admin/config/shared/config.service.ts index 2a39c7155..1565774b3 100644 --- a/client/src/app/+admin/config/shared/config.service.ts +++ b/client/src/app/+admin/config/shared/config.service.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { catchError } from 'rxjs/operators' | ||
1 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' | 4 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' |
@@ -16,11 +17,11 @@ export class ConfigService { | |||
16 | 17 | ||
17 | getCustomConfig () { | 18 | getCustomConfig () { |
18 | return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom') | 19 | return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom') |
19 | .catch(res => this.restExtractor.handleError(res)) | 20 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
20 | } | 21 | } |
21 | 22 | ||
22 | updateCustomConfig (data: CustomConfig) { | 23 | updateCustomConfig (data: CustomConfig) { |
23 | return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data) | 24 | return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data) |
24 | .catch(res => this.restExtractor.handleError(res)) | 25 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
25 | } | 26 | } |
26 | } | 27 | } |
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts index 089be9d64..5897e64ca 100644 --- a/client/src/app/+admin/follows/shared/follow.service.ts +++ b/client/src/app/+admin/follows/shared/follow.service.ts | |||
@@ -1,9 +1,8 @@ | |||
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 { SortMeta } from 'primeng/primeng' | 4 | import { SortMeta } from 'primeng/primeng' |
4 | import 'rxjs/add/operator/catch' | 5 | import { Observable } from 'rxjs' |
5 | import 'rxjs/add/operator/map' | ||
6 | import { Observable } from 'rxjs/Observable' | ||
7 | import { AccountFollow, ResultList } from '../../../../../../shared' | 6 | import { AccountFollow, ResultList } from '../../../../../../shared' |
8 | import { environment } from '../../../../environments/environment' | 7 | import { environment } from '../../../../environments/environment' |
9 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | 8 | import { RestExtractor, RestPagination, RestService } from '../../../shared' |
@@ -16,24 +15,29 @@ export class FollowService { | |||
16 | private authHttp: HttpClient, | 15 | private authHttp: HttpClient, |
17 | private restService: RestService, | 16 | private restService: RestService, |
18 | private restExtractor: RestExtractor | 17 | private restExtractor: RestExtractor |
19 | ) {} | 18 | ) { |
19 | } | ||
20 | 20 | ||
21 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { | 21 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { |
22 | let params = new HttpParams() | 22 | let params = new HttpParams() |
23 | params = this.restService.addRestGetParams(params, pagination, sort) | 23 | params = this.restService.addRestGetParams(params, pagination, sort) |
24 | 24 | ||
25 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) | 25 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) |
26 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 26 | .pipe( |
27 | .catch(res => this.restExtractor.handleError(res)) | 27 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
28 | catchError(res => this.restExtractor.handleError(res)) | ||
29 | ) | ||
28 | } | 30 | } |
29 | 31 | ||
30 | getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { | 32 | getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { |
31 | let params = new HttpParams() | 33 | let params = new HttpParams() |
32 | params = this.restService.addRestGetParams(params, pagination, sort) | 34 | params = this.restService.addRestGetParams(params, pagination, sort) |
33 | 35 | ||
34 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) | 36 | return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) |
35 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 37 | .pipe( |
36 | .catch(res => this.restExtractor.handleError(res)) | 38 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
39 | catchError(res => this.restExtractor.handleError(res)) | ||
40 | ) | ||
37 | } | 41 | } |
38 | 42 | ||
39 | follow (notEmptyHosts: string[]) { | 43 | follow (notEmptyHosts: string[]) { |
@@ -42,13 +46,17 @@ export class FollowService { | |||
42 | } | 46 | } |
43 | 47 | ||
44 | return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body) | 48 | return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body) |
45 | .map(this.restExtractor.extractDataBool) | 49 | .pipe( |
46 | .catch(res => this.restExtractor.handleError(res)) | 50 | map(this.restExtractor.extractDataBool), |
51 | catchError(res => this.restExtractor.handleError(res)) | ||
52 | ) | ||
47 | } | 53 | } |
48 | 54 | ||
49 | unfollow (follow: AccountFollow) { | 55 | unfollow (follow: AccountFollow) { |
50 | return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) | 56 | return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) |
51 | .map(this.restExtractor.extractDataBool) | 57 | .pipe( |
52 | .catch(res => this.restExtractor.handleError(res)) | 58 | map(this.restExtractor.extractDataBool), |
59 | catchError(res => this.restExtractor.handleError(res)) | ||
60 | ) | ||
53 | } | 61 | } |
54 | } | 62 | } |
diff --git a/client/src/app/+admin/jobs/shared/job.service.ts b/client/src/app/+admin/jobs/shared/job.service.ts index 98f29b742..6441eaac1 100644 --- a/client/src/app/+admin/jobs/shared/job.service.ts +++ b/client/src/app/+admin/jobs/shared/job.service.ts | |||
@@ -1,9 +1,8 @@ | |||
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 { SortMeta } from 'primeng/primeng' | 4 | import { SortMeta } from 'primeng/primeng' |
4 | import 'rxjs/add/operator/catch' | 5 | import { Observable } from 'rxjs' |
5 | import 'rxjs/add/operator/map' | ||
6 | import { Observable } from 'rxjs/Observable' | ||
7 | import { ResultList } from '../../../../../../shared' | 6 | import { ResultList } from '../../../../../../shared' |
8 | import { JobState } from '../../../../../../shared/models' | 7 | import { JobState } from '../../../../../../shared/models' |
9 | import { Job } from '../../../../../../shared/models/server/job.model' | 8 | import { Job } from '../../../../../../shared/models/server/job.model' |
@@ -25,9 +24,11 @@ export class JobService { | |||
25 | params = this.restService.addRestGetParams(params, pagination, sort) | 24 | params = this.restService.addRestGetParams(params, pagination, sort) |
26 | 25 | ||
27 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params }) | 26 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params }) |
28 | .map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ])) | 27 | .pipe( |
29 | .map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)) | 28 | map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ])), |
30 | .catch(err => this.restExtractor.handleError(err)) | 29 | map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)), |
30 | catchError(err => this.restExtractor.handleError(err)) | ||
31 | ) | ||
31 | } | 32 | } |
32 | 33 | ||
33 | private prettyPrintData (obj: Job) { | 34 | private prettyPrintData (obj: Job) { |
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', |