File

src/app/app.component.ts

Description

main app component

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
HostListeners

Constructor

constructor(cacheService: CacheService, browserCacheTtlService: BrowserCacheTtlService, userService: UserService, navigationHelperService: NavigationHelperService, permissionService: PermissionService, resourceService: ResourceService, deviceRegisterService: DeviceRegisterService, courseService: CoursesService, tenantService: TenantService, telemetryService: TelemetryService, router: Router, configService: ConfigService, orgDetailsService: OrgDetailsService, activatedRoute: ActivatedRoute, profileService: ProfileService, toasterService: ToasterService, utilService: UtilService, formService: FormService, _document: any, sessionExpiryInterceptor: SessionExpiryInterceptor, changeDetectorRef: ChangeDetectorRef, layoutService: LayoutService, generaliseLabelService: GeneraliseLabelService, renderer: Renderer2, zone: NgZone, connectionService: ConnectionService, genericResourceService: GenericResourceService)
Parameters :
Name Type Optional
cacheService CacheService No
browserCacheTtlService BrowserCacheTtlService No
userService UserService No
navigationHelperService NavigationHelperService No
permissionService PermissionService No
resourceService ResourceService No
deviceRegisterService DeviceRegisterService No
courseService CoursesService No
tenantService TenantService No
telemetryService TelemetryService No
router Router No
configService ConfigService No
orgDetailsService OrgDetailsService No
activatedRoute ActivatedRoute No
profileService ProfileService No
toasterService ToasterService No
utilService UtilService No
formService FormService No
_document any No
sessionExpiryInterceptor SessionExpiryInterceptor No
changeDetectorRef ChangeDetectorRef No
layoutService LayoutService No
generaliseLabelService GeneraliseLabelService No
renderer Renderer2 No
zone NgZone No
connectionService ConnectionService No
genericResourceService GenericResourceService No

HostListeners

window:beforeunload
Arguments : '$event'
window:beforeunload($event)

dispatch telemetry window unload event before browser closes

Parameters :
Name Optional
event No

Methods

Public beforeunloadHandler
beforeunloadHandler($event)
Decorators :
@HostListener('window:beforeunload', ['$event'])

dispatch telemetry window unload event before browser closes

Parameters :
Name Optional
$event No
Returns : void
changeFontSize
changeFontSize(value: string)
Parameters :
Name Type Optional
value string No
Returns : void
changeLanguageAttribute
changeLanguageAttribute()
Returns : void
Public checkForCustodianUser
checkForCustodianUser()
Returns : void
checkFormData
checkFormData()
Returns : Observable<any>
Public checkFrameworkSelected
checkFrameworkSelected()

checks if user has selected the framework and shows popup if not selected.

Returns : void
checkFullScreenView
checkFullScreenView()
Returns : void
checkLocationStatus
checkLocationStatus()
Returns : void
Public checkTncAndFrameWorkSelected
checkTncAndFrameWorkSelected()

checks if user has accepted the tnc and show tnc popup.

Returns : void
checkToShowPopups
checkToShowPopups()
Returns : void
Public closeConsentPopUp
closeConsentPopUp()
Returns : void
closeFrameworkPopup
closeFrameworkPopup()
Returns : void
closeIcon
closeIcon()
Returns : void
getLocalFontSize
getLocalFontSize()
Returns : void
getLocalTheme
getLocalTheme()
Returns : void
getOnboardingList
getOnboardingList()
Returns : void
Public getOrgDetails
getOrgDetails(storeOrgDetails)
Parameters :
Name Optional Default value
storeOrgDetails No true
Returns : any
getStepperInfo
getStepperInfo()
Returns : void
Private getTelemetryContext
getTelemetryContext()

returns telemetry context based on user loggedIn

Returns : ITelemetryContext
getUserFeedData
getUserFeedData()

It will fetch user feed data if user is custodian as well as logged in.

Returns : void
handleHeaderNFooter
handleHeaderNFooter()
Returns : void
handleLogin
handleLogin()
Returns : void
interpolateInstance
interpolateInstance(message)
Parameters :
Name Optional
message No
Returns : any
isBotdisplayforRoute
isBotdisplayforRoute()
Returns : boolean
isDisableFontSize
isDisableFontSize(value: any)
Parameters :
Name Type Optional
value any No
Returns : void
isLocationStatusRequired
isLocationStatusRequired()
Returns : boolean
isStepper
isStepper(event)
Parameters :
Name Optional
event No
Returns : void
joyThemePopup
joyThemePopup()
Returns : void
logCdnStatus
logCdnStatus()
Returns : void
logExData
logExData(type: string, data: object)
Parameters :
Name Type Optional
type string No
data object No
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
notifyNetworkChange
notifyNetworkChange()
Returns : void
Public onAcceptTnc
onAcceptTnc()

once tnc is accepted from tnc popup on submit this function is triggered

Returns : void
onActivate
onActivate(event)
Parameters :
Name Optional
event No
Returns : void
onCloseJoyThemePopup
onCloseJoyThemePopup()
Returns : void
onLocationSubmit
onLocationSubmit()

will be triggered once location popup gets closed

Returns : void
scrollTo
scrollTo(height)
Parameters :
Name Optional
height No
Returns : void
Public setDeviceId
setDeviceId()

fetch device id using fingerPrint2 library.

Returns : Observable<string>
Private setDynamicPageTitle
setDynamicPageTitle()
Returns : void
setFingerPrintTelemetry
setFingerPrintTelemetry()
Returns : void
setLocalFontSize
setLocalFontSize(value: any)
Parameters :
Name Type Optional
value any No
Returns : void
setLocalTheme
setLocalTheme(value: string)
Parameters :
Name Type Optional
value string No
Returns : void
Private setOrgDetails
setOrgDetails()

set org Details for Anonymous user.

Returns : Observable<any>
Private setPortalTitleLogo
setPortalTitleLogo()

set app title and favicon after getting tenant data

Returns : void
setSelectedThemeColour
setSelectedThemeColour(value)
Parameters :
Name Optional
value No
Returns : void
setTagManager
setTagManager()
Returns : void
setTheme
setTheme()
Returns : void
Private setUserDetails
setUserDetails()

set user details for loggedIn user.

Returns : Observable<any>
setUserOptions
setUserOptions()
Returns : void
skipToMainContent
skipToMainContent()
Returns : void
storeThemeColour
storeThemeColour(value)
Parameters :
Name Optional
value No
Returns : void
toggleLightDarkMode
toggleLightDarkMode()
Returns : void
Public updateFrameWork
updateFrameWork(event)

updates user framework. After update redirects to library

Parameters :
Name Optional
event No
Returns : void
viewInBrowser
viewInBrowser()
Returns : void

Properties

Private _routeData$
Default value : new BehaviorSubject(undefined)
baseUrl
Default value : (<HTMLInputElement>document.getElementById('offlineDesktopAppDownloadUrl')) ? (<HTMLInputElement>document.getElementById('offlineDesktopAppDownloadUrl')).value : ''
Public botObject
Type : any
Default value : {}
botServiceURL
Default value : (<HTMLInputElement>document.getElementById('botServiceURL')) ? (<HTMLInputElement>document.getElementById('botServiceURL')).value : ''
Public changeDetectorRef
Type : ChangeDetectorRef
Public channel
Type : string

Used to config telemetry service and device register api. Possible values

  1. org hashtag for Anonymous user
  2. user profile rootOrg hashtag for logged in
consentConfig
Type : literal type
darkModeToggle
Type : ElementRef
Decorators :
@ViewChild('darkModeToggle')
dataThemeAttribute
Type : string
decreaseFontSize
Type : ElementRef
Decorators :
@ViewChild('decreaseFontSize')
defaultFontSize
Type : number
Default value : 16
deviceId
Type : string
deviceProfile
Type : any
didV2
Type : boolean
feedCategory
Type : string
Default value : 'OrgMigrationAction'
Private fingerprintInfo
Type : any
flag
Default value : false
fontSize
Type : any
FORM_CONFIG_ENABLED
Default value : false
Public formService
Type : FormService
frameWorkPopUp
Decorators :
@ViewChild('frameWorkPopUp')
Public generaliseLabelService
Type : GeneraliseLabelService
Public genericResourceService
Type : GenericResourceService
globalConsent
Type : string
Default value : 'global-consent'
guestUserDetails
hideHeaderNFooter
Default value : true
increaseFontSize
Type : ElementRef
Decorators :
@ViewChild('increaseFontSize')
Public initApp
Default value : false

