diff --git a/frontend/src/app/shared/layout/component/layout-main/app.layout.component.ts b/frontend/src/app/shared/layout/component/layout-main/app.layout.component.ts index 1e885a00b..280d2ffba 100644 --- a/frontend/src/app/shared/layout/component/layout-main/app.layout.component.ts +++ b/frontend/src/app/shared/layout/component/layout-main/app.layout.component.ts @@ -1,4 +1,4 @@ -import {Component, OnDestroy, OnInit, Renderer2, ViewChild} from '@angular/core'; +import {Component, inject, OnDestroy, OnInit, Renderer2, ViewChild} from '@angular/core'; import {NavigationEnd, Router, RouterOutlet} from '@angular/router'; import {filter, Subscription} from 'rxjs'; import {LayoutService} from "./service/app.layout.service"; @@ -20,8 +20,12 @@ import {LocalStorageService} from '../../../service/local-storage.service'; templateUrl: './app.layout.component.html' }) export class AppLayoutComponent implements OnInit, OnDestroy { + public layoutService = inject(LayoutService); + public renderer = inject(Renderer2); + public router = inject(Router); + private localStorageService = inject(LocalStorageService); - overlayMenuOpenSubscription: Subscription; + overlayMenuOpenSubscription!: Subscription; menuOutsideClickListener: (() => void) | null = null; @@ -31,7 +35,7 @@ export class AppLayoutComponent implements OnInit, OnDestroy { @ViewChild(AppTopBarComponent) appTopbar!: AppTopBarComponent; - constructor(public layoutService: LayoutService, public renderer: Renderer2, public router: Router, private localStorageService: LocalStorageService) { + constructor() { this.overlayMenuOpenSubscription = this.layoutService.overlayOpen$.subscribe(() => { if (!this.menuOutsideClickListener) { this.menuOutsideClickListener = this.renderer.listen('document', 'click', (event) => { diff --git a/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts b/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts index eee779a46..38dcf3548 100644 --- a/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts +++ b/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts @@ -63,16 +63,15 @@ export class AppMenuitemComponent implements OnInit, OnDestroy { } private userService = inject(UserService); + public router = inject(Router); + private menuService = inject(MenuService); + private dialogLauncher = inject(DialogLauncherService); + private bookDialogHelperService = inject(BookDialogHelperService); menuSourceSubscription: Subscription; menuResetSubscription: Subscription; private routerSubscription: Subscription; - constructor( - public router: Router, - private menuService: MenuService, - private dialogLauncher: DialogLauncherService, - private bookDialogHelperService: BookDialogHelperService - ) { + constructor() { effect(() => { const user = this.userService.currentUser(); if (user) { diff --git a/frontend/src/app/shared/layout/component/layout-sidebar/app.sidebar.component.ts b/frontend/src/app/shared/layout/component/layout-sidebar/app.sidebar.component.ts index 3d90d03b1..209de7d9e 100644 --- a/frontend/src/app/shared/layout/component/layout-sidebar/app.sidebar.component.ts +++ b/frontend/src/app/shared/layout/component/layout-sidebar/app.sidebar.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef } from '@angular/core'; +import {Component, ElementRef, inject} from '@angular/core'; import { LayoutService } from "../layout-main/service/app.layout.service"; import {AppMenuComponent} from '../layout-menu/app.menu.component'; @@ -10,6 +10,6 @@ import {AppMenuComponent} from '../layout-menu/app.menu.component'; templateUrl: './app.sidebar.component.html' }) export class AppSidebarComponent { - constructor(public layoutService: LayoutService, public el: ElementRef) { } + public layoutService = inject(LayoutService); + public el = inject(ElementRef); } - diff --git a/frontend/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts b/frontend/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts index e6e72861d..2af0a182c 100644 --- a/frontend/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts +++ b/frontend/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts @@ -53,8 +53,16 @@ import {LANG_STORAGE_KEY} from '../../../../core/config/language-initializer'; ], }) export class AppTopBarComponent implements OnDestroy { + public layoutService = inject(LayoutService); protected readonly userService = inject(UserService); protected readonly user = this.userService.currentUser; + private notificationService = inject(NotificationEventService); + private router = inject(Router); + private authService = inject(AuthService); + private metadataProgressService = inject(MetadataProgressService); + private bookdropFileService = inject(BookdropFileService); + private dialogLauncher = inject(DialogLauncherService); + private translocoService = inject(TranslocoService); items!: MenuItem[]; ref?: DynamicDialogRef; statsMenuItems: MenuItem[] = []; @@ -82,20 +90,8 @@ export class AppTopBarComponent implements OnDestroy { activeLang = ''; langMenuItems: MenuItem[] = []; - private translocoService: TranslocoService; - - constructor( - public layoutService: LayoutService, - private notificationService: NotificationEventService, - private router: Router, - private authService: AuthService, - private metadataProgressService: MetadataProgressService, - private bookdropFileService: BookdropFileService, - private dialogLauncher: DialogLauncherService, - translocoService: TranslocoService - ) { - this.translocoService = translocoService; - this.activeLang = translocoService.getActiveLang(); + constructor() { + this.activeLang = this.translocoService.getActiveLang(); this.langMenuItems = AVAILABLE_LANGS.map(lang => ({ label: LANG_LABELS[lang] || lang, icon: lang === this.activeLang ? 'pi pi-check' : undefined, diff --git a/frontend/src/app/shared/service/version.service.ts b/frontend/src/app/shared/service/version.service.ts index 000a9dff2..6b61428ca 100644 --- a/frontend/src/app/shared/service/version.service.ts +++ b/frontend/src/app/shared/service/version.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import {inject, Injectable} from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import {API_CONFIG} from '../../core/config/api-config'; @@ -20,10 +20,9 @@ export interface ReleaseNote { providedIn: 'root' }) export class VersionService { + private http = inject(HttpClient); private versionUrl = `${API_CONFIG.BASE_URL}/api/v1/version`; - constructor(private http: HttpClient) {} - getVersion(): Observable { return this.http.get(this.versionUrl); } diff --git a/frontend/src/app/shared/websocket/rx-stomp.service.ts b/frontend/src/app/shared/websocket/rx-stomp.service.ts index c873800f2..5edfd24b4 100644 --- a/frontend/src/app/shared/websocket/rx-stomp.service.ts +++ b/frontend/src/app/shared/websocket/rx-stomp.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import {inject, Injectable} from '@angular/core'; import {RxStomp, RxStompConfig} from '@stomp/rx-stomp'; import { AuthService } from '../service/auth.service'; import { createRxStompConfig } from './rx-stomp.config'; @@ -7,8 +7,9 @@ import { createRxStompConfig } from './rx-stomp.config'; providedIn: 'root', }) export class RxStompService extends RxStomp { + private authService = inject(AuthService); - constructor(private authService: AuthService) { + constructor() { super(); const stompConfig = createRxStompConfig(this.authService); this.configure(stompConfig);