From 67ed6552b831df66713bac9e672738796128d33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:10:17 +0200 Subject: Reorganize client shared modules --- client/src/app/shared/video-import/index.ts | 1 - .../shared/video-import/video-import.service.ts | 105 --------------------- 2 files changed, 106 deletions(-) delete mode 100644 client/src/app/shared/video-import/index.ts delete mode 100644 client/src/app/shared/video-import/video-import.service.ts (limited to 'client/src/app/shared/video-import') diff --git a/client/src/app/shared/video-import/index.ts b/client/src/app/shared/video-import/index.ts deleted file mode 100644 index 9bb73ec2c..000000000 --- a/client/src/app/shared/video-import/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './video-import.service' diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.ts deleted file mode 100644 index afd9e3fb5..000000000 --- a/client/src/app/shared/video-import/video-import.service.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { catchError, map, switchMap } from 'rxjs/operators' -import { HttpClient, HttpParams } from '@angular/common/http' -import { Injectable } from '@angular/core' -import { Observable } from 'rxjs' -import { peertubeTranslate, VideoImport } from '../../../../../shared' -import { environment } from '../../../environments/environment' -import { RestExtractor, RestService } from '../rest' -import { VideoImportCreate, VideoUpdate } from '../../../../../shared/models/videos' -import { objectToFormData } from '@app/shared/misc/utils' -import { ResultList } from '../../../../../shared/models/result-list.model' -import { UserService } from '@app/shared/users/user.service' -import { SortMeta } from 'primeng/api' -import { RestPagination } from '@app/shared/rest' -import { ServerService } from '@app/core' - -@Injectable() -export class VideoImportService { - private static BASE_VIDEO_IMPORT_URL = environment.apiUrl + '/api/v1/videos/imports/' - - constructor ( - private authHttp: HttpClient, - private restService: RestService, - private restExtractor: RestExtractor, - private serverService: ServerService - ) {} - - importVideoUrl (targetUrl: string, video: VideoUpdate): Observable { - const url = VideoImportService.BASE_VIDEO_IMPORT_URL - - const body = this.buildImportVideoObject(video) - body.targetUrl = targetUrl - - const data = objectToFormData(body) - return this.authHttp.post(url, data) - .pipe(catchError(res => this.restExtractor.handleError(res))) - } - - importVideoTorrent (target: string | Blob, video: VideoUpdate): Observable { - const url = VideoImportService.BASE_VIDEO_IMPORT_URL - const body: VideoImportCreate = this.buildImportVideoObject(video) - - if (typeof target === 'string') body.magnetUri = target - else body.torrentfile = target - - const data = objectToFormData(body) - return this.authHttp.post(url, data) - .pipe(catchError(res => this.restExtractor.handleError(res))) - } - - getMyVideoImports (pagination: RestPagination, sort: SortMeta): Observable> { - let params = new HttpParams() - params = this.restService.addRestGetParams(params, pagination, sort) - - 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)) - ) - } - - private buildImportVideoObject (video: VideoUpdate): VideoImportCreate { - const language = video.language || null - const licence = video.licence || null - const category = video.category || null - const description = video.description || null - const support = video.support || null - const scheduleUpdate = video.scheduleUpdate || null - const originallyPublishedAt = video.originallyPublishedAt || null - - return { - name: video.name, - category, - licence, - language, - support, - description, - channelId: video.channelId, - privacy: video.privacy, - tags: video.tags, - nsfw: video.nsfw, - waitTranscoding: video.waitTranscoding, - commentsEnabled: video.commentsEnabled, - downloadEnabled: video.downloadEnabled, - thumbnailfile: video.thumbnailfile, - previewfile: video.previewfile, - scheduleUpdate, - originallyPublishedAt - } - } - - private extractVideoImports (result: ResultList): Observable> { - return this.serverService.getServerLocale() - .pipe( - map(translations => { - result.data.forEach(d => - d.state.label = peertubeTranslate(d.state.label, translations) - ) - - return result - }) - ) - } -} -- cgit v1.2.3