user to load app after fetching user/org details.

instance
Type : string
isBotEnabled
Default value : (<HTMLInputElement>document.getElementById('isBotConfigured')) ? (<HTMLInputElement>document.getElementById('isBotConfigured')).value : 'false'
isCustodianOrgUser
Type : any
isDesktopApp
Default value : false
isFullScreenView
isglobalConsent
Default value : true
isGuestUser
Default value : true
Public isIOS
Default value : false
isLocationConfirmed
Default value : true
isPopupEnabled
Default value : false
isStepperCompleted
Default value : false
isStepperEnabled
Default value : false
labels
Type : literal type
layoutConfiguration
Public layoutService
Type : LayoutService
loadPopUps
Default value : true
OnboardingFormConfig
Type : any
Private orgDetails
Type : any

stores organization details for Anonymous user.

queryParams
Type : any
resetFontSize
Type : ElementRef
Decorators :
@ViewChild('resetFontSize')
resourceDataSubscription
Type : any
Public resourceService
Type : ResourceService
Public Readonly routeData$
Default value : this._routeData$.asObservable() .pipe(skipWhile(data => data === undefined || data === null))
Public router
Type : Router
scrollHeight
Type : number
sessionExpired
Default value : false
Public sessionExpiryInterceptor
Type : SessionExpiryInterceptor
showAppPopUp
Default value : false

Variable to show popup to install the app

Public showFrameWorkPopUp
Default value : false

this variable is used to show the FrameWorkPopUp

Public showGlobalConsentPopUpSection
Default value : false

this variable is used to show the global consent pop up

showJoyThemePopUp
Default value : false
showNavAccessibility
Type : any
Default value : (<HTMLInputElement>document.getElementById('sunbirdNavAccessibility')) ? (<HTMLInputElement>document.getElementById('sunbirdNavAccessibility')).value : 'true'
Public showTermsAndCondPopUp
Default value : false

this variable is used to show the terms and conditions popup

showUserTypePopup
Default value : false
showUserVerificationPopup
Default value : false
showYearOfBirthPopup
Default value : false
telemetryContextData
Type : any
title
Default value : _.get(this.resourceService, 'frmelmnts.btn.botTitle') ? _.get(this.resourceService, 'frmelmnts.btn.botTitle') : 'Ask Tara'
Public unsubscribe$
Default value : new Subject<void>()
userFeed
Type : any
Private userProfile
Type : IUserProfile

user profile details.

Public userService
Type : UserService
usersProfile
Type : any
Public utilService
Type : UtilService
viewinBrowser
Default value : false
import { environment } from '@sunbird/environment';
import { ActivatedRoute, Router, NavigationEnd } from '@angular/router';
import { TelemetryService, ITelemetryContext } from '@sunbird/telemetry';
import {
  UtilService, ResourceService, ToasterService, IUserData, IUserProfile, ConnectionService,
  NavigationHelperService, ConfigService, BrowserCacheTtlService, LayoutService, GenericResourceService
} from '@sunbird/shared';
import { Component, HostListener, OnInit, ViewChild, Inject, OnDestroy, ChangeDetectorRef, ElementRef, Renderer2, NgZone } from '@angular/core';
import {
  UserService, PermissionService, CoursesService, TenantService, OrgDetailsService, DeviceRegisterService,
  SessionExpiryInterceptor, FormService, GeneraliseLabelService
} from '@sunbird/core';
import * as _ from 'lodash-es';
import { ProfileService } from '@sunbird/profile';
import { Observable, of, throwError, combineLatest, BehaviorSubject, forkJoin, zip, Subject } from 'rxjs';
import { first, filter, mergeMap, tap, skipWhile, startWith, takeUntil, debounceTime } from 'rxjs/operators';
import { CacheService } from '../app/modules/shared/services/cache-service/cache.service';
import { DOCUMENT } from '@angular/common';
import { image } from '../assets/images/tara-bot-icon';
import { SBTagModule } from 'sb-tag-manager';

