From db216afd980846c418a4ebab8190c3ead561dfc1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Apr 2017 14:57:05 +0200 Subject: [PATCH] Client: support video language --- client/src/app/app.component.ts | 1 + .../src/app/shared/forms/form-validators/video.ts | 5 +++++ client/src/app/videos/shared/video.model.ts | 3 +++ client/src/app/videos/shared/video.service.ts | 14 ++++++++++++++ .../app/videos/video-add/video-add.component.html | 12 ++++++++++++ .../app/videos/video-add/video-add.component.ts | 13 +++++++++++++ .../videos/video-watch/video-watch.component.html | 7 +++++++ .../videos/video-watch/video-watch.component.scss | 2 +- 8 files changed, 56 insertions(+), 1 deletion(-) diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 3c06b320e..c29790d96 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -42,6 +42,7 @@ export class AppComponent implements OnInit { this.configService.loadConfig(); this.videoService.loadVideoCategories(); this.videoService.loadVideoLicences(); + this.videoService.loadVideoLanguages(); } isInAdmin() { diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index 50d7304b5..293fd805f 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts @@ -23,6 +23,11 @@ export const VIDEO_LICENCE = { } }; +export const VIDEO_LANGUAGE = { + VALIDATORS: [ ], + MESSAGES: {} +}; + export const VIDEO_DESCRIPTION = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ], MESSAGES: { diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 3c588c446..f135ca707 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -6,6 +6,7 @@ export class Video { createdAt: Date; categoryLabel: string; licenceLabel: string; + languageLabel: string; description: string; duration: string; id: string; @@ -38,6 +39,7 @@ export class Video { createdAt: string, categoryLabel: string, licenceLabel: string, + languageLabel: string; description: string, duration: number; id: string, @@ -56,6 +58,7 @@ export class Video { this.createdAt = new Date(hash.createdAt); this.categoryLabel = hash.categoryLabel; this.licenceLabel = hash.licenceLabel; + this.languageLabel = hash.languageLabel; this.description = hash.description; this.duration = Video.createDurationString(hash.duration); this.id = hash.id; diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index 15f017e33..13d4ca246 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -24,6 +24,7 @@ export class VideoService { videoCategories: Array<{ id: number, label: string }> = []; videoLicences: Array<{ id: number, label: string }> = []; + videoLanguages: Array<{ id: number, label: string }> = []; constructor( private authService: AuthService, @@ -59,6 +60,19 @@ export class VideoService { }); } + loadVideoLanguages() { + return this.http.get(VideoService.BASE_VIDEO_URL + 'languages') + .map(this.restExtractor.extractDataGet) + .subscribe(data => { + Object.keys(data).forEach(languageKey => { + this.videoLanguages.push({ + id: parseInt(languageKey), + label: data[languageKey] + }); + }); + }); + } + getVideo(id: string): Observable