File

src/app/modules/public/module/explore/components/explore-curriculum-courses/explore-curriculum-courses.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(searchService: SearchService, toasterService: ToasterService, resourceService: ResourceService, activatedRoute: ActivatedRoute, router: Router, navigationhelperService: NavigationHelperService, telemetryService: TelemetryService, location: Location)
Parameters :
Name Type Optional
searchService SearchService No
toasterService ToasterService No
resourceService ResourceService No
activatedRoute ActivatedRoute No
router Router No
navigationhelperService NavigationHelperService No
telemetryService TelemetryService No
location Location No

Methods

getInteractData
getInteractData(event)
Parameters :
Name Optional
event No
Returns : void
goBack
goBack()
Returns : void
navigateToCourse
navigateToCourse(event)
Parameters :
Name Optional
event No
Returns : void
ngOnInit
ngOnInit()
Returns : void
setTelemetryImpression
setTelemetryImpression()
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
Public courseList
Type : Array<literal type>
Default value : []
Public defaultBg
Default value : false
Public resourceService
Type : ResourceService
Public selectedCourse
Public telemetryImpression
Type : IImpressionEventInput
Public title
Type : string
import { Location } from '@angular/common';
import { IImpressionEventInput, TelemetryService } from '@sunbird/telemetry';
import { SearchService } from '@sunbird/core';
import { Component, OnInit } from '@angular/core';
import {
  ResourceService, ToasterService, NavigationHelperService } from '@sunbird/shared';
import { Router, ActivatedRoute } from '@angular/router';
import * as _ from 'lodash-es';

@Component({
  selector: 'app-explore-curriculum-courses',
  templateUrl: './explore-curriculum-courses.component.html',
  styleUrls: ['./explore-curriculum-courses.component.scss']
})
export class ExploreCurriculumCoursesComponent implements OnInit {
  public defaultBg = false;
  public selectedCourse;
  public courseList: Array<{}> = [];
  public title: string;
  public telemetryImpression: IImpressionEventInput;

  constructor(private searchService: SearchService, private toasterService: ToasterService,
    public resourceService: ResourceService, public activatedRoute: ActivatedRoute,
    private router: Router, private navigationhelperService: NavigationHelperService, private telemetryService: TelemetryService,
    private location: Location) { }

    ngOnInit() {
      this.title = _.get(this.activatedRoute, 'snapshot.queryParams.title');
      const subjectThemeAndCourse = this.searchService.subjectThemeAndCourse;
      if (!_.isEmpty(_.get(subjectThemeAndCourse, 'contents'))) {
        this.courseList = _.get(subjectThemeAndCourse, 'contents');
        this.selectedCourse = _.omit(subjectThemeAndCourse, 'contents');
      } else {
        this.toasterService.error(this.resourceService.frmelmnts.lbl.fetchingContentFailed);
        this.location.back();
      }
      this.setTelemetryImpression();
    }

    setTelemetryImpression() {
      this.telemetryImpression = {
        context: {
          env: this.activatedRoute.snapshot.data.telemetry.env
        },
        edata: {
          type: this.activatedRoute.snapshot.data.telemetry.type,
          pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
          uri: this.router.url,
          subtype: this.activatedRoute.snapshot.data.telemetry.subtype,
          duration: this.navigationhelperService.getPageLoadTime()
        }
      };
    }

    navigateToCourse(event) {
      this.router.navigate(['explore-course/course', event.data.identifier]);
    }

    goBack() {
      this.location.back();
    }

    getInteractData(event) {
      const cardClickInteractData = {
        context: {
          cdata: [],
          env: this.activatedRoute.snapshot.data.telemetry.env,
        },
        edata: {
          id: _.get(event, 'data.identifier'),
          type: 'click',
          pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
        },
        object: {
            id: event.data.identifier,
            type: event.data.contentType || 'course',
            ver: event.data.pkgVersion ? event.data.pkgVersion.toString() : '1.0'
        }
      };
      this.telemetryService.interact(cardClickInteractData);
    }
}
<div *ngIf="courseList.length > 0" [appTelemetryImpression]="telemetryImpression">

  <div class="sb-bg-color-white">
    <div class="ui container py-8">
      <button type="button" class="sb-btn sb-btn-normal sb-btn-link
        sb-btn-link-primary sb-left-icon-btn px-0" tabindex="0" (click)="goBack()">
        <i class="icon-svg icon-svg--xxs icon-back mr-4"><svg class="icon
            icon-svg--primary">
            <use xlink:href="./assets/images/sprite.svg#arrow-long-left"></use>
          </svg></i> {{resourceService?.frmelmnts?.btn?.back}}</button>
    </div>
  </div>
  
  <div class="content-header" [ngStyle]="!defaultBg  && {'background': selectedCourse?.theme}">
    <div class="ui container py-16">
      <div class="d-flex flex-ai-center flex-jc-space-between flex-w-wrap">
        <div class="content-header__img mr-8" *ngIf="selectedCourse?.cardImg">
          <img [src]="selectedCourse?.cardImg" style="width: 48px;">
        </div>
        <div class="flex-basis-1 mr-32">
          <div class="content-header__title font-weight-bold sb__ellipsis
            sb__ellipsis--one" [ngStyle]="!defaultBg  && {'color': selectedCourse?.titleColor}">
            <div>{{title}}</div>
          </div>
          <div class="d-flex flex-ai-center content-header__info fsmall mt-4" *ngIf="courseList?.length"> {{courseList.length}} {{(resourceService?.frmelmnts?.lbl?.courses).toUpperCase()}}</div>
        </div>
      </div>
    </div>
  </div>
  
  <div class="ui container mt-24 sb-library-cards right-flower-position-adjust-container">
      <div class="sbgrid">
        <div *ngFor="let course of courseList">
          <sb-course-card [course]="course" [cardImg]="course.appIcon" (cardClick)="navigateToCourse($event); getInteractData($event)" [section]="null"></sb-course-card>
        </div>
        
      </div>
  
  </div>
  </div>

./explore-curriculum-courses.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
@use 'pages/content-header' as *;
.sbgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(291.98px, 1fr));
  grid-gap: 1rem;
  grid-row-gap: 1.5rem;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""