X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-main%2Fvideo%2Fvideo-import.service.ts;h=607c08d7142e30f8d406cddfff0c8573947b540a;hb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;hp=a700abacb0c317fce22b82c1bd7fea6b5c9fd4c5;hpb=67ed6552b831df66713bac9e672738796128d33f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.ts index a700abacb..607c08d71 100644 --- a/client/src/app/shared/shared-main/video/video-import.service.ts +++ b/client/src/app/shared/shared-main/video/video-import.service.ts @@ -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> { + getMyVideoImports (pagination: RestPagination, sort: SortMeta, search?: string): Observable> { 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>(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