src/app/shared/abort-modal/info-modal.component.ts

Implements

OnInit

Metadata

Relationships

Used by

Depends on

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(helperService: HelperService, eventService: EventService, sasService: SasService, router: Router)
Parameters :
Name Type Optional
helperService HelperService No
eventService EventService No
sasService SasService No
router Router No

Inputs

data
Type : InfoModal
Default value : new InfoModal()
forceReload
Type : boolean
Default value : false

Outputs

onConfirmModalClick
Type : EventEmitter<any>

Methods

closeAbortModal
closeAbortModal()
Returns : void
downloadLog
downloadLog()
Returns : void
ngOnInit
ngOnInit()
Returns : void
openConfigurator
openConfigurator()

Only on SAS9, opening a backend configurator/deploy page

Returns : void
openRequestsModal
openRequestsModal()
Returns : void
openServiceInNewWindow
openServiceInNewWindow()

Runs the startupservice in a new browser window so the SAS log is available even when the adapter response carried none (e.g. a Viya execution task that timed out).

Returns : void
reload
reload()
Returns : void
showConfiguratorButton
showConfiguratorButton(sasService: string | null)

Wheter or not to show the Open configurator button Button used for navigating to the configuration page Only for SAS9 Decision is made based on that service path

Parameters :
Name Type Optional Description
sasService string | null No

backend service that caused this info modal to be shown Decision is made based on that service path

Returns : any
showServiceLauncher
showServiceLauncher(sasService: string | null)

Whether to show the Show log button.

The startupservice failure modal is a dead end otherwise: the adapter returned no log, so the only way to see the backend reason is to run the service through the JES / STP web app in a browser tab. Offered on every server type - SAS 9, Viya and SASjs Server all accept the _program URL.

Parameters :
Name Type Optional
sasService string | null No
Returns : boolean

Properties

Public defaultData
Type : InfoModal
Default value : { modalTitle: 'Abort Message', sasService: null, message: '', details: new AbortDetails() }
Public modalEnabled
Type : boolean
Default value : true
import {
  Component,
  EventEmitter,
  Input,
  OnInit,
  Output,
  ViewEncapsulation
} from '@angular/core'
import { Router } from '@angular/router'
import { ServerType } from '@sasjs/utils/types/serverType'
import { EventService } from 'src/app/services/event.service'
import { HelperService } from 'src/app/services/helper.service'
import { SasService } from 'src/app/services/sas.service'
import { AbortDetails, InfoModal } from '../../models/InfoModal'

@Component({
  selector: 'app-info-modal',
  templateUrl: './info-modal.component.html',
  styleUrls: ['./info-modal.component.scss'],
  encapsulation: ViewEncapsulation.None,
  standalone: false
})
export class InfoModalComponent implements OnInit {
  @Output() onConfirmModalClick: EventEmitter<any> = new EventEmitter()
  @Input() data: InfoModal = new InfoModal()
  @Input() forceReload: boolean = false

  public modalEnabled: boolean = true

  public defaultData: InfoModal = {
    modalTitle: 'Abort Message',
    sasService: null,
    message: '',
    details: new AbortDetails()
  }

  constructor(
    private helperService: HelperService,
    private eventService: EventService,
    private sasService: SasService,
    private router: Router
  ) {}

  ngOnInit() {
    let newData: InfoModal = {
      ...this.defaultData,
      ...this.data
    }

    this.data = newData
  }

  /**
   * Wheter or not to show the `Open configurator button`
   * Button used for navigating to the `configuration` page
   * Only for SAS9
   * @param sasService backend service that caused this info modal to be shown
   * Decision is made based on that service path
   * @returns
   */
  showConfiguratorButton(sasService: string | null) {
    const sasjsConfig = this.sasService.getSasjsConfig()

    return (
      sasService?.includes('startupservice') &&
      sasjsConfig.serverType === ServerType.Sas9
    )
  }

  closeAbortModal() {
    this.onConfirmModalClick.emit()
  }

  /**
   * Whether to show the `Show log` button.
   *
   * The startupservice failure modal is a dead end otherwise: the adapter
   * returned no log, so the only way to see the backend reason is to run the
   * service through the JES / STP web app in a browser tab. Offered on every
   * server type - SAS 9, Viya and SASjs Server all accept the `_program` URL.
   */
  showServiceLauncher(sasService: string | null) {
    return !!sasService?.includes('startupservice')
  }

  /**
   * Runs the startupservice in a new browser window so the SAS log is
   * available even when the adapter response carried none (e.g. a Viya
   * execution task that timed out).
   */
  openServiceInNewWindow() {
    const sasjsConfig = this.sasService.getSasjsConfig()
    const params: { [name: string]: string } = {}

    if (sasjsConfig.contextName) {
      params['_contextname'] = sasjsConfig.contextName
    }

    this.sasService.openServiceInNewWindow(this.data.sasService || '', params)
  }

  /**
   * Only on SAS9, opening a backend configurator/deploy page
   */
  openConfigurator() {
    this.eventService.startupDataLoaded()
    this.router.navigateByUrl('/deploy')
    this.closeAbortModal()
  }

  downloadLog() {
    this.helperService.downloadTextFile(
      `${this.data.sasService}-LOG`,
      this.data.details?.LOG || 'Error parsing the log'
    )
  }

  openRequestsModal() {
    this.eventService.openRequestsModal()
  }

  reload() {
    location.reload()
  }
}
<clr-modal
  appDragNdrop
  [(clrModalOpen)]="modalEnabled"
  [clrModalSize]="'xl'"
  [clrModalClosable]="!forceReload"
  class="clr-abort-modal"
>
  <h3 class="modal-title">
    {{ data.modalTitle }}
    @if (data.sasService && data.sasService.length > 0) {
      <p class="sasService mt-0">
        SAS Service: <strong>{{ data.sasService }}</strong>
      </p>
    }
  </h3>
  <div class="modal-body">
    <div [innerHTML]="data.message" class="abortMsg"></div>

    @if (data.details !== null) {
      <div class="systext">
        <p>
          <strong>SYSWARNINGTEXT:</strong> {{ data.details.SYSWARNINGTEXT }}
        </p>
        <p><strong>SYSERRORTEXT:</strong> {{ data.details.SYSERRORTEXT }}</p>
        <p><strong>MAC:</strong> {{ data.details.MAC }}</p>
        <p><strong>_PROGRAM:</strong> {{ data.details._PROGRAM }}</p>
      </div>
    }
  </div>
  <div class="modal-footer">
    @if (showServiceLauncher(data.sasService)) {
      <button
        type="button"
        class="btn btn-primary"
        (click)="openServiceInNewWindow()"
      >
        Show log
      </button>
    }

    @if (showConfiguratorButton(data.sasService)) {
      <button
        type="button"
        class="btn btn-primary"
        (click)="openConfigurator()"
      >
        Open configurator
      </button>
    }

    @if (data.details !== null) {
      <button
        type="button"
        class="btn btn-primary"
        (click)="openRequestsModal()"
      >
        Open requests modal
      </button>
    }

    @if (data.details?.LOG && (data.details?.LOG?.trim())!.length > 0) {
      <button type="button" class="btn btn-primary" (click)="downloadLog()">
        Download log
      </button>
    }

    @if (!forceReload) {
      <button type="button" class="btn btn-primary" (click)="closeAbortModal()">
        Close
      </button>
    }

    @if (forceReload) {
      <button type="button" class="btn btn-primary" (click)="reload()">
        Reload
      </button>
    }
  </div>
</clr-modal>

./info-modal.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""