/**
 * main app component
 */
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent implements OnInit, OnDestroy {
  @ViewChild('frameWorkPopUp') frameWorkPopUp;
  /**
   * user profile details.
   */
  private userProfile: IUserProfile;
  /**
   * user to load app after fetching user/org details.
   */
  public initApp = false;
  /**
   * stores organization details for Anonymous user.
   */
  private orgDetails: any;
  /**
   * this variable is used to show the FrameWorkPopUp
   */
  public showFrameWorkPopUp = false;

  /**
   * this variable is used to show the terms and conditions popup
   */
  public showTermsAndCondPopUp = false;

  /**
   * this variable is used to show the global consent pop up
   */
  public showGlobalConsentPopUpSection = false;
  /**
   * Used to config telemetry service and device register api. Possible values
   * 1. org hashtag for Anonymous user
   * 2. user profile rootOrg hashtag for logged in
   */
  public channel: string;
  private _routeData$ = new BehaviorSubject(undefined);
  public readonly routeData$ = this._routeData$.asObservable()
    .pipe(skipWhile(data => data === undefined || data === null));

  /**
   * constructor
   */
  /**
  * Variable to show popup to install the app
  */
  showAppPopUp = false;
  viewinBrowser = false;
  sessionExpired = false;
  isglobalConsent = true;
  instance: string;
  resourceDataSubscription: any;
  private fingerprintInfo: any;
  hideHeaderNFooter = true;
  queryParams: any;
  telemetryContextData: any;
  didV2: boolean;
  flag = false;
  deviceProfile: any;
  isCustodianOrgUser: any;
  usersProfile: any;
  isLocationConfirmed = true;
  userFeed: any;
  isFullScreenView;
  showUserVerificationPopup = false;
  feedCategory = 'OrgMigrationAction';
  globalConsent = 'global-consent';
  labels: {};
  showUserTypePopup = false;
  deviceId: string;
  dataThemeAttribute: string;
  scrollHeight: number;
  public botObject: any = {};
  isBotEnabled = (<HTMLInputElement>document.getElementById('isBotConfigured'))
    ? (<HTMLInputElement>document.getElementById('isBotConfigured')).value : 'false';
  showNavAccessibility: any = (<HTMLInputElement>document.getElementById('sunbirdNavAccessibility'))
    ? (<HTMLInputElement>document.getElementById('sunbirdNavAccessibility')).value : 'true';
  botServiceURL = (<HTMLInputElement>document.getElementById('botServiceURL'))
    ? (<HTMLInputElement>document.getElementById('botServiceURL')).value : '';
  baseUrl = (<HTMLInputElement>document.getElementById('offlineDesktopAppDownloadUrl'))
    ? (<HTMLInputElement>document.getElementById('offlineDesktopAppDownloadUrl')).value : '';
  layoutConfiguration;
  title = _.get(this.resourceService, 'frmelmnts.btn.botTitle') ? _.get(this.resourceService, 'frmelmnts.btn.botTitle') : 'Ask Tara';
  showJoyThemePopUp = false;
  public unsubscribe$ = new Subject<void>();
  consentConfig: { tncLink: string; tncText: any; };
  isDesktopApp = false;
  // Font Increase Decrease Variables
  fontSize: any;
  defaultFontSize = 16;
  isGuestUser = true;
  guestUserDetails;
  showYearOfBirthPopup = false;
  public isIOS = false;
  loadPopUps = true;
  FORM_CONFIG_ENABLED = false;
  isStepperCompleted = false;
  OnboardingFormConfig: any;
  isStepperEnabled = false;
  isPopupEnabled = false;
  @ViewChild('increaseFontSize') increaseFontSize: ElementRef;
  @ViewChild('decreaseFontSize') decreaseFontSize: ElementRef;
  @ViewChild('resetFontSize') resetFontSize: ElementRef;
  @ViewChild('darkModeToggle') darkModeToggle: ElementRef;

  constructor(private cacheService: CacheService, private browserCacheTtlService: BrowserCacheTtlService,
    public userService: UserService, private navigationHelperService: NavigationHelperService,
    private permissionService: PermissionService, public resourceService: ResourceService,
    private deviceRegisterService: DeviceRegisterService, private courseService: CoursesService, private tenantService: TenantService,
    private telemetryService: TelemetryService, public router: Router, private configService: ConfigService,
    private orgDetailsService: OrgDetailsService, private activatedRoute: ActivatedRoute,
    private profileService: ProfileService, private toasterService: ToasterService, public utilService: UtilService,
    public formService: FormService, @Inject(DOCUMENT) private _document: any, public sessionExpiryInterceptor: SessionExpiryInterceptor,
    public changeDetectorRef: ChangeDetectorRef, public layoutService: LayoutService,
    public generaliseLabelService: GeneraliseLabelService, private renderer: Renderer2, private zone: NgZone,
    private connectionService: ConnectionService, public genericResourceService: GenericResourceService) {
    this.instance = (<HTMLInputElement>document.getElementById('instance'))
      ? (<HTMLInputElement>document.getElementById('instance')).value : 'sunbird';
    const layoutType = localStorage.getItem('layoutType') || 'base';
    if (layoutType === 'base' || layoutType === 'joy') {
      this.layoutConfiguration = this.configService.appConfig.layoutConfiguration;
      document.documentElement.setAttribute('layout', 'joy');
    } else {
      document.documentElement.setAttribute('layout', 'base');
    }
  }
  
  /**
   * dispatch telemetry window unload event before browser closes
   * @param  event
   */
  @HostListener('window:beforeunload', ['$event'])
  public beforeunloadHandler($event) {
    this.telemetryService.syncEvents(false);
    this.ngOnDestroy();
  }

  handleLogin() {
    window.location.replace('/sessionExpired');
    this.cacheService.removeAll();
  }

  private setDynamicPageTitle() {
    let child = this.activatedRoute.firstChild;
    while (child.firstChild) {
      child = child.firstChild;
    }
    const pageTitle = _.get(child, 'snapshot.data.pageTitle') || _.get(child, 'snapshot.data.telemetry.pageid') || _.get(this.userService, 'rootOrgName');
    if (pageTitle) {
      document.title = pageTitle;
    }
  }

  handleHeaderNFooter() {
    this.router.events
      .pipe(
        filter(event => event instanceof NavigationEnd),
        tap((event: NavigationEnd) => this._routeData$.next(event))
      ).subscribe(data => {
        this.setDynamicPageTitle();
        this.hideHeaderNFooter = _.get(this.activatedRoute, 'snapshot.firstChild.firstChild.data.hideHeaderNFooter') ||
          _.get(this.activatedRoute, 'snapshot.firstChild.firstChild.firstChild.data.hideHeaderNFooter');
      });
  }

  ngAfterViewInit() {
    // themeing code
    const trans = () => {
      document.documentElement.classList.add('transition');
      window.setTimeout(() => {
        document.documentElement.classList.remove('transition');
      }, 1000);
    };
    const selector = document.querySelectorAll('input[name=selector]');
    for (let i = 0; i < selector.length; i++) {
      selector[i].addEventListener('change', function () {
        if (this.checked) {
          trans();
          document.documentElement.setAttribute('data-theme', this.value);
        }
      });
    }
    this.setTheme();
    // themeing code
    this.getLocalFontSize();
    // dark theme
    this.getLocalTheme();

    this.setTagManager();
    this.userService.userData$.subscribe((user: IUserData) => {
      if (user.err) {
        return throwError(user.err);
      }
      // If User is logged in and dob is missing, initiate consent workflow
      // Skip for managed users - SB-30762
      // Skip for SSO users     - SB-30762
      if (!_.get(user, 'userProfile.dob') &&
        (this.userService.loggedIn && !_.get(user, 'userProfile.managedBy')) &&
        (_.isArray(_.get(user, 'userProfile.externalIds')) && _.get(user, 'userProfile.externalIds').length === 0)
      ) {
        this.router.navigate(['/signup'], { queryParams: { loginMode: 'gmail' } });
      }
    });
  }

  setTagManager() {
    window['TagManager'] = SBTagModule.instance;
    window['TagManager'].init();
    if (this.userService.loggedIn) {
      if (localStorage.getItem('tagManager_' + this.userService.userid)) {
        window['TagManager'].SBTagService.restoreTags(localStorage.getItem('tagManager_' + this.userService.userid));
      }
    } else {
      if (localStorage.getItem('tagManager_' + 'guest')) {
        window['TagManager'].SBTagService.restoreTags(localStorage.getItem('tagManager_' + 'guest'));
      }
    }
  }

  setTheme() {
    const themeColour = localStorage.getItem('layoutColour') || 'default';
    if (this.darkModeToggle && this.darkModeToggle.nativeElement) {
      this.renderer.setAttribute(this.darkModeToggle.nativeElement, 'aria-label', `Selected theme ${themeColour}`);
    }
    this.setSelectedThemeColour(themeColour);
    document.documentElement.setAttribute('data-theme', themeColour);
    this.layoutService.setLayoutConfig(this.layoutConfiguration);
  }
  checkToShowPopups() {
    const formReadInputParams = {
      formType: 'user',
      formAction: 'onboarding',
      contentType: 'exclusion',
      component: 'portal'
    };
    this.formService.getFormConfig(formReadInputParams).subscribe(
      (formResponsedata) => {
        const routesArray = formResponsedata;
        const url = location.href
        routesArray.forEach(element => {
          if (_.includes(url, element)) {
            this.loadPopUps = false;
          }
        });
      }
    );
  }
  checkFormData(): Observable<any> {
    const formReadInputParams = {
      formType: 'newUserOnboarding',
      formAction: 'onboarding',
      contentType: 'global',
      component: 'portal'
    };
    return of(this.formService.getFormConfig(formReadInputParams).subscribe(
      (formResponsedata) => {
        console.log('userOnboarding Form is called and we are trying to get the update', formResponsedata);
        if (_.get(formResponsedata, 'shownewUserOnboarding') === 'false') {
          this.FORM_CONFIG_ENABLED = true;
        }
      }
    ));
  }
  /**
   * @description - get the stepper flag from localstorage to check weather stepper process completes or not
   */
  getStepperInfo() {
    const isStepperCompleted = localStorage.getItem('isStepperCompleted');
    this.isStepperCompleted = isStepperCompleted ? true : false;
  }
  /**
   * @description -  to fetch all form config data list for onboarding stepper flow
   */
  getOnboardingList() {
    // const formReadInputParams = {
    //   formType: 'useronboardingsteps',
    //   formAction: 'onboarding',
    //   contentType: 'global',
    //   component: 'portal'
    // };
    // this.formService.getFormConfig(formReadInputParams).subscribe(
    //   (formResponsedata) => {
    //     if (formResponsedata) {
    //       this.OnboardingFormConfig = formResponsedata;
    //       this.isStepperEnabled = true;
    //     }
    //     else { this.isPopupEnabled = true; }
    //   }, error => { this.isPopupEnabled = true; });
    this.isPopupEnabled = true;
  }
  ngOnInit() {
    this.getOnboardingList();
    this.checkToShowPopups();
    this.getStepperInfo();
    this.isIOS = this.utilService.isIos;
    this.isDesktopApp = this.utilService.isDesktopApp;
    if (this.isDesktopApp) {
      this._document.body.classList.add('desktop-app');
      this.notifyNetworkChange();
    }
    this.checkFullScreenView();
    this.layoutService.switchableLayout().pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
      if (layoutConfig != null) {
        this.layoutConfiguration = layoutConfig.layout;
      }
    });
    this.activatedRoute.queryParams.pipe(filter(param => !_.isEmpty(param))).subscribe(params => {
      const utmParams = ['utm_campaign', 'utm_medium', 'utm_source', 'utm_term', 'utm_content', 'channel'];
      if (_.some(_.intersection(utmParams, _.keys(params)))) {
        this.telemetryService.makeUTMSession(params);
      }
    });
    this.didV2 = (localStorage && localStorage.getItem('fpDetails_v2')) ? true : false;
    const queryParams$ = this.activatedRoute.queryParams.pipe(
      filter(queryParams => queryParams && queryParams.clientId === 'android' && queryParams.context),
      tap(queryParams => {
        this.telemetryContextData = JSON.parse(decodeURIComponent(queryParams.context));
      }),
      startWith(null)
    );
    this.handleHeaderNFooter();
    this.resourceService.initialize();
    this.genericResourceService.initialize();
    combineLatest(queryParams$, this.setDeviceId(), this.checkFormData())
      .pipe(
        mergeMap(data => {
          this.navigationHelperService.initialize();
          this.userService.initialize(this.userService.loggedIn);
          this.getOrgDetails();
          if (this.userService.loggedIn && !this.FORM_CONFIG_ENABLED) {
            this.isGuestUser = false;
            this.permissionService.initialize();
            this.courseService.initialize();
            this.userService.startSession();
            this.checkForCustodianUser();
            return this.setUserDetails();
          } else if (this.userService.loggedIn && this.FORM_CONFIG_ENABLED) {
            this.setUserOptions();
          } else {
            this.isGuestUser = true;
            this.userService.getGuestUser().subscribe((response) => {
              this.guestUserDetails = response;
            }, error => {
              console.error('Error while fetching guest user', error);
            });

            return this.setOrgDetails();
          }
        }))
      .subscribe(data => {
        this.tenantService.getTenantInfo(this.userService.slug);
        this.tenantService.initialize();
        this.setPortalTitleLogo();
        this.telemetryService.initialize(this.getTelemetryContext());
        this.logCdnStatus();
        this.setFingerPrintTelemetry();
        this.initApp = true;
        localStorage.setItem('joyThemePopup', 'true');
        this.joyThemePopup();
        this.changeDetectorRef.detectChanges();
      }, error => {
        this.initApp = true;
        this.changeDetectorRef.detectChanges();
      });

    this.changeLanguageAttribute();
    if (this.userService.loggedIn) {
      this.botObject['userId'] = this.userService.userid;
    } else {
      this.botObject['userId'] = this.deviceId;
    }
    this.botObject['appId'] = this.userService.appId;
    this.botObject['chatbotUrl'] = this.baseUrl + this.botServiceURL;

    this.botObject['imageUrl'] = image.imageUrl;
    this.botObject['title'] = this.botObject['header'] = this.title;
    this.generaliseLabelService.getGeneraliseResourceBundle();
    // keyboard accessibility enter key click event
    document.onkeydown = function (e) {
      const element = document.getElementById('overlay-button') as HTMLElement;
      if (e.keyCode === 13 && document.activeElement !== element) { // The Enter/Return key
        (document.activeElement as HTMLElement).click();
      }
    };
  }
  setUserOptions() {
    const userStoredData = JSON.parse(localStorage.getItem('guestUserDetails'));
    if (userStoredData) {
      const userFrameworkData = _.get(userStoredData, 'framework');
      if (userFrameworkData && !(_.get(this.userService.userProfile, 'framework'))) {
        const req = {
          framework: userFrameworkData
        };
        this.profileService.updateProfile(req).subscribe(res => {
          console.log('user data updated---->', req);
        }, err => {
          this.toasterService.warning(this.resourceService.messages.emsg.m0012);
          this.closeFrameworkPopup();
          this.checkLocationStatus();
        });
      }
    }
  }
  onCloseJoyThemePopup() {
    this.showJoyThemePopUp = false;
    this.checkTncAndFrameWorkSelected();
  }

  isBotdisplayforRoute() {
    const url = this.router.url;
    return !!(_.includes(url, 'signup') || _.includes(url, 'recover') || _.includes(url, 'sign-in'));
  }

  checkFullScreenView() {
    this.navigationHelperService.contentFullScreenEvent.pipe(takeUntil(this.unsubscribe$)).subscribe(isFullScreen => {
      this.isFullScreenView = isFullScreen;
    });
  }

  storeThemeColour(value) {
    localStorage.setItem('layoutColour', value);
  }

  setSelectedThemeColour(value) {
    const element = (<HTMLInputElement>document.getElementById(value));
    if (element) {
      element.checked = true;
    }
  }

  isLocationStatusRequired() {
    const url = location.href;
    return !!(_.includes(url, 'signup') || _.includes(url, 'recover') || _.includes(url, 'sign-in'));
  }

  joyThemePopup() {
    const joyThemePopup = localStorage.getItem('joyThemePopup');
    // if (joyThemePopup === 'true') {
    //   this.checkTncAndFrameWorkSelected();
    // } else {
    //   this.showJoyThemePopUp = true;
    // }
    this.checkTncAndFrameWorkSelected();
  }

  checkLocationStatus() {
    // should not show location popup for sign up and recover route
    if (this.isLocationStatusRequired()) {
      return;
    }
    this.usersProfile = this.userService.userProfile;
    const deviceRegister = this.deviceRegisterService.getDeviceProfile();
    const custodianOrgDetails = this.orgDetailsService.getCustodianOrgDetails();
    forkJoin([deviceRegister, custodianOrgDetails]).subscribe((res) => {
      const deviceProfile = res[0];
      this.deviceProfile = deviceProfile;
      if (_.get(this.userService, 'userProfile.rootOrg.rootOrgId') === _.get(res[1], 'result.response.value')) {
        // non state user
        this.isCustodianOrgUser = true;
        this.deviceProfile = deviceProfile;
        if (this.userService.loggedIn) {
          if (!deviceProfile.userDeclaredLocation ||
            !(this.usersProfile && this.usersProfile.userLocations && this.usersProfile.userLocations.length >= 1)) {
            this.isLocationConfirmed = false;
          }
        } else {
          if (!deviceProfile.userDeclaredLocation) {
            this.isLocationConfirmed = false;
          }
        }
      } else {
        // state user
        this.isCustodianOrgUser = false;
        if (this.userService.loggedIn) {
          if (!deviceProfile.userDeclaredLocation) {
            this.isLocationConfirmed = false;
          }
        } else {
          if (!deviceProfile.userDeclaredLocation) {
            this.isLocationConfirmed = false;
          }
        }
      }
      // TODO: code can be removed in 3.1 release from user-onboarding component as it is handled here.
      zip(this.tenantService.tenantData$, this.getOrgDetails(false)).subscribe((res) => {
        if (_.get(res[0], 'tenantData')) {
          const orgDetailsFromSlug = this.cacheService.get('orgDetailsFromSlug');
          // if (_.get(orgDetailsFromSlug, 'slug') !== this.tenantService.slugForIgot) {

          let userType;
          if (this.isDesktopApp && this.isGuestUser) {
            userType = _.get(this.guestUserDetails, 'role') ? this.guestUserDetails.role : undefined;
            this.showUserTypePopup = userType ? false : true;
          } else if (this.isGuestUser) {
            userType = localStorage.getItem('userType');
            if (!this.showUserTypePopup && this.isLocationConfirmed) {
              this.checkFrameworkSelected();
            }
            if (!this.isLocationConfirmed) {
              this.zone.run(() => {
                this.showUserTypePopup = true
              })
            }
          } else {
            userType = localStorage.getItem('userType');
          }
          this.showUserTypePopup = _.get(this.userService, 'loggedIn') ? (!_.get(this.userService, 'userProfile.profileUserType.type') || !userType) : this.showUserTypePopup;
          // }
        }
      });
    }, (err) => {
      this.isLocationConfirmed = false;
      this.showUserTypePopup = true;
    });
    this.getUserFeedData();
  }

  setFingerPrintTelemetry() {
    const printFingerprintDetails = (<HTMLInputElement>document.getElementById('logFingerprintDetails'))
      ? (<HTMLInputElement>document.getElementById('logFingerprintDetails')).value : 'false';
    if (printFingerprintDetails !== 'true') {
      return;
    }

    if (this.fingerprintInfo && !this.didV2) {
      this.logExData('fingerprint_info', this.fingerprintInfo);
    }

    if (localStorage && localStorage.getItem('fpDetails_v1')) {
      const fpDetails = JSON.parse(localStorage.getItem('fpDetails_v1'));
      const fingerprintInfoV1 = {
        deviceId: fpDetails.result,
        components: fpDetails.components,
        version: 'v1'
      };
      this.logExData('fingerprint_info', fingerprintInfoV1);
      if (localStorage.getItem('fpDetails_v2')) {
        localStorage.removeItem('fpDetails_v1');
      }
    }
  }

  logExData(type: string, data: object) {
    const event = {
      context: {
        env: 'portal'
      },
      edata: {
        type: type,
        data: JSON.stringify(data)
      }
    };
    this.telemetryService.exData(event);
  }

  logCdnStatus() {
    const isCdnWorking = (<HTMLInputElement>document.getElementById('cdnWorking'))
      ? (<HTMLInputElement>document.getElementById('cdnWorking')).value : 'no';
    if (isCdnWorking !== 'no') {
      return;
    }
    const event = {
      context: {
        env: 'app'
      },
      edata: {
        type: 'cdn_failed',
        level: 'ERROR',
        message: 'cdn failed, loading files from portal',
        pageid: this.router.url.split('?')[0]
      }
    };
    this.telemetryService.log(event);
  }
  /**
   * checks if user has accepted the tnc and show tnc popup.
   */
  public checkTncAndFrameWorkSelected() {
    if (_.has(this.userService.userProfile, 'promptTnC') && _.has(this.userService.userProfile, 'tncLatestVersion') &&
      _.has(this.userService.userProfile, 'tncLatestVersion') && this.userService.userProfile.promptTnC === true) {
      this.showTermsAndCondPopUp = true;
    } else {
      if (this.userService.loggedIn) {
        this.orgDetailsService.getCustodianOrgDetails().subscribe((custodianOrg) => {
          if (_.get(this.userService, 'userProfile.rootOrg.rootOrgId') !== _.get(custodianOrg, 'result.response.value')) {
            // Check for non custodian user and show global consent pop up
            this.consentConfig = { tncLink: _.get(this.resourceService, 'frmelmnts.lbl.privacyPolicy'), tncText: _.get(this.resourceService, 'frmelmnts.lbl.nonCustodianTC') };
            this.showGlobalConsentPopUpSection = true;
          } else {
            this.isGuestUser ? this.checkLocationStatus() : this.checkFrameworkSelected();
          }
        });
      } else {
        this.isGuestUser ? this.checkLocationStatus() : this.checkFrameworkSelected();
      }
    }
  }
  public getOrgDetails(storeOrgDetails = true) {
    const slug = this.userService.slug;
    return this.orgDetailsService.getOrgDetails(slug).pipe(
      tap(data => {
        if (slug !== '' && storeOrgDetails) {
          this.cacheService.set('orgDetailsFromSlug', data, {
            maxAge: 86400
          });
        }
      })
    );
  }
  public checkForCustodianUser() {
    this.orgDetailsService.getCustodianOrgDetails().subscribe((custodianOrg) => {
      if (_.get(this.userService, 'userProfile.rootOrg.rootOrgId') === _.get(custodianOrg, 'result.response.value')) {
        this.userService.setIsCustodianUser(true);
      } else {
        this.userService.setIsCustodianUser(false);
      }
    });
  }
  /**
   * checks if user has selected the framework and shows popup if not selected.
   */
  public checkFrameworkSelected() {
    // should not show framework popup for sign up and recover route
    if (this.isLocationStatusRequired()) {
      return;
    }
    this.zone.run(() => {
      const frameWorkPopUp: boolean = this.cacheService.get('showFrameWorkPopUp');
      if (frameWorkPopUp) {
        this.showFrameWorkPopUp = false;
        !this.isGuestUser ? this.checkLocationStatus() : null;
      } else {
        if (this.userService.loggedIn && _.isEmpty(_.get(this.userProfile, 'framework'))) {
          this.showFrameWorkPopUp = true;
        } else if (this.isGuestUser) {
          if (!this.guestUserDetails) {
            this.userService.getGuestUser().subscribe((response) => {
              this.guestUserDetails = response;
              this.showFrameWorkPopUp = false;
            }, error => {
              this.showFrameWorkPopUp = true;
            });
          } else {
            this.checkLocationStatus();
          }
        } else {
          this.checkLocationStatus();
        }
      }
    });
  }

  /**
   * once tnc is accepted from tnc popup on submit this function is triggered
   */
  public onAcceptTnc() {
    this.showTermsAndCondPopUp = false;
    if (this.userService.loggedIn) {
      this.orgDetailsService.getCustodianOrgDetails().subscribe((custodianOrg) => {
        if (_.get(this.userService, 'userProfile.rootOrg.rootOrgId') !== _.get(custodianOrg, 'result.response.value')) {
          // Check for non custodian user and show global consent pop up
          this.consentConfig = { tncLink: _.get(this.resourceService, 'frmelmnts.lbl.privacyPolicy'), tncText: _.get(this.resourceService, 'frmelmnts.lbl.nonCustodianTC') };
          this.showGlobalConsentPopUpSection = true;
        } else {
          this.checkFrameworkSelected();
        }
      });
    } else {
      this.checkFrameworkSelected();
    }
  }

  public closeConsentPopUp() {
    this.showGlobalConsentPopUpSection = false;
    this.isglobalConsent = false;
    this.globalConsent = '';
    this.checkFrameworkSelected();
  }

  /**
   * fetch device id using fingerPrint2 library.
   */
  public setDeviceId(): Observable<string> {
    return new Observable(observer => this.telemetryService.getDeviceId((deviceId, components, version) => {
      if (this.utilService.isDesktopApp) {
        deviceId = (<HTMLInputElement>document.getElementById('deviceId')).value;
      }
      this.fingerprintInfo = { deviceId, components, version };
      (<HTMLInputElement>document.getElementById('deviceId')).value = deviceId;
      this.deviceId = deviceId;
      this.botObject['did'] = deviceId;
      this.deviceRegisterService.setDeviceId();
      observer.next(deviceId);
      observer.complete();
    }));
  }
  /**
   * set user details for loggedIn user.
   */
  private setUserDetails(): Observable<any> {
    return this.userService.userData$.pipe(first(),
      mergeMap((user: IUserData) => {
        if (user.err) {
          return throwError(user.err);
        }
        this.userProfile = user.userProfile;
        this.channel = this.userService.hashTagId;
        this.botObject['channel'] = this.channel;
        return of(user.userProfile);
      }));
  }
  /**
   * set org Details for Anonymous user.
   */
  private setOrgDetails(): Observable<any> {
    return this.orgDetailsService.getOrgDetails(this.userService.slug).pipe(
      tap(data => {
        localStorage.setItem('orgHashTagId', _.get(data, 'hashTagId'));
        this.orgDetails = data;
        this.channel = this.orgDetails.hashTagId;
        this.botObject['channel'] = this.channel;
        if (this.userService.slug !== '') {
          this.cacheService.set('orgDetailsFromSlug', data, {
            maxAge: 86400
          });
        }
      })
    );
  }
  /**
   * returns telemetry context based on user loggedIn
   */
  private getTelemetryContext(): ITelemetryContext {
    const buildNumber = (<HTMLInputElement>document.getElementById('buildNumber'));
    const version = buildNumber && buildNumber.value ? buildNumber.value.slice(0, buildNumber.value.lastIndexOf('.')) : '1.0';
    if (this.userService.loggedIn) {
      return {
        userOrgDetails: {
          userId: this.userProfile.userId,
          rootOrgId: this.userProfile.rootOrgId,
          rootOrg: this.userProfile.rootOrg,
          organisationIds: this.userProfile.hashTagIds
        },
        config: {
          pdata: {
            id: this.userService.appId,
            ver: version,
            pid: this.configService.appConfig.TELEMETRY.PID
          },
          endpoint: this.configService.urlConFig.URLS.TELEMETRY.SYNC,
          apislug: this.configService.urlConFig.URLS.CONTENT_PREFIX,
          host: '',
          uid: this.userProfile.userId,
          sid: this.userService.sessionId,
          channel: _.get(this.userProfile, 'rootOrg.hashTagId'),
          env: 'home',
          enableValidation: environment.enableTelemetryValidation,
          timeDiff: this.userService.getServerTimeDiff
        }
      };
    } else {
      const anonymousTelemetryContextData = {
        userOrgDetails: {
          userId: 'anonymous',
          rootOrgId: this.orgDetails.id,
          organisationIds: [this.orgDetails.hashTagId]
        },
        config: {
          pdata: {
            id: this.userService.appId,
            ver: version,
            pid: this.configService.appConfig.TELEMETRY.PID
          },
          batchsize: 10,
          endpoint: this.configService.urlConFig.URLS.TELEMETRY.SYNC,
          apislug: this.configService.urlConFig.URLS.CONTENT_PREFIX,
          host: '',
          sid: this.userService.anonymousSid,
          channel: this.orgDetails.hashTagId,
          env: 'home',
          enableValidation: environment.enableTelemetryValidation,
          timeDiff: this.orgDetailsService.getServerTimeDiff
        }
      };
      if (this.telemetryContextData) {
        anonymousTelemetryContextData['config']['did'] = _.get(this.telemetryContextData, 'did');
        anonymousTelemetryContextData['config']['pdata'] = _.get(this.telemetryContextData, 'pdata');
        anonymousTelemetryContextData['config']['channel'] = _.get(this.telemetryContextData, 'channel');
        anonymousTelemetryContextData['config']['sid'] = _.get(this.telemetryContextData, 'sid');
      }
      return anonymousTelemetryContextData;
    }
  }
  /**
   * set app title and favicon after getting tenant data
   */
  private setPortalTitleLogo(): void {
    this.tenantService.tenantData$.subscribe(data => {
      if (!data.err) {
        // document.title = _.get(this.userService, 'rootOrgName') || _.get(data, 'tenantData.titleName');
        document.querySelector('link[rel*=\'icon\']').setAttribute('href', data.tenantData.favicon);
      }
    });
  }

  closeFrameworkPopup() {
    this.frameWorkPopUp && this.frameWorkPopUp.deny();
    this.showFrameWorkPopUp = false;
  }
  /**
   * updates user framework. After update redirects to library
   */
  public updateFrameWork(event) {
    if (this.isGuestUser && !this.guestUserDetails) {
      const user: any = { name: 'guest', formatedName: 'Guest', framework: event };
      const userType = localStorage.getItem('userType');
      if (userType) {
        user.role = userType;
      }
      this.userService.createGuestUser(user).subscribe(data => {
        this.toasterService.success(_.get(this.resourceService, 'messages.smsg.m0058'));
      }, error => {
        this.toasterService.error(_.get(this.resourceService, 'messages.emsg.m0005'));
      });
      this.closeFrameworkPopup();
      this.checkLocationStatus();
    } else {
      const req = {
        framework: event
      };
      this.profileService.updateProfile(req).subscribe(res => {
        this.closeFrameworkPopup();
        this.userService.setUserFramework(event);
        this.checkLocationStatus();
        this.utilService.toggleAppPopup();
        this.showAppPopUp = this.utilService.showAppPopUp;
      }, err => {
        this.toasterService.warning(this.resourceService.messages.emsg.m0012);
        this.closeFrameworkPopup();
        this.checkLocationStatus();
      });
    }
  }
  viewInBrowser() {
    // no action required
  }
  closeIcon() {
    this.showFrameWorkPopUp = false;
    this.cacheService.set('showFrameWorkPopUp', 'installApp');
  }
  changeLanguageAttribute() {
    this.resourceDataSubscription = this.resourceService.languageSelected$.subscribe(item => {
      if (item.value && item.dir) {
        this._document.documentElement.lang = item.value;
        this._document.documentElement.dir = item.dir;
      } else {
        this._document.documentElement.lang = 'en';
        this._document.documentElement.dir = 'ltr';
      }
    });
  }

  ngOnDestroy() {
    if (this.resourceDataSubscription) {
      this.resourceDataSubscription.unsubscribe();
    }
    if (window['TagManager']) {
      if (this.userService.loggedIn) {
        localStorage.setItem('tagManager_' + this.userService.userid, JSON.stringify(window['TagManager'].SBTagService));
      } else {
        localStorage.setItem('tagManager_' + 'guest', JSON.stringify(window['TagManager'].SBTagService));
      }
    }
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
  }
  interpolateInstance(message) {
    return message.replace('{instance}', _.upperCase(this.instance));
  }
  /** will be triggered once location popup gets closed */
  onLocationSubmit() {
    if (this.isGuestUser) {
      this.showUserTypePopup = false;
      this.checkFrameworkSelected();
    }
    this.showYearOfBirthPopup = true;
    if (this.userFeed) {
      this.showUserVerificationPopup = true;
    }
  }

  /** It will fetch user feed data if user is custodian as well as logged in. */
  getUserFeedData() {
    this.orgDetailsService.getCustodianOrgDetails().subscribe(custodianOrg => {
      if (this.userService.loggedIn && !this.userService.userProfile.managedBy &&
        (_.get(this.userService, 'userProfile.rootOrg.rootOrgId') === _.get(custodianOrg, 'result.response.value'))) {
        this.userService.getFeedData().subscribe(
          (data) => {
            this.userFeed = _.get(data, 'result.response.userFeed[0]');
            if (this.userFeed && _.get(this.userFeed, 'category').toLowerCase() === this.feedCategory.toLowerCase()) {
              const formReadInputParams = {
                formType: 'user',
                formAction: 'onboarding',
                contentType: 'externalIdVerification'
              };
              let orgId;
              if ((_.get(this.userFeed, 'data.prospectChannelsIds')) && (_.get(this.userFeed, 'data.prospectChannelsIds').length) === 1) {
                orgId = _.get(this.userFeed, 'data.prospectChannelsIds[0].id');
              }
              this.formService.getFormConfig(formReadInputParams, orgId).subscribe(
                (formResponsedata) => {
                  this.labels = _.get(formResponsedata[0], ('range[0]'));
                }
              );
              // if location popup isn't opened on the very first time.
              if (this.isLocationConfirmed) {
                this.showUserVerificationPopup = true;
              }
            }
          },
          (error) => {
          });
      }
    });
  }

  // Change Font Size (Increase & Decrease)
  getLocalFontSize() {
    const localFontSize = localStorage.getItem('fontSize');
    if (localFontSize) {
      document.documentElement.style.setProperty('font-size', localFontSize + 'px');
      this.fontSize = localFontSize;
      this.isDisableFontSize(localFontSize);
    }
  }
  changeFontSize(value: string) {

    const elFontSize = window.getComputedStyle(document.documentElement).getPropertyValue('font-size');

    const localFontSize = localStorage.getItem('fontSize');
    const currentFontSize = localFontSize ? localFontSize : elFontSize;
    this.fontSize = parseInt(currentFontSize);

    if (value === 'increase') {
      this.renderer.setAttribute(this.increaseFontSize.nativeElement, 'aria-pressed', 'true');
      this.renderer.removeAttribute(this.decreaseFontSize.nativeElement, 'aria-pressed');
      this.renderer.removeAttribute(this.resetFontSize.nativeElement, 'aria-pressed');
      this.fontSize = this.fontSize + 2;
      if (this.fontSize <= 20) {
        this.setLocalFontSize(this.fontSize);
      }
    } else if (value === 'decrease') {
      this.renderer.setAttribute(this.decreaseFontSize.nativeElement, 'aria-pressed', 'true');
      this.renderer.removeAttribute(this.increaseFontSize.nativeElement, 'aria-pressed');
      this.renderer.removeAttribute(this.resetFontSize.nativeElement, 'aria-pressed');
      this.fontSize = this.fontSize - 2;
      if (this.fontSize >= 12) {
        this.setLocalFontSize(this.fontSize);
      }
    } else {
      this.renderer.setAttribute(this.resetFontSize.nativeElement, 'aria-pressed', 'true');
      this.renderer.removeAttribute(this.increaseFontSize.nativeElement, 'aria-pressed');
      this.renderer.removeAttribute(this.decreaseFontSize.nativeElement, 'aria-pressed');
      this.setLocalFontSize(this.defaultFontSize);
    }

  }

  setLocalFontSize(value: any) {
    document.documentElement.style.setProperty('font-size', value + 'px');
    localStorage.setItem('fontSize', value);
    this.isDisableFontSize(value);
  }

  isDisableFontSize(value: any) {
    value = parseInt(value);
    if (value === 20) {
      this.renderer.setAttribute(this.increaseFontSize.nativeElement, 'disabled', 'true');
      this.renderer.removeAttribute(this.decreaseFontSize.nativeElement, 'disabled');
      this.renderer.removeAttribute(this.resetFontSize.nativeElement, 'disabled');
    } else if (value === 12) {
      this.renderer.setAttribute(this.decreaseFontSize.nativeElement, 'disabled', 'true');
      this.renderer.removeAttribute(this.increaseFontSize.nativeElement, 'disabled');
      this.renderer.removeAttribute(this.resetFontSize.nativeElement, 'disabled');
    } else if (value === 16) {
      this.renderer.setAttribute(this.resetFontSize.nativeElement, 'disabled', 'true');
      this.renderer.removeAttribute(this.increaseFontSize.nativeElement, 'disabled');
      this.renderer.removeAttribute(this.decreaseFontSize.nativeElement, 'disabled');
    } else {
      this.renderer.removeAttribute(this.increaseFontSize.nativeElement, 'disabled');
      this.renderer.removeAttribute(this.decreaseFontSize.nativeElement, 'disabled');
      this.renderer.removeAttribute(this.resetFontSize.nativeElement, 'disabled');
    }
  }
  skipToMainContent() {
    const getTheme = document.documentElement.attributes['layout'].value;
    if (getTheme == 'joy') {
      const headerElement = document.getElementsByClassName('sbt-fluid-header-bg');
      if (headerElement.length > 0) {
        const headerHeight = headerElement[headerElement.length - 1].clientHeight;
        if (typeof window.orientation !== 'undefined') {
          this.scrollHeight = headerElement[0].clientHeight + 150;
        } else {
          this.scrollHeight = headerHeight * 2;
        }
        this.scrollTo(this.scrollHeight);
      }
    } else {
      const header = document.getElementsByTagName('app-header');
      const headerElement = header[0].children[0].children[0].clientHeight;
      if (document.getElementsByTagName('app-search-filter').length > 0) {
        const searchFilter = document.getElementsByTagName('app-search-filter')[0]
          .children[0].clientHeight;
        this.scrollTo(searchFilter + headerElement + 48);
      } else if (
        document.getElementsByTagName('app-global-search-filter').length > 0
      ) {
        const searchFilter = document.getElementsByTagName(
          'app-global-search-filter'
        )[0].children[0].clientHeight;
        this.scrollTo(searchFilter + headerElement + 48);
      } else {
        this.scrollTo(headerElement + 48);
      }
    }
  }
  scrollTo(height) {
    window.scroll({
      top: height,
      behavior: 'smooth',
    });
  }
  getLocalTheme() {
    const localDataThemeAttribute = localStorage.getItem('data-mode');
    if (localDataThemeAttribute) {
      this.setLocalTheme(localDataThemeAttribute);
    }
  }
  toggleLightDarkMode() {
    this.dataThemeAttribute = document.documentElement.getAttribute('data-mode');
    this.dataThemeAttribute = this.dataThemeAttribute === 'light' ? 'darkmode' : 'light';
    this.renderer.setAttribute(this.darkModeToggle.nativeElement, 'aria-label', `Selected theme ${this.dataThemeAttribute}`);
    this.setLocalTheme(this.dataThemeAttribute);
    localStorage.setItem('data-mode', this.dataThemeAttribute);
  }
  setLocalTheme(value: string) {
    document.documentElement.setAttribute('data-mode', value);
  }
  notifyNetworkChange() {
    this.connectionService.monitor().pipe(debounceTime(5000)).subscribe((status: boolean) => {
      const message = status ? _.get(this.resourceService, 'messages.stmsg.desktop.onlineStatus') : _.get(this.resourceService, 'messages.emsg.desktop.offlineStatus');
      this.toasterService.info(message);
      if (!status && this.router.url.indexOf('mydownloads') <= 0) {
        this.router.navigate(['mydownloads'], { queryParams: { selectedTab: 'mydownloads' } });
      }
    });
  }
  onActivate(event) {
    this.layoutService.scrollTop();
  }
  /**
   * @param  {boolean} event
   * @description  - set the flag in localstorage when stepper process completes
   */
  isStepper(event) {
    this.isStepperCompleted = event;
    localStorage.setItem('isStepperCompleted', JSON.stringify(this.isStepperCompleted));
  }
}
<div [ngClass]="!layoutConfiguration ? 'footer-fix' : 'new-footer'">
  <app-desktop-app-update *appDesktopOnly></app-desktop-app-update>
  <div [ngClass]="{'loggedInUser': userService.loggedIn, 'guestUser': !userService.loggedIn}">
    <div *ngIf="!isDesktopApp"
      class="sbt-container d-flex flex-ai-center sb-bg-color-black py-8 flex-w-wrap sbt-sticky-topbar sb-fontresizecontainer"
      [ngClass]="{'hide': isFullScreenView}">
      <div class="ui container">
        <div class="brand-header-tail">
          <div class="dk-country-flag">
          </div>
          <div class="d-flex flex-ai-center head-tail-right-side">
            <div class="dk-top-head-ul">
              <nav title="accessibility_links" class="d-flex flex-ai-center">
                <ul role="navigation" aria-label="accessibility links" *ngIf="showNavAccessibility === 'true'">
                  <li class="mb-0" *ngIf="!hideHeaderNFooter">
                    <a href="javascript:void(0);" title="{{resourceService?.frmelmnts?.lbl?.accessibilitytskip}}"
                      tabindex="0" (click)="skipToMainContent()"
                      class="cursor-pointer">{{resourceService?.frmelmnts?.lbl?.accessibilitytskip}}</a>
                  </li>
                  <li aria-hidden="true" *ngIf="!hideHeaderNFooter" class="mx-4 mb-0">|</li>
                  <li class="screen-reader-link"><a href="/screenreaderaccess.html" tabindex="0"
                      title="{{resourceService?.frmelmnts?.lbl?.accessibility}}">{{resourceService?.frmelmnts?.lbl?.accessibility}}</a>
                  </li>
                  <li aria-hidden="true" class="mx-4">|</li>
                  <li class="mb-0">
                    <ng-container *ngIf="userService.loggedIn">
                      <a title="{{resourceService?.frmelmnts?.lbl?.accessibilitytext}}" tabindex="0"
                        href="/sitemap.html?session=true"
                        class="cursor-pointer">{{resourceService?.frmelmnts?.lbl?.accessibilitytext}}</a>
                    </ng-container>
                    <ng-container *ngIf="!userService.loggedIn">
                      <a title="{{resourceService?.frmelmnts?.lbl?.accessibilitytext}}" tabindex="0"
                        href="/sitemap.html"
                        class="cursor-pointer">{{resourceService?.frmelmnts?.lbl?.accessibilitytext}}</a>
                    </ng-container>
                  </li>
                  <li aria-hidden="true" class="mx-4">|</li>
                </ul>
                <ul>
                  <li class="fontResize-container d-flex flex-ai-center pull-right" role="navigation"
                    aria-label="Font Size">
                    <button type="button" [attr.aria-pressed]="false" tabindex="0"
                      attr.aria-label="{{resourceService?.frmelmnts?.lbl?.accessibilityfont}}"
                      class="fontResizeBtn fontResizeBtn_A-"
                      title="{{resourceService?.frmelmnts?.lbl?.accessibilityfont}}"
                      (click)="changeFontSize('decrease');" #decreaseFontSize>A-</button>
                    <button [attr.aria-pressed]="false" type="button" tabindex="0"
                      attr.aria-label="{{resourceService?.frmelmnts?.lbl?.accessibilityfntdflt}}"
                      class="fontResizeBtn fontResizeBtn_A"
                      title="{{resourceService?.frmelmnts?.lbl?.accessibilityfntdflt}}"
                      (click)="changeFontSize('reset');" #resetFontSize>A</button>
                    <button [attr.aria-pressed]="false" type="button" tabindex="0"
                      attr.aria-label="{{resourceService?.frmelmnts?.lbl?.accessibilitytextsize}}"
                      class="fontResizeBtn fontResizeBtn_A+"
                      title="{{resourceService?.frmelmnts?.lbl?.accessibilitytextsize}}"
                      (click)="changeFontSize('increase');" #increaseFontSize>A+</button>
                  </li>
                  <li aria-hidden="true" class="mx-4">|</li>
                  <li>
                    <button id="dark-mode-toggle" class="dark-mode-toggle" tabindex="0"
                      title="{{resourceService?.frmelmnts?.lbl?.accessibilitytheme}}" (click)="toggleLightDarkMode()"
                      (keydown.enter)="toggleLightDarkMode();" #darkModeToggle>
                      <svg width="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 496">
                        <path fill="var(--white)"
                          d="M8,256C8,393,119,504,256,504S504,393,504,256,393,8,256,8,8,119,8,256ZM256,440V72a184,184,0,0,1,0,368Z"
                          transform="translate(-8 -8)" />
                      </svg>
                    </button>
                  </li>
                </ul>
              </nav>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- onboarding stepper -->
    <app-onboarding-popup *ngIf="isStepperEnabled && !isStepperCompleted" [guestUserDetails]="guestUserDetails"
      [isGuestUser]="isGuestUser" [OnboardingFormConfig]="OnboardingFormConfig" [deviceProfile]="deviceProfile"
      (isStepperCompleted)="isStepper($event)">
    </app-onboarding-popup>

    <!-- popup disabled  -->
    <div *ngIf="loadPopUps && isPopupEnabled">
      <!-- 2nd popup BMGS  -->
      <app-modal-wrapper #frameWorkPopUp *ngIf="showFrameWorkPopUp"
        [config]="{disableClose: true, panelClass: ['overflow-visible', 'material-modal'], autoFocus: false}">
        <ng-template sbModalContent let-data>
          <app-popup [dialogProps]="data" [buttonLabel]="resourceService?.frmelmnts?.btn?.submit"
            [isGuestUser]="isGuestUser" (submit)="updateFrameWork($event)"></app-popup>
        </ng-template>
      </app-modal-wrapper>
      <app-validate-teacher-identifier-popup *ngIf="showUserVerificationPopup && labels" [labels]="labels"
        [userFeedData]="userFeed"> </app-validate-teacher-identifier-popup>
      <!-- 1 & 3rd popup User Type & location -->
      <app-user-onboarding (close)="onLocationSubmit()"
        *ngIf="isGuestUser ? showUserTypePopup :(showUserTypePopup || !isLocationConfirmed)"
        [isCustodianOrgUser]="isCustodianOrgUser" [deviceProfile]="deviceProfile"></app-user-onboarding>
    </div>
    <app-tnc-popup (close)="onAcceptTnc()" #termsAndCondPopUp *ngIf="showTermsAndCondPopUp">
    </app-tnc-popup>
    <div *ngIf="showGlobalConsentPopUpSection">
      <app-global-consent-pii [type]="globalConsent" [isglobalConsent]="isglobalConsent" (close)="closeConsentPopUp()"
        [consentConfig]="consentConfig"></app-global-consent-pii>
    </div>
    <app-modal-wrapper [config]="{disableClose: true, size: 'small', panelClass: 'material-modal'}"
      *ngIf="isCustodianOrgUser && usersProfile && !usersProfile?.managedBy && !usersProfile?.dob && (usersProfile?.userLocations?.length>0 || showYearOfBirthPopup)">
      <ng-template sbModalContent let-data>
        <app-year-of-birth [dialogProps]="data"></app-year-of-birth>
      </ng-template>
    </app-modal-wrapper>

    <app-header *ngIf="!hideHeaderNFooter" [layoutConfiguration]="layoutConfiguration" [routerEvents]="routeData$"
      [ngClass]="{'header-block': isFullScreenView}"></app-header>
    <app-install-app (viewInBrowser)="viewInBrowser($event)" *ngIf="showAppPopUp && userService.loggedIn">
    </app-install-app>
    <!--<app-breadcrumbs *ngIf="userService.loggedIn"></app-breadcrumbs>-->

    <main>
      <router-outlet *ngIf="isIOS || (initApp && !showFrameWorkPopUp && !showTermsAndCondPopUp)"
        (activate)="onActivate($event)"></router-outlet>
    </main>
  </div>
