File

src/app/modules/groups/components/activity/add-activity-content-types/add-activity-content-types.component.ts

Implements

OnInit AfterViewInit OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(groupService: GroupsService, resourceService: ResourceService, toasterService: ToasterService, activatedRoute: ActivatedRoute, router: Router, navigationHelperService: NavigationHelperService, telemetryService: TelemetryService, layoutService: LayoutService)
Parameters :
Name Type Optional
groupService GroupsService No
resourceService ResourceService No
toasterService ToasterService No
activatedRoute ActivatedRoute No
router Router No
navigationHelperService NavigationHelperService No
telemetryService TelemetryService No
layoutService LayoutService No

Methods

fetchActivityList
fetchActivityList()
Returns : void
initLayout
initLayout()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onCardClick
onCardClick(cardData: CsGroupSupportedActivitiesFormField)
Parameters :
Name Type Optional
cardData CsGroupSupportedActivitiesFormField No
Returns : void
sendInteractData
sendInteractData(interactData, edata?)
Parameters :
Name Optional
interactData No
edata Yes
Returns : void
setTelemetryImpressionData
setTelemetryImpressionData(edata?)
Parameters :
Name Optional
edata Yes
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
Private csGroupAddableBloc
Type : CsGroupAddableBloc
Public groupCreator
Type : string
Public groupName
Type : string
Public groupService
Type : GroupsService
Public layoutConfiguration
Type : any
Public layoutService
Type : LayoutService
Public navigationHelperService
Type : NavigationHelperService
Public resourceService
Type : ResourceService
Public router
Type : Router
Public showLoader
Default value : true
Public supportedActivityList
Public telemetryImpression
Type : IImpressionEventInput
Public toasterService
Type : ToasterService
unsubscribe$
Default value : new Subject<void>()
import { Component, OnInit, AfterViewInit , OnDestroy} from '@angular/core';
import { GroupsService } from '../../../services';
import { ResourceService, ToasterService, NavigationHelperService, LayoutService } from '@sunbird/shared';
import * as _ from 'lodash-es';
import { ActivatedRoute, Router } from '@angular/router';
import { ADD_ACTIVITY_TO_GROUP} from '../../../interfaces';
import { CsGroupAddableBloc } from '@project-sunbird/client-services/blocs';
import { CsGroupSupportedActivitiesFormField } from '@project-sunbird/client-services/services/group/interface';
import { TelemetryService, IImpressionEventInput } from '@sunbird/telemetry';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { CONTENT_CATEGORIES, SELECT_CATEGORY } from '../../../interfaces/telemetryConstants';



@Component({
  selector: 'app-add-activity-content-types',
  templateUrl: './add-activity-content-types.component.html',
  styleUrls: ['./add-activity-content-types.component.scss']
})
export class AddActivityContentTypesComponent implements OnInit, AfterViewInit, OnDestroy {
  unsubscribe$ = new Subject<void>();
  public supportedActivityList;
  public groupName: string;
  public groupCreator: string;
  private csGroupAddableBloc: CsGroupAddableBloc;
  public telemetryImpression: IImpressionEventInput;
  public layoutConfiguration: any;
  public showLoader = true;

  constructor(
    public groupService: GroupsService,
    public resourceService: ResourceService,
    public toasterService: ToasterService,
    public activatedRoute: ActivatedRoute,
    public router: Router,
    public navigationHelperService: NavigationHelperService,
    private telemetryService: TelemetryService,
    public layoutService: LayoutService
  ) {
    this.csGroupAddableBloc = CsGroupAddableBloc.instance;
   }

  ngOnInit() {
    this.navigationHelperService.setNavigationUrl();
    if (!this.csGroupAddableBloc.initialised) {
      this.csGroupAddableBloc.init();
    }
    this.activatedRoute.queryParams.subscribe((params) => {
     this.groupName = _.get(params, 'groupName');
     this.groupCreator = _.get(params, 'createdBy');
    });
    this.fetchActivityList();
    this.initLayout();
  }

  ngAfterViewInit() {
    this.setTelemetryImpressionData({type: CONTENT_CATEGORIES});
  }

