mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
Add host-window.service
This commit is contained in:
@@ -8,9 +8,10 @@ import {
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { HostWindowState } from "./shared/host-window.reducer";
|
||||
import { Store } from "@ngrx/store";
|
||||
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
||||
|
||||
import { HostWindowResizeAction } from "./shared/host-window.actions";
|
||||
import { EnvConfig, GLOBAL_CONFIG, GlobalConfig } from '../config';
|
||||
import { NativeWindowRef, NativeWindowService } from "./shared/window.service";
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
@@ -23,6 +24,7 @@ export class AppComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
@Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig,
|
||||
@Inject(NativeWindowService) private _window: NativeWindowRef,
|
||||
private translate: TranslateService,
|
||||
private store: Store<HostWindowState>
|
||||
) {
|
||||
@@ -33,6 +35,7 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.onInit();
|
||||
const env: string = EnvConfig.production ? "Production" : "Development";
|
||||
const color: string = EnvConfig.production ? "red" : "green";
|
||||
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
||||
@@ -45,4 +48,12 @@ export class AppComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
private onInit(): void {
|
||||
if (typeof this._window !== 'undefined') {
|
||||
this.store.dispatch(
|
||||
new HostWindowResizeAction(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user