File

src/app/home/user-home/user-home.page.ts

Implements

OnInit OnDestroy OnTabViewWillEnter

Metadata

Index

Properties
Methods

Constructor

constructor(frameworkService: FrameworkService, frameworkUtilService: FrameworkUtilService, profileService: ProfileService, preferences: SharedPreferences, contentService: ContentService, commonUtilService: CommonUtilService, router: Router, appGlobalService: AppGlobalService, appVersion: AppVersion, contentAggregatorHandler: ContentAggregatorHandler, navService: NavigationService, headerService: AppHeaderService, events: Events, qrScanner: SunbirdQRScanner, modalCtrl: ModalController, telemetryGeneratorService: TelemetryGeneratorService, formAndFrameworkUtilService: FormAndFrameworkUtilService, frameworkSelectionDelegateService: FrameworkSelectionDelegateService, translate: TranslateService, splaschreenDeeplinkActionHandlerDelegate: SplaschreenDeeplinkActionHandlerDelegate, segmentationTagService: SegmentationTagService, popoverCtrl: PopoverController, onboardingConfigurationService: OnboardingConfigurationService)
Parameters :
Name Type Optional
frameworkService FrameworkService No
frameworkUtilService FrameworkUtilService No
profileService ProfileService No
preferences SharedPreferences No
contentService ContentService No
commonUtilService CommonUtilService No
router Router No
appGlobalService AppGlobalService No
appVersion AppVersion No
contentAggregatorHandler ContentAggregatorHandler No
navService NavigationService No
headerService AppHeaderService No
events Events No
qrScanner SunbirdQRScanner No
modalCtrl ModalController No
telemetryGeneratorService TelemetryGeneratorService No
formAndFrameworkUtilService FormAndFrameworkUtilService No
frameworkSelectionDelegateService FrameworkSelectionDelegateService No
translate TranslateService No
splaschreenDeeplinkActionHandlerDelegate SplaschreenDeeplinkActionHandlerDelegate No
segmentationTagService SegmentationTagService No
popoverCtrl PopoverController No
onboardingConfigurationService OnboardingConfigurationService No

Methods

checkHomeData
checkHomeData(displayItems)
Parameters :
Name Optional
displayItems No
Returns : void
doRefresh
doRefresh(refresher?)
Parameters :
Name Optional
refresher Yes
Returns : void
editProfileDetails
editProfileDetails()
Returns : void
Async exploreOtherContents
exploreOtherContents()
Returns : any
Private Async fetchDisplayElements
fetchDisplayElements(refresher?)
Parameters :
Name Optional
refresher Yes
Returns : any
getFieldDisplayValues
getFieldDisplayValues(field: Array, categoryCode: string, lowerCase?: boolean)
Parameters :
Name Type Optional
field Array<any> No
categoryCode string No
lowerCase boolean Yes
Returns : any[]
Async getFrameworkData
getFrameworkData(frameworkId, requiredCategories, currentCategoryCode)
Parameters :
Name Optional
frameworkId No
requiredCategories No
currentCategoryCode No
Private Async getFrameworkDetails
getFrameworkDetails(frameworkId?: string)
Parameters :
Name Type Optional
frameworkId string Yes
Returns : any
Async getOtherMLCategories
getOtherMLCategories()
Returns : any
Private Async getUserProfileDetails
getUserProfileDetails()
Returns : any
handleHeaderEvents
handleHeaderEvents($event)
Parameters :
Name Optional
$event No
Returns : void
Async handleOtherCategories
handleOtherCategories(event)
Parameters :
Name Optional
event No
Returns : any
handlePillSelect
handlePillSelect(event, section, isFromPopover?: boolean)
Parameters :
Name Type Optional
event No
section No
isFromPopover boolean Yes
Returns : void
ionViewDidEnter
ionViewDidEnter()
Returns : void
ionViewDidLeave
ionViewDidLeave()
Returns : void
Async ionViewWillEnter
ionViewWillEnter()
Returns : any
ionViewWillLeave
ionViewWillLeave()
Returns : void
mapContentFacteTheme
mapContentFacteTheme(displayItems)
Parameters :
Name Optional
displayItems No
Returns : any
mapPrimaryCategoryTheme
mapPrimaryCategoryTheme(displayItems)
Parameters :
Name Optional
displayItems No
Returns : any
mapSubjectTheme
mapSubjectTheme(displayItems)
Parameters :
Name Optional
displayItems No
Returns : any
modifyContentData
modifyContentData(displayItems)
Parameters :
Name Optional
displayItems No
Returns : any
modifyCourseData
modifyCourseData(displayItems)
Parameters :
Name Optional
displayItems No
Returns : any
navigateToDetailPage
navigateToDetailPage(event, sectionName)
Parameters :
Name Optional
event No
sectionName No
Returns : void
navigateToSpecificLocation
navigateToSpecificLocation(event, section)
Parameters :
Name Optional
event No
section No
Returns : void
navigateToViewMoreContentsPage
navigateToViewMoreContentsPage(section, subsection)
Parameters :
Name Optional
section No
subsection No
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
Async onFrameworkSelectionSubmit
onFrameworkSelectionSubmit(formInput: any, formOutput: any, router: Router, commonUtilService: CommonUtilService, telemetryGeneratorService: TelemetryGeneratorService, corRelation: Array)
Parameters :
Name Type Optional
formInput any No
formOutput any No
router Router No
commonUtilService CommonUtilService No
telemetryGeneratorService TelemetryGeneratorService No
corRelation Array<CorrelationData> No
Returns : any
Async onViewMorePillList
onViewMorePillList(event, section)
Parameters :
Name Optional
event No
section No
Returns : any
redirectToActivedownloads
redirectToActivedownloads()
Returns : void
redirectToNotifications
redirectToNotifications()
Returns : void
Async requestMoreContent
requestMoreContent()
Returns : any
setBannerConfig
setBannerConfig()
Returns : void
showorHideBanners
showorHideBanners()
Returns : void
tabViewWillEnter
tabViewWillEnter()
Returns : void
Async viewPreferenceInfo
viewPreferenceInfo()
Returns : any

Properties

