src/app/features/third-party-authentication/goto-third-party-system/goto-third-party-system.component.ts

Description

A simple button that allows the user to navigate to the external system through which that user session has been authenticated via the third-party-authentication API. (usually displayed in the main navigation menu)

Implements

OnInit

Example

Metadata

Relationships

Used by

Depends on

import {
  Component,
  inject,
  OnInit,
  ChangeDetectionStrategy,
} from "@angular/core";
import { Angulartics2Module } from "angulartics2";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
import { MatButton } from "@angular/material/button";
import { ThirdPartyAuthenticationService } from "../third-party-authentication.service";
import { Logging } from "../../../core/logging/logging.service";

/**
 * A simple button that allows the user to navigate to the external system
 * through which that user session has been authenticated via the
 * third-party-authentication API.
 * (usually displayed in the main navigation menu)
 */
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: "app-goto-third-party-system",
  imports: [Angulartics2Module, FaIconComponent, MatButton],
  templateUrl: "./goto-third-party-system.component.html",
  styleUrl: "./goto-third-party-system.component.scss",
})
export class GotoThirdPartySystemComponent implements OnInit {
  sessionId: string;

  private readonly thirdPartyAuthService = inject(
    ThirdPartyAuthenticationService,
  );

  ngOnInit() {
    this.sessionId = this.thirdPartyAuthService.getSessionId();
  }

  async goToExternalRedirect() {
    const redirectUrl = await this.thirdPartyAuthService.getRedirectUrl();
    if (!redirectUrl) {
      Logging.warn("TPA: unexpected undefined redirect URL");
      return;
    }

    window.open(redirectUrl, "_blank");
  }
}
@if (sessionId) {
  <button
    mat-flat-button
    class="nav-button"
    color="accent"
    angulartics2On="click"
    angularticsCategory="UserAction"
    angularticsAction="open_third_party_system"
    (click)="goToExternalRedirect()"
  >
    <fa-icon
      icon="up-right-from-square"
      class="standard-icon-with-text"
    ></fa-icon>
    <span i18n>Open M&E Module</span>
  </button>
}

./goto-third-party-system.component.scss


.nav-button {
  border-top: solid 1px rgba(0, 0, 0, 0.12);
  border-radius: 0;
  overflow: hidden;
  width: 100%;
  color: white;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""