File
Implements
Methods
setMainHeader
|
setMainHeader(domain)
|
|
|
domain$
|
Type : Observable<string>
|
|
isInIFrame
|
Default value : false
|
|
route$
|
Type : Observable<ParamMap>
|
|
import { Component, OnInit, Inject } from '@angular/core';
import { filter, map, tap } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { SessionStore, StorageService } from '../../providers';
import { ActivatedRoute, ParamMap } from '@angular/router';
declare var window: any;
const CYPRESS_KEY = 'cypress';
@Component({
selector: 'app-main-title',
templateUrl: './app-main-title.component.html',
styleUrls: ['./app-main-title.component.css']
})
// TODO "Return to BillPay" button needs to behave differently based on how the app is consumed.
// If stand-alone the link should be "log out" which will logout the user and cause a redirect to the login
// If embedded inside an iframe then the
export class AppMainTitleComponent implements OnInit {
domain$: Observable<string>;
route$: Observable<ParamMap>;
isInIFrame = false;
mainHeader: string;
constructor(private sessionStore: SessionStore, private storageService: StorageService, private route: ActivatedRoute) { }
ngOnInit(): void {
this.route$ = this.route.queryParamMap.pipe(
tap((queryParams) => {
const toBeSaved = queryParams.get(CYPRESS_KEY) ? true : false;
if (toBeSaved) {
this.storageService.set(CYPRESS_KEY, toBeSaved);
}
const cypressActive = this.storageService.get(CYPRESS_KEY);
console.log('cypressActive', cypressActive);
this.isInIFrame = cypressActive ? false : window.top !== window.self;
})
);
this.domain$ = this.sessionStore.session$.pipe(
filter(session => !!session && !!session.domain),
map(session => session.domain.toLowerCase()),
map(domain => {
this.setMainHeader(domain);
return domain;
})
);
}
setMainHeader(domain) {
switch (domain) {
case 'seattlebank':
this.mainHeader = 'External Transfers';
break;
case 'swfinancial':
this.mainHeader = 'External Transfers';
break;
default:
this.mainHeader = 'Transfer Money';
}
}
}
<ng-container *ngIf="route$ | async"> </ng-container>
<div class="main-header-ctn" *ngIf="!isInIFrame">
<div class="main-header">
<h1>{{ mainHeader }}</h1>
</div>
<ng-container *ngIf="domain$ | async as domain">
<div [hidden]="domain != 'allied'" class="header-return">
<h3>
<a id="logoutButton" [routerLink]="['/logout']">Log Out</a>
</h3>
</div>
</ng-container>
</div>
h1, h3 {
font-family: Arial, Helvetica, sans-serif; /*Fi Font*/
color: #fff;
margin: 0px;
display: inline-block;
margin: 0px 20px;
font-weight: normal;
line-height: 50px;
letter-spacing: 0px;
}
a {
text-decoration:none;
color: #fff;
}
a:hover {
text-decoration:underline;
color: #fff;
}
.main-header-ctn {
width: 100%;
height: 50px;
background-color: #dc8e49; /*Fi Secondary Color*/
display: table;
min-width: 310px;
}
.main-header {
display: table-cell;
text-align: left;
}
.main-header h1 {
font-size: 14px;
}
.header-return {
display: table-cell;
text-align: right;
}
.header-return h3 {
font-size: 12px;
}
Legend
Html element with directive