From 4fd8aa327004b27530fd96bdde5df60e6745a1f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 May 2016 17:49:18 +0200 Subject: Alphabetical --- client/app/videos/shared/video.model.ts | 59 ++++++++++++++++--------------- client/app/videos/shared/video.service.ts | 39 ++++++++++---------- 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'client/app/videos/shared') diff --git a/client/app/videos/shared/video.model.ts b/client/app/videos/shared/video.model.ts index 2b018ad86..614403d79 100644 --- a/client/app/videos/shared/video.model.ts +++ b/client/app/videos/shared/video.model.ts @@ -1,24 +1,15 @@ export class Video { - id: string; - name: string; + author: string; + by: string; + createdDate: Date; description: string; + duration: string; + id: string; + isLocal: boolean; magnetUri: string; + name: string; podUrl: string; - isLocal: boolean; thumbnailPath: string; - author: string; - createdDate: Date; - by: string; - duration: string; - - private static createDurationString(duration: number) { - const minutes = Math.floor(duration / 60); - const seconds = duration % 60; - const minutes_padding = minutes >= 10 ? '' : '0'; - const seconds_padding = seconds >= 10 ? '' : '0'; - - return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); - } private static createByString(author: string, podUrl: string) { let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':'); @@ -32,28 +23,38 @@ export class Video { return author + '@' + host + port; } + private static createDurationString(duration: number) { + const minutes = Math.floor(duration / 60); + const seconds = duration % 60; + const minutes_padding = minutes >= 10 ? '' : '0'; + const seconds_padding = seconds >= 10 ? '' : '0'; + + return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); + } + constructor(hash: { - id: string, - name: string, - description: string, - magnetUri: string, - podUrl: string, - isLocal: boolean, - thumbnailPath: string, author: string, createdDate: string, + description: string, duration: number; + id: string, + isLocal: boolean, + magnetUri: string, + name: string, + podUrl: string, + thumbnailPath: string }) { - this.id = hash.id; - this.name = hash.name; + this.author = hash.author; + this.createdDate = new Date(hash.createdDate); this.description = hash.description; + this.duration = Video.createDurationString(hash.duration); + this.id = hash.id; + this.isLocal = hash.isLocal; this.magnetUri = hash.magnetUri; + this.name = hash.name; this.podUrl = hash.podUrl; - this.isLocal = hash.isLocal; this.thumbnailPath = hash.thumbnailPath; - this.author = hash.author; - this.createdDate = new Date(hash.createdDate); - this.duration = Video.createDurationString(hash.duration); + this.by = Video.createByString(hash.author, hash.podUrl); } diff --git a/client/app/videos/shared/video.service.ts b/client/app/videos/shared/video.service.ts index b6e0800a0..7b6519f00 100644 --- a/client/app/videos/shared/video.service.ts +++ b/client/app/videos/shared/video.service.ts @@ -12,7 +12,16 @@ import { Video } from './video.model'; export class VideoService { private static BASE_VIDEO_URL = '/api/v1/videos/'; - constructor(private http: Http, private authService: AuthService) {} + constructor( + private authService: AuthService, + private http: Http + ) {} + + getVideo(id: string) { + return this.http.get(VideoService.BASE_VIDEO_URL + id) + .map(res =>