mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
93219: Move general initialization from AppComponent to InitService
This commit is contained in:
@@ -11,9 +11,17 @@ import { AppState } from '../../app/app.reducer';
|
||||
import { TransferState } from '@angular/platform-browser';
|
||||
import { DSpaceTransferState } from '../transfer-state/dspace-transfer-state.service';
|
||||
import { CorrelationIdService } from '../../app/correlation-id/correlation-id.service';
|
||||
import { APP_CONFIG_STATE, AppConfig } from '../../config/app-config.interface';
|
||||
import { APP_CONFIG, APP_CONFIG_STATE, AppConfig } from '../../config/app-config.interface';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { LocaleService } from '../../app/core/locale/locale.service';
|
||||
import { Angulartics2DSpace } from '../../app/statistics/angulartics/dspace-provider';
|
||||
import { GoogleAnalyticsService } from '../../app/statistics/google-analytics.service';
|
||||
import { MetadataService } from '../../app/core/metadata/metadata.service';
|
||||
import { BreadcrumbsService } from '../../app/breadcrumbs/breadcrumbs.service';
|
||||
import { CSSVariableService } from '../../app/shared/sass-helper/sass-helper.service';
|
||||
import { KlaroService } from '../../app/shared/cookies/klaro.service';
|
||||
|
||||
/**
|
||||
* Performs server-side initialization.
|
||||
@@ -25,8 +33,29 @@ export class ServerInitService extends InitService {
|
||||
protected correlationIdService: CorrelationIdService,
|
||||
protected transferState: TransferState,
|
||||
protected dspaceTransferState: DSpaceTransferState,
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
protected translate: TranslateService,
|
||||
protected localeService: LocaleService,
|
||||
protected angulartics2DSpace: Angulartics2DSpace,
|
||||
@Optional() protected googleAnalyticsService: GoogleAnalyticsService,
|
||||
protected metadata: MetadataService,
|
||||
protected breadcrumbsService: BreadcrumbsService,
|
||||
protected cssService: CSSVariableService,
|
||||
@Optional() protected klaroService: KlaroService,
|
||||
) {
|
||||
super(store, correlationIdService, dspaceTransferState);
|
||||
super(
|
||||
store,
|
||||
correlationIdService,
|
||||
dspaceTransferState,
|
||||
appConfig,
|
||||
translate,
|
||||
localeService,
|
||||
angulartics2DSpace,
|
||||
googleAnalyticsService,
|
||||
metadata,
|
||||
breadcrumbsService,
|
||||
klaroService,
|
||||
);
|
||||
}
|
||||
|
||||
protected init(): () => Promise<boolean> {
|
||||
@@ -36,10 +65,19 @@ export class ServerInitService extends InitService {
|
||||
this.transferAppState(); // todo: SSR breaks if we await this (why?)
|
||||
this.initCorrelationId();
|
||||
|
||||
this.checkEnvironment();
|
||||
this.initI18n();
|
||||
this.initAnalytics();
|
||||
this.initRouteListeners();
|
||||
|
||||
this.initKlaro();
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// Server-only initialization steps
|
||||
|
||||
private saveAppConfigForCSR(): void {
|
||||
this.transferState.set<AppConfig>(APP_CONFIG_STATE, environment as AppConfig);
|
||||
}
|
||||
|
Reference in New Issue
Block a user