File

src/app/modules/workspace/components/upforreview-contentplayer/upforreview-contentplayer.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(resourceService: ResourceService, activatedRoute: ActivatedRoute, userService: UserService, playerService: PlayerService, windowScrollService: WindowScrollService, permissionService: PermissionService, toasterService: ToasterService, layoutService: LayoutService, navigationHelperService: NavigationHelperService, router: Router)

Constructor to create injected service(s) object Default method of Draft Component class

Parameters :
Name Type Optional Description
resourceService ResourceService No

Reference of resourceService

activatedRoute ActivatedRoute No
userService UserService No
playerService PlayerService No
windowScrollService WindowScrollService No
permissionService PermissionService No
toasterService ToasterService No

Reference of ToasterService

layoutService LayoutService No
navigationHelperService NavigationHelperService No
router Router No

Methods

checkComments
checkComments()
Returns : void
close
close()

closes conent player and revert to previous url

Returns : void
Public contentProgressEvent
contentProgressEvent(event)
Parameters :
Name Optional
event No
Returns : void
getContent
getContent()

used to fetch content details and player config. On success launches player.

Returns : void
goToPublish
goToPublish()
Returns : void
Public handleReviewCommentEvent
handleReviewCommentEvent(event)
Parameters :
Name Optional
event No
Returns : void
Public handleSceneChangeEvent
handleSceneChangeEvent(data)
Parameters :
Name Optional
data No
Returns : void
initLayout
initLayout()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
setInteractEventData
setInteractEventData()
Returns : void
tryAgain
tryAgain()

retry launching player with same content details

Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
Public closeInteractEdata
Type : IInteractEventEdata
closeUrl
Type : any

To close url

Public commentList
Type : any
contentData
Type : ContentData

contain contentData

contentId
Type : string

content id

errorMessage
Type : string

contain error message

layoutConfiguration
Type : any
Public layoutService
Type : LayoutService
loaderMessage
Type : ILoaderMessage

loader message

Public navigationHelperService
Type : NavigationHelperService
Public permissionService
Type : PermissionService

To call Permission service

playerConfig
Type : PlayerConfig

contains player configuration

Public playerLoaded
Default value : false
Public playerService
Type : PlayerService

To call PlayerService service

Public publishInteractEdata
Type : IInteractEventEdata
publishWarningModal
Decorators :
@ViewChild('publishWarningModal')
Public requestForChangesInteractEdata
Type : IInteractEventEdata
Public resourceService
Type : ResourceService

To call resource service which helps to use language constant

Public reviewCommentsWarningNoInteractEdata
Type : IInteractEventEdata
Public reviewCommentsWarningYesInteractEdata
Type : IInteractEventEdata
router
Type : Router

To navigate to other pages

showCommentBoxClass
Type : string
Default value : 'twelve wide column'

This variable is used to increase/decrease the player width according to content mime type

showError
Default value : false

Flag to show error

showLoader
Default value : true

To show / hide loader

showPublishWarningModal
Default value : false
Public stageId
Type : string
Public telemetryInteractObject
Type : IInteractEventObject
Private toasterService
Type : ToasterService

To show toaster(error, success etc) after any API calls

Public unsubscribe$
Default value : new Subject<void>()
userId
Type : string

user id

Public userService
Type : UserService

To call user service

Public windowScrollService
Type : WindowScrollService

To call PlayerService service

import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {
  ResourceService, ILoaderMessage, PlayerConfig, ContentData,
  WindowScrollService, ToasterService, NavigationHelperService, LayoutService
} from '@sunbird/shared';
import { PlayerService, PermissionService, UserService } from '@sunbird/core';
import * as _ from 'lodash-es';
import { IInteractEventObject, IInteractEventEdata } from '@sunbird/telemetry';
import { takeUntil } from 'rxjs/operators';
import { Subject} from 'rxjs';
@Component({
  selector: 'app-upforreview-contentplayer',
  templateUrl: './upforreview-contentplayer.component.html',
  styleUrls: ['./upforreview-contentplayer.component.scss']
})
export class UpforreviewContentplayerComponent implements OnInit, OnDestroy {
  public requestForChangesInteractEdata: IInteractEventEdata;
  public publishInteractEdata: IInteractEventEdata;
  public reviewCommentsWarningYesInteractEdata: IInteractEventEdata;
  public reviewCommentsWarningNoInteractEdata: IInteractEventEdata;
  public telemetryInteractObject: IInteractEventObject;
  public closeInteractEdata: IInteractEventEdata;

