]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/video-abuse/video-abuse.service.ts
Only use account name in routes
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video-abuse / video-abuse.service.ts
index 98458111415c52d7676b7f728fd26f1fc6a75e68..6fab3ef43e32456ba86facaf02e1413644b6b660 100644 (file)
@@ -1,19 +1,15 @@
-import { Injectable } from '@angular/core'
+import { catchError, map } from 'rxjs/operators'
 import { HttpClient, HttpParams } from '@angular/common/http'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
-
-import { SortMeta } from 'primeng/primeng'
-
-import { AuthService } from '../core'
-import { RestExtractor, RestPagination, RestService } from '../rest'
-import { Utils } from '../utils'
+import { Injectable } from '@angular/core'
+import { SortMeta } from 'primeng/components/common/sortmeta'
+import { Observable } from 'rxjs'
 import { ResultList, VideoAbuse } from '../../../../../shared'
+import { environment } from '../../../environments/environment'
+import { RestExtractor, RestPagination, RestService } from '../rest'
 
 @Injectable()
 export class VideoAbuseService {
-  private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/'
+  private static BASE_VIDEO_ABUSE_URL = environment.apiUrl + '/api/v1/videos/'
 
   constructor (
     private authHttp: HttpClient,
@@ -28,9 +24,10 @@ export class VideoAbuseService {
     params = this.restService.addRestGetParams(params, pagination, sort)
 
     return this.authHttp.get<ResultList<VideoAbuse>>(url, { params })
-                        .map(res => this.restExtractor.convertResultListDateToHuman(res))
-                        .map(res => this.restExtractor.applyToResultListData(res, this.formatVideoAbuse.bind(this)))
-                        .catch(res => this.restExtractor.handleError(res))
+               .pipe(
+                 map(res => this.restExtractor.convertResultListDateToHuman(res)),
+                 catchError(res => this.restExtractor.handleError(res))
+               )
   }
 
   reportVideo (id: number, reason: string) {
@@ -40,14 +37,9 @@ export class VideoAbuseService {
     }
 
     return this.authHttp.post(url, body)
-                        .map(this.restExtractor.extractDataBool)
-                        .catch(res => this.restExtractor.handleError(res))
-  }
-
-  private formatVideoAbuse (videoAbuse: VideoAbuse) {
-    return Object.assign(videoAbuse, {
-      createdAt: Utils.dateToHuman(videoAbuse.createdAt)
-    })
+               .pipe(
+                 map(this.restExtractor.extractDataBool),
+                 catchError(res => this.restExtractor.handleError(res))
+               )
   }
-
 }