File

src/app/modules/public/module/signup/components/signup/signup.component.ts

Implements

OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods
Accessors

Constructor

constructor(resourceService: ResourceService, tenantService: TenantService, deviceDetectorService: DeviceDetectorService, activatedRoute: ActivatedRoute, telemetryService: TelemetryService, navigationhelperService: NavigationHelperService, router: Router)
Parameters :
Name Type Optional
resourceService ResourceService No
tenantService TenantService No
deviceDetectorService DeviceDetectorService No
activatedRoute ActivatedRoute No
telemetryService TelemetryService No
navigationhelperService NavigationHelperService No
router Router No

Methods

changeStep
changeStep()
Returns : void
initializeFormFields
initializeFormFields()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
redirectToLogin
redirectToLogin()
Returns : void
setInteractEventData
setInteractEventData()
Returns : void
signUpTelemetryImpression
signUpTelemetryImpression()
Returns : void
signUpTelemetryStart
signUpTelemetryStart()
Returns : void
subformInitialized
subformInitialized(name: string, group: object)
Parameters :
Name Type Optional
name string No
group object No
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
captchaRef
Type : RecaptchaComponent
Decorators :
@ViewChild('captchaRef')
Public deviceDetectorService
Type : DeviceDetectorService
formInputType
Type : string
instance
Type : string
isIOSDevice
Default value : false
logo
Type : string
Public navigationhelperService
Type : NavigationHelperService
resourceDataSubscription
Type : any
Public resourceService
Type : ResourceService
routeParams
Type : any
signUpForm
signupStage
Type : SignUpStage
submitInteractEdata
Type : IInteractEventEdata
telemetryCdata
Type : Array<literal type>
telemetryImpression
Type : IImpressionEventInput
Public telemetryService
Type : TelemetryService
telemetryStart
Type : IStartEventInput
tenantDataSubscription
Type : Subscription
tenantName
Type : string
Public tenantService
Type : TenantService
Public unsubscribe
Default value : new Subject<void>()

Accessors

Stage
getStage()
import { Component, OnInit, OnDestroy, AfterViewInit, ViewChild } from '@angular/core';
import { Subject, Subscription } from 'rxjs';
import {
  ResourceService,
  NavigationHelperService
} from '@sunbird/shared';
import { TenantService } from '@sunbird/core';
import { TelemetryService } from '@sunbird/telemetry';
import * as _ from 'lodash-es';
import { IStartEventInput, IImpressionEventInput, IInteractEventEdata } from '@sunbird/telemetry';
import { DeviceDetectorService } from 'ngx-device-detector';
import { Router, ActivatedRoute } from '@angular/router';
import { RecaptchaComponent } from 'ng-recaptcha';

export enum SignUpStage {
  BASIC_INFO = 'basic_info',
  ONBOARDING_INFO = 'onboarding_info',
  EMAIL_PASSWORD = 'email_password',
  OTP = 'otp'
}

@Component({
  selector: 'app-signup',
  templateUrl: './signup.component.html',
  styleUrls: ['./signup.component.scss','./signup_form.component.scss']
})
export class SignupComponent implements OnInit, OnDestroy, AfterViewInit {
  @ViewChild('captchaRef') captchaRef: RecaptchaComponent;
  public unsubscribe = new Subject<void>();
  signUpForm;
  tenantDataSubscription: Subscription;
  logo: string;
  tenantName: string;
  resourceDataSubscription: any;
  telemetryStart: IStartEventInput;
  telemetryImpression: IImpressionEventInput;
  submitInteractEdata: IInteractEventEdata;
  telemetryCdata: Array<{}>;
  instance: string;
  formInputType: string;
  isIOSDevice = false;
  signupStage: SignUpStage;
  routeParams: any;
  get Stage() { return SignUpStage; }

  constructor(public resourceService: ResourceService, public tenantService: TenantService, public deviceDetectorService: DeviceDetectorService,
    public activatedRoute: ActivatedRoute, public telemetryService: TelemetryService,
    public navigationhelperService: NavigationHelperService, private router: Router) {
  }

  ngOnInit() {
    this.activatedRoute.queryParams.subscribe(params => {
      this.routeParams = params;
    });
    this.signupStage = SignUpStage.BASIC_INFO;
    this.isIOSDevice = /iPad|iPhone|iPod/.test(navigator.userAgent);
    this.instance = _.upperCase(this.resourceService.instance || 'SUNBIRD');
    this.tenantDataSubscription = this.tenantService.tenantData$.subscribe(
      data => {
        if (data && !data.err) {
          this.logo = data.tenantData.logo;
          this.tenantName = data.tenantData.titleName;
        }
      }
    );

    this.initializeFormFields();
    this.setInteractEventData();

    // Telemetry Start
    this.signUpTelemetryStart();
  }

  signUpTelemetryStart() {
    const deviceInfo = this.deviceDetectorService.getDeviceInfo();
    this.telemetryStart = {
      context: {
        env: this.activatedRoute.snapshot.data.telemetry.env,
        cdata: this.telemetryCdata,
      },
      edata: {
        type: this.activatedRoute.snapshot.data.telemetry.type,
        pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
        mode: this.activatedRoute.snapshot.data.telemetry.mode,
        uaspec: {
          agent: deviceInfo.browser,
          ver: deviceInfo.browser_version,
          system: deviceInfo.os_version,
          platform: deviceInfo.os,
          raw: deviceInfo.userAgent
        }
      }
    };
  }

