diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/shared.module.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/video-import/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/video-import/video-import.service.ts | 56 | ||||
-rw-r--r-- | client/src/app/shared/video/video-edit.model.ts | 40 |
4 files changed, 79 insertions, 20 deletions
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 99df61cdb..62ce97102 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -51,6 +51,7 @@ import { ScreenService } from '@app/shared/misc/screen.service' | |||
51 | import { VideoCaptionsValidatorsService } from '@app/shared/forms/form-validators/video-captions-validators.service' | 51 | import { VideoCaptionsValidatorsService } from '@app/shared/forms/form-validators/video-captions-validators.service' |
52 | import { VideoCaptionService } from '@app/shared/video-caption' | 52 | import { VideoCaptionService } from '@app/shared/video-caption' |
53 | import { PeertubeCheckboxComponent } from '@app/shared/forms/peertube-checkbox.component' | 53 | import { PeertubeCheckboxComponent } from '@app/shared/forms/peertube-checkbox.component' |
54 | import { VideoImportService } from '@app/shared/video-import/video-import.service' | ||
54 | 55 | ||
55 | @NgModule({ | 56 | @NgModule({ |
56 | imports: [ | 57 | imports: [ |
@@ -143,6 +144,7 @@ import { PeertubeCheckboxComponent } from '@app/shared/forms/peertube-checkbox.c | |||
143 | VideoCommentValidatorsService, | 144 | VideoCommentValidatorsService, |
144 | VideoValidatorsService, | 145 | VideoValidatorsService, |
145 | VideoCaptionsValidatorsService, | 146 | VideoCaptionsValidatorsService, |
147 | VideoImportService, | ||
146 | 148 | ||
147 | I18nPrimengCalendarService, | 149 | I18nPrimengCalendarService, |
148 | ScreenService, | 150 | ScreenService, |
diff --git a/client/src/app/shared/video-import/index.ts b/client/src/app/shared/video-import/index.ts new file mode 100644 index 000000000..9bb73ec2c --- /dev/null +++ b/client/src/app/shared/video-import/index.ts | |||
@@ -0,0 +1 @@ | |||
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 new file mode 100644 index 000000000..b4709866a --- /dev/null +++ b/client/src/app/shared/video-import/video-import.service.ts | |||
@@ -0,0 +1,56 @@ | |||
1 | import { catchError } from 'rxjs/operators' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { Observable } from 'rxjs' | ||
5 | import { VideoImport } from '../../../../../shared' | ||
6 | import { environment } from '../../../environments/environment' | ||
7 | import { RestExtractor, RestService } from '../rest' | ||
8 | import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' | ||
9 | import { objectToFormData } from '@app/shared/misc/utils' | ||
10 | import { VideoUpdate } from '../../../../../shared/models/videos' | ||
11 | |||
12 | @Injectable() | ||
13 | export class VideoImportService { | ||
14 | private static BASE_VIDEO_IMPORT_URL = environment.apiUrl + '/api/v1/videos/imports/' | ||
15 | |||
16 | constructor ( | ||
17 | private authHttp: HttpClient, | ||
18 | private restService: RestService, | ||
19 | private restExtractor: RestExtractor | ||
20 | ) {} | ||
21 | |||
22 | importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> { | ||
23 | const url = VideoImportService.BASE_VIDEO_IMPORT_URL | ||
24 | const language = video.language || null | ||
25 | const licence = video.licence || null | ||
26 | const category = video.category || null | ||
27 | const description = video.description || null | ||
28 | const support = video.support || null | ||
29 | const scheduleUpdate = video.scheduleUpdate || null | ||
30 | |||
31 | const body: VideoImportCreate = { | ||
32 | targetUrl, | ||
33 | |||
34 | name: video.name, | ||
35 | category, | ||
36 | licence, | ||
37 | language, | ||
38 | support, | ||
39 | description, | ||
40 | channelId: video.channelId, | ||
41 | privacy: video.privacy, | ||
42 | tags: video.tags, | ||
43 | nsfw: video.nsfw, | ||
44 | waitTranscoding: video.waitTranscoding, | ||
45 | commentsEnabled: video.commentsEnabled, | ||
46 | thumbnailfile: video.thumbnailfile, | ||
47 | previewfile: video.previewfile, | ||
48 | scheduleUpdate | ||
49 | } | ||
50 | |||
51 | const data = objectToFormData(body) | ||
52 | return this.authHttp.post<VideoImport>(url, data) | ||
53 | .pipe(catchError(res => this.restExtractor.handleError(res))) | ||
54 | } | ||
55 | |||
56 | } | ||
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index 8562f8d25..0046be964 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { VideoDetails } from './video-details.model' | ||
2 | import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum' | 1 | import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum' |
3 | import { VideoUpdate } from '../../../../../shared/models/videos' | 2 | import { VideoUpdate } from '../../../../../shared/models/videos' |
4 | import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model' | 3 | import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model' |
4 | import { Video } from '../../../../../shared/models/videos/video.model' | ||
5 | 5 | ||
6 | export class VideoEdit implements VideoUpdate { | 6 | export class VideoEdit implements VideoUpdate { |
7 | static readonly SPECIAL_SCHEDULED_PRIVACY = -1 | 7 | static readonly SPECIAL_SCHEDULED_PRIVACY = -1 |
@@ -26,26 +26,26 @@ export class VideoEdit implements VideoUpdate { | |||
26 | id?: number | 26 | id?: number |
27 | scheduleUpdate?: VideoScheduleUpdate | 27 | scheduleUpdate?: VideoScheduleUpdate |
28 | 28 | ||
29 | constructor (videoDetails?: VideoDetails) { | 29 | constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { |
30 | if (videoDetails) { | 30 | if (video) { |
31 | this.id = videoDetails.id | 31 | this.id = video.id |
32 | this.uuid = videoDetails.uuid | 32 | this.uuid = video.uuid |
33 | this.category = videoDetails.category.id | 33 | this.category = video.category.id |
34 | this.licence = videoDetails.licence.id | 34 | this.licence = video.licence.id |
35 | this.language = videoDetails.language.id | 35 | this.language = video.language.id |
36 | this.description = videoDetails.description | 36 | this.description = video.description |
37 | this.name = videoDetails.name | 37 | this.name = video.name |
38 | this.tags = videoDetails.tags | 38 | this.tags = video.tags |
39 | this.nsfw = videoDetails.nsfw | 39 | this.nsfw = video.nsfw |
40 | this.commentsEnabled = videoDetails.commentsEnabled | 40 | this.commentsEnabled = video.commentsEnabled |
41 | this.waitTranscoding = videoDetails.waitTranscoding | 41 | this.waitTranscoding = video.waitTranscoding |
42 | this.channelId = videoDetails.channel.id | 42 | this.channelId = video.channel.id |
43 | this.privacy = videoDetails.privacy.id | 43 | this.privacy = video.privacy.id |
44 | this.support = videoDetails.support | 44 | this.support = video.support |
45 | this.thumbnailUrl = videoDetails.thumbnailUrl | 45 | this.thumbnailUrl = video.thumbnailUrl |
46 | this.previewUrl = videoDetails.previewUrl | 46 | this.previewUrl = video.previewUrl |
47 | 47 | ||
48 | this.scheduleUpdate = videoDetails.scheduledUpdate | 48 | this.scheduleUpdate = video.scheduledUpdate |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||