Browse Source

Migrate services to Angular 22 @Service()

pull/7671/head
Thomas Kaul 1 week ago
parent
commit
395b0b9acc
  1. 10
      apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
  2. 4
      apps/client/src/app/core/auth.interceptor.ts
  3. 4
      apps/client/src/app/core/http-response.interceptor.ts
  4. 4
      apps/client/src/app/core/language.service.ts
  5. 3
      apps/client/src/app/core/layout.service.ts
  6. 4
      apps/client/src/app/core/module-preload.service.ts
  7. 8
      apps/client/src/app/services/page-title.strategy.ts
  8. 2
      libs/ui/src/lib/entity-logo/entity-logo-image-source.service.ts
  9. 4
      libs/ui/src/lib/fire-calculator/fire-calculator.service.ts
  10. 4
      libs/ui/src/lib/notifications/notification.service.ts

10
apps/client/src/app/components/admin-market-data/admin-market-data.service.ts

@ -3,15 +3,13 @@ import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
import { NotificationService } from '@ghostfolio/ui/notifications'; import { NotificationService } from '@ghostfolio/ui/notifications';
import { AdminService } from '@ghostfolio/ui/services'; import { AdminService } from '@ghostfolio/ui/services';
import { Injectable } from '@angular/core'; import { inject, Service } from '@angular/core';
import { EMPTY, Subject, catchError, finalize, forkJoin } from 'rxjs'; import { EMPTY, Subject, catchError, finalize, forkJoin } from 'rxjs';
@Injectable() @Service({ autoProvided: false })
export class AdminMarketDataService { export class AdminMarketDataService {
public constructor( private readonly adminService = inject(AdminService);
private adminService: AdminService, private readonly notificationService = inject(NotificationService);
private notificationService: NotificationService
) {}
public deleteAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) { public deleteAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) {
const assetProfileDeleted = new Subject<void>(); const assetProfileDeleted = new Subject<void>();

4
apps/client/src/app/core/auth.interceptor.ts

@ -13,10 +13,10 @@ import {
HttpInterceptor, HttpInterceptor,
HttpRequest HttpRequest
} from '@angular/common/http'; } from '@angular/common/http';
import { inject, Injectable } from '@angular/core'; import { inject, Service } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@Injectable() @Service({ autoProvided: false })
export class AuthInterceptor implements HttpInterceptor { export class AuthInterceptor implements HttpInterceptor {
private readonly impersonationStorageService = inject( private readonly impersonationStorageService = inject(
ImpersonationStorageService ImpersonationStorageService

4
apps/client/src/app/core/http-response.interceptor.ts

@ -14,7 +14,7 @@ import {
HttpInterceptor, HttpInterceptor,
HttpRequest HttpRequest
} from '@angular/common/http'; } from '@angular/common/http';
import { inject, Injectable } from '@angular/core'; import { inject, Service } from '@angular/core';
import { import {
MatSnackBar, MatSnackBar,
MatSnackBarRef, MatSnackBarRef,
@ -26,7 +26,7 @@ import ms from 'ms';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
@Injectable() @Service({ autoProvided: false })
export class HttpResponseInterceptor implements HttpInterceptor { export class HttpResponseInterceptor implements HttpInterceptor {
private readonly info: InfoItem; private readonly info: InfoItem;
private snackBarRef: MatSnackBarRef<TextOnlySnackBar> | undefined; private snackBarRef: MatSnackBarRef<TextOnlySnackBar> | undefined;

4
apps/client/src/app/core/language.service.ts

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'; import { Service } from '@angular/core';
@Injectable() @Service({ autoProvided: false })
export class LanguageService {} export class LanguageService {}

3
apps/client/src/app/core/layout.service.ts

@ -11,9 +11,10 @@ export class LayoutService {
public shouldReloadContent$: Observable<void>; public shouldReloadContent$: Observable<void>;
private readonly shouldReloadSubject = new Subject<void>();
private readonly deviceDetectorService = inject(DeviceDetectorService); private readonly deviceDetectorService = inject(DeviceDetectorService);
private readonly notificationService = inject(NotificationService); private readonly notificationService = inject(NotificationService);
private shouldReloadSubject = new Subject<void>();
public constructor() { public constructor() {
this.shouldReloadContent$ = this.shouldReloadSubject.asObservable(); this.shouldReloadContent$ = this.shouldReloadSubject.asObservable();

4
apps/client/src/app/core/module-preload.service.ts

@ -1,8 +1,8 @@
import { Injectable } from '@angular/core'; import { Service } from '@angular/core';
import { PreloadingStrategy, Route } from '@angular/router'; import { PreloadingStrategy, Route } from '@angular/router';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
@Injectable() @Service({ autoProvided: false })
export class ModulePreloadService implements PreloadingStrategy { export class ModulePreloadService implements PreloadingStrategy {
/** /**
* Preloads all lazy loading modules with the attribute 'preload' set to true * Preloads all lazy loading modules with the attribute 'preload' set to true

8
apps/client/src/app/services/page-title.strategy.ts

@ -1,16 +1,14 @@
import { Injectable } from '@angular/core'; import { inject, Service } from '@angular/core';
import { Title } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
import { RouterStateSnapshot, TitleStrategy } from '@angular/router'; import { RouterStateSnapshot, TitleStrategy } from '@angular/router';
@Injectable() @Service({ autoProvided: false })
export class PageTitleStrategy extends TitleStrategy { export class PageTitleStrategy extends TitleStrategy {
private static readonly DEFAULT_TITLE = private static readonly DEFAULT_TITLE =
'Ghostfolio – Open Source Wealth Management Software'; 'Ghostfolio – Open Source Wealth Management Software';
private static readonly DEFAULT_TITLE_SHORT = 'Ghostfolio'; private static readonly DEFAULT_TITLE_SHORT = 'Ghostfolio';
public constructor(private readonly title: Title) { private readonly title = inject(Title);
super();
}
public override updateTitle(routerState: RouterStateSnapshot) { public override updateTitle(routerState: RouterStateSnapshot) {
const title = this.buildTitle(routerState); const title = this.buildTitle(routerState);

2
libs/ui/src/lib/entity-logo/entity-logo-image-source.service.ts

@ -2,7 +2,7 @@ import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
import { Service } from '@angular/core'; import { Service } from '@angular/core';
// Required to allow mocking in Storybook // Must stay auto-provided so it can be mocked in Storybook
@Service() @Service()
export class EntityLogoImageSourceService { export class EntityLogoImageSourceService {
public getLogoUrlByAssetProfileIdentifier({ public getLogoUrlByAssetProfileIdentifier({

4
libs/ui/src/lib/fire-calculator/fire-calculator.service.ts

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Service } from '@angular/core';
import { Big } from 'big.js'; import { Big } from 'big.js';
@Injectable() @Service({ autoProvided: false })
export class FireCalculatorService { export class FireCalculatorService {
private readonly COMPOUND_PERIOD = 12; private readonly COMPOUND_PERIOD = 12;

4
libs/ui/src/lib/notifications/notification.service.ts

@ -1,7 +1,7 @@
import { ConfirmationDialogType } from '@ghostfolio/common/enums'; import { ConfirmationDialogType } from '@ghostfolio/common/enums';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
import { inject, Injectable } from '@angular/core'; import { inject, Service } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { isFunction } from 'lodash'; import { isFunction } from 'lodash';
@ -14,7 +14,7 @@ import {
} from './interfaces/interfaces'; } from './interfaces/interfaces';
import { GfPromptDialogComponent } from './prompt-dialog/prompt-dialog.component'; import { GfPromptDialogComponent } from './prompt-dialog/prompt-dialog.component';
@Injectable() @Service({ autoProvided: false })
export class NotificationService { export class NotificationService {
private dialogMaxWidth: string; private dialogMaxWidth: string;
private dialogWidth: string; private dialogWidth: string;

Loading…
Cancel
Save