aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-04-07 14:57:05 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-04-07 14:57:05 +0200
commitdb216afd980846c418a4ebab8190c3ead561dfc1 (patch)
tree4542ab1e5c9b4d750f5877e22b1de627892564d2
parent3092476e64d09b449b4ad4f5198024afec1b22ca (diff)
downloadPeerTube-db216afd980846c418a4ebab8190c3ead561dfc1.tar.gz
PeerTube-db216afd980846c418a4ebab8190c3ead561dfc1.tar.zst
PeerTube-db216afd980846c418a4ebab8190c3ead561dfc1.zip
Client: support video language
-rw-r--r--client/src/app/app.component.ts1
-rw-r--r--client/src/app/shared/forms/form-validators/video.ts5
-rw-r--r--client/src/app/videos/shared/video.model.ts3
-rw-r--r--client/src/app/videos/shared/video.service.ts14
-rw-r--r--client/src/app/videos/video-add/video-add.component.html12
-rw-r--r--client/src/app/videos/video-add/video-add.component.ts13
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.html7
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.scss2
8 files changed, 56 insertions, 1 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 3c06b320e..c29790d96 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -42,6 +42,7 @@ export class AppComponent implements OnInit {
42 this.configService.loadConfig(); 42 this.configService.loadConfig();
43 this.videoService.loadVideoCategories(); 43 this.videoService.loadVideoCategories();
44 this.videoService.loadVideoLicences(); 44 this.videoService.loadVideoLicences();
45 this.videoService.loadVideoLanguages();
45 } 46 }
46 47
47 isInAdmin() { 48 isInAdmin() {
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts
index 50d7304b5..293fd805f 100644
--- a/client/src/app/shared/forms/form-validators/video.ts
+++ b/client/src/app/shared/forms/form-validators/video.ts
@@ -23,6 +23,11 @@ export const VIDEO_LICENCE = {
23 } 23 }
24}; 24};
25 25
26export const VIDEO_LANGUAGE = {
27 VALIDATORS: [ ],
28 MESSAGES: {}
29};
30
26export const VIDEO_DESCRIPTION = { 31export const VIDEO_DESCRIPTION = {
27 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ], 32 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],
28 MESSAGES: { 33 MESSAGES: {
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts
index 3c588c446..f135ca707 100644
--- a/client/src/app/videos/shared/video.model.ts
+++ b/client/src/app/videos/shared/video.model.ts
@@ -6,6 +6,7 @@ export class Video {
6 createdAt: Date; 6 createdAt: Date;
7 categoryLabel: string; 7 categoryLabel: string;
8 licenceLabel: string; 8 licenceLabel: string;
9 languageLabel: string;
9 description: string; 10 description: string;
10 duration: string; 11 duration: string;
11 id: string; 12 id: string;
@@ -38,6 +39,7 @@ export class Video {
38 createdAt: string, 39 createdAt: string,
39 categoryLabel: string, 40 categoryLabel: string,
40 licenceLabel: string, 41 licenceLabel: string,
42 languageLabel: string;
41 description: string, 43 description: string,
42 duration: number; 44 duration: number;
43 id: string, 45 id: string,
@@ -56,6 +58,7 @@ export class Video {
56 this.createdAt = new Date(hash.createdAt); 58 this.createdAt = new Date(hash.createdAt);
57 this.categoryLabel = hash.categoryLabel; 59 this.categoryLabel = hash.categoryLabel;
58 this.licenceLabel = hash.licenceLabel; 60 this.licenceLabel = hash.licenceLabel;
61 this.languageLabel = hash.languageLabel;
59 this.description = hash.description; 62 this.description = hash.description;
60 this.duration = Video.createDurationString(hash.duration); 63 this.duration = Video.createDurationString(hash.duration);
61 this.id = hash.id; 64 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 15f017e33..13d4ca246 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -24,6 +24,7 @@ export class VideoService {
24 24
25 videoCategories: Array<{ id: number, label: string }> = []; 25 videoCategories: Array<{ id: number, label: string }> = [];
26 videoLicences: Array<{ id: number, label: string }> = []; 26 videoLicences: Array<{ id: number, label: string }> = [];
27 videoLanguages: Array<{ id: number, label: string }> = [];
27 28
28 constructor( 29 constructor(
29 private authService: AuthService, 30 private authService: AuthService,
@@ -59,6 +60,19 @@ export class VideoService {
59 }); 60 });
60 } 61 }
61 62
63 loadVideoLanguages() {
64 return this.http.get(VideoService.BASE_VIDEO_URL + 'languages')
65 .map(this.restExtractor.extractDataGet)
66 .subscribe(data => {
67 Object.keys(data).forEach(languageKey => {
68 this.videoLanguages.push({
69 id: parseInt(languageKey),
70 label: data[languageKey]
71 });
72 });
73 });
74 }
75
62 getVideo(id: string): Observable<Video> { 76 getVideo(id: string): Observable<Video> {
63 return this.http.get(VideoService.BASE_VIDEO_URL + id) 77 return this.http.get(VideoService.BASE_VIDEO_URL + id)
64 .map(this.restExtractor.extractDataGet) 78 .map(this.restExtractor.extractDataGet)
diff --git a/client/src/app/videos/video-add/video-add.component.html b/client/src/app/videos/video-add/video-add.component.html
index a3c25c14b..104747a8c 100644
--- a/client/src/app/videos/video-add/video-add.component.html
+++ b/client/src/app/videos/video-add/video-add.component.html
@@ -47,6 +47,18 @@
47 </div> 47 </div>
48 48
49 <div class="form-group"> 49 <div class="form-group">
50 <label for="language">Language</label>
51 <select class="form-control" id="language" formControlName="language">
52 <option></option>
53 <option *ngFor="let language of videoLanguages" [value]="language.id">{{ language.label }}</option>
54 </select>
55
56 <div *ngIf="formErrors.language" class="alert alert-danger">
57 {{ formErrors.language }}
58 </div>
59 </div>
60
61 <div class="form-group">
50 <label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> 62 <label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
51 <input 63 <input
52 type="text" class="form-control" id="currentTag" 64 type="text" class="form-control" id="currentTag"
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts
index ea7ad2e5c..da556f48d 100644
--- a/client/src/app/videos/video-add/video-add.component.ts
+++ b/client/src/app/videos/video-add/video-add.component.ts
@@ -11,6 +11,7 @@ import {
11 VIDEO_NAME, 11 VIDEO_NAME,
12 VIDEO_CATEGORY, 12 VIDEO_CATEGORY,
13 VIDEO_LICENCE, 13 VIDEO_LICENCE,
14 VIDEO_LANGUAGE,
14 VIDEO_DESCRIPTION, 15 VIDEO_DESCRIPTION,
15 VIDEO_TAGS 16 VIDEO_TAGS
16} from '../../shared'; 17} from '../../shared';
@@ -27,6 +28,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
27 uploader: FileUploader; 28 uploader: FileUploader;
28 videoCategories = []; 29 videoCategories = [];
29 videoLicences = []; 30 videoLicences = [];
31 videoLanguages = [];
30 32
31 error: string = null; 33 error: string = null;
32 form: FormGroup; 34 form: FormGroup;
@@ -34,6 +36,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
34 name: '', 36 name: '',
35 category: '', 37 category: '',
36 licence: '', 38 licence: '',
39 language: '',
37 description: '', 40 description: '',
38 currentTag: '' 41 currentTag: ''
39 }; 42 };
@@ -41,6 +44,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
41 name: VIDEO_NAME.MESSAGES, 44 name: VIDEO_NAME.MESSAGES,
42 category: VIDEO_CATEGORY.MESSAGES, 45 category: VIDEO_CATEGORY.MESSAGES,
43 licence: VIDEO_LICENCE.MESSAGES, 46 licence: VIDEO_LICENCE.MESSAGES,
47 language: VIDEO_LANGUAGE.MESSAGES,
44 description: VIDEO_DESCRIPTION.MESSAGES, 48 description: VIDEO_DESCRIPTION.MESSAGES,
45 currentTag: VIDEO_TAGS.MESSAGES 49 currentTag: VIDEO_TAGS.MESSAGES
46 }; 50 };
@@ -74,6 +78,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
74 nsfw: [ false ], 78 nsfw: [ false ],
75 category: [ '', VIDEO_CATEGORY.VALIDATORS ], 79 category: [ '', VIDEO_CATEGORY.VALIDATORS ],
76 licence: [ '', VIDEO_LICENCE.VALIDATORS ], 80 licence: [ '', VIDEO_LICENCE.VALIDATORS ],
81 language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
77 description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], 82 description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
78 currentTag: [ '', VIDEO_TAGS.VALIDATORS ] 83 currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
79 }); 84 });
@@ -84,6 +89,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
84 ngOnInit() { 89 ngOnInit() {
85 this.videoCategories = this.videoService.videoCategories; 90 this.videoCategories = this.videoService.videoCategories;
86 this.videoLicences = this.videoService.videoLicences; 91 this.videoLicences = this.videoService.videoLicences;
92 this.videoLanguages = this.videoService.videoLanguages;
87 93
88 this.uploader = new FileUploader({ 94 this.uploader = new FileUploader({
89 authToken: this.authService.getRequestHeaderValue(), 95 authToken: this.authService.getRequestHeaderValue(),
@@ -97,12 +103,19 @@ export class VideoAddComponent extends FormReactive implements OnInit {
97 const nsfw = this.form.value['nsfw']; 103 const nsfw = this.form.value['nsfw'];
98 const category = this.form.value['category']; 104 const category = this.form.value['category'];
99 const licence = this.form.value['licence']; 105 const licence = this.form.value['licence'];
106 const language = this.form.value['language'];
100 const description = this.form.value['description']; 107 const description = this.form.value['description'];
101 108
102 form.append('name', name); 109 form.append('name', name);
103 form.append('category', category); 110 form.append('category', category);
104 form.append('nsfw', nsfw); 111 form.append('nsfw', nsfw);
105 form.append('licence', licence); 112 form.append('licence', licence);
113
114 // Language is optional
115 if (language) {
116 form.append('language', language);
117 }
118
106 form.append('description', description); 119 form.append('description', description);
107 120
108 for (let i = 0; i < this.tags.length; i++) { 121 for (let i = 0; i < this.tags.length; i++) {
diff --git a/client/src/app/videos/video-watch/video-watch.component.html b/client/src/app/videos/video-watch/video-watch.component.html
index 897561c14..a6ec7b20f 100644
--- a/client/src/app/videos/video-watch/video-watch.component.html
+++ b/client/src/app/videos/video-watch/video-watch.component.html
@@ -121,6 +121,13 @@
121 </div> 121 </div>
122 </div> 122 </div>
123 123
124 <div id="video-language" class="row">
125 <div class="col-md-12">
126 <span id="language-label">Language:</span>
127 {{ video.languageLabel }}
128 </div>
129 </div>
130
124 <div id="video-description" class="row"> 131 <div id="video-description" class="row">
125 <div class="col-md-12"> 132 <div class="col-md-12">
126 <div id="description-label">Description</div> 133 <div id="description-label">Description</div>
diff --git a/client/src/app/videos/video-watch/video-watch.component.scss b/client/src/app/videos/video-watch/video-watch.component.scss
index bf989e78b..92192221f 100644
--- a/client/src/app/videos/video-watch/video-watch.component.scss
+++ b/client/src/app/videos/video-watch/video-watch.component.scss
@@ -119,7 +119,7 @@
119 } 119 }
120 } 120 }
121 121
122 #video-licence #licence-label { 122 #video-licence #licence-label, #video-language #language-label {
123 font-weight: bold; 123 font-weight: bold;
124 } 124 }
125 125