From d12b40fb96d56786a96c06a621f3d8e0a0d24f4a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Oct 2022 11:06:28 +0200 Subject: Implement two factor in client --- client/src/app/+login/login.component.html | 46 +++++---- client/src/app/+login/login.component.ts | 38 ++++++-- .../app/+my-account/my-account-routing.module.ts | 11 +++ .../my-account-change-email.component.ts | 4 +- .../my-account-change-password.component.ts | 4 +- .../my-account-danger-zone.component.ts | 2 +- .../my-account-settings.component.html | 10 ++ .../my-account-two-factor/index.ts | 3 + .../my-account-two-factor-button.component.html | 12 +++ .../my-account-two-factor-button.component.ts | 49 ++++++++++ .../my-account-two-factor.component.html | 54 +++++++++++ .../my-account-two-factor.component.scss | 16 ++++ .../my-account-two-factor.component.ts | 105 +++++++++++++++++++++ .../my-account-two-factor/two-factor.service.ts | 52 ++++++++++ client/src/app/+my-account/my-account.module.ts | 14 ++- .../my-video-channels.component.ts | 2 +- .../app/+signup/+register/register.component.ts | 2 +- client/src/app/core/auth/auth.service.ts | 23 ++++- client/src/app/core/confirm/confirm.service.ts | 47 ++++++--- client/src/app/core/rest/rest-extractor.service.ts | 6 +- client/src/app/core/users/user.model.ts | 4 + client/src/app/modal/confirm.component.html | 7 +- client/src/app/modal/confirm.component.ts | 30 +++++- .../app/shared/form-validators/user-validators.ts | 9 ++ .../shared/shared-forms/form-reactive.service.ts | 101 ++++++++++++++++++++ .../src/app/shared/shared-forms/form-reactive.ts | 7 +- .../shared/shared-forms/form-validator.service.ts | 2 +- client/src/app/shared/shared-forms/index.ts | 1 + .../shared/shared-forms/input-text.component.ts | 10 +- .../app/shared/shared-forms/shared-form.module.ts | 5 +- .../shared-main/auth/auth-interceptor.service.ts | 13 ++- 31 files changed, 621 insertions(+), 68 deletions(-) create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.html create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.html create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.scss create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts create mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts create mode 100644 client/src/app/shared/shared-forms/form-reactive.service.ts (limited to 'client/src') diff --git a/client/src/app/+login/login.component.html b/client/src/app/+login/login.component.html index f3a2476f9..49b443a20 100644 --- a/client/src/app/+login/login.component.html +++ b/client/src/app/+login/login.component.html @@ -39,34 +39,48 @@
-
-
- - + +
+
+ + +
+ +
{{ formErrors.username }}
+ +
+ ⚠️ Most email addresses do not include capital letters. +
-
{{ formErrors.username }}
+
+ -
- ⚠️ Most email addresses do not include capital letters. +
-
+
+ +
+

Enter the two-factor code generated by your phone app:

-
- +
- +
+
+ +
+ +
+ +
+
+
diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts new file mode 100644 index 000000000..ef83009a5 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts @@ -0,0 +1,3 @@ +export * from './my-account-two-factor-button.component' +export * from './my-account-two-factor.component' +export * from './two-factor.service' diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.html b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.html new file mode 100644 index 000000000..2fcfffbf3 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.html @@ -0,0 +1,12 @@ +
+ +

Two factor authentication adds an additional layer of security to your account by requiring a numeric code from another device (most commonly mobile phones) when you log in.