aggregatorResponse
Type : []
Default value : []
appLabel
Type : string
audienceFilter
Type : []
Default value : []
bannerSegment
Type : any
boardList
Type : []
Default value : []
ButtonPosition
Default value : ButtonPosition
Public commonUtilService
Type : CommonUtilService
concatProfileFilter
Type : Array<string>
Default value : []
contentView
Type : ContentView
Decorators :
@ViewChild('contentView', {static: false})
courseCardType
Default value : CourseCardGridTypes
displayBanner
Type : boolean
Optional displaySections
Type : any[]
Private frameworkCategoriesMap
Type : literal type
Default value : {}
gradeLevelList
Type : []
Default value : []
guestUser
Type : boolean
headerObservable
Type : Subscription
homeDataAvailable
Default value : false
layoutConfiguration
Type : object
Default value : { layout: 'v3' }
LibraryCardTypes
Default value : LibraryCardTypes
mediumList
Type : []
Default value : []
newThemeTimeout
Type : any
otherCategories
Type : []
Default value : []
pillShape
Default value : PillShape
PillsMultiRow
Default value : PillsMultiRow
pillsViewType
Default value : PillsViewType
preferenceList
Type : []
Default value : []
primaryBanner
Type : []
Default value : []
profile
Type : Profile
refresh
Type : boolean
refresher
Type : IonRefresher
Decorators :
@ViewChild('refresher', {static: false})
secondaryBanner
Type : []
Default value : []
selectedFilter
Type : string
selectMode
Default value : SelectMode
ShowMoreViewType
Default value : ShowMoreViewType
subjectList
Type : []
Default value : []
import { CorReleationDataType, ImpressionType, PageId } from './../../../services/telemetry-constants';
import { TelemetryGeneratorService } from './../../../services/telemetry-generator.service';
import { Component, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
import {
  AppGlobalService,
  AppHeaderService,
  CommonUtilService,
  ContentAggregatorHandler,
  Environment,
  FormAndFrameworkUtilService,
  ImpressionSubtype,
  InteractSubtype,
  InteractType,
  OnboardingConfigurationService,
  SunbirdQRScanner
} from '@app/services';
import {
  ButtonPosition,
  CourseCardGridTypes,
  LibraryCardTypes,
  PillShape,
  PillsMultiRow,
  PillsViewType,
  SelectMode,
  ShowMoreViewType
} from '@project-sunbird/common-consumption';
import { NavigationExtras, Router } from '@angular/router';
import {
  CachedItemRequestSourceFrom,
  ContentAggregatorRequest,
  ContentSearchCriteria,
  ContentService,
  CorrelationData,
  Framework,
  FrameworkCategoryCode,
  FrameworkCategoryCodesGroup,
  FrameworkDetailsRequest,
  FrameworkService,
  FrameworkUtilService,
  GetFrameworkCategoryTermsRequest,
  Profile,
  ProfileService,
  ProfileType,
  SearchType,
  SharedPreferences
} from '@project-sunbird/sunbird-sdk';
import {
  AudienceFilter,
  ColorMapping,
  EventTopics,
  PrimaryCaregoryMapping,
  PrimaryCategory,
  ProfileConstants,
  RouterLinks,
  SubjectMapping,
  ViewMore
} from '../../app.constant';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { OnTabViewWillEnter } from '@app/app/tabs/on-tab-view-will-enter';
import { AggregatorPageType } from '@app/services/content/content-aggregator-namespaces';
import { NavigationService } from '@app/services/navigation-handler.service';
import { IonContent as ContentView, IonRefresher, ModalController, PopoverController } from '@ionic/angular';
import { Events } from '@app/util/events';
import { Subscription } from 'rxjs';
import { SbSubjectListPopupComponent } from '@app/app/components/popups/sb-subject-list-popup/sb-subject-list-popup.component';
import { CategoryTerm, FrameworkCategory } from '@project-sunbird/client-services/models/channel';
import { FrameworkSelectionDelegateService } from './../../profile/framework-selection/framework-selection.page';
import { TranslateService } from '@ngx-translate/core';
import { SplaschreenDeeplinkActionHandlerDelegate } from '@app/services/sunbird-splashscreen/splaschreen-deeplink-action-handler-delegate';
import { SegmentationTagService } from '@app/services/segmentation-tag/segmentation-tag.service';
import { FormConstants } from '@app/app/form.constants';
import { SbPopoverComponent } from '../../components/popups';
import { SbPreferencePopupComponent } from './../../components/popups/sb-preferences-popup/sb-preferences-popup.component';

@Component({
  selector: 'app-user-home',
  templateUrl: './user-home.page.html',
  styleUrls: ['./user-home.page.scss'],
})
export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter {
  private frameworkCategoriesMap: { [code: string]: FrameworkCategory | undefined } = {};

  @ViewChild('refresher', { static: false }) refresher: IonRefresher;

  aggregatorResponse = [];
  courseCardType = CourseCardGridTypes;
  selectedFilter: string;
  concatProfileFilter: Array<string> = [];
  profile: Profile;
  guestUser: boolean;
  appLabel: string;

  displaySections?: any[];
  headerObservable: Subscription;

  pillsViewType = PillsViewType;
  selectMode = SelectMode;
  pillShape = PillShape;
  @ViewChild('contentView', { static: false }) contentView: ContentView;

  LibraryCardTypes = LibraryCardTypes;
  ButtonPosition = ButtonPosition;
  ShowMoreViewType = ShowMoreViewType;
  PillsMultiRow = PillsMultiRow;
  audienceFilter = [];
  newThemeTimeout: any;
  refresh: boolean;
  homeDataAvailable = false;
  displayBanner: boolean;
  bannerSegment: any;
  preferenceList = [];
  boardList = [];
  mediumList = [];
  gradeLevelList = [];
  otherCategories = [];
  subjectList = [];
  primaryBanner = [];
  secondaryBanner = [];
  layoutConfiguration = {
    layout: 'v3'
  };

  constructor(
    @Inject('FRAMEWORK_SERVICE') private frameworkService: FrameworkService,
    @Inject('FRAMEWORK_UTIL_SERVICE') private frameworkUtilService: FrameworkUtilService,
    @Inject('PROFILE_SERVICE') private profileService: ProfileService,
    @Inject('SHARED_PREFERENCES') private preferences: SharedPreferences,
    @Inject('CONTENT_SERVICE') private contentService: ContentService,
    public commonUtilService: CommonUtilService,
    private router: Router,
    private appGlobalService: AppGlobalService,
    private appVersion: AppVersion,
    private contentAggregatorHandler: ContentAggregatorHandler,
    private navService: NavigationService,
    private headerService: AppHeaderService,
    private events: Events,
    private qrScanner: SunbirdQRScanner,
    private modalCtrl: ModalController,
    private telemetryGeneratorService: TelemetryGeneratorService,
    private formAndFrameworkUtilService: FormAndFrameworkUtilService,
    private frameworkSelectionDelegateService: FrameworkSelectionDelegateService,
    private translate: TranslateService,
    private splaschreenDeeplinkActionHandlerDelegate: SplaschreenDeeplinkActionHandlerDelegate,
    private segmentationTagService: SegmentationTagService,
    private popoverCtrl: PopoverController,
    private onboardingConfigurationService: OnboardingConfigurationService
  ) {
  }

  ngOnInit() {
    this.events.subscribe(AppGlobalService.PROFILE_OBJ_CHANGED, () => {
      this.getUserProfileDetails();
    });

    this.events.subscribe('refresh:loggedInProfile', () => {
      this.getUserProfileDetails();
    });

    this.events.subscribe(EventTopics.TAB_CHANGE, (data: string) => {
      if (data === '') {
        this.qrScanner.startScanner(this.appGlobalService.getPageIdForTelemetry());
      }
    });
  }

  async ionViewWillEnter() {
    this.events.subscribe('update_header', () => {
      this.headerService.showHeaderWithHomeButton(['download', 'notification']);
    });
    this.headerObservable = this.headerService.headerEventEmitted$.subscribe(eventName => {
      this.handleHeaderEvents(eventName);
    });
    this.headerService.showHeaderWithHomeButton(['download', 'notification']);
    this.getUserProfileDetails();
  }

  doRefresh(refresher?) {
    this.refresh = true;
    this.fetchDisplayElements(refresher);
    this.events.publish(EventTopics.NOTIFICATION_REFRESH);
  }

  private async getUserProfileDetails() {
    this.profile = await this.profileService.getActiveSessionProfile(
      { requiredFields: ProfileConstants.REQUIRED_FIELDS }
    ).toPromise();
    await this.getFrameworkDetails();
    await this.fetchDisplayElements();
    this.guestUser = !this.appGlobalService.isUserLoggedIn();
    if (this.guestUser) {
      this.audienceFilter = AudienceFilter.GUEST_TEACHER;
    } else if (this.guestUser && this.profile.profileType === ProfileType.STUDENT) {
      this.audienceFilter = AudienceFilter.GUEST_STUDENT;
    } else {
      this.audienceFilter = AudienceFilter.LOGGED_IN_USER;
    }
    this.appVersion.getAppName()
      .then((appName: any) => {
        this.appLabel = appName;
      });
    // impression telemetry
    this.telemetryGeneratorService.generateImpressionTelemetry(
      ImpressionType.PAGE_LOADED,
      ImpressionSubtype.LOCATION,
      PageId.HOME,
      Environment.HOME
    );
  }


  editProfileDetails() {
    if (!this.guestUser) {
      this.router.navigate([`/${RouterLinks.PROFILE}/${RouterLinks.CATEGORIES_EDIT}`], { state: { shouldUpdatePreference: true } });
    } else {
      const navigationExtras: NavigationExtras = {
        state: {
          profile: this.profile,
          isCurrentUser: true
        }
      };
      this.router.navigate([RouterLinks.GUEST_EDIT], navigationExtras);
    }
  }

  private async getFrameworkDetails(frameworkId?: string) {
    const guestUser = await this.commonUtilService.getGuestUserConfig();
    let id = "";
    if(this.profile && this.profile.syllabus && this.profile.syllabus[0]) {
      id = this.profile.syllabus[0]
    } else if(guestUser && guestUser.syllabus && guestUser.syllabus[0]) {
      id = guestUser.syllabus[0];
    }
    const frameworkDetailsRequest: FrameworkDetailsRequest = {
      frameworkId: id,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };
    await this.frameworkService.getFrameworkDetails(frameworkDetailsRequest).toPromise()
      .then(async (framework: Framework) => {
        this.frameworkCategoriesMap = framework.categories.reduce((acc, category) => {
          acc[category.code] = category;
          return acc;
        }, {});
        this.preferenceList = [];
        setTimeout(() => {
          this.boardList = this.getFieldDisplayValues(this.profile.board.length > 0 ? this.profile.board : guestUser.board, 'board');
          this.mediumList = this.getFieldDisplayValues(this.profile.medium.length > 0 ? this.profile.medium : guestUser.medium, 'medium');
          this.gradeLevelList = this.getFieldDisplayValues(this.profile.grade.length > 0 ?  this.profile.grade : guestUser.grade, 'gradeLevel');
          this.subjectList = this.getFieldDisplayValues(this.profile.subject.length > 0 ? this.profile.subject : guestUser.subject, 'subject');

          this.preferenceList.push(this.boardList);
          this.preferenceList.push(this.mediumList);
          this.preferenceList.push(this.gradeLevelList);
        }, 0);
      });
  }

  getFieldDisplayValues(field: Array<any>, categoryCode: string, lowerCase?: boolean): any[] {
    const displayValues = [];

    if (!this.frameworkCategoriesMap[categoryCode]) {
      return displayValues;
    }

    this.frameworkCategoriesMap[categoryCode].terms.forEach(element => {
      if (field.includes(element.code) || field.includes(element.name.replace(/[^a-zA-Z0-9]/g,'').toLowerCase())) {
        if (lowerCase) {
          displayValues.push(element.name.toLowerCase());
        } else {
          displayValues.push(element.name);
        }
      }
    });

    return displayValues;
  }

  private async fetchDisplayElements(refresher?) {
    this.displaySections = undefined;
    const request: ContentAggregatorRequest = {
      userPreferences: {
        board: this.getFieldDisplayValues(this.profile.board, 'board', true),
        medium: this.getFieldDisplayValues(this.profile.medium, 'medium', true),
        gradeLevel: this.getFieldDisplayValues(this.profile.grade, 'gradeLevel', true),
        subject: this.getFieldDisplayValues(this.profile.subject, 'subject', true),
      },
      interceptSearchCriteria: (contentSearchCriteria: ContentSearchCriteria) => {
        contentSearchCriteria.board = this.getFieldDisplayValues(this.profile.board, 'board', true);
        contentSearchCriteria.medium = this.getFieldDisplayValues(this.profile.medium, 'medium', true);
        contentSearchCriteria.grade = this.getFieldDisplayValues(this.profile.grade, 'gradeLevel', true);
        return contentSearchCriteria;
      }, from: refresher ? CachedItemRequestSourceFrom.SERVER : CachedItemRequestSourceFrom.CACHE
    };
    const rootOrgId = this.onboardingConfigurationService.getAppConfig().overriddenDefaultChannelId
    let displayItems = await this.contentAggregatorHandler.newAggregate(request, AggregatorPageType.HOME, rootOrgId);
    this.getOtherMLCategories();
    displayItems = this.mapContentFacteTheme(displayItems);
    this.checkHomeData(displayItems);
    this.displaySections = this.contentAggregatorHandler.populateIcons(displayItems);
    this.showorHideBanners();
    this.refresh = false;
    if (refresher) {
       refresher.target.complete();
    }
  }

  handlePillSelect(event, section, isFromPopover?: boolean) {
    if (!event || !event.data || !event.data.length) {
      return;
    }
    const corRelationList: Array<CorrelationData> = [];
    corRelationList.push({
      id: event.data[0].name || '',
      type: isFromPopover ? CorReleationDataType.SUBJECT : CorReleationDataType.CATEGORY
    });
    this.telemetryGeneratorService.generateInteractTelemetry(
      isFromPopover ? InteractType.SELECT_ATTRIBUTE : InteractType.SELECT_CATEGORY,
      isFromPopover ? '' : event.data[0].name,
      Environment.HOME,
      PageId.HOME,
      undefined, undefined, undefined,
      isFromPopover ? corRelationList : undefined
    );
    if (section.dataSrc && section.dataSrc.params && section.dataSrc.params.config) {
      const filterConfig = section.dataSrc.params.config.find(((facet) => (facet.type === 'filter' && facet.code === section.code)));
      event.data[0].value['primaryFacetFilters'] = filterConfig ? filterConfig.values : undefined;

      if(!event.data[0].value['filterIdentifier']){
        const filterIdentifierList = section.dataSrc.params.config.find(((facet) => (facet.type === 'filterConfigIdentifier' && facet.code === section.code)));
        const filterVal = filterIdentifierList && filterIdentifierList.values && filterIdentifierList.values.find(v=>{
          if(v.code && event.data[0].name) {
            return v.code.toLowerCase().replace(/ /g, '') === event.data[0].name.toLowerCase().replace(/ /g, '')
          }
          return false;
        });
        event.data[0].value['filterIdentifier'] = filterVal ? filterVal.filterIdentifier : undefined;
      }
    }
    const params = {
      code: section.code,
      formField: event.data[0].value,
      fromLibrary: false,
      title: (section && section.landingDetails && section.landingDetails.title) || '',
      description: (section && section.landingDetails && section.landingDetails.description) || ''
    };
    this.router.navigate([RouterLinks.CATEGORY_LIST], { state: params });
  }

  navigateToViewMoreContentsPage(section, subsection) {
    let state = {};
    switch (section.dataSrc.type) {
      case 'TRACKABLE_COLLECTIONS':
        state = {
          enrolledCourses: subsection.contents,
          pageName: ViewMore.PAGE_COURSE_ENROLLED,
          headerTitle: this.commonUtilService.getTranslatedValue(section.title, ''),
          userId: this.appGlobalService.getUserId()
        };
        break;
      case 'RECENTLY_VIEWED_CONTENTS':
        state = {
          requestParams: {
            request: {
              searchType: SearchType.FILTER,
              offset: 0
            }
          },
          pageName: ViewMore.PAGE_TV_PROGRAMS,
          headerTitle: this.commonUtilService.getTranslatedValue(section.title, ''),
        };
        break;
      case 'CONTENTS':
        state = {
          contentList: subsection[0].contents,
          pageName: ViewMore.PAGE_TV_PROGRAMS,
          subjectName: this.commonUtilService.getTranslatedValue(section.title, ''),
        };
        break;
    }

    const values = new Map();
    values['SectionName'] = JSON.parse(section.title)['en'];
    this.telemetryGeneratorService.generateInteractTelemetry(InteractType.TOUCH,
      InteractSubtype.VIEWALL_CLICKED,
      Environment.HOME,
      PageId.HOME, undefined,
      values);
    const params: NavigationExtras = {
      state
    };
    this.router.navigate(section.dataSrc.type !== 'CONTENTS' ? [RouterLinks.VIEW_MORE_ACTIVITY] :
      [RouterLinks.TEXTBOOK_VIEW_MORE], params);
  }

  navigateToDetailPage(event, sectionName) {
    const item = event.data;
    const index = event.index;
    const values = {};
    values['sectionName'] = sectionName;
    values['positionClicked'] = index;
    if (this.commonUtilService.networkInfo.isNetworkAvailable || item.isAvailableLocally) {
      this.navService.navigateToDetailPage(item, { content: item });
    } else {
      this.commonUtilService.presentToastForOffline('OFFLINE_WARNING_ETBUI');
    }
  }

  handleHeaderEvents($event) {
    switch ($event.name) {
      case 'download':
        this.redirectToActivedownloads();
        break;
      case 'notification':
        this.redirectToNotifications();
        break;

      default: console.warn('Use Proper Event name');
    }
  }

  redirectToActivedownloads() {
    this.telemetryGeneratorService.generateInteractTelemetry(
      InteractType.TOUCH,
      InteractSubtype.ACTIVE_DOWNLOADS_CLICKED,
      Environment.HOME,
      PageId.HOME);
    this.router.navigate([RouterLinks.ACTIVE_DOWNLOADS]);
  }

  redirectToNotifications() {
    this.telemetryGeneratorService.generateInteractTelemetry(
      InteractType.TOUCH,
      InteractSubtype.SELECT_BELL,
      Environment.HOME,
      PageId.HOME);
    this.router.navigate([RouterLinks.NOTIFICATION]);
  }

  ionViewWillLeave(): void {
    this.events.unsubscribe('update_header');
    if (this.headerObservable) {
      this.headerObservable.unsubscribe();
    }
    this.refresher.disabled = true;
  }

  ngOnDestroy() {
    if (this.headerObservable) {
      this.headerObservable.unsubscribe();
    }
  }

  ionViewDidLeave() {
    if (this.newThemeTimeout && this.newThemeTimeout.clearTimeout) {
      this.newThemeTimeout.clearTimeout();
    }
  }

  ionViewDidEnter() {
    // Need timer to load the newTheme screen and for the newTheme screen to hide if user comes from deeplink.
    // this.newThemeTimeout = setTimeout(() => {
    //   this.appGlobalService.showJoyfulPopup();
    // }, 2000);
    this.refresher.disabled = false;
  }

  async viewPreferenceInfo() {
    const preferenceData = [
      {
        name: this.commonUtilService.translateMessage('BOARD'),
        list: this.boardList && this.boardList.length ? [this.boardList] : []
      },
      {
        name: this.commonUtilService.translateMessage('MEDIUM'),
        list: this.mediumList && this.mediumList.length ? [this.mediumList] : []
      },
      {
        name: this.commonUtilService.translateMessage('CLASS'),
        list: this.gradeLevelList && this.gradeLevelList.length ? [this.gradeLevelList] : []
      },
      {
        name: this.commonUtilService.translateMessage('SUBJECT'),
        list: this.subjectList && this.subjectList.length ? [this.subjectList] : []
      }
    ]
    const subjectListPopover = await this.modalCtrl.create({
      component: SbPreferencePopupComponent,
      componentProps: {
        userName: this.profile && this.profile.handle || '',
        preferenceData
      },
      backdropDismiss: true,
      showBackdrop: true,
      cssClass: 'preference-popup',
    });
    await subjectListPopover.present();
    const { data } = await subjectListPopover.onDidDismiss();
    if (data && data.showPreference) {
      this.editProfileDetails();
    }
  }

  async onViewMorePillList(event, section) {
    if (!event || !event.data) {
      return;
    }
    this.telemetryGeneratorService.generateInteractTelemetry(
      InteractType.SELECT_VIEW_ALL,
      '',
      Environment.HOME,
      PageId.HOME
    );
    const subjectListPopover = await this.modalCtrl.create({
      component: SbSubjectListPopupComponent,
      componentProps: {
        subjectList: event.data,
        title: section && section.title,
        theme: section && section.theme
      },
      backdropDismiss: true,
      showBackdrop: true,
      cssClass: 'subject-list-popup',
    });
    await subjectListPopover.present();
    const { data } = await subjectListPopover.onDidDismiss();
    this.handlePillSelect(data, section, true);
  }

  mapContentFacteTheme(displayItems) {
    if (displayItems && displayItems.length) {
      for (let count = 0; count < displayItems.length; count++) {
        if (!displayItems[count].data) {
          continue;
        }
        if (displayItems[count].dataSrc && (displayItems[count].dataSrc.type
          === 'CONTENT_FACETS') && (displayItems[count].dataSrc.facet === 'subject')) {
          displayItems[count] = this.mapSubjectTheme(displayItems[count]);
        }
        if (displayItems[count].dataSrc && (displayItems[count].dataSrc.type
          === 'CONTENT_FACETS') && (displayItems[count].dataSrc.facet === 'primaryCategory')) {
          displayItems[count] = this.mapPrimaryCategoryTheme(displayItems[count]);
        }
        if (displayItems[count].dataSrc && displayItems[count].dataSrc.type === 'RECENTLY_VIEWED_CONTENTS') {
          displayItems[count] = this.modifyContentData(displayItems[count]);
        }
        if (displayItems[count].dataSrc && displayItems[count].dataSrc.type === 'TRACKABLE_COLLECTIONS') {
          displayItems[count] = this.modifyCourseData(displayItems[count]);
        }
      }
    }
    return displayItems;
  }

  mapSubjectTheme(displayItems) {
    displayItems.data.forEach(item => {
      const subjectMap = item.facet && SubjectMapping[item.facet.toLowerCase()]
        ? SubjectMapping[item.facet.toLowerCase()] : SubjectMapping['default'];
      item.icon = item.icon ? item.icon : subjectMap.icon;
      item.theme = item.theme ? item.theme : subjectMap.theme;
      if (!item.theme) {
        const colorTheme = ColorMapping[Math.floor(Math.random() * ColorMapping.length)];
        item.theme = {
          iconBgColor: colorTheme.primary,
          pillBgColor: colorTheme.secondary
        };
      }
    });
    return displayItems;
  }

  mapPrimaryCategoryTheme(displayItems) {
    displayItems.data.forEach(item => {
      const primaryCaregoryMap = item.facet && PrimaryCaregoryMapping
      [item.facet.toLowerCase()] ? PrimaryCaregoryMapping[item.facet.toLowerCase()] :
        PrimaryCaregoryMapping['default'];
      item.icon = item.icon ? item.icon : primaryCaregoryMap.icon;
    });
    return displayItems;
  }

  modifyContentData(displayItems) {
    if (!displayItems.data.sections && !displayItems.data.sections[0] && !displayItems.data.sections[0].contents) {
      return;
    }
    displayItems.data.sections[0].contents.forEach(item => {
      item['cardImg'] = item['cardImg'] || (item.contentData && item.contentData['cardImg']);
      item['subject'] = item['subject'] || (item.contentData && item.contentData['subject']);
      item['gradeLevel'] = item['gradeLevel'] || (item.contentData && item.contentData['gradeLevel']);
      item['medium'] = item['medium'] || (item.contentData && item.contentData['medium']);
      item['organisation'] = item['organisation'] || (item.contentData && item.contentData['organisation']);
      item['badgeAssertions'] = item['badgeAssertions'] || (item.contentData && item.contentData['badgeAssertions']);
      item['resourceType'] = item['resourceType'] || (item.contentData && item.contentData['resourceType']);
    });
    return displayItems;
  }

  modifyCourseData(displayItems) {
    if (!displayItems.data.sections && !displayItems.data.sections[0] && !displayItems.data.sections[0].contents) {
      return;
    }
    displayItems.data.sections[0].contents.forEach(item => {
      item['cardImg'] = item['cardImg'] || (item.content && item.content['appIcon']);
    });
    return displayItems;
  }

  checkHomeData(displayItems) {
    this.homeDataAvailable = false;
    for (let index = 0; index < displayItems.length; index++) {
      if (displayItems[index] && displayItems[index].data && ((displayItems[index].data.length) ||
        (displayItems[index].data.sections && displayItems[index].data.sections.length && 
          displayItems[index].data.sections[0].contents && displayItems[index].data.sections[0].contents.length)
      )) {
        this.homeDataAvailable = true;
        break;
      }
    }
  }

  async requestMoreContent() {
    this.telemetryGeneratorService.generateInteractTelemetry(
      InteractType.TOUCH,
      InteractSubtype.LET_US_KNOW_CLICKED,
      Environment.LIBRARY,
      PageId.LIBRARY,
    );

    const formConfig = await this.formAndFrameworkUtilService.getContentRequestFormConfig();
    this.appGlobalService.formConfig = formConfig;
    this.frameworkSelectionDelegateService.delegate = this;
    this.router.navigate([`/${RouterLinks.PROFILE}/${RouterLinks.FRAMEWORK_SELECTION}`],
      {
        state: {
          showHeader: true,
          corRelation: [{ id: PageId.LIBRARY, type: CorReleationDataType.FROM_PAGE }],
          title: this.commonUtilService.translateMessage('FRMELEMNTS_LBL_REQUEST_CONTENT'),
          subTitle: this.commonUtilService.translateMessage('FRMELEMNTS_LBL_RELEVANT_CONTENT_SUB_HEADING'),
          formConfig,
          submitDetails: {
            label: this.commonUtilService.translateMessage('BTN_SUBMIT')
          }
        }
      });
  }

  async onFrameworkSelectionSubmit(formInput: any, formOutput: any, router: Router, commonUtilService: CommonUtilService,
    telemetryGeneratorService: TelemetryGeneratorService, corRelation: Array<CorrelationData>) {
    if (!commonUtilService.networkInfo.isNetworkAvailable) {
      await commonUtilService.showToast('OFFLINE_WARNING_ETBUI');
      return;
    }
    const selectedCorRelation: Array<CorrelationData> = [];

    if (formOutput['children']) {
      for (const key in formOutput['children']) {
        if (formOutput[key] && formOutput['children'][key]['other']) {
          formOutput[key] = formOutput['children'][key]['other'];
        }
      }

      delete formOutput['children'];
    }

    for (const key in formOutput) {
      if (typeof formOutput[key] === 'string') {
        selectedCorRelation.push({ id: formOutput[key], type: key });
      } else if (typeof formOutput[key] === 'object' && formOutput[key].name) {
        selectedCorRelation.push({ id: formOutput[key].name, type: key });
      }
    }
    telemetryGeneratorService.generateInteractTelemetry(
      InteractType.TOUCH,
      InteractSubtype.SUBMIT_CLICKED,
      Environment.HOME,
      PageId.FRAMEWORK_SELECTION,
      undefined,
      undefined,
      undefined,
      selectedCorRelation);
    const params = {
      formInput,
      formOutput,
      corRelation
    };
    router.navigate([`/${RouterLinks.RESOURCES}/${RouterLinks.RELEVANT_CONTENTS}`], { state: params });
  }

  async exploreOtherContents() {
    const categories: Array<FrameworkCategoryCode> = FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES;
    const syllabus: Array<string> = this.appGlobalService.getCurrentUser().syllabus;
    const frameworkId = (syllabus && syllabus.length) ? syllabus[0] : undefined;

    const navigationExtras = {
      state: {
        subjects: await this.getFrameworkData(frameworkId, categories, FrameworkCategoryCode.SUBJECT),
        categoryGradeLevels: await this.getFrameworkData(frameworkId, categories, FrameworkCategoryCode.GRADE_LEVEL),
        primaryCategories: PrimaryCategory.FOR_LIBRARY_TAB,
        selectedGrade: this.profile.grade,
        selectedMedium: this.profile.medium
      }
    };
    this.router.navigate([RouterLinks.EXPLORE_BOOK], navigationExtras);
  }

  async getFrameworkData(frameworkId, requiredCategories, currentCategoryCode): Promise<CategoryTerm[]> {
    const req: GetFrameworkCategoryTermsRequest = {
      currentCategoryCode,
      language: this.translate.currentLang,
      requiredCategories,
      frameworkId
    };
    try {
      return await this.frameworkUtilService.getFrameworkCategoryTerms(req).toPromise();
    } catch (e) {
      console.log(e);
      return [];
    }
  }

  tabViewWillEnter() {
    this.headerService.showHeaderWithHomeButton(['download', 'notification']);
    this.getUserProfileDetails();
  }

  navigateToSpecificLocation(event, section) {
    let banner = Array.isArray(event.data) ? event.data[0].value : event.data;
    const corRelationList: Array<CorrelationData> = [];
    let bannerType = ''
    if (banner){
      bannerType = banner.code
    }
    corRelationList.push({ id: bannerType, type: 'BannerType' });
    this.telemetryGeneratorService.generateInteractTelemetry(
      InteractType.SELECT_BANNER,
      '',
      Environment.HOME,
      PageId.HOME, undefined, undefined, undefined,
      corRelationList
    );
    switch (banner.code) {
      case 'banner_external_url':
        this.commonUtilService.openLink(banner.action.params.route);
        break;
      case 'banner_internal_url':
        if (this.guestUser && banner.action.params.route === RouterLinks.PROFILE) {
          this.router.navigate([`/${RouterLinks.GUEST_PROFILE}`]);
        } else {
          this.router.navigate([banner.action.params.route]);
        }
        break;
      case 'banner_search':
        if (banner.action && banner.action.params && banner.action.params.filter) {
          (banner['searchCriteria'] as ContentSearchCriteria) =
            this.contentService.formatSearchCriteria({ request: banner.action.params.filter });
          if (section.dataSrc && section.dataSrc.mapping) {
            const bannerMap = section.dataSrc.mapping.find(m => m.code === banner.code);
            if (bannerMap) {
              banner = { ...banner, ...bannerMap };
            }
            banner['facet'] = (banner.ui && banner.ui.landing && banner.ui.landing.title) || '';
            banner['description'] = (banner.ui && banner.ui.description) || '';
          }
        }
        section['description'] = (banner.ui && banner.ui.landing && banner.ui.landing.description) || '';
        this.handlePillSelect({ data: [{ value: banner }] }, section);
        break;
      case 'banner_content':
        this.splaschreenDeeplinkActionHandlerDelegate.navigateContent(banner.action.params.identifier,
          undefined, undefined, undefined, undefined, corRelationList);
        break;
    }
  }

  showorHideBanners() {
    this.bannerSegment = this.segmentationTagService.exeCommands.filter((cmd) => {
      if (cmd.controlFunction === 'BANNER_CONFIG') {
        return cmd;
      }
    });
    this.displayBanner = !!(this.bannerSegment && this.bannerSegment.length);
    this.bannerSegment = this.bannerSegment.reduce((accumulator, cmd) => {
      const bannerConfig = cmd.controlFunctionPayload.values.filter((value) =>
        Number(value.expiry) > Math.floor(Date.now() / 1000));
      accumulator = accumulator.concat(bannerConfig);
      return accumulator;
    }, []);
    if (this.bannerSegment) {
      this.setBannerConfig();
    }
  }

  setBannerConfig() {
    this.displaySections.forEach((section, index) => {
      if (section.dataSrc.type === 'CONTENT_DISCOVERY_BANNER') {
        const corRelationList: Array<CorrelationData> = [];
        corRelationList.push({ id: this.boardList.join(',') || '', type: CorReleationDataType.BOARD });
        corRelationList.push({ id: this.gradeLevelList.join(',') || '', type: CorReleationDataType.CLASS });
        corRelationList.push({ id: this.mediumList.join(',') || '', type: CorReleationDataType.MEDIUM });
        corRelationList.push({
          id: (this.profile && this.profile.profileType)
            ? this.profile.profileType : '', type: CorReleationDataType.USERTYPE
        });
        this.telemetryGeneratorService.generateImpressionTelemetry(
          ImpressionType.VIEW, ImpressionSubtype.BANNER,
          PageId.HOME,
          Environment.HOME,
          undefined,
          undefined,
          undefined,
          undefined,
          corRelationList
        );
        this.displaySections[index]['data'] = this.bannerSegment;
        this.primaryBanner = [];
        this.secondaryBanner = [];
        this.bannerSegment.forEach((banner) => {
          if (banner.type === 'secondary') {
            this.secondaryBanner.push(banner);
          } else {
            this.primaryBanner.push(banner);
          }
        });
      }
    });
  }

  async getOtherMLCategories() {
    try {
      let board = [];
      board.push(this.profile?.syllabus?.length  ?  this.profile?.syllabus[0]: null)
      board.push(this.profile?.board?.length  ?  this.profile?.board[0]: null)
      let role = this.profile.profileType.toLowerCase();
      if (this.profile.serverProfile) {
        role = this.profile.serverProfile.profileUserType.type.toLowerCase();
      }
      const otherCategories = await this.formAndFrameworkUtilService.getFormFields(
        FormConstants.ML_HOME_CATEGORIES
      );
      board.forEach(element => {
        if(otherCategories[element] && otherCategories[element][role]){
         this.otherCategories = otherCategories[element][role]; 
         return;
         }
      });
      if (this.otherCategories.length) {
        this.homeDataAvailable = true;
        this.events.publish('onPreferenceChange:showReport', true);
      } else {
        this.events.publish('onPreferenceChange:showReport', false);
      }
    } catch (error) {
        this.otherCategories = [];
        this.events.publish('onPreferenceChange:showReport', false);
    }
  }

  async handleOtherCategories(event) {
    if (!event || !event.data || !event.data.length) {
      return;
    }
    const title = event.data[0]['name'] === 'Project' ? 'FRMELEMENTS_MSG_YOU_MUST_JOIN_TO_PROJECT' :'FRMELEMENTS_MSG_YOU_MUST_JOIN_TO_OBSERVATIONS';
    const meta = event.data[0]['name'] === 'Project' ? 'FRMELEMENTS_MSG_ONLY_REGISTERED_USERS_CAN_TAKE_PROJECT': 'FRMELEMENTS_MSG_ONLY_REGISTERED_USERS_CAN_TAKE_OBSERVATION';
    const selectedPill = event.data[0].value.name;
    const confirm = await this.popoverCtrl.create({
      component: SbPopoverComponent,
      componentProps: {
        sbPopoverMainTitle: this.commonUtilService.translateMessage(title),
        metaInfo: this.commonUtilService.translateMessage(meta),
        sbPopoverHeading: this.commonUtilService.translateMessage('OVERLAY_SIGN_IN'),
        isNotShowCloseIcon: true,
        actionsButtons: [
          {
            btntext: this.commonUtilService.translateMessage('OVERLAY_SIGN_IN'),
            btnClass: 'popover-color label-uppercase label-bold-font'
          },
        ]
      },
      cssClass: 'sb-popover info',
    });
    if (this.guestUser) {
      await confirm.present();
      const { data } = await confirm.onDidDismiss();
      if (data && data.canDelete) {
        this.router.navigate([RouterLinks.SIGN_IN], { state: { navigateToCourse: true } });
      }
      return;
    }
    switch (selectedPill) {
      case 'observation':
        this.router.navigate([RouterLinks.OBSERVATION], {});
        break;
      case 'project':
        this.router.navigate([RouterLinks.PROJECT], {});
        break;  
      default:
        break;
    }
  }
}


<ion-content>
  <div class="spinner-div" *ngIf="refresh">
      <ion-spinner icon="spiral" class="refreshspinner"></ion-spinner>
  </div>
  <ion-refresher #refresher slot="fixed" (ionRefresh)="doRefresh($event)">
      <ion-refresher-content refreshingSpinner="circles"></ion-refresher-content>
  </ion-refresher>
  <div class="container-focus">
    <div class="user-profile">
      <div class="user-name-text"><span>{{'HI' | translate}}</span>&nbsp;{{profile?.handle}}</div>
    </div> 
    
    <div class="preference-container" *ngIf="preferenceList && preferenceList.length">
      <div class="user-preference">
        <div class="preference-data" (click)="viewPreferenceInfo()">
          <div>
            <span>{{'YOUR_PREFERENCES' | translate}}</span>
            <img class="preference-info-icon" role="button" src="assets/imgs/info-white.svg" alt="preferences-info">
          </div>
          <div>
            <app-truncated-ellipsis 
              [arrayList]= "preferenceList"
              [showCount]="1"
              [separatorText]="', '">
            </app-truncated-ellipsis>
          </div>
        </div>
        <div class="change-btn py-8" (click)="editProfileDetails()">
          <button class="sb-btn sb-btn-sm sb-btn-primary-outline">change</button>
        </div>
      </div>
    </div>
  </div>

  <ion-list class="m-n" *ngIf="!displaySections">
    <app-skeleton-item height="16px" width="40%" style="padding: 16px;"></app-skeleton-item>
    <ion-item *ngFor="let i of [0,1,2,3,4,5,6,7,8]" class="animation-background">
      <ion-avatar item-start>
        <app-skeleton-item height="72px" width="72px"></app-skeleton-item>
      </ion-avatar>
      <ion-label style="padding-left: 40px;">
        <app-skeleton-item height="12px" width="67%" style="padding-bottom: 8px;"></app-skeleton-item>
        <app-skeleton-item height="12px" width="47%" style="padding-bottom: 8px;"></app-skeleton-item>
      </ion-label>
    </ion-item>
  </ion-list>

  <div class="form-api-components" *ngIf="displaySections && displaySections.length && (homeDataAvailable || displayBanner)">

    <ng-container *ngFor="let section of displaySections">

      <ng-container *ngIf="section?.theme?.component === 'sb-course-cards-hlist'">
        <ng-container *ngFor="let subSection of section?.data?.sections">
          <ng-container *ngIf="subSection?.contents?.length">
            <sb-course-cards-hlist
              [title]="(section?.title) | translateJson"
              [type]="section?.theme?.inputs?.type || courseCardType.MY_COURSE_RECENTLY_VIEWED_CARD_GRID"
              [contentList]="subSection.contents"
              [hideProgress]="section?.theme?.inputs?.hideProgress || true"
              [viewMoreButtonText]="(section?.theme?.inputs?.viewMoreButtonText | translateJson) || ('VIEW_ALL' | translate)"
              [maxCardCount]="section?.theme?.inputs?.maxCardCount || 10"
              [viewMoreButtonPosition]="section?.theme?.inputs?.viewMoreButtonPosition || ButtonPosition.TOP"
              [publishedByText]="'CONTENT_CREATED_BY' | translate"
              (viewMoreClick)="navigateToViewMoreContentsPage(section, subSection)"
              (cardClick)="navigateToDetailPage($event, (subSection.name || section?.title))">
            </sb-course-cards-hlist>
          </ng-container>
        </ng-container>
      </ng-container>

      <!--banner-->
      <div class="heading-label" *ngIf="section?.title && section?.data?.length && section?.theme?.component === 'sb-banner-card-hlist' && displayBanner">
        <span>{{section?.title | translateJson}}</span>
        <hr>
      </div>
      <ng-container *ngIf="section?.theme?.component === 'sb-banner-card-hlist' && displayBanner">
        <sb-banner-card-hlist [bannerList]="primaryBanner" (cardClick)="navigateToSpecificLocation($event, section)"></sb-banner-card-hlist>
        <sb-banner-card-hlist [bannerList]="secondaryBanner" [secondaryBanner]="true" (cardClick)="navigateToSpecificLocation($event, section)"></sb-banner-card-hlist>
      </ng-container> 

      <!-- Pills -->
      <div class="heading-label" *ngIf="section?.title && section?.data?.length && section?.theme?.component === 'sb-pills-grid'">
        <span>{{section?.title | translateJson}}</span>
        <hr>
      </div>

      <ng-container *ngIf="section?.theme?.component === 'sb-pills-grid'">
        <sb-pills-grid [pillShape]="section?.theme?.inputs?.pillShape"
          [pillsViewType]="section?.theme?.inputs?.pillsViewType"
          [selectMode]="section?.theme?.inputs?.selectMode"
          [minDisplayCount]="section?.theme?.inputs?.minDisplayCount"
          [viewMoreText]="section?.theme?.inputs?.viewMoreText | translateJson"
          [viewLessText]="section?.theme?.inputs?.viewLessText | translateJson"
          [showMoreViewType]="section?.theme?.inputs?.showMoreViewType"
          [pillsMultiRow]="section?.theme?.inputs?.pillsMultiRow"
          [pillBorder]="section?.theme?.inputs?.pillBorder"
          [pillSize]="section?.theme?.inputs?.pillSize"
          [pillTextElipsis]="section?.theme?.inputs?.pillTextElipsis"
          [pillBoxShadow]="section?.theme?.inputs?.pillBoxShadow"
          (viewMorePillList)="onViewMorePillList($event, section)"
          (select)="handlePillSelect($event, section, false)">
          <sb-pill-item *ngFor="let pillData of section?.data; let index=index" [name]="pillData?.facet | titlecase"
                        [icon]="{ component: 'sb-pill-item', input: 'icon' } | themeInputsSelector : section?.theme : (pillData?.code || pillData?.facet)"
                        [theme]="({ component: 'sb-pill-item', input: 'theme' } | themeInputsSelector : section?.theme : pillData?.facet) || (pillData?.facet | randomColorMapPipe: index)"
                        [value]="pillData"></sb-pill-item>
        </sb-pills-grid>
      </ng-container>

      <!-- Recently published courses -->
      <div *ngIf="section?.data?.sections?.length && section?.data?.sections[0].contents?.length && section?.theme?.component === 'sb-course-cards'">
        <sb-library-cards-hlist
          [title]="section?.title | translateJson"
          [contentList]="section?.data?.sections[0]?.contents"
          [type]="section?.theme?.inputs?.type || LibraryCardTypes.MOBILE_TEXTBOOK"
          [layoutConfig]="layoutConfiguration"
          [isLoading]="false"
          [isOffline]="!commonUtilService.networkInfo.isNetworkAvailable"
          [maxCardCount]="section?.theme?.inputs?.maxCardCount || 10"
          [viewMoreButtonText]="(section?.theme?.inputs?.viewMoreButtonText | translateJson) || ('VIEW_ALL' | translate)"
          [viewMoreButtonPosition]="section?.theme?.inputs?.viewMoreButtonPosition || ButtonPosition.TOP"
          (viewMoreClick)="navigateToViewMoreContentsPage(section, section?.data?.sections)"
          (cardClick)="navigateToDetailPage($event, section?.title);">
        </sb-library-cards-hlist>
      </div>

      <!-- Recently viewed -->
      <div class="sb-recently-viewed-container" *ngIf="section?.data?.sections?.length && section?.data?.sections[0].contents?.length && section?.theme?.component === 'sb-library-cards-hlist'">
        <sb-library-cards-hlist
          [title]="section?.title | translateJson"
          [contentList]="section?.data?.sections[0]?.contents"
          [type]="section?.theme?.inputs?.type || LibraryCardTypes.MOBILE_TEXTBOOK"
          [isLoading]="false"
          [isOffline]="!commonUtilService.networkInfo.isNetworkAvailable"
          [maxCardCount]="section?.theme?.inputs?.maxCardCount || 10"
          [viewMoreButtonText]="(section?.theme?.inputs?.viewMoreButtonText | translateJson) || ('VIEW_ALL' | translate)"
          [viewMoreButtonPosition]="section?.theme?.inputs?.viewMoreButtonPosition || ButtonPosition.TOP"
          (viewMoreClick)="navigateToViewMoreContentsPage(section, section?.data?.sections)"
          (cardClick)="navigateToDetailPage($event, section?.title);">
        </sb-library-cards-hlist>
      </div>

    </ng-container>

      <!-- Ml tile other category start -->
      <ng-container *ngIf="otherCategories?.length">
        <div class="heading-label">
          <span role="heading" aria-level="2">{{ 'BROWSE_OTHER_CATEGORIES' | translate }}</span>
          <hr>
        </div>
        <sb-pills-grid 
          [pillShape]="'image_overlap'"
          [pillsViewType]="'scroll'"          
          [pillTextElipsis]="'three_line'"
          (select)="handleOtherCategories($event)"
          >
          <sb-pill-item 
           *ngFor="let pillData of otherCategories; let index=index"
              [name]="pillData?.name | titlecase"
              [icon]="pillData?.icon?.app"
              [value]="pillData"
              [theme]="({ component: 'sb-pill-item', input: 'theme' })"
          >
          </sb-pill-item>
        </sb-pills-grid>
      </ng-container>
      <!-- Ml tile other category end -->
  </div>

  <div *ngIf="!homeDataAvailable" class="p-16 pt-32">
    <div class="sb-nodownloads-container" *ngIf="commonUtilService?.networkInfo?.isNetworkAvailable">
      <div class="text-center">
        <img style="width: 30%;" src="./assets/imgs/group.svg" alt="">
      </div>
      <div class="text-center">
        <p class="sub-heading">{{'FRMELEMNTS_LBL_COULD_NOT_FIND_CONTENT' | translate }}</p>
        <ion-button class="explore-more-books" expand="block" (click)="requestMoreContent()">
          {{'REQUEST_CONTENT' | translate}} </ion-button>
        <ion-button class="explore-more-content" expand="block" fill="outline" (click)="exploreOtherContents()">
          {{'SEE_MORE_BOOKS' | translate}} </ion-button>
      </div>
    </div>

    <div class="ion-padding ion-text-center mt-32 mb-32" style="padding-top: 34px;"
      *ngIf="!commonUtilService?.networkInfo?.isNetworkAvailable">
      <img src="assets/imgs/outline-cloud_off.svg" alt="" />
      <ion-text>
        <h6 class="offline-header">
          <strong>{{ 'NO_INTERNET_TITLE' | translate }}</strong>
        </h6>
      </ion-text>
      <p class="offline-content">{{ 'OFFLINE_WARNING_ETBUI' | translate }}</p>
    </div>
  </div>

</ion-content>

./user-home.page.scss

@import "src/assets/styles/_variables.scss";
.filter-style {
  font-size: $font-size-base;
  font-weight: bold;
  color: var(--app-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: inline-block;
}

.user-profile {
  padding: 0.5rem 1.5rem 0;
  font-size: 1.188rem;
  color: var(--app-gray);
  .welcome-text{
    font-size: 1.125rem;
  }
  .user-name-text{
    font-size: 1.375rem;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.spinner-div {
  padding: 40px;
  background-color: map-get($colors, light_gray);
  text-align: center;
  border: none !important;
}

.preference-container {
  margin: 0 1rem;
  padding: 0 .5rem;
  font-size: 0.75rem;
  color: var(--app-gray);
  .user-preference {
    display: flex;
    align-items: center;
    .preference-data{
      width: 70%;
    }
    .change-btn{
      width: 30%;
      text-align: center;
      button{
        float: right;
        color: var(--app-primary);
        height: 1.5rem !important;
      }
    }
  }
}

.sb-card-scroll-container {
  overflow-x: auto;
  padding: 0 0 8px 0;
}
.sb-card-recently-container {
  .recently-viewed-card-size{
    margin: 0 8px; 
    min-width:18rem;
    max-width:18rem;
    &:only-child {
      min-width: 100%;
      max-width: calc(100vw - 32px);
    }
  }
}

.sb-btn-primary-outline{
  border-color: var(--app-white);  
}

.heading-ruler{
  width: 100%;
  margin-left: 1rem;
  background-color: var(--app-primary-header);
}

.preference-info-icon{
  height: 1rem;
  padding: 2px;
  background-color: var(--app-tertiary);
  border-radius: 50px;
  margin: 0.5rem;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""