  public unsubscribe$ = new Subject<void>();
  /**
   * To navigate to other pages
   */
  router: Router;
  /**
   * loader message
  */
 loaderMessage: ILoaderMessage;
  /**
   * To close url
  */
 closeUrl: any;
  /**
  * To show / hide loader
  */
  showLoader = true;
  /**
   * Flag to show error
   */
  showError = false;
  /**
   * content id
   */
  contentId: string;
  /**
   * user id
   */
  userId: string;
  /**
  * contain error message
  */
  errorMessage: string;
    /**
    * This variable is used to increase/decrease the player width
    * according to content mime type
    */
  showCommentBoxClass = 'twelve wide column';
 /**
  * To call resource service which helps to use language constant
  */
 public resourceService: ResourceService;
  /**
  * To call user service
  */
 public userService: UserService;

  /**
  * To call PlayerService service
  */
  public playerService: PlayerService;
  /**
  * To call Permission service
  */
 public permissionService: PermissionService;
  /**
  * To call PlayerService service
  */
  public windowScrollService: WindowScrollService;
  /**
   * contains player configuration
   */
  playerConfig: PlayerConfig;
  /**
   * contain contentData
  */
  contentData: ContentData;
  /**
  * To show toaster(error, success etc) after any API calls
  */
  private toasterService: ToasterService;

  public stageId: string;

  public commentList: any;

  public playerLoaded = false;

  @ViewChild('publishWarningModal') publishWarningModal;