+ + Enable two-factor authentication +
+ + + Disable two-factor authentication + + +
diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts new file mode 100644 index 000000000..03b00e933 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts @@ -0,0 +1,49 @@ +import { Subject } from 'rxjs' +import { Component, Input, OnInit } from '@angular/core' +import { AuthService, ConfirmService, Notifier, User } from '@app/core' +import { TwoFactorService } from './two-factor.service' + +@Component({ + selector: 'my-account-two-factor-button', + templateUrl: './my-account-two-factor-button.component.html' +}) +export class MyAccountTwoFactorButtonComponent implements OnInit { + @Input() user: User = null + @Input() userInformationLoaded: Subject + + twoFactorEnabled = false + + constructor ( + private notifier: Notifier, + private twoFactorService: TwoFactorService, + private confirmService: ConfirmService, + private auth: AuthService + ) { + } + + ngOnInit () { + this.userInformationLoaded.subscribe(() => { + this.twoFactorEnabled = this.user.twoFactorEnabled + }) + } + + async disableTwoFactor () { + const message = $localize`Are you sure you want to disable two factor authentication of your account?` + + const { confirmed, password } = await this.confirmService.confirmWithPassword(message, $localize`Disable two factor`) + if (confirmed === false) return + + this.twoFactorService.disableTwoFactor({ userId: this.user.id, currentPassword: password }) + .subscribe({ + next: () => { + this.twoFactorEnabled = false + + this.auth.refreshUserInformation() + + this.notifier.success($localize`Two factor authentication disabled`) + }, + + error: err => this.notifier.error(err.message) + }) + } +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.html b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.html new file mode 100644 index 000000000..16c344e3b --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.html @@ -0,0 +1,54 @@ +

+ + Two factor authentication +

+ +
+ Two factor authentication is already enabled. +
+ +
+ + + + +
Confirm your password to enable two factor authentication
+ + + + + +
+ + + +

+ Scan this QR code into a TOTP app on your phone. This app will generate tokens that you will have to enter when logging in. +

+ + + +
+ If you can't scan the QR code and need to enter it manually, here is the plain-text secret: +
+ +
{{ twoFactorSecret }}
+ +
+ + +
Enter the code generated by your authenticator app to confirm
+ + + + +
+
+ +
diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.scss b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.scss new file mode 100644 index 000000000..cee016bb8 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.scss @@ -0,0 +1,16 @@ +@use '_variables' as *; +@use '_mixins' as *; + +.root { + max-width: 600px; +} + +.secret-plain-text { + font-family: monospace; + font-size: 0.9rem; +} + +qrcode { + display: inline-block; + margin: auto; +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts new file mode 100644 index 000000000..e4d4188f7 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts @@ -0,0 +1,105 @@ +import { Component, OnInit } from '@angular/core' +import { FormGroup } from '@angular/forms' +import { Router } from '@angular/router' +import { AuthService, Notifier, User } from '@app/core' +import { USER_EXISTING_PASSWORD_VALIDATOR, USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-validators' +import { FormReactiveService } from '@app/shared/shared-forms' +import { TwoFactorService } from './two-factor.service' + +@Component({ + selector: 'my-account-two-factor', + templateUrl: './my-account-two-factor.component.html', + styleUrls: [ './my-account-two-factor.component.scss' ] +}) +export class MyAccountTwoFactorComponent implements OnInit { + twoFactorAlreadyEnabled: boolean + + step: 'request' | 'confirm' | 'confirmed' = 'request' + + twoFactorSecret: string + twoFactorURI: string + + inPasswordStep = true + + formPassword: FormGroup + formErrorsPassword: any + + formOTP: FormGroup + formErrorsOTP: any + + private user: User + private requestToken: string + + constructor ( + private notifier: Notifier, + private twoFactorService: TwoFactorService, + private formReactiveService: FormReactiveService, + private auth: AuthService, + private router: Router + ) { + } + + ngOnInit () { + this.buildPasswordForm() + this.buildOTPForm() + + this.auth.userInformationLoaded.subscribe(() => { + this.user = this.auth.getUser() + + this.twoFactorAlreadyEnabled = this.user.twoFactorEnabled + }) + } + + requestTwoFactor () { + this.twoFactorService.requestTwoFactor({ + userId: this.user.id, + currentPassword: this.formPassword.value['current-password'] + }).subscribe({ + next: ({ otpRequest }) => { + this.requestToken = otpRequest.requestToken + this.twoFactorURI = otpRequest.uri + this.twoFactorSecret = otpRequest.secret.replace(/(.{4})/g, '$1 ').trim() + + this.step = 'confirm' + }, + + error: err => this.notifier.error(err.message) + }) + } + + confirmTwoFactor () { + this.twoFactorService.confirmTwoFactorRequest({ + userId: this.user.id, + requestToken: this.requestToken, + otpToken: this.formOTP.value['otp-token'] + }).subscribe({ + next: () => { + this.notifier.success($localize`Two factor authentication has been enabled.`) + + this.auth.refreshUserInformation() + + this.router.navigateByUrl('/my-account/settings') + }, + + error: err => this.notifier.error(err.message) + }) + } + + private buildPasswordForm () { + const { form, formErrors } = this.formReactiveService.buildForm({ + 'current-password': USER_EXISTING_PASSWORD_VALIDATOR + }) + + this.formPassword = form + this.formErrorsPassword = formErrors + } + + private buildOTPForm () { + const { form, formErrors } = this.formReactiveService.buildForm({ + 'otp-token': USER_OTP_TOKEN_VALIDATOR + }) + + this.formOTP = form + this.formErrorsOTP = formErrors + } +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts new file mode 100644 index 000000000..c0e5ac492 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts @@ -0,0 +1,52 @@ +import { catchError } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { RestExtractor, UserService } from '@app/core' +import { TwoFactorEnableResult } from '@shared/models' + +@Injectable() +export class TwoFactorService { + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor + ) { } + + // --------------------------------------------------------------------------- + + requestTwoFactor (options: { + userId: number + currentPassword: string + }) { + const { userId, currentPassword } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/request' + + return this.authHttp.post(url, { currentPassword }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + confirmTwoFactorRequest (options: { + userId: number + requestToken: string + otpToken: string + }) { + const { userId, requestToken, otpToken } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/confirm-request' + + return this.authHttp.post(url, { requestToken, otpToken }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + disableTwoFactor (options: { + userId: number + currentPassword: string + }) { + const { userId, currentPassword } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/disable' + + return this.authHttp.post(url, { currentPassword }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } +} diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index 4081e4f01..f5beaa4db 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -1,3 +1,4 @@ +import { QRCodeModule } from 'angularx-qrcode' import { AutoCompleteModule } from 'primeng/autocomplete' import { TableModule } from 'primeng/table' import { DragDropModule } from '@angular/cdk/drag-drop' @@ -23,12 +24,18 @@ import { MyAccountDangerZoneComponent } from './my-account-settings/my-account-d import { MyAccountNotificationPreferencesComponent } from './my-account-settings/my-account-notification-preferences' import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component' import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component' +import { + MyAccountTwoFactorButtonComponent, + MyAccountTwoFactorComponent, + TwoFactorService +} from './my-account-settings/my-account-two-factor' import { MyAccountComponent } from './my-account.component' @NgModule({ imports: [ MyAccountRoutingModule, + QRCodeModule, AutoCompleteModule, TableModule, DragDropModule, @@ -52,6 +59,9 @@ import { MyAccountComponent } from './my-account.component' MyAccountChangeEmailComponent, MyAccountApplicationsComponent, + MyAccountTwoFactorButtonComponent, + MyAccountTwoFactorComponent, + MyAccountDangerZoneComponent, MyAccountBlocklistComponent, MyAccountAbusesListComponent, @@ -64,7 +74,9 @@ import { MyAccountComponent } from './my-account.component' MyAccountComponent ], - providers: [] + providers: [ + TwoFactorService + ] }) export class MyAccountModule { } diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts index 205ad7a89..ece59c2ff 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts +++ b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts @@ -40,7 +40,7 @@ export class MyVideoChannelsComponent { } async deleteVideoChannel (videoChannel: VideoChannel) { - const res = await this.confirmService.confirmWithInput( + const res = await this.confirmService.confirmWithExpectedInput( $localize`Do you really want to delete ${videoChannel.displayName}? It will delete ${videoChannel.videosCount} videos uploaded in this channel, and you will not be able to create another channel with the same name (${videoChannel.name})!`, diff --git a/client/src/app/+signup/+register/register.component.ts b/client/src/app/+signup/+register/register.component.ts index 4ab327b1b..958770ebf 100644 --- a/client/src/app/+signup/+register/register.component.ts +++ b/client/src/app/+signup/+register/register.component.ts @@ -158,7 +158,7 @@ export class RegisterComponent implements OnInit { } // Auto login - this.authService.login(body.username, body.password) + this.authService.login({ username: body.username, password: body.password }) .subscribe({ next: () => { this.signupSuccess = true diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index ca46866f5..7f4fae4aa 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -1,7 +1,7 @@ import { Hotkey, HotkeysService } from 'angular2-hotkeys' import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs' import { catchError, map, mergeMap, share, tap } from 'rxjs/operators' -import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' +import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { Router } from '@angular/router' import { Notifier } from '@app/core/notification/notifier.service' @@ -141,7 +141,14 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular return !!this.getAccessToken() } - login (username: string, password: string, token?: string) { + login (options: { + username: string + password: string + otpToken?: string + token?: string + }) { + const { username, password, token, otpToken } = options + // Form url encoded const body = { client_id: this.clientId, @@ -155,7 +162,9 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular if (token) Object.assign(body, { externalAuthToken: token }) - const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') + let headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') + if (otpToken) headers = headers.set('x-peertube-otp', otpToken) + return this.http.post(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers }) .pipe( map(res => Object.assign(res, { username })), @@ -245,6 +254,14 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular }) } + isOTPMissingError (err: HttpErrorResponse) { + if (err.status !== HttpStatusCode.UNAUTHORIZED_401) return false + + if (err.headers.get('x-peertube-otp') !== 'required; app') return false + + return true + } + private mergeUserInformation (obj: UserLoginWithUsername): Observable { // User is not loaded yet, set manually auth header const headers = new HttpHeaders().set('Authorization', `${obj.token_type} ${obj.access_token}`) diff --git a/client/src/app/core/confirm/confirm.service.ts b/client/src/app/core/confirm/confirm.service.ts index 338b8762c..89a25f0a5 100644 --- a/client/src/app/core/confirm/confirm.service.ts +++ b/client/src/app/core/confirm/confirm.service.ts @@ -1,28 +1,53 @@ -import { firstValueFrom, Subject } from 'rxjs' +import { firstValueFrom, map, Observable, Subject } from 'rxjs' import { Injectable } from '@angular/core' type ConfirmOptions = { title: string message: string - inputLabel?: string - expectedInputValue?: string - confirmButtonText?: string -} +} & ( + { + type: 'confirm' + confirmButtonText?: string + } | + { + type: 'confirm-password' + confirmButtonText?: string + } | + { + type: 'confirm-expected-input' + inputLabel?: string + expectedInputValue?: string + confirmButtonText?: string + } +) @Injectable() export class ConfirmService { showConfirm = new Subject() - confirmResponse = new Subject() + confirmResponse = new Subject<{ confirmed: boolean, value?: string }>() confirm (message: string, title = '', confirmButtonText?: string) { - this.showConfirm.next({ title, message, confirmButtonText }) + this.showConfirm.next({ type: 'confirm', title, message, confirmButtonText }) + + return firstValueFrom(this.extractConfirmed(this.confirmResponse.asObservable())) + } - return firstValueFrom(this.confirmResponse.asObservable()) + confirmWithPassword (message: string, title = '', confirmButtonText?: string) { + this.showConfirm.next({ type: 'confirm-password', title, message, confirmButtonText }) + + const obs = this.confirmResponse.asObservable() + .pipe(map(({ confirmed, value }) => ({ confirmed, password: value }))) + + return firstValueFrom(obs) } - confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { - this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) + confirmWithExpectedInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { + this.showConfirm.next({ type: 'confirm-expected-input', title, message, inputLabel, expectedInputValue, confirmButtonText }) + + return firstValueFrom(this.extractConfirmed(this.confirmResponse.asObservable())) + } - return firstValueFrom(this.confirmResponse.asObservable()) + private extractConfirmed (obs: Observable<{ confirmed: boolean }>) { + return obs.pipe(map(({ confirmed }) => confirmed)) } } diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 7eec2eca6..57dd9ae26 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts @@ -4,6 +4,7 @@ import { Router } from '@angular/router' import { DateFormat, dateToHuman } from '@app/helpers' import { logger } from '@root-helpers/logger' import { HttpStatusCode, ResultList } from '@shared/models' +import { HttpHeaderResponse } from '@angular/common/http' @Injectable() export class RestExtractor { @@ -54,10 +55,11 @@ export class RestExtractor { handleError (err: any) { const errorMessage = this.buildErrorMessage(err) - const errorObj: { message: string, status: string, body: string } = { + const errorObj: { message: string, status: string, body: string, headers: HttpHeaderResponse } = { message: errorMessage, status: undefined, - body: undefined + body: undefined, + headers: err.headers } if (err.status) { diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 6ba30e4b8..8385a4012 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts @@ -66,6 +66,8 @@ export class User implements UserServerModel { lastLoginDate: Date | null + twoFactorEnabled: boolean + createdAt: Date constructor (hash: Partial) { @@ -108,6 +110,8 @@ export class User implements UserServerModel { this.notificationSettings = hash.notificationSettings + this.twoFactorEnabled = hash.twoFactorEnabled + this.createdAt = hash.createdAt this.pluginAuth = hash.pluginAuth diff --git a/client/src/app/modal/confirm.component.html b/client/src/app/modal/confirm.component.html index c59c25770..f364165c4 100644 --- a/client/src/app/modal/confirm.component.html +++ b/client/src/app/modal/confirm.component.html @@ -9,9 +9,12 @@ -
+
@@ -213,7 +213,7 @@
-
+
@@ -222,6 +222,11 @@
+ +
+ + +
diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss b/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss index 68fa1215f..698628149 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss @@ -48,17 +48,13 @@ my-user-real-quota-info { } .danger-zone { - .reset-password-email { - margin-bottom: 30px; + button { + @include peertube-button; + @include danger-button; + @include disable-outline; - button { - @include peertube-button; - @include danger-button; - @include disable-outline; - - display: block; - margin-top: 0; - } + display: block; + margin-top: 0; } } diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.ts b/client/src/app/+admin/overview/users/user-edit/user-edit.ts index 6dae4110d..21e9629ab 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.ts @@ -60,10 +60,22 @@ export abstract class UserEdit extends FormReactive implements OnInit { ] } + displayDangerZone () { + if (this.isCreation()) return false + if (this.user?.pluginAuth) return false + if (this.auth.getUser().id === this.user.id) return false + + return true + } + resetPassword () { return } + disableTwoFactorAuth () { + return + } + getUserVideoQuota () { return this.form.value['videoQuota'] } diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index bab288a67..1482a1902 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -10,7 +10,7 @@ import { USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormValidatorService } from '@app/shared/shared-forms' -import { 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 { UserEdit } from './user-edit' @@ -34,6 +34,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private router: Router, private notifier: Notifier, private userService: UserService, + private twoFactorService: TwoFactorService, private userAdminService: UserAdminService ) { super() @@ -120,10 +121,22 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`) }, - error: err => { - this.error = err.message - } + error: err => this.notifier.error(err.message) + }) + } + + disableTwoFactorAuth () { + this.twoFactorService.disableTwoFactor({ userId: this.user.id }) + .subscribe({ + next: () => { + this.user.twoFactorEnabled = false + + this.notifier.success($localize`Two factor authentication of ${this.user.username} disabled.`) + }, + + error: err => this.notifier.error(err.message) }) + } private onUserFetched (userJson: UserType) { diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts index ef83009a5..cc774bde3 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts @@ -1,3 +1,2 @@ export * from './my-account-two-factor-button.component' export * from './my-account-two-factor.component' -export * from './two-factor.service' diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts index 03b00e933..97ffb6013 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' import { AuthService, ConfirmService, Notifier, User } from '@app/core' -import { TwoFactorService } from './two-factor.service' +import { TwoFactorService } from '@app/shared/shared-users' @Component({ selector: 'my-account-two-factor-button', diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts index e4d4188f7..259090d64 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router' import { AuthService, Notifier, User } from '@app/core' import { USER_EXISTING_PASSWORD_VALIDATOR, USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactiveService } from '@app/shared/shared-forms' -import { TwoFactorService } from './two-factor.service' +import { TwoFactorService } from '@app/shared/shared-users' @Component({ selector: 'my-account-two-factor', diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts deleted file mode 100644 index c0e5ac492..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { catchError } from 'rxjs/operators' -import { HttpClient } from '@angular/common/http' -import { Injectable } from '@angular/core' -import { RestExtractor, UserService } from '@app/core' -import { TwoFactorEnableResult } from '@shared/models' - -@Injectable() -export class TwoFactorService { - constructor ( - private authHttp: HttpClient, - private restExtractor: RestExtractor - ) { } - - // --------------------------------------------------------------------------- - - requestTwoFactor (options: { - userId: number - currentPassword: string - }) { - const { userId, currentPassword } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/request' - - return this.authHttp.post(url, { currentPassword }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } - - confirmTwoFactorRequest (options: { - userId: number - requestToken: string - otpToken: string - }) { - const { userId, requestToken, otpToken } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/confirm-request' - - return this.authHttp.post(url, { requestToken, otpToken }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } - - disableTwoFactor (options: { - userId: number - currentPassword: string - }) { - const { userId, currentPassword } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/disable' - - return this.authHttp.post(url, { currentPassword }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } -} diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index f5beaa4db..84b057647 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -11,6 +11,7 @@ import { SharedMainModule } from '@app/shared/shared-main' import { SharedModerationModule } from '@app/shared/shared-moderation' import { SharedShareModal } from '@app/shared/shared-share-modal' import { SharedUserInterfaceSettingsModule } from '@app/shared/shared-user-settings' +import { SharedUsersModule } from '@app/shared/shared-users' import { SharedActorImageModule } from '../shared/shared-actor-image/shared-actor-image.module' import { MyAccountAbusesListComponent } from './my-account-abuses/my-account-abuses-list.component' import { MyAccountApplicationsComponent } from './my-account-applications/my-account-applications.component' @@ -24,11 +25,7 @@ import { MyAccountDangerZoneComponent } from './my-account-settings/my-account-d import { MyAccountNotificationPreferencesComponent } from './my-account-settings/my-account-notification-preferences' import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component' import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component' -import { - MyAccountTwoFactorButtonComponent, - MyAccountTwoFactorComponent, - TwoFactorService -} from './my-account-settings/my-account-two-factor' +import { MyAccountTwoFactorButtonComponent, MyAccountTwoFactorComponent } from './my-account-settings/my-account-two-factor' import { MyAccountComponent } from './my-account.component' @NgModule({ @@ -44,6 +41,7 @@ import { MyAccountComponent } from './my-account.component' SharedFormModule, SharedModerationModule, SharedUserInterfaceSettingsModule, + SharedUsersModule, SharedGlobalIconModule, SharedAbuseListModule, SharedShareModal, @@ -74,9 +72,7 @@ import { MyAccountComponent } from './my-account.component' MyAccountComponent ], - providers: [ - TwoFactorService - ] + providers: [] }) export class MyAccountModule { } diff --git a/client/src/app/shared/shared-users/index.ts b/client/src/app/shared/shared-users/index.ts index 8f90f2515..20e60486d 100644 --- a/client/src/app/shared/shared-users/index.ts +++ b/client/src/app/shared/shared-users/index.ts @@ -1,4 +1,5 @@ export * from './user-admin.service' export * from './user-signup.service' +export * from './two-factor.service' export * from './shared-users.module' diff --git a/client/src/app/shared/shared-users/shared-users.module.ts b/client/src/app/shared/shared-users/shared-users.module.ts index 2a1dadf20..5a1675dc9 100644 --- a/client/src/app/shared/shared-users/shared-users.module.ts +++ b/client/src/app/shared/shared-users/shared-users.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core' import { SharedMainModule } from '../shared-main/shared-main.module' +import { TwoFactorService } from './two-factor.service' import { UserAdminService } from './user-admin.service' import { UserSignupService } from './user-signup.service' @@ -15,7 +16,8 @@ import { UserSignupService } from './user-signup.service' providers: [ UserSignupService, - UserAdminService + UserAdminService, + TwoFactorService ] }) export class SharedUsersModule { } diff --git a/client/src/app/shared/shared-users/two-factor.service.ts b/client/src/app/shared/shared-users/two-factor.service.ts new file mode 100644 index 000000000..9ff916f15 --- /dev/null +++ b/client/src/app/shared/shared-users/two-factor.service.ts @@ -0,0 +1,52 @@ +import { catchError } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { RestExtractor, UserService } from '@app/core' +import { TwoFactorEnableResult } from '@shared/models' + +@Injectable() +export class TwoFactorService { + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor + ) { } + + // --------------------------------------------------------------------------- + + requestTwoFactor (options: { + userId: number + currentPassword: string + }) { + const { userId, currentPassword } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/request' + + return this.authHttp.post(url, { currentPassword }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + confirmTwoFactorRequest (options: { + userId: number + requestToken: string + otpToken: string + }) { + const { userId, requestToken, otpToken } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/confirm-request' + + return this.authHttp.post(url, { requestToken, otpToken }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + disableTwoFactor (options: { + userId: number + currentPassword?: string + }) { + const { userId, currentPassword } = options + + const url = UserService.BASE_USERS_URL + userId + '/two-factor/disable' + + return this.authHttp.post(url, { currentPassword }) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } +} -- cgit v1.2.3 From 5c5bcea2e64daf0a66a796c89432732ed27308d2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Oct 2022 15:26:53 +0200 Subject: Refactor form reactive --- .../contact-admin-modal.component.ts | 4 +- .../edit-custom-config.component.ts | 8 +-- .../following-list/follow-modal.component.ts | 4 +- .../users/user-edit/user-create.component.ts | 4 +- .../users/user-edit/user-password.component.ts | 4 +- .../users/user-edit/user-update.component.ts | 4 +- .../plugin-show-installed.component.ts | 4 +- client/src/app/+login/login.component.ts | 5 +- .../video-channel-create.component.ts | 4 +- .../video-channel-update.component.ts | 4 +- .../my-account-change-email.component.ts | 4 +- .../my-account-change-password.component.ts | 4 +- .../my-account-profile.component.ts | 4 +- .../my-accept-ownership.component.ts | 4 +- .../video-channel-sync-edit.component.ts | 4 +- .../my-video-playlist-create.component.ts | 4 +- .../my-video-playlist-update.component.ts | 4 +- .../modals/video-change-ownership.component.ts | 4 +- .../+reset-password/reset-password.component.ts | 4 +- .../steps/register-step-channel.component.ts | 4 +- .../steps/register-step-terms.component.ts | 8 +-- .../steps/register-step-user.component.ts | 4 +- .../verify-account-ask-send-email.component.ts | 4 +- .../edit/video-studio-edit.component.ts | 4 +- .../shared/video-caption-add-modal.component.ts | 4 +- .../video-caption-edit-modal-content.component.ts | 7 +- .../video-go-live.component.ts | 4 +- .../video-import-torrent.component.ts | 4 +- .../video-import-url.component.ts | 4 +- .../video-add-components/video-upload.component.ts | 4 +- .../+videos/+video-edit/video-update.component.ts | 4 +- .../shared/comment/video-comment-add.component.ts | 4 +- .../abuse-message-modal.component.ts | 4 +- .../moderation-comment-modal.component.ts | 4 +- .../shared/shared-forms/form-reactive.service.ts | 2 +- .../src/app/shared/shared-forms/form-reactive.ts | 82 +++------------------- .../batch-domains-modal.component.ts | 4 +- .../report-modals/account-report.component.ts | 4 +- .../report-modals/comment-report.component.ts | 4 +- .../report-modals/video-report.component.ts | 4 +- .../shared-moderation/user-ban-modal.component.ts | 4 +- .../shared-moderation/video-block.component.ts | 4 +- .../user-interface-settings.component.ts | 4 +- .../user-video-settings.component.ts | 4 +- .../remote-subscribe.component.ts | 4 +- .../video-add-to-playlist.component.ts | 4 +- 46 files changed, 101 insertions(+), 171 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts index fab9cfc4b..0e2bf51e8 100644 --- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts +++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts @@ -7,7 +7,7 @@ import { FROM_NAME_VALIDATOR, SUBJECT_VALIDATOR } 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -32,7 +32,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { private serverConfig: HTMLServerConfig constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private router: Router, private modalService: NgbModal, private instanceService: InstanceService, 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 545e37857..168f4702c 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 @@ -18,15 +18,15 @@ import { MAX_INSTANCE_LIVES_VALIDATOR, MAX_LIVE_DURATION_VALIDATOR, MAX_USER_LIVES_VALIDATOR, + MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR, SEARCH_INDEX_URL_VALIDATOR, SERVICES_TWITTER_USERNAME_VALIDATOR, SIGNUP_LIMIT_VALIDATOR, SIGNUP_MINIMUM_AGE_VALIDATOR, - TRANSCODING_THREADS_VALIDATOR, - MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR + TRANSCODING_THREADS_VALIDATOR } 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 { 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 { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models' import { EditConfigurationService } from './edit-configuration.service' @@ -52,9 +52,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { categoryItems: SelectOptionsItem[] = [] constructor ( + protected formReactiveService: FormReactiveService, private router: Router, private route: ActivatedRoute, - protected formValidatorService: FormValidatorService, private notifier: Notifier, private configService: ConfigService, private customPage: CustomPageService, diff --git a/client/src/app/+admin/follows/following-list/follow-modal.component.ts b/client/src/app/+admin/follows/following-list/follow-modal.component.ts index 07cc75d77..8f74e82a6 100644 --- a/client/src/app/+admin/follows/following-list/follow-modal.component.ts +++ b/client/src/app/+admin/follows/following-list/follow-modal.component.ts @@ -2,7 +2,7 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/cor import { Notifier } from '@app/core' import { prepareIcu } from '@app/helpers' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -22,7 +22,7 @@ export class FollowModalComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private followService: InstanceFollowService, private notifier: Notifier diff --git a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts index 1713e06ce..0627aa887 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts @@ -12,7 +12,7 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } 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 { UserCreate, UserRole } from '@shared/models' import { UserEdit } from './user-edit' @@ -27,7 +27,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { constructor ( protected serverService: ServerService, - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected configService: ConfigService, protected screenService: ScreenService, protected auth: AuthService, diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts index 8999d1f00..d6616e077 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core' import { Notifier } from '@app/core' 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 { UserUpdate } from '@shared/models' @@ -18,7 +18,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit { @Input() userId: number constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier, private userAdminService: UserAdminService ) { diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index 1482a1902..71212b19c 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -9,7 +9,7 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } 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 { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' import { UserEdit } from './user-edit' @@ -25,7 +25,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private paramsSub: Subscription constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected serverService: ServerService, protected configService: ConfigService, protected screenService: ScreenService, diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts index ec02cfcd9..b1a41567e 100644 --- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts @@ -4,7 +4,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { HooksService, Notifier, PluginService } from '@app/core' 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 { PluginApiService } from '../shared/plugin-api.service' @@ -22,7 +22,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit private npmName: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private pluginService: PluginService, private pluginAPIService: PluginApiService, private notifier: Notifier, diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts index 9095e43a7..c1705807f 100644 --- a/client/src/app/+login/login.component.ts +++ b/client/src/app/+login/login.component.ts @@ -1,11 +1,10 @@ - import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' import { HooksService } from '@app/core/plugins/hooks.service' 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 { 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 { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { PluginsManager } from '@root-helpers/plugins-manager' @@ -45,7 +44,7 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni private serverConfig: ServerConfig constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private route: ActivatedRoute, private modalService: NgbModal, private authService: AuthService, diff --git a/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts b/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts index 8211451a4..372066890 100644 --- a/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts +++ b/client/src/app/+manage/video-channel-edit/video-channel-create.component.ts @@ -9,7 +9,7 @@ import { VIDEO_CHANNEL_NAME_VALIDATOR, VIDEO_CHANNEL_SUPPORT_VALIDATOR } 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 { HttpStatusCode, VideoChannelCreate } from '@shared/models' import { VideoChannelEdit } from './video-channel-edit' @@ -26,7 +26,7 @@ export class VideoChannelCreateComponent extends VideoChannelEdit implements OnI private banner: FormData constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private router: Router, diff --git a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts index 7e8d6ffe6..32f6d650d 100644 --- a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts +++ b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts @@ -9,7 +9,7 @@ import { 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 { FormReactiveService } from '@app/shared/shared-forms' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { HTMLServerConfig, VideoChannelUpdate } from '@shared/models' import { VideoChannelEdit } from './video-channel-edit' @@ -28,7 +28,7 @@ export class VideoChannelUpdateComponent extends VideoChannelEdit implements OnI private serverConfig: HTMLServerConfig constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private route: ActivatedRoute, 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 9e6b8e21d..235fbec4a 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 @@ -3,7 +3,7 @@ import { tap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { AuthService, ServerService, UserService } from '@app/core' 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' @Component({ @@ -17,7 +17,7 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni user: User = null constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private userService: UserService, private serverService: ServerService 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 dd405de33..805d50070 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 @@ -6,7 +6,7 @@ import { USER_EXISTING_PASSWORD_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' @Component({ @@ -19,7 +19,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On user: User = null constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier, private authService: AuthService, private userService: UserService 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 f395ad73f..8621eb7aa 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 @@ -2,7 +2,7 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/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 { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' @Component({ selector: 'my-account-profile', @@ -16,7 +16,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit { error: string = null constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier, private userService: UserService ) { diff --git a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts index 8ead237c7..ca7eb680b 100644 --- a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts +++ b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts @@ -3,7 +3,7 @@ import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from ' import { AuthService, Notifier } from '@app/core' import { listUserChannelsForSelect } from '@app/helpers' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { VideoChangeOwnership } from '@shared/models' @@ -24,7 +24,7 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit { error: string = null constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private videoOwnershipService: VideoOwnershipService, private notifier: Notifier, private authService: AuthService, diff --git a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts index 9ceb6dfd1..a14ab5b92 100644 --- a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts +++ b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts @@ -5,7 +5,7 @@ import { Router } from '@angular/router' import { AuthService, Notifier } from '@app/core' import { listUserChannelsForSelect } from '@app/helpers' 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 { VideoChannelSyncCreate } from '@shared/models/videos' @@ -20,7 +20,7 @@ export class VideoChannelSyncEditComponent extends FormReactive implements OnIni existingVideosStrategy: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private router: Router, private notifier: Notifier, diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts index 9eb3e9888..63f72df3f 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts @@ -9,7 +9,7 @@ import { 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 { FormReactiveService } 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' @@ -23,7 +23,7 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemen error: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private router: Router, diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts index ef7ba0018..bbe8a5f80 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts @@ -11,7 +11,7 @@ import { 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 { FormReactiveService } from '@app/shared/shared-forms' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylistUpdate } from '@shared/models' import { MyVideoPlaylistEdit } from './my-video-playlist-edit' @@ -27,7 +27,7 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemen private paramsSub: Subscription constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private router: Router, diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts index 960c9a4f7..72187e893 100644 --- a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts +++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts @@ -1,7 +1,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { Notifier, UserService } from '@app/core' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' @@ -20,7 +20,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni private video: Video | undefined = undefined constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private videoOwnershipService: VideoOwnershipService, private notifier: Notifier, private userService: UserService, diff --git a/client/src/app/+reset-password/reset-password.component.ts b/client/src/app/+reset-password/reset-password.component.ts index 11c5110fd..44216f978 100644 --- a/client/src/app/+reset-password/reset-password.component.ts +++ b/client/src/app/+reset-password/reset-password.component.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router' import { Notifier, UserService } from '@app/core' 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 { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' @Component({ selector: 'my-login', @@ -16,7 +16,7 @@ export class ResetPasswordComponent extends FormReactive implements OnInit { private verificationString: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private userService: UserService, private notifier: Notifier, private router: Router, diff --git a/client/src/app/+signup/+register/steps/register-step-channel.component.ts b/client/src/app/+signup/+register/steps/register-step-channel.component.ts index c10b568ba..df92c5145 100644 --- a/client/src/app/+signup/+register/steps/register-step-channel.component.ts +++ b/client/src/app/+signup/+register/steps/register-step-channel.component.ts @@ -3,7 +3,7 @@ import { pairwise } from 'rxjs/operators' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { FormGroup } from '@angular/forms' 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' @Component({ @@ -19,7 +19,7 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit @Output() formBuilt = new EventEmitter() constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private userSignupService: UserSignupService ) { super() diff --git a/client/src/app/+signup/+register/steps/register-step-terms.component.ts b/client/src/app/+signup/+register/steps/register-step-terms.component.ts index 87d16696e..2df963b30 100644 --- a/client/src/app/+signup/+register/steps/register-step-terms.component.ts +++ b/client/src/app/+signup/+register/steps/register-step-terms.component.ts @@ -1,9 +1,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { FormGroup } from '@angular/forms' -import { - USER_TERMS_VALIDATOR -} from '@app/shared/form-validators/user-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { USER_TERMS_VALIDATOR } from '@app/shared/form-validators/user-validators' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' @Component({ selector: 'my-register-step-terms', @@ -19,7 +17,7 @@ export class RegisterStepTermsComponent extends FormReactive implements OnInit { @Output() codeOfConductClick = new EventEmitter() constructor ( - protected formValidatorService: FormValidatorService + protected formReactiveService: FormReactiveService ) { super() } diff --git a/client/src/app/+signup/+register/steps/register-step-user.component.ts b/client/src/app/+signup/+register/steps/register-step-user.component.ts index b89e38a28..822f8f5c5 100644 --- a/client/src/app/+signup/+register/steps/register-step-user.component.ts +++ b/client/src/app/+signup/+register/steps/register-step-user.component.ts @@ -8,7 +8,7 @@ import { USER_PASSWORD_VALIDATOR, USER_USERNAME_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' @Component({ @@ -23,7 +23,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit { @Output() formBuilt = new EventEmitter() constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private userSignupService: UserSignupService ) { super() diff --git a/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts b/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts index a0ed66a3a..06905f678 100644 --- a/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts +++ b/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core' import { Notifier, RedirectService, ServerService } from '@app/core' 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' @Component({ @@ -14,7 +14,7 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements requiresEmailVerification = false constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private userSignupService: UserSignupService, private serverService: ServerService, private notifier: Notifier, diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.ts b/client/src/app/+video-studio/edit/video-studio-edit.component.ts index bf91c237a..dad083bf9 100644 --- a/client/src/app/+video-studio/edit/video-studio-edit.component.ts +++ b/client/src/app/+video-studio/edit/video-studio-edit.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' 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 { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' @@ -20,7 +20,7 @@ export class VideoStudioEditComponent extends FormReactive implements OnInit { video: VideoDetails constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private serverService: ServerService, private notifier: Notifier, private router: Router, diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts index 95d83b131..4ab2d42db 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -1,7 +1,7 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { ServerService } from '@app/core' 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 { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { HTMLServerConfig, VideoConstant } from '@shared/models' @@ -26,7 +26,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni private closingModal = false constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private serverService: ServerService ) { diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts index f33353d36..2cb470a24 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.ts @@ -1,8 +1,8 @@ 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 { 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 { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { HTMLServerConfig, VideoConstant } from '@shared/models' import { ServerService } from '../../../../core' @@ -29,8 +29,7 @@ export class VideoCaptionEditModalContentComponent extends FormReactive implemen constructor ( protected openedModal: NgbActiveModal, - protected formValidatorService: FormValidatorService, - private modalService: NgbModal, + protected formReactiveService: FormReactiveService, private videoCaptionService: VideoCaptionService, private serverService: ServerService ) { diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 344b99ea2..4f2276e8c 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -3,7 +3,7 @@ import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular import { Router } from '@angular/router' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 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 { LiveVideoService } from '@app/shared/shared-video-live' import { LoadingBarService } from '@ngx-loading-bar/core' @@ -39,7 +39,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView error: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected loadingBar: LoadingBarService, protected notifier: Notifier, protected authService: AuthService, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index 7b9531d27..4a1408a4a 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -3,7 +3,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, Vie import { Router } from '@angular/router' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 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 { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' @@ -35,7 +35,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af error: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected loadingBar: LoadingBarService, protected notifier: Notifier, protected authService: AuthService, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts index 422f0c643..502f3818e 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts @@ -4,7 +4,7 @@ import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular import { Router } from '@angular/router' import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 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 { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' @@ -34,7 +34,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV error: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected loadingBar: LoadingBarService, protected notifier: Notifier, protected authService: AuthService, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index 19fba2a83..b0d846664 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -5,7 +5,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, import { ActivatedRoute, Router } from '@angular/router' import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core' 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 { LoadingBarService } from '@ngx-loading-bar/core' import { logger } from '@root-helpers/logger' @@ -60,7 +60,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy private uploadServiceSubscription: Subscription constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected loadingBar: LoadingBarService, protected notifier: Notifier, protected authService: AuthService, diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index ed17dff06..212971447 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -4,7 +4,7 @@ import { SelectChannelItem } from 'src/types/select-options-item.model' import { Component, HostListener, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' 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 { LiveVideoService } from '@app/shared/shared-video-live' import { LoadingBarService } from '@ngx-loading-bar/core' @@ -33,7 +33,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { private updateDone = false constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private route: ActivatedRoute, private router: Router, private notifier: Notifier, diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts index 9f4a68736..9a9bfe710 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts @@ -16,7 +16,7 @@ import { import { Router } from '@angular/router' import { Notifier, User } from '@app/core' 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 { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' @@ -48,7 +48,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, private emojiMarkupList: { emoji: string, name: string }[] constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier, private videoCommentService: VideoCommentService, private modalService: NgbModal, diff --git a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts index d24a5d58d..12d503f56 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/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 { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { logger } from '@root-helpers/logger' @@ -29,7 +29,7 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit { private abuse: UserAbuse constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private htmlRenderer: HtmlRendererService, private auth: AuthService, diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts index 2600da8da..4ad807d25 100644 --- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -20,7 +20,7 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private notifier: Notifier, private abuseService: AbuseService diff --git a/client/src/app/shared/shared-forms/form-reactive.service.ts b/client/src/app/shared/shared-forms/form-reactive.service.ts index 69077eb07..f1b7e0ef2 100644 --- a/client/src/app/shared/shared-forms/form-reactive.service.ts +++ b/client/src/app/shared/shared-forms/form-reactive.service.ts @@ -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 }) } diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts index acaeaba33..d1e7be802 100644 --- a/client/src/app/shared/shared-forms/form-reactive.ts +++ b/client/src/app/shared/shared-forms/form-reactive.ts @@ -1,11 +1,9 @@ -import { AbstractControl, FormGroup } from '@angular/forms' -import { wait } from '@root-helpers/utils' +import { FormGroup } from '@angular/forms' import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' -import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive.service' -import { FormValidatorService } from './form-validator.service' +import { FormReactiveService, FormReactiveValidationMessages } from './form-reactive.service' export abstract class FormReactive { - protected abstract formValidatorService: FormValidatorService + protected abstract formReactiveService: FormReactiveService protected formChanged = false form: FormGroup @@ -13,86 +11,22 @@ export abstract class FormReactive { validationMessages: FormReactiveValidationMessages 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.formErrors = formErrors 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 () { - if (this.form.status !== 'PENDING') return - - // 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') + return this.formReactiveService.waitPendingCheck(this.form) } - protected markAllAsDirty (controlsArg?: { [ key: string ]: AbstractControl }) { - const controls = controlsArg || 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 markAllAsDirty () { + return this.formReactiveService.markAllAsDirty(this.form.controls) } protected forceCheck () { - this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false) - } - - 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') - } - } + return this.formReactiveService.forceCheck(this.form, this.formErrors, this.validationMessages) } } diff --git a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts index 20be728f6..ec2fea528 100644 --- a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts +++ b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts @@ -1,5 +1,5 @@ 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 { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { splitAndGetNotEmpty, UNIQUE_HOSTS_VALIDATOR } from '../form-validators/host-validators' @@ -18,7 +18,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal ) { super() diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts index 78c9b3382..d587a9709 100644 --- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts @@ -2,7 +2,7 @@ import { mapValues, pickBy } from 'lodash-es' import { Component, OnInit, ViewChild } from '@angular/core' import { Notifier } from '@app/core' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -26,7 +26,7 @@ export class AccountReportComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private abuseService: AbuseService, private notifier: Notifier diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts index 7c0907ce4..e35d70c8f 100644 --- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts @@ -2,7 +2,7 @@ import { mapValues, pickBy } from 'lodash-es' import { Component, Input, OnInit, ViewChild } from '@angular/core' import { Notifier } from '@app/core' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -27,7 +27,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private abuseService: AbuseService, private notifier: Notifier diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts index 38dd92910..16be8e0a1 100644 --- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts @@ -3,7 +3,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core' import { DomSanitizer } from '@angular/platform-browser' import { Notifier } from '@app/core' 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 { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' @@ -27,7 +27,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private abuseService: AbuseService, private notifier: Notifier, diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index 617408f2a..27dcf043a 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts @@ -2,7 +2,7 @@ import { forkJoin } from 'rxjs' import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Notifier } from '@app/core' 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 { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { User } from '@shared/models' @@ -25,7 +25,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { modalMessage = '' constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private notifier: Notifier, private userAdminService: UserAdminService, diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts index f8b22a3f6..3ff53443a 100644 --- a/client/src/app/shared/shared-moderation/video-block.component.ts +++ b/client/src/app/shared/shared-moderation/video-block.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Notifier } from '@app/core' 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -25,7 +25,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private videoBlocklistService: VideoBlockService, private notifier: Notifier diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts index 13e2e5424..c2c30d38b 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts @@ -1,7 +1,7 @@ import { Subject, Subscription } from 'rxjs' import { Component, Input, OnDestroy, OnInit } from '@angular/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 { SelectOptionsItem } from 'src/types' @@ -22,7 +22,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn private serverConfig: HTMLServerConfig constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private userService: UserService, diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index 7d6b69469..af0870f12 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts @@ -3,7 +3,7 @@ import { Subject, Subscription } from 'rxjs' import { first } from 'rxjs/operators' import { Component, Input, OnDestroy, OnInit } from '@angular/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 { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' @@ -22,7 +22,7 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, formValuesWatcher: Subscription constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private userService: UserService, diff --git a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts index 7bcfdd8aa..61bcd5345 100644 --- a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts +++ b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit } from '@angular/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 { USER_HANDLE_VALIDATOR } from '../form-validators/user-validators' @@ -15,7 +15,7 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit { @Input() showHelp = false constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier ) { super() diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts index e019fdd26..f81de7c6b 100644 --- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts @@ -3,7 +3,7 @@ import { Subject, Subscription } from 'rxjs' import { debounceTime, filter } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/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 { Video, @@ -59,7 +59,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, private pendingAddId: number constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private authService: AuthService, private notifier: Notifier, private videoPlaylistService: VideoPlaylistService, -- cgit v1.2.3 From a0da6f90d16027b385a67da6a5691b163626a363 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Oct 2022 15:29:53 +0200 Subject: Prevent sass deprecated warning --- .../users/user-list/user-list.component.scss | 2 +- client/src/app/+login/login.component.scss | 4 +- .../my-account-settings.component.scss | 2 +- client/src/sass/bootstrap.scss | 52 +++++++++++----------- client/src/sass/include/_variables.scss | 2 +- client/src/sass/ng-select.scss | 2 +- client/src/sass/player/_player-variables.scss | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.scss b/client/src/app/+admin/overview/users/user-list/user-list.component.scss index 3c775cac5..23e0d29ee 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.scss +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.scss @@ -1,6 +1,6 @@ @use '_variables' as *; @use '_mixins' as *; -@use '~bootstrap/scss/functions' as *; +@use 'bootstrap/scss/functions' as *; .add-button { @include create-button; diff --git a/client/src/app/+login/login.component.scss b/client/src/app/+login/login.component.scss index d31d428f7..17e151fd8 100644 --- a/client/src/app/+login/login.component.scss +++ b/client/src/app/+login/login.component.scss @@ -1,8 +1,8 @@ @use '_variables' as *; @use '_mixins' as *; -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; +@import 'bootstrap/scss/functions'; +@import 'bootstrap/scss/variables'; label { display: block; diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.scss b/client/src/app/+my-account/my-account-settings/my-account-settings.component.scss index 8206f4dd8..3d686a146 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.scss +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.scss @@ -1,6 +1,6 @@ @use '_variables' as *; @use '_mixins' as *; -@use '~bootstrap/scss/functions' as *; +@use 'bootstrap/scss/functions' as *; .account-title { @include settings-big-title; diff --git a/client/src/sass/bootstrap.scss b/client/src/sass/bootstrap.scss index 9328a27a2..a5d06de98 100644 --- a/client/src/sass/bootstrap.scss +++ b/client/src/sass/bootstrap.scss @@ -3,32 +3,32 @@ @import './_bootstrap-variables'; -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; -@import '~bootstrap/scss/maps'; -@import '~bootstrap/scss/mixins'; -@import '~bootstrap/scss/utilities'; - -@import '~bootstrap/scss/root'; -@import '~bootstrap/scss/reboot'; -@import '~bootstrap/scss/type'; -@import '~bootstrap/scss/grid'; -@import '~bootstrap/scss/forms'; -@import '~bootstrap/scss/buttons'; -@import '~bootstrap/scss/dropdown'; -@import '~bootstrap/scss/button-group'; -@import '~bootstrap/scss/nav'; -@import '~bootstrap/scss/card'; -@import '~bootstrap/scss/accordion'; -@import '~bootstrap/scss/alert'; -@import '~bootstrap/scss/close'; -@import '~bootstrap/scss/modal'; -@import '~bootstrap/scss/tooltip'; -@import '~bootstrap/scss/popover'; -@import '~bootstrap/scss/spinners'; - -@import '~bootstrap/scss/helpers'; -@import '~bootstrap/scss/utilities/api'; +@import 'bootstrap/scss/functions'; +@import 'bootstrap/scss/variables'; +@import 'bootstrap/scss/maps'; +@import 'bootstrap/scss/mixins'; +@import 'bootstrap/scss/utilities'; + +@import 'bootstrap/scss/root'; +@import 'bootstrap/scss/reboot'; +@import 'bootstrap/scss/type'; +@import 'bootstrap/scss/grid'; +@import 'bootstrap/scss/forms'; +@import 'bootstrap/scss/buttons'; +@import 'bootstrap/scss/dropdown'; +@import 'bootstrap/scss/button-group'; +@import 'bootstrap/scss/nav'; +@import 'bootstrap/scss/card'; +@import 'bootstrap/scss/accordion'; +@import 'bootstrap/scss/alert'; +@import 'bootstrap/scss/close'; +@import 'bootstrap/scss/modal'; +@import 'bootstrap/scss/tooltip'; +@import 'bootstrap/scss/popover'; +@import 'bootstrap/scss/spinners'; + +@import 'bootstrap/scss/helpers'; +@import 'bootstrap/scss/utilities/api'; .accordion { --bs-accordion-color: #{pvar(--mainForegroundColor)}; diff --git a/client/src/sass/include/_variables.scss b/client/src/sass/include/_variables.scss index c02359f28..02fa7f1f0 100644 --- a/client/src/sass/include/_variables.scss +++ b/client/src/sass/include/_variables.scss @@ -1,6 +1,6 @@ @use 'sass:math'; @use 'sass:color'; -@use '~bootstrap/scss/functions' as *; +@use 'bootstrap/scss/functions' as *; $small-view: 800px; $mobile-view: 500px; diff --git a/client/src/sass/ng-select.scss b/client/src/sass/ng-select.scss index 78e3a6de3..e231e4fed 100644 --- a/client/src/sass/ng-select.scss +++ b/client/src/sass/ng-select.scss @@ -15,7 +15,7 @@ $ng-select-height: 30px; $ng-select-value-padding-left: 15px; $ng-select-value-font-size: $form-input-font-size; -@import '~@ng-select/ng-select/scss/default.theme'; +@import '@ng-select/ng-select/scss/default.theme'; .ng-select { font-size: $ng-select-value-font-size; diff --git a/client/src/sass/player/_player-variables.scss b/client/src/sass/player/_player-variables.scss index 47b8adda4..d5f24dd91 100644 --- a/client/src/sass/player/_player-variables.scss +++ b/client/src/sass/player/_player-variables.scss @@ -1,4 +1,4 @@ -@use '~bootstrap/scss/functions' as *; +@use 'bootstrap/scss/functions' as *; $primary-foreground-color: #fff; $primary-foreground-opacity: 0.9; -- cgit v1.2.3