Refactor form reactive

This commit is contained in:
Chocobozzz 2022-10-07 15:26:53 +02:00
parent a69ea13086
commit 5c5bcea2e6
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
46 changed files with 101 additions and 171 deletions

View File

@ -7,7 +7,7 @@ import {
FROM_NAME_VALIDATOR, FROM_NAME_VALIDATOR,
SUBJECT_VALIDATOR SUBJECT_VALIDATOR
} from '@app/shared/form-validators/instance-validators' } from '@app/shared/form-validators/instance-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance' import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -32,7 +32,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private router: Router, private router: Router,
private modalService: NgbModal, private modalService: NgbModal,
private instanceService: InstanceService, private instanceService: InstanceService,

View File

@ -18,15 +18,15 @@ import {
MAX_INSTANCE_LIVES_VALIDATOR, MAX_INSTANCE_LIVES_VALIDATOR,
MAX_LIVE_DURATION_VALIDATOR, MAX_LIVE_DURATION_VALIDATOR,
MAX_USER_LIVES_VALIDATOR, MAX_USER_LIVES_VALIDATOR,
MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR,
SEARCH_INDEX_URL_VALIDATOR, SEARCH_INDEX_URL_VALIDATOR,
SERVICES_TWITTER_USERNAME_VALIDATOR, SERVICES_TWITTER_USERNAME_VALIDATOR,
SIGNUP_LIMIT_VALIDATOR, SIGNUP_LIMIT_VALIDATOR,
SIGNUP_MINIMUM_AGE_VALIDATOR, SIGNUP_MINIMUM_AGE_VALIDATOR,
TRANSCODING_THREADS_VALIDATOR, TRANSCODING_THREADS_VALIDATOR
MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR
} from '@app/shared/form-validators/custom-config-validators' } from '@app/shared/form-validators/custom-config-validators'
import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { CustomPageService } from '@app/shared/shared-main/custom-page' import { CustomPageService } from '@app/shared/shared-main/custom-page'
import { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models' import { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models'
import { EditConfigurationService } from './edit-configuration.service' import { EditConfigurationService } from './edit-configuration.service'
@ -52,9 +52,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
categoryItems: SelectOptionsItem[] = [] categoryItems: SelectOptionsItem[] = []
constructor ( constructor (
protected formReactiveService: FormReactiveService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
protected formValidatorService: FormValidatorService,
private notifier: Notifier, private notifier: Notifier,
private configService: ConfigService, private configService: ConfigService,
private customPage: CustomPageService, private customPage: CustomPageService,

View File

@ -2,7 +2,7 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/cor
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { prepareIcu } from '@app/helpers' import { prepareIcu } from '@app/helpers'
import { splitAndGetNotEmpty, UNIQUE_HOSTS_OR_HANDLE_VALIDATOR } from '@app/shared/form-validators/host-validators' import { splitAndGetNotEmpty, UNIQUE_HOSTS_OR_HANDLE_VALIDATOR } from '@app/shared/form-validators/host-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { InstanceFollowService } from '@app/shared/shared-instance' import { InstanceFollowService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -22,7 +22,7 @@ export class FollowModalComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private followService: InstanceFollowService, private followService: InstanceFollowService,
private notifier: Notifier private notifier: Notifier

View File

@ -12,7 +12,7 @@ import {
USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_DAILY_VALIDATOR,
USER_VIDEO_QUOTA_VALIDATOR USER_VIDEO_QUOTA_VALIDATOR
} from '@app/shared/form-validators/user-validators' } from '@app/shared/form-validators/user-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { UserAdminService } from '@app/shared/shared-users' import { UserAdminService } from '@app/shared/shared-users'
import { UserCreate, UserRole } from '@shared/models' import { UserCreate, UserRole } from '@shared/models'
import { UserEdit } from './user-edit' import { UserEdit } from './user-edit'
@ -27,7 +27,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
constructor ( constructor (
protected serverService: ServerService, protected serverService: ServerService,
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected configService: ConfigService, protected configService: ConfigService,
protected screenService: ScreenService, protected screenService: ScreenService,
protected auth: AuthService, protected auth: AuthService,

View File

@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { UserAdminService } from '@app/shared/shared-users' import { UserAdminService } from '@app/shared/shared-users'
import { UserUpdate } from '@shared/models' import { UserUpdate } from '@shared/models'
@ -18,7 +18,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
@Input() userId: number @Input() userId: number
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private notifier: Notifier, private notifier: Notifier,
private userAdminService: UserAdminService private userAdminService: UserAdminService
) { ) {

View File

@ -9,7 +9,7 @@ import {
USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_DAILY_VALIDATOR,
USER_VIDEO_QUOTA_VALIDATOR USER_VIDEO_QUOTA_VALIDATOR
} from '@app/shared/form-validators/user-validators' } from '@app/shared/form-validators/user-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { TwoFactorService, UserAdminService } from '@app/shared/shared-users' import { TwoFactorService, UserAdminService } from '@app/shared/shared-users'
import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models'
import { UserEdit } from './user-edit' import { UserEdit } from './user-edit'
@ -25,7 +25,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
private paramsSub: Subscription private paramsSub: Subscription
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected serverService: ServerService, protected serverService: ServerService,
protected configService: ConfigService, protected configService: ConfigService,
protected screenService: ScreenService, protected screenService: ScreenService,

View File

@ -4,7 +4,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router' import { ActivatedRoute } from '@angular/router'
import { HooksService, Notifier, PluginService } from '@app/core' import { HooksService, Notifier, PluginService } from '@app/core'
import { BuildFormArgument } from '@app/shared/form-validators' import { BuildFormArgument } from '@app/shared/form-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
import { PluginApiService } from '../shared/plugin-api.service' import { PluginApiService } from '../shared/plugin-api.service'
@ -22,7 +22,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
private npmName: string private npmName: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private pluginService: PluginService, private pluginService: PluginService,
private pluginAPIService: PluginApiService, private pluginAPIService: PluginApiService,
private notifier: Notifier, private notifier: Notifier,

View File

@ -1,11 +1,10 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service' import { HooksService } from '@app/core/plugins/hooks.service'
import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
import { USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService, InputTextComponent } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService, InputTextComponent } from '@app/shared/shared-forms'
import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance' import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { PluginsManager } from '@root-helpers/plugins-manager' import { PluginsManager } from '@root-helpers/plugins-manager'
@ -45,7 +44,7 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
private serverConfig: ServerConfig private serverConfig: ServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private route: ActivatedRoute, private route: ActivatedRoute,
private modalService: NgbModal, private modalService: NgbModal,
private authService: AuthService, private authService: AuthService,

View File

@ -9,7 +9,7 @@ import {
VIDEO_CHANNEL_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR,
VIDEO_CHANNEL_SUPPORT_VALIDATOR VIDEO_CHANNEL_SUPPORT_VALIDATOR
} from '@app/shared/form-validators/video-channel-validators' } from '@app/shared/form-validators/video-channel-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
import { HttpStatusCode, VideoChannelCreate } from '@shared/models' import { HttpStatusCode, VideoChannelCreate } from '@shared/models'
import { VideoChannelEdit } from './video-channel-edit' import { VideoChannelEdit } from './video-channel-edit'
@ -26,7 +26,7 @@ export class VideoChannelCreateComponent extends VideoChannelEdit implements OnI
private banner: FormData private banner: FormData
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private router: Router, private router: Router,

View File

@ -9,7 +9,7 @@ import {
VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
VIDEO_CHANNEL_SUPPORT_VALIDATOR VIDEO_CHANNEL_SUPPORT_VALIDATOR
} from '@app/shared/form-validators/video-channel-validators' } from '@app/shared/form-validators/video-channel-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
import { HTMLServerConfig, VideoChannelUpdate } from '@shared/models' import { HTMLServerConfig, VideoChannelUpdate } from '@shared/models'
import { VideoChannelEdit } from './video-channel-edit' import { VideoChannelEdit } from './video-channel-edit'
@ -28,7 +28,7 @@ export class VideoChannelUpdateComponent extends VideoChannelEdit implements OnI
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private route: ActivatedRoute, private route: ActivatedRoute,

