From: Chocobozzz Date: Mon, 27 Mar 2017 19:11:37 +0000 (+0200) Subject: Client: add support for video licences X-Git-Tag: v0.0.1-alpha~487 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d07137b90b2b2b0c1e93a6f0e7bf8719b133027c;p=oweals%2Fpeertube.git Client: add support for video licences --- 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