  fetchActivityList() {
    this.groupService.getSupportedActivityList().subscribe( data => {
      this.showLoader = false;
      this.supportedActivityList = _.get(data, 'data.fields');
      this.supportedActivityList.forEach(activity => {
        activity['title'] =  this.groupService.getSelectedLanguageStrings(activity);
      });
    }, (error) => {
      this.showLoader = false;
      this.toasterService.error(this.resourceService.messages.emsg.m0005);
    });
  }

  onCardClick(cardData: CsGroupSupportedActivitiesFormField) {
    this.csGroupAddableBloc.updateState({
      pageIds: [cardData.activityType.toLowerCase(), ADD_ACTIVITY_TO_GROUP],
      groupId: _.get(this.groupService, 'groupData.id'),
      params: {
        searchQuery: JSON.parse(cardData.searchQuery),
        groupData: _.get(this.groupService, 'groupData'),
        contentType: cardData.activityType
      }
    });
    this.sendInteractData({id: `${cardData.activityType}-card`}, {type: SELECT_CATEGORY} );
    this.router.navigate([`${ADD_ACTIVITY_TO_GROUP}`, cardData.activityType , 1], { relativeTo: this.activatedRoute });
  }

  sendInteractData(interactData, edata?) {
    const data = {
      context: {
        env: this.activatedRoute.snapshot.data.telemetry.env,
        cdata: [{
          type: 'Group',
          id: _.get(this.groupService, 'groupData.id')
        }]
      },
      edata: {
        id: _.kebabCase(_.get(interactData, 'id')),
        type: 'CLICK',
        pageid: this.activatedRoute.snapshot.data.telemetry.pageid
      }
    };
    if (edata) {
      data.edata.type = edata.type;
    }
    this.telemetryService.interact(data);
  }

  setTelemetryImpressionData(edata?) {
    this.telemetryImpression = {
      context: {
        env: this.activatedRoute.snapshot.data.telemetry.env,
        cdata: [{
          type: 'Group',
          id: _.get(this.groupService, 'groupData.id')
        }]
      },
      edata: {
        type: this.activatedRoute.snapshot.data.telemetry.type,
        subtype: this.activatedRoute.snapshot.data.telemetry.subtype,
        pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
        uri: this.router.url,
        duration: this.navigationHelperService.getPageLoadTime()
      }
    };
    if (edata) {
      this.telemetryImpression.edata.type = edata.type;
    }
    this.telemetryService.impression(this.telemetryImpression);
  }

  initLayout() {
    this.layoutConfiguration = this.layoutService.initlayoutConfig();
    this.layoutService.switchableLayout().pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
      if (layoutConfig != null) {
        this.layoutConfiguration = layoutConfig.layout;
      }
    });
  }

  ngOnDestroy() {
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
  }

}
<div [ngClass]="layoutConfiguration ? 'sb-back-actionbar mt-0' : 'sb-bg-white cc-player__btn-back'" class="relative position mt-0">
  <div class="ui container d-flex flex-ai-center py-8">
    <app-back-button></app-back-button>
    <div class="d-flex flex-ai-center flex-jc-space-between flex-w-wrap ml-16 w-100">
      <div class="d-flex flex-dc">
        <h4 class="mb-4 font-weight-bold sb__ellipsis sb__ellipsis--one d-flex">{{groupName}}</h4>
        <div class="fsmall">{{resourceService?.frmelmnts?.lbl?.groupCreatedBy | interpolate:'{name}': groupCreator}}</div>
      </div>
      <div class="d-flex flex-ai-end flex-w-wrap content-header__buttons">
      </div>
    </div>
  </div>
</div>
<div [ngClass]="layoutConfiguration ? 'sbt-center-container sbt-back-header sbt-mygroups-details relative9':''" >
  <div class="ui container" *ngIf="showLoader">
    <app-loader></app-loader>
  </div>
  <div *ngIf="!showLoader">
    <div class="ui container">
      <div class="sb-card-grid sb-add-activity-content-cards my-24">
        <div class="add-activity-content" role="link" *ngFor="let activity of supportedActivityList; let i = index;">
          <sb-course-curiculum-card  [title]="activity?.title" (click)="onCardClick(activity)" [isActivityTypeCard]="true" [cardData]="activity" [index]="i"></sb-course-curiculum-card>
        </div>
      </div>
    </div>
  </div>
</div>

./add-activity-content-types.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;

.sb-add-activity-content-cards{
 @include respond-above(md){
     grid-template-columns: repeat(4,1fr);
 }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""