aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-add
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-03-22 21:15:55 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-03-22 21:25:24 +0100
commit6e07c3de88791a0b342e0cc319590048117f9c2d (patch)
tree049f88d3f6d3ec0aeea09702a583deb86d6ef78f /client/src/app/videos/video-add
parent2d7653dc8726185615bab66353c4e3fb8fbb5a5f (diff)
downloadPeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.tar.gz
PeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.tar.zst
PeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.zip
Add video category support
Diffstat (limited to 'client/src/app/videos/video-add')
-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.ts20
2 files changed, 30 insertions, 2 deletions
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 b6be0d782..c6692b21d 100644
--- a/client/src/app/videos/video-add/video-add.component.html
+++ b/client/src/app/videos/video-add/video-add.component.html
@@ -15,6 +15,18 @@
15 </div> 15 </div>
16 16
17 <div class="form-group"> 17 <div class="form-group">
18 <label for="category">Category</label>
19 <select class="form-control" id="category" formControlName="category">
20 <option></option>
21 <option *ngFor="let category of videoCategories" [value]="category.id">{{ category.label }}</option>
22 </select>
23
24 <div *ngIf="formErrors.category" class="alert alert-danger">
25 {{ formErrors.category }}
26 </div>
27 </div>
28
29 <div class="form-group">
18 <label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> 30 <label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
19 <input 31 <input
20 type="text" class="form-control" id="currentTag" 32 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 cd6bb9989..2ef666e17 100644
--- a/client/src/app/videos/video-add/video-add.component.ts
+++ b/client/src/app/videos/video-add/video-add.component.ts
@@ -6,7 +6,14 @@ import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
6import { NotificationsService } from 'angular2-notifications'; 6import { NotificationsService } from 'angular2-notifications';
7 7
8import { AuthService } from '../../core'; 8import { AuthService } from '../../core';
9import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared'; 9import {
10 FormReactive,
11 VIDEO_NAME,
12 VIDEO_CATEGORY,
13 VIDEO_DESCRIPTION,
14 VIDEO_TAGS
15} from '../../shared';
16import { VideoService } from '../shared';
10 17
11@Component({ 18@Component({
12 selector: 'my-videos-add', 19 selector: 'my-videos-add',
@@ -17,16 +24,19 @@ import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../s
17export class VideoAddComponent extends FormReactive implements OnInit { 24export class VideoAddComponent extends FormReactive implements OnInit {
18 tags: string[] = []; 25 tags: string[] = [];
19 uploader: FileUploader; 26 uploader: FileUploader;
27 videoCategories = [];
20 28
21 error: string = null; 29 error: string = null;
22 form: FormGroup; 30 form: FormGroup;
23 formErrors = { 31 formErrors = {
24 name: '', 32 name: '',
33 category: '',
25 description: '', 34 description: '',
26 currentTag: '' 35 currentTag: ''
27 }; 36 };
28 validationMessages = { 37 validationMessages = {
29 name: VIDEO_NAME.MESSAGES, 38 name: VIDEO_NAME.MESSAGES,
39 category: VIDEO_CATEGORY.MESSAGES,
30 description: VIDEO_DESCRIPTION.MESSAGES, 40 description: VIDEO_DESCRIPTION.MESSAGES,
31 currentTag: VIDEO_TAGS.MESSAGES 41 currentTag: VIDEO_TAGS.MESSAGES
32 }; 42 };
@@ -40,7 +50,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
40 private elementRef: ElementRef, 50 private elementRef: ElementRef,
41 private formBuilder: FormBuilder, 51 private formBuilder: FormBuilder,
42 private router: Router, 52 private router: Router,
43 private notificationsService: NotificationsService 53 private notificationsService: NotificationsService,
54 private videoService: VideoService
44 ) { 55 ) {
45 super(); 56 super();
46 } 57 }
@@ -56,6 +67,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
56 buildForm() { 67 buildForm() {
57 this.form = this.formBuilder.group({ 68 this.form = this.formBuilder.group({
58 name: [ '', VIDEO_NAME.VALIDATORS ], 69 name: [ '', VIDEO_NAME.VALIDATORS ],
70 category: [ '', VIDEO_CATEGORY.VALIDATORS ],
59 description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], 71 description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
60 currentTag: [ '', VIDEO_TAGS.VALIDATORS ] 72 currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
61 }); 73 });
@@ -64,6 +76,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
64 } 76 }
65 77
66 ngOnInit() { 78 ngOnInit() {
79 this.videoCategories = this.videoService.videoCategories;
80
67 this.uploader = new FileUploader({ 81 this.uploader = new FileUploader({
68 authToken: this.authService.getRequestHeaderValue(), 82 authToken: this.authService.getRequestHeaderValue(),
69 queueLimit: 1, 83 queueLimit: 1,
@@ -73,9 +87,11 @@ export class VideoAddComponent extends FormReactive implements OnInit {
73 87
74 this.uploader.onBuildItemForm = (item, form) => { 88 this.uploader.onBuildItemForm = (item, form) => {
75 const name = this.form.value['name']; 89 const name = this.form.value['name'];
90 const category = this.form.value['category'];
76 const description = this.form.value['description']; 91 const description = this.form.value['description'];
77 92
78 form.append('name', name); 93 form.append('name', name);
94 form.append('category', category);
79 form.append('description', description); 95 form.append('description', description);
80 96
81 for (let i = 0; i < this.tags.length; i++) { 97 for (let i = 0; i < this.tags.length; i++) {