diff options
Diffstat (limited to 'client/src/app/videos/+video-edit')
4 files changed, 51 insertions, 3 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.html b/client/src/app/videos/+video-edit/video-add.component.html index a70788ed8..b4e0f9f7c 100644 --- a/client/src/app/videos/+video-edit/video-add.component.html +++ b/client/src/app/videos/+video-edit/video-add.component.html | |||
@@ -18,6 +18,18 @@ | |||
18 | </div> | 18 | </div> |
19 | 19 | ||
20 | <div class="form-group"> | 20 | <div class="form-group"> |
21 | <label for="privacy">Privacy</label> | ||
22 | <select class="form-control" id="privacy" formControlName="privacy"> | ||
23 | <option></option> | ||
24 | <option *ngFor="let privacy of videoPrivacies" [value]="privacy.id">{{ privacy.label }}</option> | ||
25 | </select> | ||
26 | |||
27 | <div *ngIf="formErrors.privacy" class="alert alert-danger"> | ||
28 | {{ formErrors.privacy }} | ||
29 | </div> | ||
30 | </div> | ||
31 | |||
32 | <div class="form-group"> | ||
21 | <input | 33 | <input |
22 | type="checkbox" id="nsfw" | 34 | type="checkbox" id="nsfw" |
23 | formControlName="nsfw" | 35 | formControlName="nsfw" |
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 5b5557ed9..c8094f792 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -13,7 +13,8 @@ import { | |||
13 | VIDEO_DESCRIPTION, | 13 | VIDEO_DESCRIPTION, |
14 | VIDEO_TAGS, | 14 | VIDEO_TAGS, |
15 | VIDEO_CHANNEL, | 15 | VIDEO_CHANNEL, |
16 | VIDEO_FILE | 16 | VIDEO_FILE, |
17 | VIDEO_PRIVACY | ||
17 | } from '../../shared' | 18 | } from '../../shared' |
18 | import { AuthService, ServerService } from '../../core' | 19 | import { AuthService, ServerService } from '../../core' |
19 | import { VideoService } from '../shared' | 20 | import { VideoService } from '../shared' |
@@ -34,6 +35,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
34 | videoCategories = [] | 35 | videoCategories = [] |
35 | videoLicences = [] | 36 | videoLicences = [] |
36 | videoLanguages = [] | 37 | videoLanguages = [] |
38 | videoPrivacies = [] | ||
37 | userVideoChannels = [] | 39 | userVideoChannels = [] |
38 | 40 | ||
39 | tagValidators = VIDEO_TAGS.VALIDATORS | 41 | tagValidators = VIDEO_TAGS.VALIDATORS |
@@ -43,6 +45,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
43 | form: FormGroup | 45 | form: FormGroup |
44 | formErrors = { | 46 | formErrors = { |
45 | name: '', | 47 | name: '', |
48 | privacy: '', | ||
46 | category: '', | 49 | category: '', |
47 | licence: '', | 50 | licence: '', |
48 | language: '', | 51 | language: '', |
@@ -52,6 +55,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
52 | } | 55 | } |
53 | validationMessages = { | 56 | validationMessages = { |
54 | name: VIDEO_NAME.MESSAGES, | 57 | name: VIDEO_NAME.MESSAGES, |
58 | privacy: VIDEO_PRIVACY.MESSAGES, | ||
55 | category: VIDEO_CATEGORY.MESSAGES, | 59 | category: VIDEO_CATEGORY.MESSAGES, |
56 | licence: VIDEO_LICENCE.MESSAGES, | 60 | licence: VIDEO_LICENCE.MESSAGES, |
57 | language: VIDEO_LANGUAGE.MESSAGES, | 61 | language: VIDEO_LANGUAGE.MESSAGES, |
@@ -79,6 +83,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
79 | this.form = this.formBuilder.group({ | 83 | this.form = this.formBuilder.group({ |
80 | name: [ '', VIDEO_NAME.VALIDATORS ], | 84 | name: [ '', VIDEO_NAME.VALIDATORS ], |
81 | nsfw: [ false ], | 85 | nsfw: [ false ], |
86 | privacy: [ '', VIDEO_PRIVACY.VALIDATORS ], | ||
82 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], | 87 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], |
83 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], | 88 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], |
84 | language: [ '', VIDEO_LANGUAGE.VALIDATORS ], | 89 | language: [ '', VIDEO_LANGUAGE.VALIDATORS ], |
@@ -95,6 +100,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
95 | this.videoCategories = this.serverService.getVideoCategories() | 100 | this.videoCategories = this.serverService.getVideoCategories() |
96 | this.videoLicences = this.serverService.getVideoLicences() | 101 | this.videoLicences = this.serverService.getVideoLicences() |
97 | this.videoLanguages = this.serverService.getVideoLanguages() | 102 | this.videoLanguages = this.serverService.getVideoLanguages() |
103 | this.videoPrivacies = this.serverService.getVideoPrivacies() | ||
98 | 104 | ||
99 | this.buildForm() | 105 | this.buildForm() |
100 | 106 | ||
@@ -139,6 +145,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
139 | const formValue: VideoCreate = this.form.value | 145 | const formValue: VideoCreate = this.form.value |
140 | 146 | ||
141 | const name = formValue.name | 147 | const name = formValue.name |
148 | const privacy = formValue.privacy | ||
142 | const nsfw = formValue.nsfw | 149 | const nsfw = formValue.nsfw |
143 | const category = formValue.category | 150 | const category = formValue.category |
144 | const licence = formValue.licence | 151 | const licence = formValue.licence |
@@ -150,6 +157,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
150 | 157 | ||
151 | const formData = new FormData() | 158 | const formData = new FormData() |
152 | formData.append('name', name) | 159 | formData.append('name', name) |
160 | formData.append('privacy', privacy.toString()) | ||
153 | formData.append('category', '' + category) | 161 | formData.append('category', '' + category) |
154 | formData.append('nsfw', '' + nsfw) | 162 | formData.append('nsfw', '' + nsfw) |
155 | formData.append('licence', '' + licence) | 163 | formData.append('licence', '' + licence) |
diff --git a/client/src/app/videos/+video-edit/video-update.component.html b/client/src/app/videos/+video-edit/video-update.component.html index ec040630e..b9c6139b2 100644 --- a/client/src/app/videos/+video-edit/video-update.component.html +++ b/client/src/app/videos/+video-edit/video-update.component.html | |||
@@ -18,6 +18,18 @@ | |||
18 | </div> | 18 | </div> |
19 | 19 | ||
20 | <div class="form-group"> | 20 | <div class="form-group"> |
21 | <label for="privacy">Privacy</label> | ||
22 | <select class="form-control" id="privacy" formControlName="privacy"> | ||
23 | <option></option> | ||
24 | <option *ngFor="let privacy of videoPrivacies" [value]="privacy.id">{{ privacy.label }}</option> | ||
25 | </select> | ||
26 | |||
27 | <div *ngIf="formErrors.privacy" class="alert alert-danger"> | ||
28 | {{ formErrors.privacy }} | ||
29 | </div> | ||
30 | </div> | ||
31 | |||
32 | <div class="form-group"> | ||
21 | <input | 33 | <input |
22 | type="checkbox" id="nsfw" | 34 | type="checkbox" id="nsfw" |
23 | formControlName="nsfw" | 35 | formControlName="nsfw" |
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 6ced77f1a..be663575f 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { FormBuilder, FormGroup } from '@angular/forms' | 2 | import { FormBuilder, FormGroup } from '@angular/forms' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { Observable } from 'rxjs/Observable' | ||
5 | import 'rxjs/add/observable/forkJoin' | 4 | import 'rxjs/add/observable/forkJoin' |
6 | 5 | ||
7 | import { NotificationsService } from 'angular2-notifications' | 6 | import { NotificationsService } from 'angular2-notifications' |
@@ -14,9 +13,11 @@ import { | |||
14 | VIDEO_LICENCE, | 13 | VIDEO_LICENCE, |
15 | VIDEO_LANGUAGE, | 14 | VIDEO_LANGUAGE, |
16 | VIDEO_DESCRIPTION, | 15 | VIDEO_DESCRIPTION, |
17 | VIDEO_TAGS | 16 | VIDEO_TAGS, |
17 | VIDEO_PRIVACY | ||
18 | } from '../../shared' | 18 | } from '../../shared' |
19 | import { VideoEdit, VideoService } from '../shared' | 19 | import { VideoEdit, VideoService } from '../shared' |
20 | import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum' | ||
20 | 21 | ||
21 | @Component({ | 22 | @Component({ |
22 | selector: 'my-videos-update', | 23 | selector: 'my-videos-update', |
@@ -29,6 +30,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
29 | videoCategories = [] | 30 | videoCategories = [] |
30 | videoLicences = [] | 31 | videoLicences = [] |
31 | videoLanguages = [] | 32 | videoLanguages = [] |
33 | videoPrivacies = [] | ||
32 | video: VideoEdit | 34 | video: VideoEdit |
33 | 35 | ||
34 | tagValidators = VIDEO_TAGS.VALIDATORS | 36 | tagValidators = VIDEO_TAGS.VALIDATORS |
@@ -38,6 +40,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
38 | form: FormGroup | 40 | form: FormGroup |
39 | formErrors = { | 41 | formErrors = { |
40 | name: '', | 42 | name: '', |
43 | privacy: '', | ||
41 | category: '', | 44 | category: '', |
42 | licence: '', | 45 | licence: '', |
43 | language: '', | 46 | language: '', |
@@ -45,6 +48,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
45 | } | 48 | } |
46 | validationMessages = { | 49 | validationMessages = { |
47 | name: VIDEO_NAME.MESSAGES, | 50 | name: VIDEO_NAME.MESSAGES, |
51 | privacy: VIDEO_PRIVACY.MESSAGES, | ||
48 | category: VIDEO_CATEGORY.MESSAGES, | 52 | category: VIDEO_CATEGORY.MESSAGES, |
49 | licence: VIDEO_LICENCE.MESSAGES, | 53 | licence: VIDEO_LICENCE.MESSAGES, |
50 | language: VIDEO_LANGUAGE.MESSAGES, | 54 | language: VIDEO_LANGUAGE.MESSAGES, |
@@ -67,6 +71,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
67 | buildForm () { | 71 | buildForm () { |
68 | this.form = this.formBuilder.group({ | 72 | this.form = this.formBuilder.group({ |
69 | name: [ '', VIDEO_NAME.VALIDATORS ], | 73 | name: [ '', VIDEO_NAME.VALIDATORS ], |
74 | privacy: [ '', VIDEO_PRIVACY.VALIDATORS ], | ||
70 | nsfw: [ false ], | 75 | nsfw: [ false ], |
71 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], | 76 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], |
72 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], | 77 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], |
@@ -84,6 +89,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
84 | this.videoCategories = this.serverService.getVideoCategories() | 89 | this.videoCategories = this.serverService.getVideoCategories() |
85 | this.videoLicences = this.serverService.getVideoLicences() | 90 | this.videoLicences = this.serverService.getVideoLicences() |
86 | this.videoLanguages = this.serverService.getVideoLanguages() | 91 | this.videoLanguages = this.serverService.getVideoLanguages() |
92 | this.videoPrivacies = this.serverService.getVideoPrivacies() | ||
87 | 93 | ||
88 | const uuid: string = this.route.snapshot.params['uuid'] | 94 | const uuid: string = this.route.snapshot.params['uuid'] |
89 | 95 | ||
@@ -98,6 +104,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
98 | video => { | 104 | video => { |
99 | this.video = new VideoEdit(video) | 105 | this.video = new VideoEdit(video) |
100 | 106 | ||
107 | // We cannot set private a video that was not private anymore | ||
108 | if (video.privacy !== VideoPrivacy.PRIVATE) { | ||
109 | const newVideoPrivacies = [] | ||
110 | for (const p of this.videoPrivacies) { | ||
111 | if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p) | ||
112 | } | ||
113 | |||
114 | this.videoPrivacies = newVideoPrivacies | ||
115 | } | ||
116 | |||
101 | this.hydrateFormFromVideo() | 117 | this.hydrateFormFromVideo() |
102 | }, | 118 | }, |
103 | 119 | ||