</div>
<div *ngIf="isBotEnabled === 'true'" [ngClass]="{'hideBot': isBotdisplayforRoute(), 'hideBot': isFullScreenView}">
  <lib-chat-window [inputValues]="botObject"></lib-chat-window>
</div>
<app-footer [layoutConfiguration]="layoutConfiguration" *ngIf="!hideHeaderNFooter"></app-footer>

<app-modal-wrapper *ngIf="sessionExpiryInterceptor.sessionExpired"
  [config]="{disableClose: true, size: 'small', panelClass: 'material-modal'}">
  <ng-template sbModalContent let-data>
    <div class="sb-mat__modal sb-mat__modal--small">

      <div mat-dialog-title>
        <div class="title">{{resourceService?.frmelmnts?.lbl?.sesnexrd}}</div>
      </div>
      <mat-dialog-content>
        <div class="sb-mat__modal__content d-flex flex-ai-center text-center flex-jc-center p-24">
          <p>
            {{resourceService?.frmelmnts?.lbl?.plslgn |
            interpolate:'{instance}': instance }}
          </p>
        </div>
      </mat-dialog-content>
      <mat-dialog-actions class="sb-mat__modal__actions">
        <button type="button" (click)="handleLogin()" tabindex="0" class="sb-btn sb-btn-normal sb-btn-primary">
          {{ resourceService?.frmelmnts?.btn?.login }}
        </button>
      </mat-dialog-actions>

    </div>
  </ng-template>
