126 lines
3.3 KiB
TypeScript
126 lines
3.3 KiB
TypeScript
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()
|
|
}
|
|
}
|