feat: add app shell (angular-material)
Add app shell built using angular-material and flex-layout. Refractor code due to configuration changes. Fixes #52
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { merge } from 'rxjs';
|
||||
import { filter, map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
import { environment } from '../environments/environment';
|
||||
import { Logger, I18nService } from './core';
|
||||
|
||||
const log = new Logger('MifosX');
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-web-app',
|
||||
templateUrl: './web-app.component.html',
|
||||
styleUrls: ['./web-app.component.scss']
|
||||
})
|
||||
export class WebAppComponent implements OnInit {
|
||||
|
||||
constructor(private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private titleService: Title,
|
||||
private translateService: TranslateService,
|
||||
private i18nService: I18nService) { }
|
||||
|
||||
ngOnInit() {
|
||||
// Setup logger
|
||||
if (environment.production) {
|
||||
Logger.enableProductionMode();
|
||||
}
|
||||
|
||||
log.debug('init');
|
||||
|
||||
// Setup translations
|
||||
this.i18nService.init(environment.defaultLanguage, environment.supportedLanguages);
|
||||
|
||||
const onNavigationEnd = this.router.events.pipe(filter(event => event instanceof NavigationEnd));
|
||||
|
||||
// Change page title on navigation or language change, based on route data
|
||||
merge(this.translateService.onLangChange, onNavigationEnd)
|
||||
.pipe(
|
||||
map(() => {
|
||||
let route = this.activatedRoute;
|
||||
while (route.firstChild) {
|
||||
route = route.firstChild;
|
||||
}
|
||||
return route;
|
||||
}),
|
||||
filter(route => route.outlet === 'primary'),
|
||||
mergeMap(route => route.data)
|
||||
)
|
||||
.subscribe(event => {
|
||||
const title = event['title'];
|
||||
if (title) {
|
||||
this.titleService.setTitle(this.translateService.instant(title));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user