</app-modal-wrapper>

<ng-container *ngIf="layoutConfiguration">
  <svg width="332px" height="358px" viewBox="0 0 332 358" class="sbt-theme-bg-img computer only" version="1.1"
    xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="Illustration-&amp;-colour-palette-" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
      <g transform="translate(106.000000, -390.000000)" class="st0">
        <g transform="translate(-106.000000, 390.000000)">
          <path
            d="M118.918045,0.564535521 C154.339379,5.57509002 108.755811,52.1143659 108.755811,52.1143659 C108.755811,52.1143659 185.339755,-2.23575328 230.549812,15.5417727 C275.757394,33.3168228 187.673287,114.572323 187.673287,114.572323 C187.673287,114.572323 287.217863,85.2828923 327.147644,127.129789 C367.077425,168.976685 101.348714,205.62258 101.348714,205.62258 C101.348714,205.62258 148.828363,288.592959 141.567958,311.1744 C141.567958,311.1744 127.106556,361.690251 56.4047156,265.925614 C56.4047156,265.925614 57.4676522,364.523693 19.8774293,357.393721 C-17.71032,350.261277 10.076548,243.873629 10.076548,243.873629 L2.56785415,83.5788451 L2.66395147,83.4746638 C5.78661141,80.0950646 84.2002875,-4.34581014 118.918045,0.564535521 Z M185.066826,37.6429976 L78.104636,142.528307 L77.8957176,143.177194 C72.4179048,160.682299 83.0348258,169.5 109.307095,169.5 C135.085318,169.5 176.196991,161.104755 232.667135,144.317206 L232.667135,144.317206 L236.143681,143.278911 L235.856319,142.321089 L234.115849,142.84208 C176.838582,159.948371 135.227065,168.5 109.307095,168.5 L109.307095,168.5 L108.533441,168.497459 C83.4175642,168.331435 73.6662583,160.0296 78.8533181,143.465566 L78.8533181,143.465566 L78.979,143.071 L185.766967,38.3570024 L185.066826,37.6429976 Z"
            id="Combined-Shape"></path>
        </g>
      </g>
    </g>
  </svg>
</ng-container>
<ng-container *ngIf="layoutConfiguration">
  <div class="sbt-theme-right-flower computer only"></div>
</ng-container>

<app-telemetry-error-modal></app-telemetry-error-modal>

./app.component.scss



.header-block {
  display: none;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""