mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
angular cli
This commit is contained in:
@@ -6,8 +6,6 @@ import { select, Store } from '@ngrx/store';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
|
||||
|
||||
import { MetadataService } from './core/metadata/metadata.service';
|
||||
import { HostWindowResizeAction } from './shared/host-window.actions';
|
||||
import { HostWindowState } from './shared/search/host-window.reducer';
|
||||
@@ -26,6 +24,8 @@ import { Theme } from '../config/theme.inferface';
|
||||
import { isNotEmpty } from './shared/empty.util';
|
||||
import { CookieService } from './core/services/cookie.service';
|
||||
import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider';
|
||||
import { environment } from '../environments/environment';
|
||||
import { models } from './core/core.module';
|
||||
|
||||
export const LANG_COOKIE = 'language_cookie';
|
||||
|
||||
@@ -44,9 +44,10 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
collapsedSidebarWidth: Observable<string>;
|
||||
totalSidebarWidth: Observable<string>;
|
||||
theme: Observable<Theme> = of({} as any);
|
||||
notificationOptions = environment.notifications;
|
||||
models;
|
||||
|
||||
constructor(
|
||||
@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
||||
@Inject(NativeWindowService) private _window: NativeWindowRef,
|
||||
private translate: TranslateService,
|
||||
private store: Store<HostWindowState>,
|
||||
@@ -60,11 +61,13 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
private windowService: HostWindowService,
|
||||
private cookie: CookieService
|
||||
) {
|
||||
/* Use models object so all decorators are actually called */
|
||||
this.models = models;
|
||||
// Load all the languages that are defined as active from the config file
|
||||
translate.addLangs(config.languages.filter((LangConfig) => LangConfig.active === true).map((a) => a.code));
|
||||
translate.addLangs(environment.languages.filter((LangConfig) => LangConfig.active === true).map((a) => a.code));
|
||||
|
||||
// Load the default language from the config file
|
||||
translate.setDefaultLang(config.defaultLanguage);
|
||||
translate.setDefaultLang(environment.defaultLanguage);
|
||||
|
||||
// Attempt to get the language from a cookie
|
||||
const lang = cookie.get(LANG_COOKIE);
|
||||
@@ -78,7 +81,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
if (translate.getLangs().includes(translate.getBrowserLang())) {
|
||||
translate.use(translate.getBrowserLang());
|
||||
} else {
|
||||
translate.use(config.defaultLanguage);
|
||||
translate.use(environment.defaultLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,16 +90,15 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
|
||||
metadata.listenForRouteChange();
|
||||
|
||||
if (config.debug) {
|
||||
console.info(config);
|
||||
if (environment.debug) {
|
||||
console.info(environment);
|
||||
}
|
||||
this.storeCSSVariables();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
const env: string = this.config.production ? 'Production' : 'Development';
|
||||
const color: string = this.config.production ? 'red' : 'green';
|
||||
const env: string = environment.production ? 'Production' : 'Development';
|
||||
const color: string = environment.production ? 'red' : 'green';
|
||||
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
||||
this.dispatchWindowSize(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight);
|
||||
|
||||
@@ -118,10 +120,18 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
private storeCSSVariables() {
|
||||
const vars = variables.locals || {};
|
||||
Object.keys(vars).forEach((name: string) => {
|
||||
this.cssService.addCSSVariable(name, vars[name]);
|
||||
})
|
||||
this.cssService.addCSSVariable('xlMin', '1200px');
|
||||
this.cssService.addCSSVariable('mdMin', '768px');
|
||||
this.cssService.addCSSVariable('lgMin', '576px');
|
||||
this.cssService.addCSSVariable('smMin', '0');
|
||||
this.cssService.addCSSVariable('adminSidebarActiveBg', '#0f1b28');
|
||||
this.cssService.addCSSVariable('sidebarItemsWidth', '250px');
|
||||
this.cssService.addCSSVariable('collapsedSidebarWidth', '53.234px');
|
||||
this.cssService.addCSSVariable('totalSidebarWidth', '303.234px');
|
||||
// const vars = variables.locals || {};
|
||||
// Object.keys(vars).forEach((name: string) => {
|
||||
// this.cssService.addCSSVariable(name, vars[name]);
|
||||
// })
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@@ -142,7 +152,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
private onResize(event): void {
|
||||
public onResize(event): void {
|
||||
this.dispatchWindowSize(event.target.innerWidth, event.target.innerHeight);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user