From 6e07c3de88791a0b342e0cc319590048117f9c2d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Mar 2017 21:15:55 +0100 Subject: Add video category support --- client/src/app/videos/shared/video.model.ts | 3 +++ client/src/app/videos/shared/video.service.ts | 15 +++++++++++++++ .../app/videos/video-add/video-add.component.html | 12 ++++++++++++ .../src/app/videos/video-add/video-add.component.ts | 20 ++++++++++++++++++-- .../videos/video-watch/video-watch.component.html | 7 +++++++ .../videos/video-watch/video-watch.component.scss | 10 +++++++++- 6 files changed, 64 insertions(+), 3 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 3eef936eb..b5d96f63a 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -2,6 +2,7 @@ export class Video { author: string; by: string; createdAt: Date; + categoryLabel: string; description: string; duration: string; id: string; @@ -31,6 +32,7 @@ export class Video { constructor(hash: { author: string, createdAt: string, + categoryLabel: string, description: string, duration: number; id: string, @@ -46,6 +48,7 @@ export class Video { }) { this.author = hash.author; this.createdAt = new Date(hash.createdAt); + this.categoryLabel = hash.categoryLabel; 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 8bb5a2933..debc114aa 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -22,6 +22,8 @@ import { Video } from './video.model'; export class VideoService { private static BASE_VIDEO_URL = '/api/v1/videos/'; + videoCategories: Array<{ id: number, label: string }> = []; + constructor( private authService: AuthService, private authHttp: AuthHttp, @@ -30,6 +32,19 @@ export class VideoService { private restService: RestService ) {} + loadVideoCategories() { + return this.http.get(VideoService.BASE_VIDEO_URL + 'categories') + .map(this.restExtractor.extractDataGet) + .subscribe(data => { + Object.keys(data).forEach(categoryKey => { + this.videoCategories.push({ + id: parseInt(categoryKey), + label: data[categoryKey] + }); + }); + }); + } + getVideo(id: string): Observable