  showPublishWarningModal = false;
  layoutConfiguration: any;
  /**
  * Constructor to create injected service(s) object
  Default method of Draft Component class
  * @param {ResourceService} resourceService Reference of resourceService
  * @param {ToasterService} toasterService Reference of ToasterService
  */
  constructor(resourceService: ResourceService, public activatedRoute: ActivatedRoute, userService: UserService,
    playerService: PlayerService, windowScrollService: WindowScrollService, permissionService: PermissionService,
    toasterService: ToasterService, public layoutService: LayoutService,
    public navigationHelperService: NavigationHelperService, router: Router) {
    this.resourceService = resourceService;
    this.playerService = playerService;
    this.userService = userService;
    this.windowScrollService = windowScrollService;
    this.permissionService = permissionService;
    this.toasterService = toasterService;
    this.router = router;
    this.loaderMessage = {
      'loaderMessage': this.resourceService.messages.stmsg.m0025,
    };
  }
  goToPublish() {
    this.router.navigate(['publish'], {relativeTo: this.activatedRoute});
  }
  checkComments() {
    if (!_.isEmpty(this.commentList)) {
      this.showPublishWarningModal = true;
    } else {
      this.goToPublish();
    }
  }
  ngOnInit() {
    this.initLayout();
    this.userService.userData$.subscribe(userdata => {
      if (userdata && !userdata.err) {
        this.userId = userdata.userProfile.userId;
        this.activatedRoute.params.subscribe((params) => {
          this.contentId = params.contentId;
          this.getContent();
        });
      }
      this.closeUrl = this.navigationHelperService.getPreviousUrl();
    });
  }
  ngOnDestroy() {
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
    if (this.publishWarningModal) {
      this.publishWarningModal.deny();
    }
  }
  initLayout() {
    this.layoutConfiguration = this.layoutService.initlayoutConfig();
    this.layoutService.switchableLayout().
        pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
        if (layoutConfig != null) {
          this.layoutConfiguration = layoutConfig.layout;
        }
      });
  }
  public handleSceneChangeEvent(data) {
    if (this.stageId !== data.stageId) {
      this.stageId = data.stageId;
    }
    if (!this.playerLoaded) {
      this.playerLoaded = true;
    }
  }
  public contentProgressEvent(event) {
    if (_.get(event, 'detail.telemetryData.eid') === 'END') {
      this.stageId = undefined;
    }
  }
  public handleReviewCommentEvent(event) {
    this.commentList = event;
  }
  /**
   * used to fetch content details and player config. On success launches player.
   */
  getContent() {
    this.showLoader = true;
    const option = {
          params: {mode: 'edit'}
    };
    this.playerService.getContent(this.contentId, option).subscribe(
      (response) => {
        if (response.result.content) {
          const contentDetails = {
            contentId: this.contentId,
            contentData: response.result.content
          };
          this.playerConfig = this.playerService.getConfig(contentDetails);
          this.playerConfig.data = this.playerService.updateContentBodyForReviewer(this.playerConfig.data);
          this.contentData = response.result.content;
          this.setInteractEventData();
          this.showCommentBoxClass = this.contentData.mimeType ===
          'application/vnd.ekstep.ecml-archive' ? 'eight wide column' : 'twelve wide column';
          this.showLoader = false;
        } else {
          this.toasterService.warning(this.resourceService.messages.imsg.m0027);
          this.close();
        }
      },
      (err) => {
        this.showError = true;
        this.errorMessage = this.resourceService.messages.stmsg.m0009;
      });
  }
  /**
   * retry launching player with same content details
   * @memberof ContentPlayerComponent
   */
  tryAgain() {
    this.showError = false;
    this.getContent();
  }
  /**
  * closes conent player and revert to previous url
  * @memberof ContentPlayerComponent
  */
  close() {
    this.navigationHelperService.navigateToWorkSpace('/workspace/content/upForReview/1');
  }

  setInteractEventData() {
    this.requestForChangesInteractEdata = {
      id: 'request-for-changes',
      type: 'click',
      pageid: 'upForReview-content-player'
    };
    this.publishInteractEdata = {
      id: 'publish',
      type: 'click',
      pageid: 'upForReview-content-player'
    };
    this.reviewCommentsWarningYesInteractEdata = {
      id: 'review-comments-warning-yes',
      type: 'click',
      pageid: 'upForReview-content-player'
    };
    this.reviewCommentsWarningNoInteractEdata = {
      id: 'review-comments-warning-no',
      type: 'click',
      pageid: 'upForReview-content-player'
    };
    this.closeInteractEdata = {
      id: 'close-button',
      type: 'click',
      pageid: 'upForReview-content-player'
    };
    this.telemetryInteractObject = {
      id: this.contentId,
      type: this.contentData.contentType,
      ver: this.contentData.pkgVersion ? this.contentData.pkgVersion.toString() : '1.0'
    };
  }
}
<app-landing-section [noTitle]= "true"
[layoutConfiguration]="layoutConfiguration"></app-landing-section>
<div [ngClass]="layoutConfiguration ? 'sbt-inside-page-container relative9': 'ui container mt-24'">
    <div [ngClass]="layoutConfiguration ? '' :'ui stackable grid'">
      <div class="twele wide column">
        <div class="row" *ngIf="showLoader">
          <app-loader [data]="loaderMessage"></app-loader>
        </div>

        <div *ngIf="!showLoader && contentData">
          <div class="sb-pageSection mb-16">
            <div class="sb-pageSection-header">
              <h1 class="sb-pageSection-title m-0 mr-8"> {{contentData.name}} </h1>
              <button class="sb-btn sb-btn-normal sb-btn-error ml-auto mouse-pointer" appTelemetryInteract
                [telemetryInteractObject]="telemetryInteractObject" [telemetryInteractEdata]="closeInteractEdata"
                tabindex="0" (click)="close()"> Close
                <i class="ui remove icon"></i>
              </button>
            </div>
          </div>


          <div class="ui grid">
            <div [ngClass]="showCommentBoxClass">
              <div class="aspectratio sbt-shadow-radius" data-ratio="16:9" #aspectRatio>
              <app-player class="content-player" [playerConfig]="playerConfig"
                (contentProgressEvent)="contentProgressEvent($event)" (sceneChangeEvent)="handleSceneChangeEvent($event)">
              </app-player>
            </div>
            </div>
            <div class="four wide column"
              *ngIf="contentData.mimeType === 'application/vnd.ekstep.ecml-archive' && stageId">
              <app-review-comments [contentData]="contentData" [playerLoaded]="playerLoaded" [stageId]="stageId"
                (reviewCommentEvent)="handleReviewCommentEvent($event)"></app-review-comments>
            </div>
          </div>
        </div>

        <div class="row d-flex" *ngIf="!showLoader">
          <div class="my-24 videosegment ui clearing segment ml-auto">
            <div
              *ngIf="permissionService.permissionAvailable && contentData && 
                  (contentData.status === 'Review' || contentData.status === 'FlagReview') && userId !== contentData.createdBy"
              appPermission [permission]="['CONTENT_REVIEWER', 'CONTENT_REVIEW','BOOK_REVIEWER','FLAG_REVIEWER']">
              <button tabindex="0" (click)="checkComments()" class="ui right floated sb-btn sb-btn-primary sb-btn-normal mr-8"
                appTelemetryInteract [telemetryInteractObject]="telemetryInteractObject"
                [telemetryInteractEdata]="publishInteractEdata">
                {{resourceService?.frmelmnts?.btn?.publish}}
              </button>
              <button [routerLink]="['requestchanges']" class="ui right floated sb-btn sb-btn-primary sb-btn-normal"
                appTelemetryInteract [telemetryInteractObject]="telemetryInteractObject"
                [telemetryInteractEdata]="requestForChangesInteractEdata">
                {{resourceService?.frmelmnts?.btn?.requestChanges}}
              </button>
            </div>
          </div>
        </div>
        <div class="ui grid" *ngIf="!showLoader && contentData">
          <div class="eight wide column">
            <app-content-player-metadata [contentData]="contentData"></app-content-player-metadata>
          </div>
          <div class="four wide column">
          </div>
        </div>

        <div *ngIf="showError">
          <div class="ui active dimmer inverted">
            <div class="content">
              <div class="center">
                <h2 class="ui header red">
                  {{errorMessage}}
                </h2>
                <span>
                  <button class="ui button" tabindex="0" (click)="tryAgain()">{{resourceService.frmelmnts.btn.tryagain}}</button>
                </span>
                <span>
                  <button class="ui red button" tabindex="0" (click)="close()">{{resourceService.frmelmnts.btn.close}}</button>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
