File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/components/live-apps-login/live-apps-login.component.ts

Description

Component perform a Login in case there is no valid Session yet.

If the user is not logged in the login component will be displayed automatically.

alt-text

Extends

LiveAppsComponent

Metadata

selector tcla-live-apps-login
styleUrls ./live-apps-login.component.css
templateUrl ./live-apps-login.component.html

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(tcAppDefinitionService: TcAppDefinitionService, configService: TcCoreConfigService, credentialsService: CredentialsService)
Parameters :
Name Type Optional
tcAppDefinitionService TcAppDefinitionService No
configService TcCoreConfigService No
credentialsService CredentialsService No

Inputs

appName
Type : string
loginPrefill
Type : LoginPrefill

Outputs

loginContext
Type : EventEmitter<LoginContext>
signUp
Type : EventEmitter

Output signUp event

useOauth
Type : EventEmitter

Output useOauth event

HostListeners

window:resize
Arguments : '$event'
window:resize(event)
Inherited from LiveAppsComponent

Methods

handleSignUp
handleSignUp()
Returns : void
handleUseOauth
handleUseOauth()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Inherited from LiveAppsComponent
Returns : void
ngOnDestroy
ngOnDestroy()
Inherited from LiveAppsComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from LiveAppsComponent
Returns : void
setupWidthObserver
setupWidthObserver()
Inherited from LiveAppsComponent
Returns : void

Properties

Public appName
Type : string
Default value : 'Cloud Starters'
handleLoggedIn
Default value : () => {...}
Protected _destroyed$
Default value : new Subject()
Inherited from LiveAppsComponent
componentChildDivs
Type : LiveAppsComponent[]
Decorators :
@ViewChildren('componentChildDiv')
Inherited from LiveAppsComponent
componentDiv
Type : ElementRef
Decorators :
@ViewChild('componentDiv', {static: false})
Inherited from LiveAppsComponent
Protected containerChanges$
Type : Observable<TcComponent>
Inherited from LiveAppsComponent
Private observer
Inherited from LiveAppsComponent
Public resize
Default value : () => {...}
Inherited from LiveAppsComponent
Public widget
Type : TcComponent
Inherited from LiveAppsComponent

Accessors

AppName
setAppName(appName: string)
Parameters :
Name Type Optional
appName string No
Returns : void
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {LoginContext} from '../../models/liveappsdata';
import {LoginPrefill, TcCoreConfigService} from '@tibco-tcstk/tc-core-lib';
import {LiveAppsService} from '../../services/live-apps.service';
import { LiveAppsComponent } from '../live-apps-component/live-apps-component.component';
import {TcAppDefinitionService} from '../../services/tc-app-definition.service';
import {take} from 'rxjs/operators';
import {CredentialsService} from '../../services/credentials.service';

/**
 * Component perform a Login in case there is no valid Session yet.
 *
 * If the user is not logged in the login component will be displayed automatically.
 *
 * ![alt-text](../Login.png "Image")
 */
@Component({
  selector: 'tcla-live-apps-login',
  templateUrl: './live-apps-login.component.html',
  styleUrls: ['./live-apps-login.component.css']
})
export class LiveAppsLoginComponent extends LiveAppsComponent {

  @Output() loginContext: EventEmitter<LoginContext> = new EventEmitter<LoginContext>();
  @Input() loginPrefill: LoginPrefill;
  /**
   * Output useOauth event
   */
  @Output() useOauth = new EventEmitter();
  /**
   * Output signUp event
   */
  @Output() signUp = new EventEmitter();
  public appName = 'Cloud Starters';
  @Input('appName') set AppName(appName: string) {
    if (appName) {
      this.appName = appName;
    }
  }

  constructor(protected tcAppDefinitionService: TcAppDefinitionService, protected configService: TcCoreConfigService, protected credentialsService: CredentialsService) {
    super();
  }

  handleUseOauth() {
    this.useOauth.emit();
  }

  handleSignUp() {
    this.signUp.emit();
  }

  // run when logged in
  handleLoggedIn = (loginInfo) => {
    // remove any stored oauth token/cookie
    this.credentialsService.setKey(undefined);
    // update claims first
    this.tcAppDefinitionService.refresh().pipe(
      take(1)
    ).subscribe(
      next => {
        sessionStorage.setItem('loggedIn', Date.now().toString());
        // emit useful details about the login and session/claims

        // clear any oauth keys stored
        /*if (this.configService && this.configService.getConfig() && this.configService.getConfig().oAuthLocalStorageKey
        && this.configService.getConfig().oAuthLocalStorageKey !== '') {
          localStorage.removeItem(this.configService.getConfig().oAuthLocalStorageKey);
        }*/
        this.credentialsService.setMode('cookies');
        this.loginContext.emit(new LoginContext().deserialize(
          {
            authInfo: loginInfo.authInfo,
            accessToken: loginInfo.accessToken
          }));
    });
  }

}
<tc-tibco-cloud-login fxFill (loggedIn)="handleLoggedIn($event)" [appName]="appName" [loginPrefill]="loginPrefill" (signUp)="handleSignUp()" (useOauth)="handleUseOauth()"></tc-tibco-cloud-login>

./live-apps-login.component.css

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""