File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-core-lib/src/lib/services/tc-general-landing-page.service.ts

Index

Properties

Constructor

constructor(generalLandingPageConfigService: TcGeneralLandingPageConfigService)
Parameters :
Name Type Optional
generalLandingPageConfigService TcGeneralLandingPageConfigService No

Properties

Public getLandingPage
Default value : () => {...}
Public getLandingPageForRole
Default value : () => {...}
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { LandingPageConfig } from '../models/tc-general-landing-page-config';
import { TcGeneralLandingPageConfigService } from './tc-general-landing-page-config.service';

@Injectable({
  providedIn: 'root'
})

export class TcGeneralLandingPageService {

    constructor(
        private generalLandingPageConfigService: TcGeneralLandingPageConfigService
    ) {
    }

    public getLandingPage = (key: string, uiAppId: string): Observable<LandingPageConfig> => {
        const landingPage = this.generalLandingPageConfigService.getGeneralLandingPageConfig(uiAppId, true, true).pipe(
            map(landingPages => {
                const page = landingPages.landingPage.filter(element => element.key === key )[0];
                return page;
            })
        )
        return landingPage;
    }

    public getLandingPageForRole = (roleId: string, uiAppId: string): Observable<LandingPageConfig> => {
        return this.generalLandingPageConfigService.getGeneralLandingPageConfig(uiAppId, true, true).pipe(
            map(landingPages => {
                const candidatePages = landingPages.landingPage.filter(element => element.roles.indexOf(roleId) != -1);
                switch (candidatePages.length) {
                    case 0:
                        return undefined;
                    case 1:
                        return candidatePages[0];
                    default:
                        return candidatePages[0];
                }
            })
        );
    }
}

result-matching ""

    No results matching ""