From 39a3ace3aed47c104461afdb5c5c5422917fb954 Mon Sep 17 00:00:00 2001 From: Quentin Monmert Date: Fri, 31 Dec 2021 17:36:30 +0100 Subject: [PATCH] [Angular] 'subscribe' is deprecated --- .../account/activate/activate.component.ts.ejs | 8 ++++---- .../password-reset-finish.component.ts.ejs | 8 ++++---- .../account/password/password.component.ts.ejs | 8 ++++---- .../account/register/register.component.ts.ejs | 2 +- .../app/admin/health/health.component.ts.ejs | 8 ++++---- .../list/user-management.component.ts.ejs | 8 ++++---- .../user-management-update.component.ts.ejs | 16 ++++++++-------- .../main/webapp/app/login/login.component.ts.ejs | 8 ++++---- .../shared/language/translate.directive.ts.ejs | 8 ++++---- .../entities/list/infinite-scroll-template.ejs | 8 ++++---- .../app/entities/list/no-pagination-template.ejs | 16 ++++++++-------- .../app/entities/list/pagination-template.ejs | 8 ++++---- .../entity-management-update.component.ts.ejs | 8 ++++---- 13 files changed, 57 insertions(+), 57 deletions(-) diff --git a/generators/client/templates/angular/src/main/webapp/app/account/activate/activate.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/activate/activate.component.ts.ejs index 360d153c135..c1c32fbda75 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/activate/activate.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/activate/activate.component.ts.ejs @@ -33,9 +33,9 @@ export class ActivateComponent implements OnInit { constructor(private activateService: ActivateService, private route: ActivatedRoute) {} ngOnInit(): void { - this.route.queryParams.pipe(mergeMap(params => this.activateService.get(params.key))).subscribe( - () => this.success = true, - () => this.error = true - ); + this.route.queryParams.pipe(mergeMap(params => this.activateService.get(params.key))).subscribe({ + next: () => this.success = true, + error: () => this.error = true + }); } } diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs index 0b72a0d6539..a764cb069b0 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs @@ -68,10 +68,10 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit { if (newPassword !== confirmPassword) { this.doNotMatch = true; } else { - this.passwordResetFinishService.save(this.key, newPassword).subscribe( - () => this.success = true, - () => this.error = true - ); + this.passwordResetFinishService.save(this.key, newPassword).subscribe({ + next: () => this.success = true, + error: () => this.error = true + }); } } } diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs index 7df1f246465..f40a98fe439 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs @@ -54,10 +54,10 @@ export class PasswordComponent implements OnInit { if (newPassword !== this.passwordForm.get(['confirmPassword'])!.value) { this.doNotMatch = true; } else { - this.passwordService.save(newPassword, this.passwordForm.get(['currentPassword'])!.value).subscribe( - () => this.success = true, - () => this.error = true - ); + this.passwordService.save(newPassword, this.passwordForm.get(['currentPassword'])!.value).subscribe({ + next: () => this.success = true, + error: () => this.error = true + }); } } } diff --git a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs index 75d8ea5f77c..152e5570b35 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs @@ -75,7 +75,7 @@ export class RegisterComponent implements AfterViewInit { const email = this.registerForm.get(['email'])!.value; this.registerService .save({ login, email, password, langKey: <% if (enableTranslation) { %>this.translateService.currentLang<% } else { %>'en'<% } %> }) - .subscribe(() => (this.success = true), response => this.processError(response)); + .subscribe({ next: () => (this.success = true), error: response => this.processError(response)}); } } diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.ts.ejs index f17f9c88134..49873a1f481 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.ts.ejs @@ -45,14 +45,14 @@ export class HealthComponent implements OnInit { } refresh(): void { - this.healthService.checkHealth().subscribe( - health => (this.health = health), - (error: HttpErrorResponse) => { + this.healthService.checkHealth().subscribe({ + next: health => (this.health = health), + error: (error: HttpErrorResponse) => { if (error.status === 503) { this.health = error.error; } } - ); + }); } showHealth(health: { key: string; value: HealthDetails }): void { diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs index 798baaf6ee1..4ddd0177ff8 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs @@ -95,13 +95,13 @@ export class UserManagementComponent implements OnInit { size: this.itemsPerPage, sort: this.sort(), }<% } %>) - .subscribe( - (res: HttpResponse) => { + .subscribe({ + next: (res: HttpResponse) => { this.isLoading = false; this.onSuccess(res.body<% if (!databaseTypeCassandra) { %>, res.headers<% } %>); }, - () => this.isLoading = false - ); + error: () => this.isLoading = false + }); } <%_ if (!databaseTypeCassandra) { _%> diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs index c01fabc9d88..fca27f46b90 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs @@ -72,18 +72,18 @@ export class UserManagementUpdateComponent implements OnInit { this.isSaving = true; this.updateUser(this.user); if (this.user.id !== undefined) { - this.userService.update(this.user).subscribe( - () => this.onSaveSuccess(), - () => this.onSaveError() - ); + this.userService.update(this.user).subscribe({ + next: () => this.onSaveSuccess(), + error: () => this.onSaveError() + }); } else { <%_ if (!enableTranslation) { _%> this.user.langKey = 'en'; <%_ } _%> - this.userService.create(this.user).subscribe( - () => this.onSaveSuccess(), - () => this.onSaveError() - ); + this.userService.create(this.user).subscribe({ + next: () => this.onSaveSuccess(), + error: () => this.onSaveError() + }); } } diff --git a/generators/client/templates/angular/src/main/webapp/app/login/login.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/login/login.component.ts.ejs index 9292e8a6d50..c1d9c570df5 100644 --- a/generators/client/templates/angular/src/main/webapp/app/login/login.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/login/login.component.ts.ejs @@ -66,15 +66,15 @@ export class LoginComponent implements OnInit, AfterViewInit { password: this.loginForm.get('password')!.value, rememberMe: this.loginForm.get('rememberMe')!.value, }) - .subscribe( - () => { + .subscribe({ + next: () => { this.authenticationError = false; if (!this.router.getCurrentNavigation()) { // There were no routing during login (eg from navigationToStoredUrl) this.router.navigate(['']); } }, - () => this.authenticationError = true - ); + error: () => this.authenticationError = true + }); } } diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/language/translate.directive.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/shared/language/translate.directive.ts.ejs index 5fdf60a5e76..b4577e4a299 100644 --- a/generators/client/templates/angular/src/main/webapp/app/shared/language/translate.directive.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/shared/language/translate.directive.ts.ejs @@ -59,11 +59,11 @@ export class TranslateDirective implements OnChanges, OnInit, OnDestroy { this.translateService .get(this.<%= jhiPrefix %>Translate, this.translateValues) .pipe(takeUntil(this.directiveDestroyed)) - .subscribe( - value => { + .subscribe({ + next: value => { this.el.nativeElement.innerHTML = value; }, - () => `${translationNotFoundMessage}[${this.<%= jhiPrefix %>Translate}]` - ); + error: () => `${translationNotFoundMessage}[${this.<%= jhiPrefix %>Translate}]` + }); } } diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/infinite-scroll-template.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/infinite-scroll-template.ejs index 9ed102cbb9c..a63470a1004 100644 --- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/infinite-scroll-template.ejs +++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/infinite-scroll-template.ejs @@ -62,15 +62,15 @@ page: this.page, size: this.itemsPerPage, sort: this.sort() - }).subscribe( - (res: HttpResponse[]>) => { + }).subscribe({ + next: (res: HttpResponse[]>) => { this.isLoading = false; this.paginate<%= entityClassPlural %>(res.body, res.headers); }, - () => { + error: () => { this.isLoading = false; } - ); + }); return; } <%_ } _%> diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/no-pagination-template.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/no-pagination-template.ejs index 855f0488658..39708d0514e 100644 --- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/no-pagination-template.ejs +++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/no-pagination-template.ejs @@ -45,28 +45,28 @@ if (this.currentSearch) { this.<%= entityInstance %>Service.search({ query: this.currentSearch, - }).subscribe( - (res: HttpResponse[]>) => { + }).subscribe({ + next: (res: HttpResponse[]>) => { this.isLoading = false; this.<%= entityInstancePlural %> = res.body ?? []; }, - () => { + error: () => { this.isLoading = false; } - ); + }); return; } <%_ } _%> - this.<%= entityInstance %>Service.query().subscribe( - (res: HttpResponse[]>) => { + this.<%= entityInstance %>Service.query().subscribe({ + next: (res: HttpResponse[]>) => { this.isLoading = false; this.<%= entityInstancePlural %> = res.body ?? []; }, - () => { + error: () => { this.isLoading = false; } - ); + }); } <%_ if (searchEngine) { _%> diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/pagination-template.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/pagination-template.ejs index 9940f40bffa..7b4eac48701 100644 --- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/pagination-template.ejs +++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/pagination-template.ejs @@ -54,16 +54,16 @@ page: pageToLoad - 1, query: this.currentSearch, size: this.itemsPerPage, - sort: this.sort()}).subscribe( - (res: HttpResponse[]>) => { + sort: this.sort()}).subscribe({ + next: (res: HttpResponse[]>) => { this.isLoading = false; this.onSuccess(res.body, res.headers, pageToLoad, !dontNavigate); }, - () => { + error: () => { this.isLoading = false; this.onError(); } - ); + }); return; } <%_ } _%> diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs index f25f8dba052..97a78c60b6b 100644 --- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs +++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs @@ -239,10 +239,10 @@ _%> <%_ } _%> protected subscribeToSaveResponse(result: Observable>>): void { - result.pipe(finalize(() => this.onSaveFinalize())).subscribe( - () => this.onSaveSuccess(), - () => this.onSaveError() - ); + result.pipe(finalize(() => this.onSaveFinalize())).subscribe({ + next: () => this.onSaveSuccess(), + error: () => this.onSaveError() + }); } protected onSaveSuccess(): void {