aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/shared')
-rw-r--r--client/src/app/videos/shared/video.model.ts38
-rw-r--r--client/src/app/videos/shared/video.service.ts19
2 files changed, 56 insertions, 1 deletions
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts
index f135ca707..404e3bf45 100644
--- a/client/src/app/videos/shared/video.model.ts
+++ b/client/src/app/videos/shared/video.model.ts
@@ -5,8 +5,11 @@ export class Video {
5 by: string; 5 by: string;
6 createdAt: Date; 6 createdAt: Date;
7 categoryLabel: string; 7 categoryLabel: string;
8 category: string;
8 licenceLabel: string; 9 licenceLabel: string;
10 licence: string;
9 languageLabel: string; 11 languageLabel: string;
12 language: string;
10 description: string; 13 description: string;
11 duration: string; 14 duration: string;
12 id: string; 15 id: string;
@@ -38,8 +41,11 @@ export class Video {
38 author: string, 41 author: string,
39 createdAt: string, 42 createdAt: string,
40 categoryLabel: string, 43 categoryLabel: string,
44 category: string,
41 licenceLabel: string, 45 licenceLabel: string,
46 licence: string,
42 languageLabel: string; 47 languageLabel: string;
48 language: string;
43 description: string, 49 description: string,
44 duration: number; 50 duration: number;
45 id: string, 51 id: string,
@@ -57,8 +63,11 @@ export class Video {
57 this.author = hash.author; 63 this.author = hash.author;
58 this.createdAt = new Date(hash.createdAt); 64 this.createdAt = new Date(hash.createdAt);
59 this.categoryLabel = hash.categoryLabel; 65 this.categoryLabel = hash.categoryLabel;
66 this.category = hash.category;
60 this.licenceLabel = hash.licenceLabel; 67 this.licenceLabel = hash.licenceLabel;
68 this.licence = hash.licence;
61 this.languageLabel = hash.languageLabel; 69 this.languageLabel = hash.languageLabel;
70 this.language = hash.language;
62 this.description = hash.description; 71 this.description = hash.description;
63 this.duration = Video.createDurationString(hash.duration); 72 this.duration = Video.createDurationString(hash.duration);
64 this.id = hash.id; 73 this.id = hash.id;
@@ -84,4 +93,33 @@ export class Video {
84 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... 93 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
85 return (this.nsfw && (!user || user.displayNSFW === false)); 94 return (this.nsfw && (!user || user.displayNSFW === false));
86 } 95 }
96
97 patch(values: Object) {
98 Object.keys(values).forEach((key) => {
99 this[key] = values[key];
100 });
101 }
102
103 toJSON() {
104 return {
105 author: this.author,
106 createdAt: this.createdAt,
107 category: this.category,
108 licence: this.licence,
109 language: this.language,
110 description: this.description,
111 duration: this.duration,
112 id: this.id,
113 isLocal: this.isLocal,
114 magnetUri: this.magnetUri,
115 name: this.name,
116 podHost: this.podHost,
117 tags: this.tags,
118 thumbnailPath: this.thumbnailPath,
119 views: this.views,
120 likes: this.likes,
121 dislikes: this.dislikes,
122 nsfw: this.nsfw
123 };
124 }
87} 125}
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index 13d4ca246..ee67bc1ae 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -1,5 +1,5 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Http } from '@angular/http'; 2import { Http, Headers, RequestOptions } from '@angular/http';
3import { Observable } from 'rxjs/Observable'; 3import { Observable } from 'rxjs/Observable';
4import 'rxjs/add/operator/catch'; 4import 'rxjs/add/operator/catch';
5import 'rxjs/add/operator/map'; 5import 'rxjs/add/operator/map';
@@ -80,6 +80,23 @@ export class VideoService {
80 .catch((res) => this.restExtractor.handleError(res)); 80 .catch((res) => this.restExtractor.handleError(res));
81 } 81 }
82 82
83 updateVideo(video: Video) {
84 const body = {
85 name: video.name,
86 category: video.category,
87 licence: video.licence,
88 language: video.language,
89 description: video.description,
90 tags: video.tags
91 };
92 const headers = new Headers({ 'Content-Type': 'application/json' });
93 const options = new RequestOptions({ headers: headers });
94
95 return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${video.id}`, body, options)
96 .map(this.restExtractor.extractDataBool)
97 .catch(this.restExtractor.handleError);
98 }
99
83 getVideos(pagination: RestPagination, sort: SortField) { 100 getVideos(pagination: RestPagination, sort: SortField) {
84 const params = this.restService.buildRestGetParams(pagination, sort); 101 const params = this.restService.buildRestGetParams(pagination, sort);
85 102