</div>
<!-- publish warning modal -->

<sui-modal [mustScroll]="true" [isClosable]="false" [transitionDuration]="0" [size]="'small'" class="sb-modal"
  appBodyScroll *ngIf="showPublishWarningModal" #publishWarningModal>
  <!--Header-->
  <i class="icon close" (click)="showPublishWarningModal = false" tabindex="0"></i>
  <div class="sb-modal-header">
    &nbsp;
  </div>
  <!--/Header-->

  <!--Content-->
  <div class="sb-modal-content">
    <div class="ui centered grid">
      <div class="row">
        <div class="ui basic icon circular button cursor-pointer">
          <i class="ui huge help outline icon"></i>
        </div>
      </div>
      <div class="row">
        <div class="ui small header">
          <h4>{{resourceService?.frmelmnts?.lbl?.publhwarng}}</h4>
        </div>
      </div>
    </div>
  </div>
  <!--/Content-->

  <!--Actions-->
  <div class="sb-modal-actions">
    <button class="sb-btn sb-btn-normal sb-btn-primary" type="button "
      tabindex="0" (click)="showPublishWarningModal = false; goToPublish();" appTelemetryInteract
      [telemetryInteractObject]="telemetryInteractObject"
      [telemetryInteractEdata]="reviewCommentsWarningYesInteractEdata">
      {{resourceService?.frmelmnts?.btn?.yes}}
    </button>
    <button class="sb-btn sb-btn-normal sb-btn-outline-primary" type="button " tabindex="0" (click)="showPublishWarningModal = false"
      appTelemetryInteract [telemetryInteractObject]="telemetryInteractObject"
      [telemetryInteractEdata]="reviewCommentsWarningNoInteractEdata">
      {{resourceService?.frmelmnts?.btn?.no}}
    </button>
  </div>
  <!--Actions-->

</sui-modal>
<router-outlet></router-outlet>

./upforreview-contentplayer.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins"as *;
@use 'pages/player-fullScreen'as *;
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""