chore(ui): clear shared prefer-inject bucket
Convert the shared layout shell and shared service constructors to field injection so the frontend shell matches the repo's Angular inject() guidance without changing behavior. Validation: just ui lint
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<AppVersion> {
|
||||
return this.http.get<AppVersion>(this.versionUrl);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user