  signUpTelemetryImpression() {
    this.telemetryImpression = {
      context: {
        env: this.activatedRoute.snapshot.data.telemetry.env,
        cdata: this.telemetryCdata,
      },
      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()
      }
    };
  }

  initializeFormFields() {
    this.signUpForm = {
      basicInfo: null,
      onboardingInfo: null,
      emailPassInfo: null,
      routeParams: this.routeParams
    };
  }

  subformInitialized(name: string, group: object) {
    this.signUpForm[name] = group
  }

  changeStep() {
    switch(this.signupStage) {
      case this.Stage.BASIC_INFO:
        this.signupStage = this.Stage.ONBOARDING_INFO;
        break;
      case this.Stage.ONBOARDING_INFO:
        this.signupStage = this.Stage.EMAIL_PASSWORD;
        break;
      case this.Stage.EMAIL_PASSWORD:
        this.signupStage = this.Stage.OTP;
        break;
      default:
        this.signupStage = this.Stage.BASIC_INFO;
        break;
    }
  }

  ngAfterViewInit () {
    setTimeout(() => {
      this.telemetryCdata = [{ 'type': 'signup', 'id': this.activatedRoute.snapshot.data.telemetry.uuid }];
      this.signUpTelemetryImpression();
    });
  }

  ngOnDestroy() {
    if (this.tenantDataSubscription) {
      this.tenantDataSubscription.unsubscribe();
    }
    this.unsubscribe.next();
    this.unsubscribe.complete();
  }

  setInteractEventData() {
    this.submitInteractEdata = {
      id: 'submit-signup',
      type: 'click',
      pageid: 'signup',
      extra: {
        // 'contactType': this.signUpForm.controls.contactType.value.toString()
      }
    };
  }

  redirectToLogin () {
    window.location.href = '/resources';
  }
  
}
<!-- New Design code for Registration page -->

<div class="layout">
  <div class="left-panel">
    <div class="image"><img alt={{tenantName}} src="{{logo}}">
    </div>
  </div>


  <div class="right-panel d-flex flex-dc">
    <div *ngIf="!routeParams?.loginMode" class="login-content w-100 fix-bottom">
      <label class="mb-0 mx-8">{{resourceService.frmelmnts?.lbl?.haveaccount}}</label>
      <button class="sb-btn sb-btn-normal sb-btn-outline-primary text-uppercase" (click)="redirectToLogin()"
        aria-label="Already have an account? Login here" tabindex="0"
        type="submit">{{resourceService.frmelmnts?.btn?.login}}</button>
    </div>

    <div class="content-center-container">
    <div class="logo-content">
        <div class="text-center mb-8">
          <img class="image centered" tabindex="0" aria-label="" alt={{tenantName}} height="56" src="{{logo}}">
        </div>
        <h3 tabindex="0" class="sb-color-primary text-center font-weight-bold mb-8" *ngIf="!routeParams?.loginMode">
          {{resourceService.frmelmnts.lbl.welcomeToInstance | interpolate:'{instance}': instance}}</h3>
    </div>

    <ng-container [ngSwitch]="signupStage">
              <app-signup-basic-info [isIOSDevice]="isIOSDevice" [telemetryImpression]="telemetryImpression"
                [submitInteractEdata]="submitInteractEdata" [telemetryCdata]="telemetryCdata"
                *ngSwitchCase="Stage.BASIC_INFO" [startingForm]="signUpForm" [routeParams]="routeParams"
                (subformInitialized)="subformInitialized('basicInfo', $event)" (triggerNext)="changeStep()">
              </app-signup-basic-info>
              <app-signup-onboarding-info *ngSwitchCase="Stage.ONBOARDING_INFO" [startingForm]="signUpForm" 
                (subformInitialized)="subformInitialized('onboardingInfo', $event)" (triggerNext)="changeStep()">
              </app-signup-onboarding-info>
              <app-signup-email-password *ngSwitchCase="Stage.EMAIL_PASSWORD" [startingForm]="signUpForm" 
                (subformInitialized)="subformInitialized('emailPassInfo', $event)" (triggerNext)="changeStep()">
              </app-signup-email-password>
              <app-otp class="w-100" *ngSwitchCase="Stage.OTP" [startingForm]="signUpForm" (triggerNext)="changeStep()"></app-otp>
    </ng-container>
  </div>
  </div>

</div>

./signup.component.scss

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

/* Layout: */

.layout {
  display: grid;
  height: calc(100vh - 3rem);
  grid-template-columns: 1fr 2fr;

  @include respond-below(sm) {
    grid-template-columns: 1fr;
    height: calc(100vh - 3.5rem);
  }

  .left-panel {
    background: url(/assets/images/bg.svg) no-repeat;
    background-size: cover;
    position: relative;
    height: 100%;

    @include respond-below(sm) {
      display: none;
    }

    .image {
      width: calculateRem(124px);
      height: calculateRem(124px);
      background: var(--signup-panel-bg);
      display: flex;
      align-items: center;
      border-radius: 50%;
      position: absolute;
      overflow: hidden;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      justify-content: center;
      padding: 0.5rem;

      img {
        max-width: 100%;
      }
    }
  }

  .right-panel {
    background: var(--signup-panel-bg);
    height: 100%;
    position: relative;

    .login-content {
      text-align: right;
      padding:1rem 1rem 1.5rem 1rem;
      position: relative;
      @include respond-below(sm) {
        text-align: center;
      }
    }
  }

  .content-center-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;    
    padding-bottom: 2rem;
  }
}

./signup_form.component.scss

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

.signup-form-content,.logo-content{
    width: 100%;
    max-width: calculateRem(360px);
    margin: 0 auto;
    padding:0 1rem
  }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""