File

src/app/modules/public/module/sign-in/sso/components/select-org/select-org.component.ts

Metadata

styleUrls select-org.component.scss
templateUrl select-org.component.html

Constructor

constructor(formService: any, activatedRoute: ActivatedRoute, tenantService: any, resourceService: any, navigationhelperService: any)

Methods

Private setTenantInfo
setTenantInfo()
Returns: void
Public handleOrgChange
handleOrgChange(event: any)
Returns: void
Private getSsoOrgList
getSsoOrgList()
Returns: void
Public handleOrgSelection
handleOrgSelection(event: any)
Returns: void
Private setTelemetryData
setTelemetryData()
Returns: void
Private setRedirectUriCookie
setRedirectUriCookie()
Returns: void

Properties

activatedRoute
activatedRoute: ActivatedRoute
Public disableSubmitBtn
disableSubmitBtn: boolean
Default value: true
Public errorUrl
errorUrl: string
Default value: /sso/sign-in/error
navigationhelperService
navigationhelperService: any
Public orgList
orgList: any[]
resourceService
resourceService: any
Public selectedOrg
selectedOrg: any
Public submitOrgInteractEdata
submitOrgInteractEdata: any
Public telemetryImpression
telemetryImpression: any
Public tenantInfo
tenantInfo: any
import { first } from 'rxjs/operators';
import { Component, OnInit, AfterViewInit } from '@angular/core';
import { FormService } from '@sunbird/core';
import { ActivatedRoute } from '@angular/router';
import { TenantService } from '@sunbird/core';
import { ResourceService, NavigationHelperService } from '@sunbird/shared';
import { get } from 'lodash-es';
@Component({
  templateUrl: './select-org.component.html',
  styleUrls: ['./select-org.component.scss']
})
export class SelectOrgComponent implements OnInit, AfterViewInit {
  public selectedOrg: any;
  public orgList: Array<any>;
  public errorUrl = '/sso/sign-in/error';
  public telemetryImpression;
  public tenantInfo: any = {};
  public disableSubmitBtn = true;
  public submitOrgInteractEdata;
  constructor(private formService: FormService, public activatedRoute: ActivatedRoute, private tenantService: TenantService,
    public resourceService: ResourceService, public navigationhelperService: NavigationHelperService) { }

  ngOnInit() {
    this.setTenantInfo();
    this.setTelemetryData();
    this.setRedirectUriCookie();

    this.getSsoOrgList().subscribe(formData => this.orgList = formData,
      error => console.log('no org configured in form')); // show toaster message
  }
  private setTenantInfo() {
    this.tenantService.tenantData$.pipe(first()).subscribe(data => {
      if (!data.err) {
        this.tenantInfo = {
          logo: data.tenantData.logo,
          tenantName: data.tenantData.titleName
        };
      }
    });
  }
  public handleOrgChange(event) {
    this.disableSubmitBtn = false;
  }
  private getSsoOrgList() {
    const formServiceInputParams = {
      formType: 'organization',
      formAction: 'sign-in',
      contentType: 'organization'
    };
    return this.formService.getFormConfig(formServiceInputParams);
  }
  public handleOrgSelection(event) {
    window.location.href = this.selectedOrg;
  }

  ngAfterViewInit () {
    setTimeout(() => {
      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.activatedRoute.snapshot.data.telemetry.uri,
          duration: this.navigationhelperService.getPageLoadTime()
        }
      };
    });
  }

  private setTelemetryData() {
    this.submitOrgInteractEdata = {
      id: 'submit-org',
      type: 'click',
      pageid: 'sso-sign-in',
    };
  }
  private setRedirectUriCookie() {
    const redirectUri = get(this.activatedRoute, 'snapshot.queryParams.redirect_uri');
    if (redirectUri) { document.cookie = `SSO_REDIRECT_URI=${redirectUri}; path=/`; }
  }
}

results matching ""

    No results matching ""