From 7ed1edbbe4ffbef28093e4f5630751cb652814e4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Aug 2020 11:47:04 +0200 Subject: We don't need services anymore for validators --- .../my-account-video-channel-create.component.ts | 17 +++++++++++------ .../my-account-video-channel-update.component.ts | 14 +++++++++----- .../my-account-accept-ownership.component.ts | 6 +++--- .../my-account-change-email.component.ts | 10 +++++----- .../my-account-change-password.component.ts | 10 +++++----- .../my-account-profile.component.ts | 10 +++++----- .../my-account-video-playlist-create.component.ts | 20 +++++++++++++------- .../my-account-video-playlist-update.component.ts | 20 +++++++++++++------- .../video-change-ownership.component.ts | 6 +++--- 9 files changed, 67 insertions(+), 46 deletions(-) (limited to 'client/src/app/+my-account') 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 5c438c3bf..e2ea87fb8 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 @@ -1,7 +1,13 @@ import { Component, OnInit } from '@angular/core' import { Router } from '@angular/router' import { AuthService, Notifier } from '@app/core' -import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' +import { + VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, + VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, + VIDEO_CHANNEL_NAME_VALIDATOR, + VIDEO_CHANNEL_SUPPORT_VALIDATOR +} from '@app/shared/form-validators/video-channel-validators' +import { FormValidatorService } from '@app/shared/shared-forms' import { VideoChannelService } from '@app/shared/shared-main' import { VideoChannelCreate } from '@shared/models' import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' @@ -17,7 +23,6 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, - private videoChannelValidatorsService: VideoChannelValidatorsService, private notifier: Notifier, private router: Router, private videoChannelService: VideoChannelService @@ -31,10 +36,10 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE ngOnInit () { this.buildForm({ - name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME, - 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, - description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, - support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT + name: VIDEO_CHANNEL_NAME_VALIDATOR, + 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, + description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, + support: VIDEO_CHANNEL_SUPPORT_VALIDATOR }) } 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 485521dcc..01659b8da 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 @@ -2,7 +2,12 @@ import { Subscription } from 'rxjs' import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, Notifier, ServerService } from '@app/core' -import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' +import { + VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, + VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, + VIDEO_CHANNEL_SUPPORT_VALIDATOR +} from '@app/shared/form-validators/video-channel-validators' +import { FormValidatorService } from '@app/shared/shared-forms' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { ServerConfig, VideoChannelUpdate } from '@shared/models' import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' @@ -23,7 +28,6 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, - private videoChannelValidatorsService: VideoChannelValidatorsService, private notifier: Notifier, private router: Router, private route: ActivatedRoute, @@ -39,9 +43,9 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE .subscribe(config => this.serverConfig = config) this.buildForm({ - 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, - description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, - support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT, + 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, + description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, + support: VIDEO_CHANNEL_SUPPORT_VALIDATOR, bulkVideosSupportUpdate: null }) diff --git a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts index 3bfffe2da..4c4436755 100644 --- a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts +++ b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts @@ -1,6 +1,7 @@ import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { AuthService, Notifier } from '@app/core' -import { FormReactive, FormValidatorService, VideoAcceptOwnershipValidatorsService } from '@app/shared/shared-forms' +import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { VideoChangeOwnership, VideoChannel } from '@shared/models' @@ -23,7 +24,6 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O constructor ( protected formValidatorService: FormValidatorService, - private videoChangeOwnershipValidatorsService: VideoAcceptOwnershipValidatorsService, private videoOwnershipService: VideoOwnershipService, private notifier: Notifier, private authService: AuthService, @@ -40,7 +40,7 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O .subscribe(videoChannels => this.videoChannels = videoChannels.data) this.buildForm({ - channel: this.videoChangeOwnershipValidatorsService.CHANNEL + channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR }) } diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts index 396936ef3..b2b7849c2 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts @@ -2,7 +2,8 @@ import { forkJoin } from 'rxjs' import { tap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { AuthService, ServerService, UserService } from '@app/core' -import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' +import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { User } from '@shared/models' @Component({ @@ -17,18 +18,17 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni constructor ( protected formValidatorService: FormValidatorService, - private userValidatorsService: UserValidatorsService, private authService: AuthService, private userService: UserService, private serverService: ServerService - ) { + ) { super() } ngOnInit () { this.buildForm({ - 'new-email': this.userValidatorsService.USER_EMAIL, - 'password': this.userValidatorsService.USER_PASSWORD + 'new-email': USER_EMAIL_VALIDATOR, + 'password': USER_PASSWORD_VALIDATOR }) this.user = this.authService.getUser() 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 91fe4ec72..ba68bab32 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,7 +1,8 @@ import { filter } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { AuthService, Notifier, UserService } from '@app/core' -import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' +import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { User } from '@shared/models' @Component({ @@ -15,7 +16,6 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On constructor ( protected formValidatorService: FormValidatorService, - private userValidatorsService: UserValidatorsService, private notifier: Notifier, private authService: AuthService, private userService: UserService @@ -25,9 +25,9 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On ngOnInit () { this.buildForm({ - 'current-password': this.userValidatorsService.USER_PASSWORD, - 'new-password': this.userValidatorsService.USER_PASSWORD, - 'new-confirmed-password': this.userValidatorsService.USER_CONFIRM_PASSWORD + 'current-password': USER_PASSWORD_VALIDATOR, + 'new-password': USER_PASSWORD_VALIDATOR, + 'new-confirmed-password': USER_CONFIRM_PASSWORD_VALIDATOR }) this.user = this.authService.getUser() 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 ed0984bf7..000a2c0ac 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,7 +1,8 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' import { Notifier, User, UserService } from '@app/core' -import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' +import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' @Component({ selector: 'my-account-profile', @@ -16,17 +17,16 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, - private userValidatorsService: UserValidatorsService, private notifier: Notifier, private userService: UserService - ) { + ) { super() } ngOnInit () { this.buildForm({ - 'display-name': this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED, - description: this.userValidatorsService.USER_DESCRIPTION + 'display-name': USER_DISPLAY_NAME_REQUIRED_VALIDATOR, + description: USER_DESCRIPTION_VALIDATOR }) this.userInformationLoaded.subscribe(() => { diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts index 5427dc3a0..7a80aaa92 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts @@ -2,7 +2,14 @@ import { Component, OnInit } from '@angular/core' import { Router } from '@angular/router' import { AuthService, Notifier, ServerService } from '@app/core' import { populateAsyncUserVideoChannels } from '@app/helpers' -import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms' +import { + setPlaylistChannelValidator, + VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR, + VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR, + VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, + VIDEO_PLAYLIST_PRIVACY_VALIDATOR +} from '@app/shared/form-validators/video-playlist-validators' +import { FormValidatorService } from '@app/shared/shared-forms' import { VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model' import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' @@ -19,7 +26,6 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, - private videoPlaylistValidatorsService: VideoPlaylistValidatorsService, private notifier: Notifier, private router: Router, private videoPlaylistService: VideoPlaylistService, @@ -30,15 +36,15 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis ngOnInit () { this.buildForm({ - displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, - privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, - description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, - videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, + displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, + privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR, + description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR, + videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR, thumbnailfile: null }) this.form.get('privacy').valueChanges.subscribe(privacy => { - this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy) + setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy) }) populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts index 149d0d94f..fefc6d607 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts @@ -4,7 +4,14 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, Notifier, ServerService } from '@app/core' import { populateAsyncUserVideoChannels } from '@app/helpers' -import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms' +import { + setPlaylistChannelValidator, + VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR, + VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR, + VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, + VIDEO_PLAYLIST_PRIVACY_VALIDATOR +} from '@app/shared/form-validators/video-playlist-validators' +import { FormValidatorService } from '@app/shared/shared-forms' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylistUpdate } from '@shared/models' import { MyAccountVideoPlaylistEdit } from './my-account-video-playlist-edit' @@ -23,7 +30,6 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, - private videoPlaylistValidatorsService: VideoPlaylistValidatorsService, private notifier: Notifier, private router: Router, private route: ActivatedRoute, @@ -35,15 +41,15 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis ngOnInit () { this.buildForm({ - displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, - privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, - description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, - videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, + displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, + privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR, + description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR, + videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR, thumbnailfile: null }) this.form.get('privacy').valueChanges.subscribe(privacy => { - this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy) + setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy) }) populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) diff --git a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts index edd691694..84237dee1 100644 --- a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts +++ b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts @@ -1,6 +1,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { Notifier, UserService } from '@app/core' -import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms' +import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { Video, VideoOwnershipService } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' @@ -20,7 +21,6 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni constructor ( protected formValidatorService: FormValidatorService, - private videoChangeOwnershipValidatorsService: VideoChangeOwnershipValidatorsService, private videoOwnershipService: VideoOwnershipService, private notifier: Notifier, private userService: UserService, @@ -31,7 +31,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni ngOnInit () { this.buildForm({ - username: this.videoChangeOwnershipValidatorsService.USERNAME + username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR }) this.usernamePropositions = [] } -- cgit v1.2.3