]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/video/video-import.service.ts
Merge branch 'release/4.3.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / video / video-import.service.ts
index a700abacb0c317fce22b82c1bd7fea6b5c9fd4c5..607c08d7142e30f8d406cddfff0c8573947b540a 100644 (file)
@@ -5,7 +5,8 @@ import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
 import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
 import { objectToFormData } from '@app/helpers'
-import { peertubeTranslate, ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models'
+import { peertubeTranslate } from '@shared/core-utils/i18n'
+import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models'
 import { environment } from '../../../../environments/environment'
 
 @Injectable()
@@ -42,19 +43,41 @@ export class VideoImportService {
                .pipe(catchError(res => this.restExtractor.handleError(res)))
   }
 
-  getMyVideoImports (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoImport>> {
+  getMyVideoImports (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<VideoImport>> {
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination, sort)
 
+    if (search) {
+      const filters = this.restService.parseQueryStringFilter(search, {
+        videoChannelSyncId: {
+          prefix: 'videoChannelSyncId:'
+        },
+        targetUrl: {
+          prefix: 'targetUrl:'
+        }
+      })
+
+      params = this.restService.addObjectParams(params, filters)
+    }
+
     return this.authHttp
                .get<ResultList<VideoImport>>(UserService.BASE_USERS_URL + '/me/videos/imports', { params })
                .pipe(
                  switchMap(res => this.extractVideoImports(res)),
-                 map(res => this.restExtractor.convertResultListDateToHuman(res)),
                  catchError(err => this.restExtractor.handleError(err))
                )
   }
 
+  deleteVideoImport (videoImport: VideoImport) {
+    return this.authHttp.delete(VideoImportService.BASE_VIDEO_IMPORT_URL + videoImport.id)
+                        .pipe(catchError(err => this.restExtractor.handleError(err)))
+  }
+
+  cancelVideoImport (videoImport: VideoImport) {
+    return this.authHttp.post(VideoImportService.BASE_VIDEO_IMPORT_URL + videoImport.id + '/cancel', {})
+                        .pipe(catchError(err => this.restExtractor.handleError(err)))
+  }
+
   private buildImportVideoObject (video: VideoUpdate): VideoImportCreate {
     const language = video.language || null
     const licence = video.licence || null