File

src/app/modules/discussion/components/forum/forum.component.ts

Implements

OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods
HostListeners

Constructor

constructor(sanitizer: DomSanitizer, activatedRoute: ActivatedRoute, location: Location, config: ConfigService, learnerService: LearnerService, userService: UserService)
Parameters :
Name Type Optional
sanitizer DomSanitizer No
activatedRoute ActivatedRoute No
location Location No
config ConfigService No
learnerService LearnerService No
userService UserService No

HostListeners

window:popstate
Arguments : '$event'
window:popstate(event)

Methods

closeModal
closeModal()
Returns : void
getDiscussionUrl
getDiscussionUrl()
Returns : void
navigateToPreviousPage
navigateToPreviousPage()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onPopState
onPopState(event)
Decorators :
@HostListener('window:popstate', ['$event'])
Parameters :
Name Optional
event No
Returns : void

Properties

discussionUrl
Type : SafeResourceUrl
modal
Decorators :
@ViewChild('modal')
Public sanitizer
Type : DomSanitizer
import { ConfigService } from '@sunbird/shared';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { LearnerService, UserService } from '@sunbird/core';
import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core';
import * as _ from 'lodash-es';
import { Location } from '@angular/common';

@Component({
  selector: 'app-forum',
  templateUrl: './forum.component.html',
  styleUrls: ['./forum.component.scss']
})

export class ForumComponent implements OnInit, OnDestroy, AfterViewInit {

  discussionUrl: SafeResourceUrl;
  @ViewChild('modal')modal;
  constructor(
    public sanitizer: DomSanitizer, private activatedRoute: ActivatedRoute,
    private location: Location, private config: ConfigService,
    private learnerService: LearnerService, private userService: UserService) { }

  @HostListener('window:popstate', ['$event'])
  onPopState(event) {
    this.closeModal();
  }

  ngOnInit() {
    this.getDiscussionUrl();
  }

  ngAfterViewInit() {
    document.body.className = 'o-y-auto';
  }

  getDiscussionUrl() {
    const option = {
      url: `${this.config.urlConFig.URLS.USER.GET_SESSION}/${this.userService.userid}`
    };
    this.learnerService.get(option).subscribe((data: any) => {
      this.discussionUrl = this.sanitizer.bypassSecurityTrustResourceUrl(
        `discussions/auth/sunbird-oidc/callback${data.id}&returnTo=/category/${_.get(this.activatedRoute.snapshot, 'queryParams.forumId')}`
      );
    });
  }

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

  closeModal() {
    if (this.modal) {
      this.modal.deny();
    }
  }

  ngOnDestroy() {
    this.closeModal();
  }

}
<app-modal-wrapper [config]="{disableClose: true, size: 'large', panelClass: 'material-modal'}"
  (dismiss)="navigateToPreviousPage()" #modal>
  <ng-template sbModalContent>
    <div class="sb-mat__modal">
      <div mat-dialog-title class="mb-0"></div>
      <div class="sb-mat__modal__content">
        <iframe scrolling="no" [src]="discussionUrl"></iframe>
      </div>
      <mat-dialog-actions class="sb-mat__modal__actions"></mat-dialog-actions>
    </div>
  </ng-template>
</app-modal-wrapper>

./forum.component.scss

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

::ng-deep {
  .sb-modal .ui.modal.fullscreen .sb-modal-content {
    height: 100vh;
    padding: 0;
    border-radius: 0;
    overflow: hidden;
  }

  iframe {
    width: 100%;
    height: 100vh;
    border: 0;
  }
  .sb-modal .ui.modal>.close {
    color: var(--black);
    background: var(--gray-0);
    border-radius: 100%;
    right: 1rem;
    top: 1rem;
    font-size: 1.25rem;
    &:hover {
      background: var(--black);
      color: var(--white);
    }
  }
  .o-y-auto {
    overflow-y: auto;
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""