aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/shared')
-rw-r--r--client/src/app/videos/shared/video.service.ts32
1 files changed, 1 insertions, 31 deletions
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index cfce4cb16..037c20416 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -14,7 +14,6 @@ import {
14import { Video } from './video.model' 14import { Video } from './video.model'
15import { VideoPagination } from './video-pagination.model' 15import { VideoPagination } from './video-pagination.model'
16import { 16import {
17 VideoCreate,
18 UserVideoRate, 17 UserVideoRate,
19 VideoRateType, 18 VideoRateType,
20 VideoUpdate, 19 VideoUpdate,
@@ -28,28 +27,12 @@ import {
28export class VideoService { 27export class VideoService {
29 private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/' 28 private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/'
30 29
31 videoCategories: Array<{ id: number, label: string }> = []
32 videoLicences: Array<{ id: number, label: string }> = []
33 videoLanguages: Array<{ id: number, label: string }> = []
34
35 constructor ( 30 constructor (
36 private authHttp: HttpClient, 31 private authHttp: HttpClient,
37 private restExtractor: RestExtractor, 32 private restExtractor: RestExtractor,
38 private restService: RestService 33 private restService: RestService
39 ) {} 34 ) {}
40 35
41 loadVideoCategories () {
42 return this.loadVideoAttributeEnum('categories', this.videoCategories)
43 }
44
45 loadVideoLicences () {
46 return this.loadVideoAttributeEnum('licences', this.videoLicences)
47 }
48
49 loadVideoLanguages () {
50 return this.loadVideoAttributeEnum('languages', this.videoLanguages)
51 }
52
53 getVideo (uuid: string) { 36 getVideo (uuid: string) {
54 return this.authHttp.get<VideoServerModel>(VideoService.BASE_VIDEO_URL + uuid) 37 return this.authHttp.get<VideoServerModel>(VideoService.BASE_VIDEO_URL + uuid)
55 .map(videoHash => new Video(videoHash)) 38 .map(videoHash => new Video(videoHash))
@@ -74,8 +57,7 @@ export class VideoService {
74 .catch(this.restExtractor.handleError) 57 .catch(this.restExtractor.handleError)
75 } 58 }
76 59
77 // uploadVideo (video: VideoCreate) { 60 uploadVideo (video: FormData) {
78 uploadVideo (video: any) {
79 const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true }) 61 const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true })
80 62
81 return this.authHttp.request(req) 63 return this.authHttp.request(req)
@@ -175,16 +157,4 @@ export class VideoService {
175 157
176 return { videos, totalVideos } 158 return { videos, totalVideos }
177 } 159 }
178
179 private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) {
180 return this.authHttp.get(VideoService.BASE_VIDEO_URL + attributeName)
181 .subscribe(data => {
182 Object.keys(data).forEach(dataKey => {
183 hashToPopulate.push({
184 id: parseInt(dataKey, 10),
185 label: data[dataKey]
186 })
187 })
188 })
189 }
190} 160}