From d07137b90b2b2b0c1e93a6f0e7bf8719b133027c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Mar 2017 21:11:37 +0200 Subject: Client: add support for video licences --- client/src/app/app.component.ts | 1 + client/src/app/shared/forms/form-validators/video.ts | 9 +++++++++ client/src/app/videos/shared/video.model.ts | 3 +++ client/src/app/videos/shared/video.service.ts | 14 ++++++++++++++ client/src/app/videos/video-add/video-add.component.html | 12 ++++++++++++ client/src/app/videos/video-add/video-add.component.ts | 8 ++++++++ .../src/app/videos/video-watch/video-watch.component.html | 7 +++++++ .../src/app/videos/video-watch/video-watch.component.scss | 4 ++++ 8 files changed, 58 insertions(+) (limited to 'client/src/app') diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index c7310690f..4e33fae52 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -39,6 +39,7 @@ export class AppComponent implements OnInit { } this.videoService.loadVideoCategories(); + this.videoService.loadVideoLicences(); } isInAdmin() { diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index de5112238..50d7304b5 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts @@ -8,12 +8,21 @@ export const VIDEO_NAME = { 'maxlength': 'Video name cannot be more than 50 characters long.' } }; + export const VIDEO_CATEGORY = { VALIDATORS: [ Validators.required ], MESSAGES: { 'required': 'Video category is required.' } }; + +export const VIDEO_LICENCE = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': 'Video licence is required.' + } +}; + 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 b5d96f63a..5ed622dce 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -3,6 +3,7 @@ export class Video { by: string; createdAt: Date; categoryLabel: string; + licenceLabel: string; description: string; duration: string; id: string; @@ -33,6 +34,7 @@ export class Video { author: string, createdAt: string, categoryLabel: string, + licenceLabel: string, description: string, duration: number; id: string, @@ -49,6 +51,7 @@ export class Video { this.author = hash.author; this.createdAt = new Date(hash.createdAt); this.categoryLabel = hash.categoryLabel; + this.licenceLabel = hash.licenceLabel; 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 debc114aa..15f017e33 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -23,6 +23,7 @@ export class VideoService { private static BASE_VIDEO_URL = '/api/v1/videos/'; videoCategories: Array<{ id: number, label: string }> = []; + videoLicences: Array<{ id: number, label: string }> = []; constructor( private authService: AuthService, @@ -45,6 +46,19 @@ export class VideoService { }); } + loadVideoLicences() { + return this.http.get(VideoService.BASE_VIDEO_URL + 'licences') + .map(this.restExtractor.extractDataGet) + .subscribe(data => { + Object.keys(data).forEach(licenceKey => { + this.videoLicences.push({ + id: parseInt(licenceKey), + label: data[licenceKey] + }); + }); + }); + } + getVideo(id: string): Observable