View File

@ -3,7 +3,7 @@ import { tap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { AuthService, ServerService, UserService } from '@app/core' import { AuthService, ServerService, UserService } from '@app/core'
import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { HttpStatusCode, User } from '@shared/models' import { HttpStatusCode, User } from '@shared/models'
@Component({ @Component({
@ -17,7 +17,7 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
user: User = null user: User = null
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private userService: UserService, private userService: UserService,
private serverService: ServerService private serverService: ServerService

View File

@ -6,7 +6,7 @@ import {
USER_EXISTING_PASSWORD_VALIDATOR, USER_EXISTING_PASSWORD_VALIDATOR,
USER_PASSWORD_VALIDATOR USER_PASSWORD_VALIDATOR
} from '@app/shared/form-validators/user-validators' } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { HttpStatusCode, User } from '@shared/models' import { HttpStatusCode, User } from '@shared/models'
@Component({ @Component({
@ -19,7 +19,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
user: User = null user: User = null
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private notifier: Notifier, private notifier: Notifier,
private authService: AuthService, private authService: AuthService,
private userService: UserService private userService: UserService

View File

@ -2,7 +2,7 @@ import { Subject } from 'rxjs'
import { Component, Input, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { Notifier, User, UserService } from '@app/core' import { Notifier, User, UserService } from '@app/core'
import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
@Component({ @Component({
selector: 'my-account-profile', selector: 'my-account-profile',
@ -16,7 +16,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
error: string = null error: string = null
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private notifier: Notifier, private notifier: Notifier,
private userService: UserService private userService: UserService
) { ) {

View File

@ -3,7 +3,7 @@ import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '
import { AuthService, Notifier } from '@app/core' import { AuthService, Notifier } from '@app/core'
import { listUserChannelsForSelect } from '@app/helpers' import { listUserChannelsForSelect } from '@app/helpers'
import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoOwnershipService } from '@app/shared/shared-main' import { VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { VideoChangeOwnership } from '@shared/models' import { VideoChangeOwnership } from '@shared/models'
@ -24,7 +24,7 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
error: string = null error: string = null
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private videoOwnershipService: VideoOwnershipService, private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier, private notifier: Notifier,
private authService: AuthService, private authService: AuthService,

View File

@ -5,7 +5,7 @@ import { Router } from '@angular/router'
import { AuthService, Notifier } from '@app/core' import { AuthService, Notifier } from '@app/core'
import { listUserChannelsForSelect } from '@app/helpers' import { listUserChannelsForSelect } from '@app/helpers'
import { VIDEO_CHANNEL_EXTERNAL_URL_VALIDATOR } from '@app/shared/form-validators/video-channel-validators' import { VIDEO_CHANNEL_EXTERNAL_URL_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoChannelService, VideoChannelSyncService } from '@app/shared/shared-main' import { VideoChannelService, VideoChannelSyncService } from '@app/shared/shared-main'
import { VideoChannelSyncCreate } from '@shared/models/videos' import { VideoChannelSyncCreate } from '@shared/models/videos'
@ -20,7 +20,7 @@ export class VideoChannelSyncEditComponent extends FormReactive implements OnIni
existingVideosStrategy: string existingVideosStrategy: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private router: Router, private router: Router,
private notifier: Notifier, private notifier: Notifier,

View File

@ -9,7 +9,7 @@ import {
VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
VIDEO_PLAYLIST_PRIVACY_VALIDATOR VIDEO_PLAYLIST_PRIVACY_VALIDATOR
} from '@app/shared/form-validators/video-playlist-validators' } from '@app/shared/form-validators/video-playlist-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model' import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
@ -23,7 +23,7 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemen
error: string error: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private router: Router, private router: Router,

View File

@ -11,7 +11,7 @@ import {
VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR, VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
VIDEO_PLAYLIST_PRIVACY_VALIDATOR VIDEO_PLAYLIST_PRIVACY_VALIDATOR
} from '@app/shared/form-validators/video-playlist-validators' } from '@app/shared/form-validators/video-playlist-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { VideoPlaylistUpdate } from '@shared/models' import { VideoPlaylistUpdate } from '@shared/models'
import { MyVideoPlaylistEdit } from './my-video-playlist-edit' import { MyVideoPlaylistEdit } from './my-video-playlist-edit'
@ -27,7 +27,7 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemen
private paramsSub: Subscription private paramsSub: Subscription
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private router: Router, private router: Router,

View File

@ -1,7 +1,7 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { Notifier, UserService } from '@app/core' import { Notifier, UserService } from '@app/core'
import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { Video, VideoOwnershipService } from '@app/shared/shared-main' import { Video, VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@ -20,7 +20,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
private video: Video | undefined = undefined private video: Video | undefined = undefined
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private videoOwnershipService: VideoOwnershipService, private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier, private notifier: Notifier,
private userService: UserService, private userService: UserService,

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router'
import { Notifier, UserService } from '@app/core' import { Notifier, UserService } from '@app/core'
import { RESET_PASSWORD_CONFIRM_VALIDATOR } from '@app/shared/form-validators/reset-password-validators' import { RESET_PASSWORD_CONFIRM_VALIDATOR } from '@app/shared/form-validators/reset-password-validators'
import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
@Component({ @Component({
selector: 'my-login', selector: 'my-login',
@ -16,7 +16,7 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
private verificationString: string private verificationString: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private userService: UserService, private userService: UserService,
private notifier: Notifier, private notifier: Notifier,
private router: Router, private router: Router,

View File

@ -3,7 +3,7 @@ import { pairwise } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR } from '@app/shared/form-validators/video-channel-validators' import { VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { UserSignupService } from '@app/shared/shared-users' import { UserSignupService } from '@app/shared/shared-users'
@Component({ @Component({
@ -19,7 +19,7 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit
@Output() formBuilt = new EventEmitter<FormGroup>() @Output() formBuilt = new EventEmitter<FormGroup>()
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private userSignupService: UserSignupService private userSignupService: UserSignupService
) { ) {
super() super()

View File

@ -1,9 +1,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { import { USER_TERMS_VALIDATOR } from '@app/shared/form-validators/user-validators'
USER_TERMS_VALIDATOR import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
} from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@Component({ @Component({
selector: 'my-register-step-terms', selector: 'my-register-step-terms',
@ -19,7 +17,7 @@ export class RegisterStepTermsComponent extends FormReactive implements OnInit {
@Output() codeOfConductClick = new EventEmitter<void>() @Output() codeOfConductClick = new EventEmitter<void>()
constructor ( constructor (
protected formValidatorService: FormValidatorService protected formReactiveService: FormReactiveService
) { ) {
super() super()
} }

View File

@ -8,7 +8,7 @@ import {
USER_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR,
USER_USERNAME_VALIDATOR USER_USERNAME_VALIDATOR
} from '@app/shared/form-validators/user-validators' } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { UserSignupService } from '@app/shared/shared-users' import { UserSignupService } from '@app/shared/shared-users'
@Component({ @Component({
@ -23,7 +23,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
@Output() formBuilt = new EventEmitter<FormGroup>() @Output() formBuilt = new EventEmitter<FormGroup>()
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private userSignupService: UserSignupService private userSignupService: UserSignupService
) { ) {
super() super()

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { Notifier, RedirectService, ServerService } from '@app/core' import { Notifier, RedirectService, ServerService } from '@app/core'
import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { UserSignupService } from '@app/shared/shared-users' import { UserSignupService } from '@app/shared/shared-users'
@Component({ @Component({
@ -14,7 +14,7 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
requiresEmailVerification = false requiresEmailVerification = false
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private userSignupService: UserSignupService, private userSignupService: UserSignupService,
private serverService: ServerService, private serverService: ServerService,
private notifier: Notifier, private notifier: Notifier,

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { ConfirmService, Notifier, ServerService } from '@app/core' import { ConfirmService, Notifier, ServerService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoDetails } from '@app/shared/shared-main' import { VideoDetails } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
@ -20,7 +20,7 @@ export class VideoStudioEditComponent extends FormReactive implements OnInit {
video: VideoDetails video: VideoDetails
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private serverService: ServerService, private serverService: ServerService,
private notifier: Notifier, private notifier: Notifier,
private router: Router, private router: Router,

View File

@ -1,7 +1,7 @@
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { ServerService } from '@app/core' import { ServerService } from '@app/core'
import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '@app/shared/form-validators/video-captions-validators' import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoCaptionEdit } from '@app/shared/shared-main' import { VideoCaptionEdit } from '@app/shared/shared-main'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig, VideoConstant } from '@shared/models' import { HTMLServerConfig, VideoConstant } from '@shared/models'
@ -26,7 +26,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
private closingModal = false private closingModal = false
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private serverService: ServerService private serverService: ServerService
) { ) {

View File

@ -1,8 +1,8 @@
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators' import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main' import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main'
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig, VideoConstant } from '@shared/models' import { HTMLServerConfig, VideoConstant } from '@shared/models'
import { ServerService } from '../../../../core' import { ServerService } from '../../../../core'
@ -29,8 +29,7 @@ export class VideoCaptionEditModalContentComponent extends FormReactive implemen
constructor ( constructor (
protected openedModal: NgbActiveModal, protected openedModal: NgbActiveModal,
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal,
private videoCaptionService: VideoCaptionService, private videoCaptionService: VideoCaptionService,
private serverService: ServerService private serverService: ServerService
) { ) {

View File

@ -3,7 +3,7 @@ import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
import { scrollToTop } from '@app/helpers' import { scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LiveVideoService } from '@app/shared/shared-video-live' import { LiveVideoService } from '@app/shared/shared-video-live'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
@ -39,7 +39,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
error: string error: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
protected notifier: Notifier, protected notifier: Notifier,
protected authService: AuthService, protected authService: AuthService,

View File

@ -3,7 +3,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, Vie
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
import { scrollToTop } from '@app/helpers' import { scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
@ -35,7 +35,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
error: string error: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
protected notifier: Notifier, protected notifier: Notifier,
protected authService: AuthService, protected authService: AuthService,

View File

@ -4,7 +4,7 @@ import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
import { scrollToTop } from '@app/helpers' import { scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
@ -34,7 +34,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
error: string error: string
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
protected notifier: Notifier, protected notifier: Notifier,
protected authService: AuthService, protected authService: AuthService,

View File

@ -5,7 +5,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit,
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core' import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core'
import { genericUploadErrorHandler, scrollToTop } from '@app/helpers' import { genericUploadErrorHandler, scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormReactiveService } from '@app/shared/shared-forms'
import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
@ -60,7 +60,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
private uploadServiceSubscription: Subscription private uploadServiceSubscription: Subscription
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
protected notifier: Notifier, protected notifier: Notifier,
protected authService: AuthService, protected authService: AuthService,

View File

@ -4,7 +4,7 @@ import { SelectChannelItem } from 'src/types/select-options-item.model'
import { Component, HostListener, OnInit } from '@angular/core' import { Component, HostListener, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { Video, VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' import { Video, VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LiveVideoService } from '@app/shared/shared-video-live' import { LiveVideoService } from '@app/shared/shared-video-live'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
@ -33,7 +33,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
private updateDone = false private updateDone = false
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private notifier: Notifier, private notifier: Notifier,

View File

@ -16,7 +16,7 @@ import {
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { Notifier, User } from '@app/core' import { Notifier, User } from '@app/core'
import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators' import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { Video } from '@app/shared/shared-main' import { Video } from '@app/shared/shared-main'
import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment' import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@ -48,7 +48,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
private emojiMarkupList: { emoji: string, name: string }[] private emojiMarkupList: { emoji: string, name: string }[]
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private notifier: Notifier, private notifier: Notifier,
private videoCommentService: VideoCommentService, private videoCommentService: VideoCommentService,
private modalService: NgbModal, private modalService: NgbModal,

View File

@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, HtmlRendererService, Notifier } from '@app/core' import { AuthService, HtmlRendererService, Notifier } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
@ -29,7 +29,7 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
private abuse: UserAbuse private abuse: UserAbuse
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private htmlRenderer: HtmlRendererService, private htmlRenderer: HtmlRendererService,
private auth: AuthService, private auth: AuthService,

View File

@ -1,6 +1,6 @@
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { AbuseService } from '@app/shared/shared-moderation' import { AbuseService } from '@app/shared/shared-moderation'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -20,7 +20,7 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private notifier: Notifier, private notifier: Notifier,
private abuseService: AbuseService private abuseService: AbuseService

View File

@ -56,7 +56,7 @@ export class FormReactiveService {
} }
} }
protected forceCheck (form: FormGroup, formErrors: any, validationMessages: FormReactiveValidationMessages) { forceCheck (form: FormGroup, formErrors: any, validationMessages: FormReactiveValidationMessages) {
this.onStatusChanged({ form, formErrors, validationMessages, onlyDirty: false }) this.onStatusChanged({ form, formErrors, validationMessages, onlyDirty: false })
} }

View File

@ -1,11 +1,9 @@
import { AbstractControl, FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { wait } from '@root-helpers/utils'
import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive.service' import { FormReactiveService, FormReactiveValidationMessages } from './form-reactive.service'
import { FormValidatorService } from './form-validator.service'
export abstract class FormReactive { export abstract class FormReactive {
protected abstract formValidatorService: FormValidatorService protected abstract formReactiveService: FormReactiveService
protected formChanged = false protected formChanged = false
form: FormGroup form: FormGroup
@ -13,86 +11,22 @@ export abstract class FormReactive {
validationMessages: FormReactiveValidationMessages validationMessages: FormReactiveValidationMessages
buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) { buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
const { formErrors, validationMessages, form } = this.formValidatorService.buildForm(obj, defaultValues) const { formErrors, validationMessages, form } = this.formReactiveService.buildForm(obj, defaultValues)
this.form = form this.form = form
this.formErrors = formErrors this.formErrors = formErrors
this.validationMessages = validationMessages this.validationMessages = validationMessages
this.form.statusChanges.subscribe(async () => {
// FIXME: remove when https://github.com/angular/angular/issues/41519 is fixed
await this.waitPendingCheck()
this.onStatusChanged(this.form, this.formErrors, this.validationMessages)
})
} }
protected async waitPendingCheck () { protected async waitPendingCheck () {
if (this.form.status !== 'PENDING') return return this.formReactiveService.waitPendingCheck(this.form)
// FIXME: the following line does not work: https://github.com/angular/angular/issues/41519
// return firstValueFrom(this.form.statusChanges.pipe(filter(status => status !== 'PENDING')))
// So we have to fallback to active wait :/
do {
await wait(10)
} while (this.form.status === 'PENDING')
} }
protected markAllAsDirty (controlsArg?: { [ key: string ]: AbstractControl }) { protected markAllAsDirty () {
const controls = controlsArg || this.form.controls return this.formReactiveService.markAllAsDirty(this.form.controls)
for (const key of Object.keys(controls)) {
const control = controls[key]
if (control instanceof FormGroup) {
this.markAllAsDirty(control.controls)
continue
}
control.markAsDirty()
}
} }
protected forceCheck () { protected forceCheck () {
this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false) return this.formReactiveService.forceCheck(this.form, this.formErrors, this.validationMessages)
}
private onStatusChanged (
form: FormGroup,
formErrors: FormReactiveErrors,
validationMessages: FormReactiveValidationMessages,
onlyDirty = true
) {
for (const field of Object.keys(formErrors)) {
if (formErrors[field] && typeof formErrors[field] === 'object') {
this.onStatusChanged(
form.controls[field] as FormGroup,
formErrors[field] as FormReactiveErrors,
validationMessages[field] as FormReactiveValidationMessages,
onlyDirty
)
continue
}
// clear previous error message (if any)
formErrors[field] = ''
const control = form.get(field)
if (control.dirty) this.formChanged = true
if (!control || (onlyDirty && !control.dirty) || !control.enabled || !control.errors) continue
const staticMessages = validationMessages[field]
for (const key of Object.keys(control.errors)) {
const formErrorValue = control.errors[key]
// Try to find error message in static validation messages first
// Then check if the validator returns a string that is the error
if (staticMessages[key]) formErrors[field] += staticMessages[key] + ' '
else if (typeof formErrorValue === 'string') formErrors[field] += control.errors[key]
else throw new Error('Form error value of ' + field + ' is invalid')
}
}
} }
} }

View File

@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { splitAndGetNotEmpty, UNIQUE_HOSTS_VALIDATOR } from '../form-validators/host-validators' import { splitAndGetNotEmpty, UNIQUE_HOSTS_VALIDATOR } from '../form-validators/host-validators'
@ -18,7 +18,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal private modalService: NgbModal
) { ) {
super() super()

View File

@ -2,7 +2,7 @@ import { mapValues, pickBy } from 'lodash-es'
import { Component, OnInit, ViewChild } from '@angular/core' import { Component, OnInit, ViewChild } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators' import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { Account } from '@app/shared/shared-main' import { Account } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -26,7 +26,7 @@ export class AccountReportComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private abuseService: AbuseService, private abuseService: AbuseService,
private notifier: Notifier private notifier: Notifier

View File

@ -2,7 +2,7 @@ import { mapValues, pickBy } from 'lodash-es'
import { Component, Input, OnInit, ViewChild } from '@angular/core' import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators' import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { VideoComment } from '@app/shared/shared-video-comment' import { VideoComment } from '@app/shared/shared-video-comment'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -27,7 +27,7 @@ export class CommentReportComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private abuseService: AbuseService, private abuseService: AbuseService,
private notifier: Notifier private notifier: Notifier

View File

@ -3,7 +3,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { DomSanitizer } from '@angular/platform-browser' import { DomSanitizer } from '@angular/platform-browser'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators' import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
@ -27,7 +27,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private abuseService: AbuseService, private abuseService: AbuseService,
private notifier: Notifier, private notifier: Notifier,

View File

@ -2,7 +2,7 @@ import { forkJoin } from 'rxjs'
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { prepareIcu } from '@app/helpers' import { prepareIcu } from '@app/helpers'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { User } from '@shared/models' import { User } from '@shared/models'
@ -25,7 +25,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
modalMessage = '' modalMessage = ''
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private notifier: Notifier, private notifier: Notifier,
private userAdminService: UserAdminService, private userAdminService: UserAdminService,

View File

@ -1,7 +1,7 @@
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { prepareIcu } from '@app/helpers' import { prepareIcu } from '@app/helpers'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { Video } from '@app/shared/shared-main' import { Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@ -25,7 +25,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
private openedModal: NgbModalRef private openedModal: NgbModalRef
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private modalService: NgbModal, private modalService: NgbModal,
private videoBlocklistService: VideoBlockService, private videoBlocklistService: VideoBlockService,
private notifier: Notifier private notifier: Notifier

View File

@ -1,7 +1,7 @@
import { Subject, Subscription } from 'rxjs' import { Subject, Subscription } from 'rxjs'
import { Component, Input, OnDestroy, OnInit } from '@angular/core' import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core' import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
import { SelectOptionsItem } from 'src/types' import { SelectOptionsItem } from 'src/types'
@ -22,7 +22,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private userService: UserService, private userService: UserService,

View File

@ -3,7 +3,7 @@ import { Subject, Subscription } from 'rxjs'
import { first } from 'rxjs/operators' import { first } from 'rxjs/operators'
import { Component, Input, OnDestroy, OnInit } from '@angular/core' import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, User, UserService } from '@app/core' import { AuthService, Notifier, ServerService, User, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { UserUpdateMe } from '@shared/models' import { UserUpdateMe } from '@shared/models'
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
@ -22,7 +22,7 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
formValuesWatcher: Subscription formValuesWatcher: Subscription
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private userService: UserService, private userService: UserService,

View File

@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { Notifier } from '@app/core' import { Notifier } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { logger } from '@root-helpers/logger' import { logger } from '@root-helpers/logger'
import { USER_HANDLE_VALIDATOR } from '../form-validators/user-validators' import { USER_HANDLE_VALIDATOR } from '../form-validators/user-validators'
@ -15,7 +15,7 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
@Input() showHelp = false @Input() showHelp = false
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private notifier: Notifier private notifier: Notifier
) { ) {
super() super()

View File

@ -3,7 +3,7 @@ import { Subject, Subscription } from 'rxjs'
import { debounceTime, filter } from 'rxjs/operators' import { debounceTime, filter } from 'rxjs/operators'
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'
import { AuthService, DisableForReuseHook, Notifier } from '@app/core' import { AuthService, DisableForReuseHook, Notifier } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
import { secondsToTime } from '@shared/core-utils' import { secondsToTime } from '@shared/core-utils'
import { import {
Video, Video,
@ -59,7 +59,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
private pendingAddId: number private pendingAddId: number
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formReactiveService: FormReactiveService,
private authService: AuthService, private authService: AuthService,
private notifier: Notifier, private notifier: Notifier,
private videoPlaylistService: VideoPlaylistService, private videoPlaylistService: VideoPlaylistService,