aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html2
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts38
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts13
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts10
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts8
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html32
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss5
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts8
-rw-r--r--client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts13
-rw-r--r--client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts13
-rw-r--r--client/src/app/app.module.ts6
-rw-r--r--client/src/app/login/login.component.ts7
-rw-r--r--client/src/app/reset-password/reset-password.component.ts10
-rw-r--r--client/src/app/shared/forms/form-validators/custom-config-validators.service.ts72
-rw-r--r--client/src/app/shared/forms/form-validators/custom-config.ts56
-rw-r--r--client/src/app/shared/forms/form-validators/form-validator.service.ts9
-rw-r--r--client/src/app/shared/forms/form-validators/index.ts11
-rw-r--r--client/src/app/shared/forms/form-validators/login-validators.service.ts30
-rw-r--r--client/src/app/shared/forms/form-validators/login.ts18
-rw-r--r--client/src/app/shared/forms/form-validators/reset-password-validators.service.ts20
-rw-r--r--client/src/app/shared/forms/form-validators/reset-password.ts10
-rw-r--r--client/src/app/shared/forms/form-validators/user-validators.service.ts93
-rw-r--r--client/src/app/shared/forms/form-validators/user.ts70
-rw-r--r--client/src/app/shared/forms/form-validators/validator-message.ts5
-rw-r--r--client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts20
-rw-r--r--client/src/app/shared/forms/form-validators/video-abuse.ts10
-rw-r--r--client/src/app/shared/forms/form-validators/video-channel-validators.service.ts48
-rw-r--r--client/src/app/shared/forms/form-validators/video-channel.ts34
-rw-r--r--client/src/app/shared/forms/form-validators/video-comment-validators.service.ts20
-rw-r--r--client/src/app/shared/forms/form-validators/video-comment.ts10
-rw-r--r--client/src/app/shared/forms/form-validators/video-validators.service.ts88
-rw-r--r--client/src/app/shared/forms/form-validators/video.ts68
-rw-r--r--client/src/app/shared/shared.module.ts16
-rw-r--r--client/src/app/signup/signup.component.ts10
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts43
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts5
-rw-r--r--client/src/app/videos/+video-watch/modal/video-report.component.ts8
37 files changed, 536 insertions, 403 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
index 4263b7b5f..a0bd01e5e 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
@@ -207,7 +207,7 @@ Check this checkbox, save the configuration and test with a video URL of your in
207 <div i18n class="inner-form-title">Cache</div> 207 <div i18n class="inner-form-title">Cache</div>
208 208
209 <div class="form-group"> 209 <div class="form-group">
210 <label i18n for="cachePreviewsSize">Preview cache size</label> 210 <label i18n for="cachePreviewsSize">Previews cache size</label>
211 <my-help 211 <my-help
212 helpType="custom" i18n-customHtml 212 helpType="custom" i18n-customHtml
213 customHtml="Previews are not federated. We fetch them directly from the origin instance and cache them." 213 customHtml="Previews are not federated. We fetch them directly from the origin instance and cache them."
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index f2a3464cb..7b3e72803 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -1,19 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { Router } from '@angular/router' 2import { Router } from '@angular/router'
4import { ConfigService } from '@app/+admin/config/shared/config.service' 3import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { ConfirmService } from '@app/core' 4import { ConfirmService } from '@app/core'
6import { ServerService } from '@app/core/server/server.service' 5import { ServerService } from '@app/core/server/server.service'
7import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' 6import { CustomConfigValidatorsService, FormReactive, UserValidatorsService } from '@app/shared'
8import {
9 ADMIN_EMAIL,
10 CACHE_PREVIEWS_SIZE,
11 INSTANCE_NAME,
12 INSTANCE_SHORT_DESCRIPTION,
13 SERVICES_TWITTER_USERNAME,
14 SIGNUP_LIMIT,
15 TRANSCODING_THREADS
16} from '@app/shared/forms/form-validators/custom-config'
17import { NotificationsService } from 'angular2-notifications' 7import { NotificationsService } from 'angular2-notifications'
18import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' 8import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
19import { I18n } from '@ngx-translate/i18n-polyfill' 9import { I18n } from '@ngx-translate/i18n-polyfill'
@@ -50,6 +40,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
50 40
51 constructor ( 41 constructor (
52 protected formValidatorService: FormValidatorService, 42 protected formValidatorService: FormValidatorService,
43 private customConfigValidatorsService: CustomConfigValidatorsService,
44 private userValidatorsService: UserValidatorsService,
53 private router: Router, 45 private router: Router,
54 private notificationsService: NotificationsService, 46 private notificationsService: NotificationsService,
55 private configService: ConfigService, 47 private configService: ConfigService,
@@ -66,20 +58,20 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
66 58
67 ngOnInit () { 59 ngOnInit () {
68 const formGroupData = { 60 const formGroupData = {
69 instanceName: INSTANCE_NAME, 61 instanceName: this.customConfigValidatorsService.INSTANCE_NAME,
70 instanceShortDescription: INSTANCE_SHORT_DESCRIPTION, 62 instanceShortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION,
71 instanceDescription: null, 63 instanceDescription: null,
72 instanceTerms: null, 64 instanceTerms: null,
73 instanceDefaultClientRoute: null, 65 instanceDefaultClientRoute: null,
74 instanceDefaultNSFWPolicy: null, 66 instanceDefaultNSFWPolicy: null,
75 servicesTwitterUsername: SERVICES_TWITTER_USERNAME, 67 servicesTwitterUsername: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME,
76 servicesTwitterWhitelisted: null, 68 servicesTwitterWhitelisted: null,
77 cachePreviewsSize: CACHE_PREVIEWS_SIZE, 69 cachePreviewsSize: this.customConfigValidatorsService.CACHE_PREVIEWS_SIZE,
78 signupEnabled: null, 70 signupEnabled: null,
79 signupLimit: SIGNUP_LIMIT, 71 signupLimit: this.customConfigValidatorsService.SIGNUP_LIMIT,
80 adminEmail: ADMIN_EMAIL, 72 adminEmail: this.customConfigValidatorsService.ADMIN_EMAIL,
81 userVideoQuota: USER_VIDEO_QUOTA, 73 userVideoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
82 transcodingThreads: TRANSCODING_THREADS, 74 transcodingThreads: this.customConfigValidatorsService.TRANSCODING_THREADS,
83 transcodingEnabled: null, 75 transcodingEnabled: null,
84 customizationJavascript: null, 76 customizationJavascript: null,
85 customizationCSS: null 77 customizationCSS: null
@@ -134,11 +126,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
134 const message = this.i18n('You set custom {{customizationsText}}. ', { customizationsText }) + 126 const message = this.i18n('You set custom {{customizationsText}}. ', { customizationsText }) +
135 this.i18n('This could lead to security issues or bugs if you do not understand it. ') + 127 this.i18n('This could lead to security issues or bugs if you do not understand it. ') +
136 this.i18n('Are you sure you want to update the configuration?') 128 this.i18n('Are you sure you want to update the configuration?')
137 const label = this.i18n( 129
138 'Please type "I understand the {{customizationsText}} I set" to confirm.', 130 const label = this.i18n('Please type') + ` "I understand the ${customizationsText} I set" ` + this.i18n('to confirm.')
139 { customizationsText } 131 const expectedInputValue = `I understand the ${customizationsText} I set`
140 )
141 const expectedInputValue = this.i18n('I understand the {{customizationsText}} I set', { customizationsText })
142 132
143 const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue) 133 const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue)
144 if (confirmRes === false) return 134 if (confirmRes === false) return
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts
index e5f0903b6..c15cfb267 100644
--- a/client/src/app/+admin/users/user-edit/user-create.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-create.component.ts
@@ -2,12 +2,12 @@ import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { UserService } from '../shared' 4import { UserService } from '../shared'
5import { USER_EMAIL, USER_PASSWORD, USER_ROLE, USER_USERNAME, USER_VIDEO_QUOTA } from '../../../shared'
6import { ServerService } from '../../../core' 5import { ServerService } from '../../../core'
7import { UserCreate, UserRole } from '../../../../../../shared' 6import { UserCreate, UserRole } from '../../../../../../shared'
8import { UserEdit } from './user-edit' 7import { UserEdit } from './user-edit'
9import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
10import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
11 11
12@Component({ 12@Component({
13 selector: 'my-user-create', 13 selector: 'my-user-create',
@@ -20,6 +20,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
20 constructor ( 20 constructor (
21 protected serverService: ServerService, 21 protected serverService: ServerService,
22 protected formValidatorService: FormValidatorService, 22 protected formValidatorService: FormValidatorService,
23 private userValidatorsService: UserValidatorsService,
23 private router: Router, 24 private router: Router,
24 private notificationsService: NotificationsService, 25 private notificationsService: NotificationsService,
25 private userService: UserService, 26 private userService: UserService,
@@ -35,11 +36,11 @@ export class UserCreateComponent extends UserEdit implements OnInit {
35 } 36 }
36 37
37 this.buildForm({ 38 this.buildForm({
38 username: USER_USERNAME, 39 username: this.userValidatorsService.USER_USERNAME,
39 email: USER_EMAIL, 40 email: this.userValidatorsService.USER_EMAIL,
40 password: USER_PASSWORD, 41 password: this.userValidatorsService.USER_PASSWORD,
41 role: USER_ROLE, 42 role: this.userValidatorsService.USER_ROLE,
42 videoQuota: USER_VIDEO_QUOTA 43 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA
43 }, defaultValues) 44 }, defaultValues)
44 } 45 }
45 46
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts
index f8073c928..3e60991d2 100644
--- a/client/src/app/+admin/users/user-edit/user-update.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-update.component.ts
@@ -3,12 +3,13 @@ import { ActivatedRoute, Router } from '@angular/router'
3import { Subscription } from 'rxjs' 3import { Subscription } from 'rxjs'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5import { UserService } from '../shared' 5import { UserService } from '../shared'
6import { User, USER_EMAIL, USER_ROLE, USER_VIDEO_QUOTA } from '../../../shared' 6import { User } from '../../../shared'
7import { ServerService } from '../../../core' 7import { ServerService } from '../../../core'
8import { UserEdit } from './user-edit' 8import { UserEdit } from './user-edit'
9import { UserUpdate } from '../../../../../../shared' 9import { UserUpdate } from '../../../../../../shared'
10import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
12import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
12 13
13@Component({ 14@Component({
14 selector: 'my-user-update', 15 selector: 'my-user-update',
@@ -25,6 +26,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
25 constructor ( 26 constructor (
26 protected formValidatorService: FormValidatorService, 27 protected formValidatorService: FormValidatorService,
27 protected serverService: ServerService, 28 protected serverService: ServerService,
29 private userValidatorsService: UserValidatorsService,
28 private route: ActivatedRoute, 30 private route: ActivatedRoute,
29 private router: Router, 31 private router: Router,
30 private notificationsService: NotificationsService, 32 private notificationsService: NotificationsService,
@@ -37,9 +39,9 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
37 ngOnInit () { 39 ngOnInit () {
38 const defaultValues = { videoQuota: '-1' } 40 const defaultValues = { videoQuota: '-1' }
39 this.buildForm({ 41 this.buildForm({
40 email: USER_EMAIL, 42 email: this.userValidatorsService.USER_EMAIL,
41 role: USER_ROLE, 43 role: this.userValidatorsService.USER_ROLE,
42 videoQuota: USER_VIDEO_QUOTA 44 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA
43 }, defaultValues) 45 }, defaultValues)
44 46
45 this.paramsSub = this.route.params.subscribe(routeParams => { 47 this.paramsSub = this.route.params.subscribe(routeParams => {
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
index 56e644f39..7be7aabc2 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
@@ -1,8 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
3import { FormReactive, USER_PASSWORD, UserService } from '../../../shared' 3import { FormReactive, UserService } from '../../../shared'
4import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
5import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 5import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
6import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
6 7
7@Component({ 8@Component({
8 selector: 'my-account-change-password', 9 selector: 'my-account-change-password',
@@ -14,6 +15,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
14 15
15 constructor ( 16 constructor (
16 protected formValidatorService: FormValidatorService, 17 protected formValidatorService: FormValidatorService,
18 private userValidatorsService: UserValidatorsService,
17 private notificationsService: NotificationsService, 19 private notificationsService: NotificationsService,
18 private userService: UserService, 20 private userService: UserService,
19 private i18n: I18n 21 private i18n: I18n
@@ -23,8 +25,8 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
23 25
24 ngOnInit () { 26 ngOnInit () {
25 this.buildForm({ 27 this.buildForm({
26 'new-password': USER_PASSWORD, 28 'new-password': this.userValidatorsService.USER_PASSWORD,
27 'new-confirmed-password': USER_PASSWORD 29 'new-confirmed-password': this.userValidatorsService.USER_PASSWORD
28 }) 30 })
29 } 31 }
30 32
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
index bbdce5b02..05c0b5ddc 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
@@ -2,22 +2,26 @@
2 2
3<form role="form" (ngSubmit)="updateMyProfile()" [formGroup]="form"> 3<form role="form" (ngSubmit)="updateMyProfile()" [formGroup]="form">
4 4
5 <label i18n for="display-name">Display name</label> 5 <div class="form-group">
6 <input 6 <label i18n for="display-name">Display name</label>
7 type="text" id="display-name" 7 <input
8 formControlName="display-name" [ngClass]="{ 'input-error': formErrors['display-name'] }" 8 type="text" id="display-name"
9 > 9 formControlName="display-name" [ngClass]="{ 'input-error': formErrors['display-name'] }"
10 <div *ngIf="formErrors['display-name']" class="form-error"> 10 >
11 {{ formErrors['display-name'] }} 11 <div *ngIf="formErrors['display-name']" class="form-error">
12 {{ formErrors['display-name'] }}
13 </div>
12 </div> 14 </div>
13 15
14 <label i18n for="description">Description</label> 16 <div class="form-group">
15 <textarea 17 <label i18n for="description">Description</label>
16 id="description" formControlName="description" 18 <textarea
17 [ngClass]="{ 'input-error': formErrors['description'] }" 19 id="description" formControlName="description"
18 ></textarea> 20 [ngClass]="{ 'input-error': formErrors['description'] }"
19 <div *ngIf="formErrors.description" class="form-error"> 21 ></textarea>
20 {{ formErrors.description }} 22 <div *ngIf="formErrors.description" class="form-error">
23 {{ formErrors.description }}
24 </div>
21 </div> 25 </div>
22 26
23 <input type="submit" i18n-value value="Update my profile" [disabled]="!form.valid"> 27 <input type="submit" i18n-value value="Update my profile" [disabled]="!form.valid">
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss
index fc2b92c89..6aabb60f4 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss
@@ -1,11 +1,14 @@
1@import '_variables'; 1@import '_variables';
2@import '_mixins'; 2@import '_mixins';
3 3
4.form-group:first-child {
5 margin-bottom: 15px;
6}
7
4input[type=text] { 8input[type=text] {
5 @include peertube-input-text(340px); 9 @include peertube-input-text(340px);
6 10
7 display: block; 11 display: block;
8 margin-bottom: 15px;
9} 12}
10 13
11textarea { 14textarea {
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
index 1fe337da0..400c3b889 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
@@ -1,10 +1,11 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
3import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' 3import { FormReactive, UserService } from '../../../shared'
4import { User } from '@app/shared' 4import { User } from '@app/shared'
5import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 6import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
7import { Subject } from 'rxjs/Subject' 7import { Subject } from 'rxjs/Subject'
8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
8 9
9@Component({ 10@Component({
10 selector: 'my-account-profile', 11 selector: 'my-account-profile',
@@ -19,6 +20,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
19 20
20 constructor ( 21 constructor (
21 protected formValidatorService: FormValidatorService, 22 protected formValidatorService: FormValidatorService,
23 private userValidatorsService: UserValidatorsService,
22 private notificationsService: NotificationsService, 24 private notificationsService: NotificationsService,
23 private userService: UserService, 25 private userService: UserService,
24 private i18n: I18n 26 private i18n: I18n
@@ -28,8 +30,8 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
28 30
29 ngOnInit () { 31 ngOnInit () {
30 this.buildForm({ 32 this.buildForm({
31 'display-name': USER_DISPLAY_NAME, 33 'display-name': this.userValidatorsService.USER_DISPLAY_NAME,
32 description: USER_DESCRIPTION 34 description: this.userValidatorsService.USER_DESCRIPTION
33 }) 35 })
34 36
35 this.userInformationLoaded.subscribe(() => { 37 this.userInformationLoaded.subscribe(() => {
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
index e38eaae9c..c0eaa4763 100644
--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
@@ -3,15 +3,11 @@ import { Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
5import { VideoChannelCreate } from '../../../../../shared/models/videos' 5import { VideoChannelCreate } from '../../../../../shared/models/videos'
6import {
7 VIDEO_CHANNEL_DESCRIPTION,
8 VIDEO_CHANNEL_DISPLAY_NAME,
9 VIDEO_CHANNEL_SUPPORT
10} from '@app/shared/forms/form-validators/video-channel'
11import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
12import { AuthService } from '@app/core' 7import { AuthService } from '@app/core'
13import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
14import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service'
15 11
16@Component({ 12@Component({
17 selector: 'my-account-video-channel-create', 13 selector: 'my-account-video-channel-create',
@@ -24,6 +20,7 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
24 constructor ( 20 constructor (
25 protected formValidatorService: FormValidatorService, 21 protected formValidatorService: FormValidatorService,
26 private authService: AuthService, 22 private authService: AuthService,
23 private videoChannelValidatorsService: VideoChannelValidatorsService,
27 private notificationsService: NotificationsService, 24 private notificationsService: NotificationsService,
28 private router: Router, 25 private router: Router,
29 private videoChannelService: VideoChannelService, 26 private videoChannelService: VideoChannelService,
@@ -34,9 +31,9 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
34 31
35 ngOnInit () { 32 ngOnInit () {
36 this.buildForm({ 33 this.buildForm({
37 'display-name': VIDEO_CHANNEL_DISPLAY_NAME, 34 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
38 description: VIDEO_CHANNEL_DESCRIPTION, 35 description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
39 support: VIDEO_CHANNEL_SUPPORT 36 support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT
40 }) 37 })
41 } 38 }
42 39
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
index eda03374a..1510c5015 100644
--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
@@ -3,17 +3,13 @@ import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
5import { VideoChannelUpdate } from '../../../../../shared/models/videos' 5import { VideoChannelUpdate } from '../../../../../shared/models/videos'
6import {
7 VIDEO_CHANNEL_DESCRIPTION,
8 VIDEO_CHANNEL_DISPLAY_NAME,
9 VIDEO_CHANNEL_SUPPORT
10} from '@app/shared/forms/form-validators/video-channel'
11import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
12import { Subscription } from 'rxjs' 7import { Subscription } from 'rxjs'
13import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 8import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
14import { AuthService } from '@app/core' 9import { AuthService } from '@app/core'
15import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
16import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
12import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service'
17 13
18@Component({ 14@Component({
19 selector: 'my-account-video-channel-update', 15 selector: 'my-account-video-channel-update',
@@ -29,6 +25,7 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
29 constructor ( 25 constructor (
30 protected formValidatorService: FormValidatorService, 26 protected formValidatorService: FormValidatorService,
31 private authService: AuthService, 27 private authService: AuthService,
28 private videoChannelValidatorsService: VideoChannelValidatorsService,
32 private notificationsService: NotificationsService, 29 private notificationsService: NotificationsService,
33 private router: Router, 30 private router: Router,
34 private route: ActivatedRoute, 31 private route: ActivatedRoute,
@@ -40,9 +37,9 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
40 37
41 ngOnInit () { 38 ngOnInit () {
42 this.buildForm({ 39 this.buildForm({
43 'display-name': VIDEO_CHANNEL_DISPLAY_NAME, 40 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
44 description: VIDEO_CHANNEL_DESCRIPTION, 41 description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
45 support: VIDEO_CHANNEL_SUPPORT 42 support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT
46 }) 43 })
47 44
48 this.paramsSub = this.route.params.subscribe(routeParams => { 45 this.paramsSub = this.route.params.subscribe(routeParams => {
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 44552021f..9992b9c44 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -17,6 +17,7 @@ import { SharedModule } from './shared'
17import { SignupModule } from './signup' 17import { SignupModule } from './signup'
18import { VideosModule } from './videos' 18import { VideosModule } from './videos'
19import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n' 19import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n'
20import { environment } from '../environments/environment'
20 21
21export function metaFactory (serverService: ServerService): MetaLoader { 22export function metaFactory (serverService: ServerService): MetaLoader {
22 return new MetaStaticLoader({ 23 return new MetaStaticLoader({
@@ -66,6 +67,11 @@ export function metaFactory (serverService: ServerService): MetaLoader {
66 { 67 {
67 provide: TRANSLATIONS, 68 provide: TRANSLATIONS,
68 useFactory: (locale) => { 69 useFactory: (locale) => {
70 // On dev mode, test locales
71 if (environment.production === false && window.location.search === '?lang=fr') {
72 return require(`raw-loader!../locale/target/messages_fr.xml`)
73 }
74
69 const fileLocale = buildFileLocale(locale) 75 const fileLocale = buildFileLocale(locale)
70 76
71 // Default locale, nothing to translate 77 // Default locale, nothing to translate
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts
index f7aad06e8..a91522db3 100644
--- a/client/src/app/login/login.component.ts
+++ b/client/src/app/login/login.component.ts
@@ -7,7 +7,7 @@ import { AuthService } from '../core'
7import { FormReactive } from '../shared' 7import { FormReactive } from '../shared'
8import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { LOGIN_PASSWORD, LOGIN_USERNAME } from '@app/shared/forms/form-validators/login' 10import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service'
11 11
12@Component({ 12@Component({
13 selector: 'my-login', 13 selector: 'my-login',
@@ -24,6 +24,7 @@ export class LoginComponent extends FormReactive implements OnInit {
24 24
25 constructor ( 25 constructor (
26 protected formValidatorService: FormValidatorService, 26 protected formValidatorService: FormValidatorService,
27 private loginValidatorsService: LoginValidatorsService,
27 private authService: AuthService, 28 private authService: AuthService,
28 private userService: UserService, 29 private userService: UserService,
29 private serverService: ServerService, 30 private serverService: ServerService,
@@ -40,8 +41,8 @@ export class LoginComponent extends FormReactive implements OnInit {
40 41
41 ngOnInit () { 42 ngOnInit () {
42 this.buildForm({ 43 this.buildForm({
43 username: LOGIN_USERNAME, 44 username: this.loginValidatorsService.LOGIN_USERNAME,
44 password: LOGIN_PASSWORD 45 password: this.loginValidatorsService.LOGIN_PASSWORD
45 }) 46 })
46 } 47 }
47 48
diff --git a/client/src/app/reset-password/reset-password.component.ts b/client/src/app/reset-password/reset-password.component.ts
index 58e086f45..cb4a634f1 100644
--- a/client/src/app/reset-password/reset-password.component.ts
+++ b/client/src/app/reset-password/reset-password.component.ts
@@ -1,12 +1,12 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { USER_PASSWORD, UserService } from '@app/shared' 3import { UserService, UserValidatorsService } from '@app/shared'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5import { AuthService } from '../core' 5import { AuthService } from '../core'
6import { FormReactive } from '../shared' 6import { FormReactive } from '../shared'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { RESET_PASSWORD_CONFIRM } from '@app/shared/forms/form-validators/reset-password'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
9import { ResetPasswordValidatorsService } from '@app/shared/forms/form-validators/reset-password-validators.service'
10 10
11@Component({ 11@Component({
12 selector: 'my-login', 12 selector: 'my-login',
@@ -20,6 +20,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
20 20
21 constructor ( 21 constructor (
22 protected formValidatorService: FormValidatorService, 22 protected formValidatorService: FormValidatorService,
23 private resetPasswordValidatorsService: ResetPasswordValidatorsService,
24 private userValidatorsService: UserValidatorsService,
23 private authService: AuthService, 25 private authService: AuthService,
24 private userService: UserService, 26 private userService: UserService,
25 private notificationsService: NotificationsService, 27 private notificationsService: NotificationsService,
@@ -32,8 +34,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
32 34
33 ngOnInit () { 35 ngOnInit () {
34 this.buildForm({ 36 this.buildForm({
35 password: USER_PASSWORD, 37 password: this.userValidatorsService.USER_PASSWORD,
36 'password-confirm': RESET_PASSWORD_CONFIRM 38 'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM
37 }) 39 })
38 40
39 this.userId = this.route.snapshot.queryParams['userId'] 41 this.userId = this.route.snapshot.queryParams['userId']
diff --git a/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts b/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts
new file mode 100644
index 000000000..1b36bbc6b
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts
@@ -0,0 +1,72 @@
1import { Validators } from '@angular/forms'
2import { I18n } from '@ngx-translate/i18n-polyfill'
3import { BuildFormValidator } from '@app/shared'
4import { Injectable } from '@angular/core'
5
6@Injectable()
7export class CustomConfigValidatorsService {
8 readonly INSTANCE_NAME: BuildFormValidator
9 readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator
10 readonly SERVICES_TWITTER_USERNAME: BuildFormValidator
11 readonly CACHE_PREVIEWS_SIZE: BuildFormValidator
12 readonly SIGNUP_LIMIT: BuildFormValidator
13 readonly ADMIN_EMAIL: BuildFormValidator
14 readonly TRANSCODING_THREADS: BuildFormValidator
15
16 constructor (private i18n: I18n) {
17 this.INSTANCE_NAME = {
18 VALIDATORS: [ Validators.required ],
19 MESSAGES: {
20 'required': this.i18n('Instance name is required.')
21 }
22 }
23
24 this.INSTANCE_SHORT_DESCRIPTION = {
25 VALIDATORS: [ Validators.max(250) ],
26 MESSAGES: {
27 'max': this.i18n('Short description should not be longer than 250 characters.')
28 }
29 }
30
31 this.SERVICES_TWITTER_USERNAME = {
32 VALIDATORS: [ Validators.required ],
33 MESSAGES: {
34 'required': this.i18n('Twitter username is required.')
35 }
36 }
37
38 this.CACHE_PREVIEWS_SIZE = {
39 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
40 MESSAGES: {
41 'required': this.i18n('Previews cache size is required.'),
42 'min': this.i18n('Previews cache size must be greater than 1.'),
43 'pattern': this.i18n('Previews cache size must be a number.')
44 }
45 }
46
47 this.SIGNUP_LIMIT = {
48 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
49 MESSAGES: {
50 'required': this.i18n('Signup limit is required.'),
51 'min': this.i18n('Signup limit must be greater than 1.'),
52 'pattern': this.i18n('Signup limit must be a number.')
53 }
54 }
55
56 this.ADMIN_EMAIL = {
57 VALIDATORS: [ Validators.required, Validators.email ],
58 MESSAGES: {
59 'required': this.i18n('Admin email is required.'),
60 'email': this.i18n('Admin email must be valid.')
61 }
62 }
63
64 this.TRANSCODING_THREADS = {
65 VALIDATORS: [ Validators.required, Validators.min(1) ],
66 MESSAGES: {
67 'required': this.i18n('Transcoding threads is required.'),
68 'min': this.i18n('Transcoding threads must be greater than 1.')
69 }
70 }
71 }
72}
diff --git a/client/src/app/shared/forms/form-validators/custom-config.ts b/client/src/app/shared/forms/form-validators/custom-config.ts
deleted file mode 100644
index e3d9a4c7b..000000000
--- a/client/src/app/shared/forms/form-validators/custom-config.ts
+++ /dev/null
@@ -1,56 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const INSTANCE_NAME = {
4 VALIDATORS: [ Validators.required ],
5 MESSAGES: {
6 'required': 'Instance name is required.'
7 }
8}
9
10export const INSTANCE_SHORT_DESCRIPTION = {
11 VALIDATORS: [ Validators.max(250) ],
12 MESSAGES: {
13 'max': 'Short description should not be longer than 250 characters.'
14 }
15}
16
17export const SERVICES_TWITTER_USERNAME = {
18 VALIDATORS: [ Validators.required ],
19 MESSAGES: {
20 'required': 'Twitter username is required.'
21 }
22}
23
24export const CACHE_PREVIEWS_SIZE = {
25 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
26 MESSAGES: {
27 'required': 'Preview cache size is required.',
28 'min': 'Preview cache size must be greater than 1.',
29 'pattern': 'Preview cache size must be a number.'
30 }
31}
32
33export const SIGNUP_LIMIT = {
34 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
35 MESSAGES: {
36 'required': 'Signup limit is required.',
37 'min': 'Signup limit must be greater than 1.',
38 'pattern': 'Preview cache size must be a number.'
39 }
40}
41
42export const ADMIN_EMAIL = {
43 VALIDATORS: [ Validators.required, Validators.email ],
44 MESSAGES: {
45 'required': 'Admin email is required.',
46 'email': 'Admin email must be valid.'
47 }
48}
49
50export const TRANSCODING_THREADS = {
51 VALIDATORS: [ Validators.required, Validators.min(1) ],
52 MESSAGES: {
53 'required': 'Transcoding threads is required.',
54 'min': 'Transcoding threads must be greater than 1.'
55 }
56}
diff --git a/client/src/app/shared/forms/form-validators/form-validator.service.ts b/client/src/app/shared/forms/form-validators/form-validator.service.ts
index 5c3d3e4bd..d10e17ca7 100644
--- a/client/src/app/shared/forms/form-validators/form-validator.service.ts
+++ b/client/src/app/shared/forms/form-validators/form-validator.service.ts
@@ -3,11 +3,12 @@ import { Injectable } from '@angular/core'
3import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive' 3import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive'
4import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
5 5
6export type BuildFormValidator = {
7 VALIDATORS: ValidatorFn[],
8 MESSAGES: { [ name: string ]: string }
9}
6export type BuildFormArgument = { 10export type BuildFormArgument = {
7 [ id: string ]: { 11 [ id: string ]: BuildFormValidator
8 VALIDATORS: ValidatorFn[],
9 MESSAGES: { [ name: string ]: string }
10 }
11} 12}
12export type BuildFormDefaultValues = { 13export type BuildFormDefaultValues = {
13 [ name: string ]: string | string[] 14 [ name: string ]: string | string[]
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts
index cf544b2a9..487683088 100644
--- a/client/src/app/shared/forms/form-validators/index.ts
+++ b/client/src/app/shared/forms/form-validators/index.ts
@@ -1,5 +1,10 @@
1export * from './custom-config-validators.service'
1export * from './form-validator.service' 2export * from './form-validator.service'
2export * from './host' 3export * from './host'
3export * from './user' 4export * from './login-validators.service'
4export * from './video-abuse' 5export * from './reset-password-validators.service'
5export * from './video' 6export * from './user-validators.service'
7export * from './video-abuse-validators.service'
8export * from './video-channel-validators.service'
9export * from './video-comment-validators.service'
10export * from './video-validators.service'
diff --git a/client/src/app/shared/forms/form-validators/login-validators.service.ts b/client/src/app/shared/forms/form-validators/login-validators.service.ts
new file mode 100644
index 000000000..9d68f830c
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/login-validators.service.ts
@@ -0,0 +1,30 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class LoginValidatorsService {
8 readonly LOGIN_USERNAME: BuildFormValidator
9 readonly LOGIN_PASSWORD: BuildFormValidator
10
11 constructor (private i18n: I18n) {
12 this.LOGIN_USERNAME = {
13 VALIDATORS: [
14 Validators.required
15 ],
16 MESSAGES: {
17 'required': this.i18n('Username is required.')
18 }
19 }
20
21 this.LOGIN_PASSWORD = {
22 VALIDATORS: [
23 Validators.required
24 ],
25 MESSAGES: {
26 'required': this.i18n('Password is required.')
27 }
28 }
29 }
30}
diff --git a/client/src/app/shared/forms/form-validators/login.ts b/client/src/app/shared/forms/form-validators/login.ts
deleted file mode 100644
index f37f8d285..000000000
--- a/client/src/app/shared/forms/form-validators/login.ts
+++ /dev/null
@@ -1,18 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const LOGIN_USERNAME = {
4 VALIDATORS: [
5 Validators.required
6 ],
7 MESSAGES: {
8 'required': 'Username is required.'
9 }
10}
11export const LOGIN_PASSWORD = {
12 VALIDATORS: [
13 Validators.required
14 ],
15 MESSAGES: {
16 'required': 'Password is required.'
17 }
18}
diff --git a/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts b/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts
new file mode 100644
index 000000000..df206254d
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts
@@ -0,0 +1,20 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class ResetPasswordValidatorsService {
8 readonly RESET_PASSWORD_CONFIRM: BuildFormValidator
9
10 constructor (private i18n: I18n) {
11 this.RESET_PASSWORD_CONFIRM = {
12 VALIDATORS: [
13 Validators.required
14 ],
15 MESSAGES: {
16 'required': this.i18n('Confirmation of the password is required.')
17 }
18 }
19 }
20}
diff --git a/client/src/app/shared/forms/form-validators/reset-password.ts b/client/src/app/shared/forms/form-validators/reset-password.ts
deleted file mode 100644
index 7dafdef9a..000000000
--- a/client/src/app/shared/forms/form-validators/reset-password.ts
+++ /dev/null
@@ -1,10 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const RESET_PASSWORD_CONFIRM = {
4 VALIDATORS: [
5 Validators.required
6 ],
7 MESSAGES: {
8 'required': 'Confirmation of the password is required.'
9 }
10}
diff --git a/client/src/app/shared/forms/form-validators/user-validators.service.ts b/client/src/app/shared/forms/form-validators/user-validators.service.ts
new file mode 100644
index 000000000..bb6ff2068
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/user-validators.service.ts
@@ -0,0 +1,93 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from '@app/shared'
4import { Injectable } from '@angular/core'
5
6@Injectable()
7export class UserValidatorsService {
8 readonly USER_USERNAME: BuildFormValidator
9 readonly USER_EMAIL: BuildFormValidator
10 readonly USER_PASSWORD: BuildFormValidator
11 readonly USER_VIDEO_QUOTA: BuildFormValidator
12 readonly USER_ROLE: BuildFormValidator
13 readonly USER_DISPLAY_NAME: BuildFormValidator
14 readonly USER_DESCRIPTION: BuildFormValidator
15
16 constructor (private i18n: I18n) {
17
18 this.USER_USERNAME = {
19 VALIDATORS: [
20 Validators.required,
21 Validators.minLength(3),
22 Validators.maxLength(20),
23 Validators.pattern(/^[a-z0-9._]+$/)
24 ],
25 MESSAGES: {
26 'required': this.i18n('Username is required.'),
27 'minlength': this.i18n('Username must be at least 3 characters long.'),
28 'maxlength': this.i18n('Username cannot be more than 20 characters long.'),
29 'pattern': this.i18n('Username should be only lowercase alphanumeric characters.')
30 }
31 }
32
33 this.USER_EMAIL = {
34 VALIDATORS: [ Validators.required, Validators.email ],
35 MESSAGES: {
36 'required': this.i18n('Email is required.'),
37 'email': this.i18n('Email must be valid.')
38 }
39 }
40
41 this.USER_PASSWORD = {
42 VALIDATORS: [
43 Validators.required,
44 Validators.minLength(6),
45 Validators.maxLength(255)
46 ],
47 MESSAGES: {
48 'required': this.i18n('Password is required.'),
49 'minlength': this.i18n('Password must be at least 6 characters long.'),
50 'maxlength': this.i18n('Password cannot be more than 255 characters long.')
51 }
52 }
53
54 this.USER_VIDEO_QUOTA = {
55 VALIDATORS: [ Validators.required, Validators.min(-1) ],
56 MESSAGES: {
57 'required': this.i18n('Video quota is required.'),
58 'min': this.i18n('Quota must be greater than -1.')
59 }
60 }
61
62 this.USER_ROLE = {
63 VALIDATORS: [ Validators.required ],
64 MESSAGES: {
65 'required': this.i18n('User role is required.')
66 }
67 }
68
69 this.USER_DISPLAY_NAME = {
70 VALIDATORS: [
71 Validators.required,
72 Validators.minLength(3),
73 Validators.maxLength(120)
74 ],
75 MESSAGES: {
76 'required': this.i18n('Display name is required.'),
77 'minlength': this.i18n('Display name must be at least 3 characters long.'),
78 'maxlength': this.i18n('Display name cannot be more than 120 characters long.')
79 }
80 }
81
82 this.USER_DESCRIPTION = {
83 VALIDATORS: [
84 Validators.minLength(3),
85 Validators.maxLength(250)
86 ],
87 MESSAGES: {
88 'minlength': this.i18n('Description must be at least 3 characters long.'),
89 'maxlength': this.i18n('Description cannot be more than 250 characters long.')
90 }
91 }
92 }
93}
diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts
deleted file mode 100644
index 0973f1b00..000000000
--- a/client/src/app/shared/forms/form-validators/user.ts
+++ /dev/null
@@ -1,70 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const USER_USERNAME = {
4 VALIDATORS: [
5 Validators.required,
6 Validators.minLength(3),
7 Validators.maxLength(20),
8 Validators.pattern(/^[a-z0-9._]+$/)
9 ],
10 MESSAGES: {
11 'required': 'Username is required.',
12 'minlength': 'Username must be at least 3 characters long.',
13 'maxlength': 'Username cannot be more than 20 characters long.',
14 'pattern': 'Username should be only lowercase alphanumeric characters.'
15 }
16}
17export const USER_EMAIL = {
18 VALIDATORS: [ Validators.required, Validators.email ],
19 MESSAGES: {
20 'required': 'Email is required.',
21 'email': 'Email must be valid.'
22 }
23}
24export const USER_PASSWORD = {
25 VALIDATORS: [
26 Validators.required,
27 Validators.minLength(6),
28 Validators.maxLength(255)
29 ],
30 MESSAGES: {
31 'required': 'Password is required.',
32 'minlength': 'Password must be at least 6 characters long.',
33 'maxlength': 'Password cannot be more than 255 characters long.'
34 }
35}
36export const USER_VIDEO_QUOTA = {
37 VALIDATORS: [ Validators.required, Validators.min(-1) ],
38 MESSAGES: {
39 'required': 'Video quota is required.',
40 'min': 'Quota must be greater than -1.'
41 }
42}
43export const USER_ROLE = {
44 VALIDATORS: [ Validators.required ],
45 MESSAGES: {
46 'required': 'User role is required.'
47 }
48}
49export const USER_DISPLAY_NAME = {
50 VALIDATORS: [
51 Validators.required,
52 Validators.minLength(3),
53 Validators.maxLength(120)
54 ],
55 MESSAGES: {
56 'required': 'Display name is required.',
57 'minlength': 'Display name must be at least 3 characters long.',
58 'maxlength': 'Display name cannot be more than 120 characters long.'
59 }
60}
61export const USER_DESCRIPTION = {
62 VALIDATORS: [
63 Validators.minLength(3),
64 Validators.maxLength(250)
65 ],
66 MESSAGES: {
67 'minlength': 'Description must be at least 3 characters long.',
68 'maxlength': 'Description cannot be more than 250 characters long.'
69 }
70}
diff --git a/client/src/app/shared/forms/form-validators/validator-message.ts b/client/src/app/shared/forms/form-validators/validator-message.ts
deleted file mode 100644
index 5ce45833b..000000000
--- a/client/src/app/shared/forms/form-validators/validator-message.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export type ValidatorMessage = {
2 [ id: string ]: {
3 [ error: string ]: string
4 }
5}
diff --git a/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts
new file mode 100644
index 000000000..774e6a488
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts
@@ -0,0 +1,20 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class VideoAbuseValidatorsService {
8 readonly VIDEO_ABUSE_REASON: BuildFormValidator
9
10 constructor (private i18n: I18n) {
11 this.VIDEO_ABUSE_REASON = {
12 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ],
13 MESSAGES: {
14 'required': this.i18n('Report reason is required.'),
15 'minlength': this.i18n('Report reason must be at least 2 characters long.'),
16 'maxlength': this.i18n('Report reason cannot be more than 300 characters long.')
17 }
18 }
19 }
20}
diff --git a/client/src/app/shared/forms/form-validators/video-abuse.ts b/client/src/app/shared/forms/form-validators/video-abuse.ts
deleted file mode 100644
index 4b2a2b789..000000000
--- a/client/src/app/shared/forms/form-validators/video-abuse.ts
+++ /dev/null
@@ -1,10 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const VIDEO_ABUSE_REASON = {
4 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ],
5 MESSAGES: {
6 'required': 'Report reason is required.',
7 'minlength': 'Report reason must be at least 2 characters long.',
8 'maxlength': 'Report reason cannot be more than 300 characters long.'
9 }
10}
diff --git a/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts b/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts
new file mode 100644
index 000000000..28b063f89
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts
@@ -0,0 +1,48 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class VideoChannelValidatorsService {
8 readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
9 readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
10 readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
11
12 constructor (private i18n: I18n) {
13 this.VIDEO_CHANNEL_DISPLAY_NAME = {
14 VALIDATORS: [
15 Validators.required,
16 Validators.minLength(3),
17 Validators.maxLength(120)
18 ],
19 MESSAGES: {
20 'required': i18n('Display name is required.'),
21 'minlength': i18n('Display name must be at least 3 characters long.'),
22 'maxlength': i18n('Display name cannot be more than 120 characters long.')
23 }
24 }
25
26 this.VIDEO_CHANNEL_DESCRIPTION = {
27 VALIDATORS: [
28 Validators.minLength(3),
29 Validators.maxLength(500)
30 ],
31 MESSAGES: {
32 'minlength': i18n('Description must be at least 3 characters long.'),
33 'maxlength': i18n('Description cannot be more than 500 characters long.')
34 }
35 }
36
37 this.VIDEO_CHANNEL_SUPPORT = {
38 VALIDATORS: [
39 Validators.minLength(3),
40 Validators.maxLength(500)
41 ],
42 MESSAGES: {
43 'minlength': i18n('Support text must be at least 3 characters long.'),
44 'maxlength': i18n('Support text cannot be more than 500 characters long.')
45 }
46 }
47 }
48}
diff --git a/client/src/app/shared/forms/form-validators/video-channel.ts b/client/src/app/shared/forms/form-validators/video-channel.ts
deleted file mode 100644
index 2185cdaa9..000000000
--- a/client/src/app/shared/forms/form-validators/video-channel.ts
+++ /dev/null
@@ -1,34 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const VIDEO_CHANNEL_DISPLAY_NAME = {
4 VALIDATORS: [
5 Validators.required,
6 Validators.minLength(3),
7 Validators.maxLength(120)
8 ],
9 MESSAGES: {
10 'required': 'Display name is required.',
11 'minlength': 'Display name must be at least 3 characters long.',
12 'maxlength': 'Display name cannot be more than 120 characters long.'
13 }
14}
15export const VIDEO_CHANNEL_DESCRIPTION = {
16 VALIDATORS: [
17 Validators.minLength(3),
18 Validators.maxLength(500)
19 ],
20 MESSAGES: {
21 'minlength': 'Description must be at least 3 characters long.',
22 'maxlength': 'Description cannot be more than 500 characters long.'
23 }
24}
25export const VIDEO_CHANNEL_SUPPORT = {
26 VALIDATORS: [
27 Validators.minLength(3),
28 Validators.maxLength(500)
29 ],
30 MESSAGES: {
31 'minlength': 'Support text must be at least 3 characters long.',
32 'maxlength': 'Support text cannot be more than 500 characters long.'
33 }
34}
diff --git a/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts b/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts
new file mode 100644
index 000000000..45c7081ef
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts
@@ -0,0 +1,20 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class VideoCommentValidatorsService {
8 readonly VIDEO_COMMENT_TEXT: BuildFormValidator
9
10 constructor (private i18n: I18n) {
11 this.VIDEO_COMMENT_TEXT = {
12 VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
13 MESSAGES: {
14 'required': this.i18n('Comment is required.'),
15 'minlength': this.i18n('Comment must be at least 2 characters long.'),
16 'maxlength': this.i18n('Comment cannot be more than 3000 characters long.')
17 }
18 }
19 }
20}
diff --git a/client/src/app/shared/forms/form-validators/video-comment.ts b/client/src/app/shared/forms/form-validators/video-comment.ts
deleted file mode 100644
index 290d83195..000000000
--- a/client/src/app/shared/forms/form-validators/video-comment.ts
+++ /dev/null
@@ -1,10 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const VIDEO_COMMENT_TEXT = {
4 VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
5 MESSAGES: {
6 'required': 'Comment is required.',
7 'minlength': 'Comment must be at least 2 characters long.',
8 'maxlength': 'Comment cannot be more than 3000 characters long.'
9 }
10}
diff --git a/client/src/app/shared/forms/form-validators/video-validators.service.ts b/client/src/app/shared/forms/form-validators/video-validators.service.ts
new file mode 100644
index 000000000..76fc5cf04
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/video-validators.service.ts
@@ -0,0 +1,88 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class VideoValidatorsService {
8 readonly VIDEO_NAME: BuildFormValidator
9 readonly VIDEO_PRIVACY: BuildFormValidator
10 readonly VIDEO_CATEGORY: BuildFormValidator
11 readonly VIDEO_LICENCE: BuildFormValidator
12 readonly VIDEO_LANGUAGE: BuildFormValidator
13 readonly VIDEO_IMAGE: BuildFormValidator
14 readonly VIDEO_CHANNEL: BuildFormValidator
15 readonly VIDEO_DESCRIPTION: BuildFormValidator
16 readonly VIDEO_TAGS: BuildFormValidator
17 readonly VIDEO_SUPPORT: BuildFormValidator
18
19 constructor (private i18n: I18n) {
20
21 this.VIDEO_NAME = {
22 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
23 MESSAGES: {
24 'required': this.i18n('Video name is required.'),
25 'minlength': this.i18n('Video name must be at least 3 characters long.'),
26 'maxlength': this.i18n('Video name cannot be more than 120 characters long.')
27 }
28 }
29
30 this.VIDEO_PRIVACY = {
31 VALIDATORS: [ Validators.required ],
32 MESSAGES: {
33 'required': this.i18n('Video privacy is required.')
34 }
35 }
36
37 this.VIDEO_CATEGORY = {
38 VALIDATORS: [ ],
39 MESSAGES: {}
40 }
41
42 this.VIDEO_LICENCE = {
43 VALIDATORS: [ ],
44 MESSAGES: {}
45 }
46
47 this.VIDEO_LANGUAGE = {
48 VALIDATORS: [ ],
49 MESSAGES: {}
50 }
51
52 this.VIDEO_IMAGE = {
53 VALIDATORS: [ ],
54 MESSAGES: {}
55 }
56
57 this.VIDEO_CHANNEL = {
58 VALIDATORS: [ Validators.required ],
59 MESSAGES: {
60 'required': this.i18n('Video channel is required.')
61 }
62 }
63
64 this.VIDEO_DESCRIPTION = {
65 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
66 MESSAGES: {
67 'minlength': this.i18n('Video description must be at least 3 characters long.'),
68 'maxlength': this.i18n('Video description cannot be more than 10000 characters long.')
69 }
70 }
71
72 this.VIDEO_TAGS = {
73 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
74 MESSAGES: {
75 'minlength': this.i18n('A tag should be more than 2 characters long.'),
76 'maxlength': this.i18n('A tag should be less than 30 characters long.')
77 }
78 }
79
80 this.VIDEO_SUPPORT = {
81 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ],
82 MESSAGES: {
83 'minlength': this.i18n('Video support must be at least 3 characters long.'),
84 'maxlength': this.i18n('Video support cannot be more than 500 characters long.')
85 }
86 }
87 }
88}
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts
deleted file mode 100644
index a986243df..000000000
--- a/client/src/app/shared/forms/form-validators/video.ts
+++ /dev/null
@@ -1,68 +0,0 @@
1import { Validators } from '@angular/forms'
2
3export const VIDEO_NAME = {
4 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
5 MESSAGES: {
6 'required': 'Video name is required.',
7 'minlength': 'Video name must be at least 3 characters long.',
8 'maxlength': 'Video name cannot be more than 120 characters long.'
9 }
10}
11
12export const VIDEO_PRIVACY = {
13 VALIDATORS: [ Validators.required ],
14 MESSAGES: {
15 'required': 'Video privacy is required.'
16 }
17}
18
19export const VIDEO_CATEGORY = {
20 VALIDATORS: [ ],
21 MESSAGES: {}
22}
23
24export const VIDEO_LICENCE = {
25 VALIDATORS: [ ],
26 MESSAGES: {}
27}
28
29export const VIDEO_LANGUAGE = {
30 VALIDATORS: [ ],
31 MESSAGES: {}
32}
33
34export const VIDEO_IMAGE = {
35 VALIDATORS: [ ],
36 MESSAGES: {}
37}
38
39export const VIDEO_CHANNEL = {
40 VALIDATORS: [ Validators.required ],
41 MESSAGES: {
42 'required': 'Video channel is required.'
43 }
44}
45
46export const VIDEO_DESCRIPTION = {
47 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
48 MESSAGES: {
49 'minlength': 'Video description must be at least 3 characters long.',
50 'maxlength': 'Video description cannot be more than 10000 characters long.'
51 }
52}
53
54export const VIDEO_TAGS = {
55 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
56 MESSAGES: {
57 'minlength': 'A tag should be more than 2 characters long.',
58 'maxlength': 'A tag should be less than 30 characters long.'
59 }
60}
61
62export const VIDEO_SUPPORT = {
63 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ],
64 MESSAGES: {
65 'minlength': 'Video support must be at least 3 characters long.',
66 'maxlength': 'Video support cannot be more than 500 characters long.'
67 }
68}
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 91d905ec7..b85445ef5 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -35,6 +35,12 @@ import { AccountService } from '@app/shared/account/account.service'
35import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 35import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
36import { I18n } from '@ngx-translate/i18n-polyfill' 36import { I18n } from '@ngx-translate/i18n-polyfill'
37import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 37import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
38import {
39 CustomConfigValidatorsService,
40 LoginValidatorsService,
41 ResetPasswordValidatorsService,
42 UserValidatorsService, VideoAbuseValidatorsService, VideoChannelValidatorsService, VideoCommentValidatorsService, VideoValidatorsService
43} from '@app/shared/forms'
38 44
39@NgModule({ 45@NgModule({
40 imports: [ 46 imports: [
@@ -111,7 +117,17 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
111 AccountService, 117 AccountService,
112 MarkdownService, 118 MarkdownService,
113 VideoChannelService, 119 VideoChannelService,
120
114 FormValidatorService, 121 FormValidatorService,
122 CustomConfigValidatorsService,
123 LoginValidatorsService,
124 ResetPasswordValidatorsService,
125 UserValidatorsService,
126 VideoAbuseValidatorsService,
127 VideoChannelValidatorsService,
128 VideoCommentValidatorsService,
129 VideoValidatorsService,
130
115 I18n 131 I18n
116 ] 132 ]
117}) 133})
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts
index 682e592c7..a40f42cb1 100644
--- a/client/src/app/signup/signup.component.ts
+++ b/client/src/app/signup/signup.component.ts
@@ -1,10 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { ServerService } from '@app/core/server' 3import { ServerService } from '@app/core/server'
4
5import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
6import { UserCreate } from '../../../../shared' 5import { UserCreate } from '../../../../shared'
7import { FormReactive, USER_EMAIL, USER_PASSWORD, USER_USERNAME, UserService } from '../shared' 6import { FormReactive, UserService, UserValidatorsService } from '../shared'
8import { RedirectService } from '@app/core' 7import { RedirectService } from '@app/core'
9import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
10import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
@@ -32,6 +31,7 @@ export class SignupComponent extends FormReactive implements OnInit {
32 31
33 constructor ( 32 constructor (
34 protected formValidatorService: FormValidatorService, 33 protected formValidatorService: FormValidatorService,
34 private userValidatorsService: UserValidatorsService,
35 private router: Router, 35 private router: Router,
36 private notificationsService: NotificationsService, 36 private notificationsService: NotificationsService,
37 private userService: UserService, 37 private userService: UserService,
@@ -48,9 +48,9 @@ export class SignupComponent extends FormReactive implements OnInit {
48 48
49 ngOnInit () { 49 ngOnInit () {
50 this.buildForm({ 50 this.buildForm({
51 username: USER_USERNAME, 51 username: this.userValidatorsService.USER_USERNAME,
52 password: USER_PASSWORD, 52 password: this.userValidatorsService.USER_PASSWORD,
53 email: USER_EMAIL 53 email: this.userValidatorsService.USER_EMAIL
54 }) 54 })
55 55
56 this.serverService.configLoaded 56 this.serverService.configLoaded
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
index cd2a26ae3..61515c0b0 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
@@ -1,20 +1,9 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { FormGroup } from '@angular/forms' 2import { FormGroup, ValidatorFn } from '@angular/forms'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { VIDEO_SUPPORT } from '@app/shared' 4import { FormReactiveValidationMessages, VideoValidatorsService } from '@app/shared'
5import { NotificationsService } from 'angular2-notifications' 5import { NotificationsService } from 'angular2-notifications'
6import { ServerService } from '../../../core/server' 6import { ServerService } from '../../../core/server'
7import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators'
8import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message'
9import {
10 VIDEO_CATEGORY,
11 VIDEO_DESCRIPTION,
12 VIDEO_LANGUAGE,
13 VIDEO_LICENCE,
14 VIDEO_NAME,
15 VIDEO_PRIVACY,
16 VIDEO_TAGS
17} from '../../../shared/forms/form-validators/video'
18import { VideoEdit } from '../../../shared/video/video-edit.model' 7import { VideoEdit } from '../../../shared/video/video-edit.model'
19import { map } from 'rxjs/operators' 8import { map } from 'rxjs/operators'
20import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
@@ -28,7 +17,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
28export class VideoEditComponent implements OnInit { 17export class VideoEditComponent implements OnInit {
29 @Input() form: FormGroup 18 @Input() form: FormGroup
30 @Input() formErrors: { [ id: string ]: string } = {} 19 @Input() formErrors: { [ id: string ]: string } = {}
31 @Input() validationMessages: ValidatorMessage = {} 20 @Input() validationMessages: FormReactiveValidationMessages = {}
32 @Input() videoPrivacies = [] 21 @Input() videoPrivacies = []
33 @Input() userVideoChannels: { id: number, label: string, support: string }[] = [] 22 @Input() userVideoChannels: { id: number, label: string, support: string }[] = []
34 23
@@ -37,18 +26,22 @@ export class VideoEditComponent implements OnInit {
37 videoLanguages = [] 26 videoLanguages = []
38 video: VideoEdit 27 video: VideoEdit
39 28
40 tagValidators = VIDEO_TAGS.VALIDATORS 29 tagValidators: ValidatorFn[]
41 tagValidatorsMessages = VIDEO_TAGS.MESSAGES 30 tagValidatorsMessages: { [ name: string ]: string }
42 31
43 error: string = null 32 error: string = null
44 33
45 constructor ( 34 constructor (
46 private formValidatorService: FormValidatorService, 35 private formValidatorService: FormValidatorService,
36 private videoValidatorsService: VideoValidatorsService,
47 private route: ActivatedRoute, 37 private route: ActivatedRoute,
48 private router: Router, 38 private router: Router,
49 private notificationsService: NotificationsService, 39 private notificationsService: NotificationsService,
50 private serverService: ServerService 40 private serverService: ServerService
51 ) { } 41 ) {
42 this.tagValidators = this.videoValidatorsService.VIDEO_TAGS.VALIDATORS
43 this.tagValidatorsMessages = this.videoValidatorsService.VIDEO_TAGS.MESSAGES
44 }
52 45
53 updateForm () { 46 updateForm () {
54 const defaultValues = { 47 const defaultValues = {
@@ -57,19 +50,19 @@ export class VideoEditComponent implements OnInit {
57 tags: [] 50 tags: []
58 } 51 }
59 const obj = { 52 const obj = {
60 name: VIDEO_NAME, 53 name: this.videoValidatorsService.VIDEO_NAME,
61 privacy: VIDEO_PRIVACY, 54 privacy: this.videoValidatorsService.VIDEO_PRIVACY,
62 channelId: VIDEO_CHANNEL, 55 channelId: this.videoValidatorsService.VIDEO_CHANNEL,
63 nsfw: null, 56 nsfw: null,
64 commentsEnabled: null, 57 commentsEnabled: null,
65 category: VIDEO_CATEGORY, 58 category: this.videoValidatorsService.VIDEO_CATEGORY,
66 licence: VIDEO_LICENCE, 59 licence: this.videoValidatorsService.VIDEO_LICENCE,
67 language: VIDEO_LANGUAGE, 60 language: this.videoValidatorsService.VIDEO_LANGUAGE,
68 description: VIDEO_DESCRIPTION, 61 description: this.videoValidatorsService.VIDEO_DESCRIPTION,
69 tags: null, 62 tags: null,
70 thumbnailfile: null, 63 thumbnailfile: null,
71 previewfile: null, 64 previewfile: null,
72 support: VIDEO_SUPPORT 65 support: this.videoValidatorsService.VIDEO_SUPPORT
73 } 66 }
74 67
75 this.formValidatorService.updateForm( 68 this.formValidatorService.updateForm(
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
index c70e544a3..46d7a4e9e 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
@@ -3,13 +3,13 @@ import { NotificationsService } from 'angular2-notifications'
3import { Observable } from 'rxjs' 3import { Observable } from 'rxjs'
4import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' 4import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model'
5import { FormReactive } from '../../../shared' 5import { FormReactive } from '../../../shared'
6import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment'
7import { User } from '../../../shared/users' 6import { User } from '../../../shared/users'
8import { Video } from '../../../shared/video/video.model' 7import { Video } from '../../../shared/video/video.model'
9import { VideoComment } from './video-comment.model' 8import { VideoComment } from './video-comment.model'
10import { VideoCommentService } from './video-comment.service' 9import { VideoCommentService } from './video-comment.service'
11import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
12import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
12import { VideoCommentValidatorsService } from '@app/shared/forms/form-validators/video-comment-validators.service'
13 13
14@Component({ 14@Component({
15 selector: 'my-video-comment-add', 15 selector: 'my-video-comment-add',
@@ -29,6 +29,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
29 29
30 constructor ( 30 constructor (
31 protected formValidatorService: FormValidatorService, 31 protected formValidatorService: FormValidatorService,
32 private videoCommentValidatorsService: VideoCommentValidatorsService,
32 private notificationsService: NotificationsService, 33 private notificationsService: NotificationsService,
33 private videoCommentService: VideoCommentService, 34 private videoCommentService: VideoCommentService,
34 private i18n: I18n 35 private i18n: I18n
@@ -38,7 +39,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
38 39
39 ngOnInit () { 40 ngOnInit () {
40 this.buildForm({ 41 this.buildForm({
41 text: VIDEO_COMMENT_TEXT 42 text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT
42 }) 43 })
43 44
44 if (this.focusOnInit === true) { 45 if (this.focusOnInit === true) {
diff --git a/client/src/app/videos/+video-watch/modal/video-report.component.ts b/client/src/app/videos/+video-watch/modal/video-report.component.ts
index 8641e8dfb..d9768fdac 100644
--- a/client/src/app/videos/+video-watch/modal/video-report.component.ts
+++ b/client/src/app/videos/+video-watch/modal/video-report.component.ts
@@ -1,12 +1,11 @@
1import { Component, Input, OnInit, ViewChild } from '@angular/core' 1import { Component, Input, OnInit, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
4import { ModalDirective } from 'ngx-bootstrap/modal' 3import { ModalDirective } from 'ngx-bootstrap/modal'
5import { FormReactive, VIDEO_ABUSE_REASON, VideoAbuseService } from '../../../shared/index' 4import { FormReactive, VideoAbuseService } from '../../../shared/index'
6import { VideoDetails } from '../../../shared/video/video-details.model' 5import { VideoDetails } from '../../../shared/video/video-details.model'
7import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
8import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 7import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service'
10 9
11@Component({ 10@Component({
12 selector: 'my-video-report', 11 selector: 'my-video-report',
@@ -22,6 +21,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
22 21
23 constructor ( 22 constructor (
24 protected formValidatorService: FormValidatorService, 23 protected formValidatorService: FormValidatorService,
24 private videoAbuseValidatorsService: VideoAbuseValidatorsService,
25 private videoAbuseService: VideoAbuseService, 25 private videoAbuseService: VideoAbuseService,
26 private notificationsService: NotificationsService, 26 private notificationsService: NotificationsService,
27 private i18n: I18n 27 private i18n: I18n
@@ -31,7 +31,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
31 31
32 ngOnInit () { 32 ngOnInit () {
33 this.buildForm({ 33 this.buildForm({
34 reason: VIDEO_ABUSE_REASON 34 reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON
35 }) 35 })
36 } 36 }
37 37