This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch 4287-migrate-angular-ui-from-constructor-injection-to-inject in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit c60dccdfb6bec5e60153404a8154f96decb03847 Author: Philipp Zehnder <[email protected]> AuthorDate: Tue Mar 24 09:57:29 2026 +0100 migrate profile UI to inject() --- .../general/general-profile-settings.component.ts | 19 ++++++++++--------- .../change-email/change-email-dialog.component.ts | 19 ++++++++++++------- .../change-password-dialog.component.ts | 19 ++++++++++++------- ui/src/app/profile/profile.component.ts | 6 +++--- ui/src/app/profile/profile.service.ts | 8 +++----- 5 files changed, 40 insertions(+), 31 deletions(-) diff --git a/ui/src/app/profile/components/general/general-profile-settings.component.ts b/ui/src/app/profile/components/general/general-profile-settings.component.ts index cffdd08ece..ec6c816b0c 100644 --- a/ui/src/app/profile/components/general/general-profile-settings.component.ts +++ b/ui/src/app/profile/components/general/general-profile-settings.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { ProfileService } from '../../profile.service'; import { BasicProfileSettings } from '../basic-profile-settings'; import { AppConstants } from '../../../services/app.constants'; @@ -72,6 +72,9 @@ export class GeneralProfileSettingsComponent extends BasicProfileSettings implements OnInit, OnDestroy { + private dialogService = inject(DialogService); + private router = inject(Router); + darkMode = false; originalDarkMode = false; darkModeChanged = false; @@ -84,14 +87,12 @@ export class GeneralProfileSettingsComponent { label: 'Polski', id: 'pl' }, ]; - constructor( - authService: AuthService, - profileService: ProfileService, - appConstants: AppConstants, - currentUserService: CurrentUserService, - private dialogService: DialogService, - private router: Router, - ) { + constructor() { + const authService = inject(AuthService); + const profileService = inject(ProfileService); + const appConstants = inject(AppConstants); + const currentUserService = inject(CurrentUserService); + super(profileService, appConstants, currentUserService, authService); } diff --git a/ui/src/app/profile/dialog/change-email/change-email-dialog.component.ts b/ui/src/app/profile/dialog/change-email/change-email-dialog.component.ts index 6265aa25cd..04e93e756e 100644 --- a/ui/src/app/profile/dialog/change-email/change-email-dialog.component.ts +++ b/ui/src/app/profile/dialog/change-email/change-email-dialog.component.ts @@ -16,7 +16,13 @@ * */ -import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; +import { + Component, + Input, + OnInit, + ViewEncapsulation, + inject, +} from '@angular/core'; import { DialogRef } from '@streampipes/shared-ui'; import { AbstractControl, @@ -55,6 +61,11 @@ import { MatDivider } from '@angular/material/divider'; ], }) export class ChangeEmailDialogComponent implements OnInit { + private dialogRef = + inject<DialogRef<ChangeEmailDialogComponent>>(DialogRef); + private fb = inject(UntypedFormBuilder); + private userService = inject(UserService); + parentForm: UntypedFormGroup; @Input() @@ -70,12 +81,6 @@ export class ChangeEmailDialogComponent implements OnInit { error = false; errorMessage = ''; - constructor( - private dialogRef: DialogRef<ChangeEmailDialogComponent>, - private fb: UntypedFormBuilder, - private userService: UserService, - ) {} - ngOnInit(): void { this.clonedUser = UserAccount.fromData(this.user); this.email = this.clonedUser.username; diff --git a/ui/src/app/profile/dialog/change-password/change-password-dialog.component.ts b/ui/src/app/profile/dialog/change-password/change-password-dialog.component.ts index c128920388..67a82d9b81 100644 --- a/ui/src/app/profile/dialog/change-password/change-password-dialog.component.ts +++ b/ui/src/app/profile/dialog/change-password/change-password-dialog.component.ts @@ -16,7 +16,13 @@ * */ -import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; +import { + Component, + Input, + OnInit, + ViewEncapsulation, + inject, +} from '@angular/core'; import { DialogRef } from '@streampipes/shared-ui'; import { AbstractControl, @@ -59,6 +65,11 @@ import { MatDivider } from '@angular/material/divider'; ], }) export class ChangePasswordDialogComponent implements OnInit { + private dialogRef = + inject<DialogRef<ChangePasswordDialogComponent>>(DialogRef); + private fb = inject(UntypedFormBuilder); + private userService = inject(UserService); + @Input() user: UserAccount; @@ -72,12 +83,6 @@ export class ChangePasswordDialogComponent implements OnInit { error = false; errorMessage = ''; - constructor( - private dialogRef: DialogRef<ChangePasswordDialogComponent>, - private fb: UntypedFormBuilder, - private userService: UserService, - ) {} - ngOnInit(): void { this.parentForm = this.fb.group({}); this.parentForm.addControl( diff --git a/ui/src/app/profile/profile.component.ts b/ui/src/app/profile/profile.component.ts index 2d9611b485..8496d979ee 100644 --- a/ui/src/app/profile/profile.component.ts +++ b/ui/src/app/profile/profile.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { SpBasicViewComponent, SpBreadcrumbService, @@ -48,9 +48,9 @@ import { TranslatePipe } from '@ngx-translate/core'; ], }) export class ProfileComponent implements OnInit { - selectedIndex = 0; + private breadcrumbService = inject(SpBreadcrumbService); - constructor(private breadcrumbService: SpBreadcrumbService) {} + selectedIndex = 0; ngOnInit(): void { this.breadcrumbService.updateBreadcrumb([{ label: 'Profile' }]); diff --git a/ui/src/app/profile/profile.service.ts b/ui/src/app/profile/profile.service.ts index 19061ca8c5..0ae362a6b8 100644 --- a/ui/src/app/profile/profile.service.ts +++ b/ui/src/app/profile/profile.service.ts @@ -16,7 +16,7 @@ * */ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Message, PlatformServicesCommons, @@ -29,10 +29,8 @@ import { map } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class ProfileService { - constructor( - private http: HttpClient, - private platformServicesCommons: PlatformServicesCommons, - ) {} + private http = inject(HttpClient); + private platformServicesCommons = inject(PlatformServicesCommons); getUserProfile(username: string): Observable<UserAccount> { return this.http.get(this.profilePath + '/username/' + username).pipe(
