fix(viya deploy): run makedata in new window to ensure logs are available for the user
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 4m12s
Build / Build-and-test-development (pull_request) Successful in 8m42s

This commit is contained in:
Mihajlo Medjedovic
2025-06-17 15:33:11 +02:00
parent 519d8953b5
commit 0b4042af60

View File

@ -78,6 +78,17 @@ export class AutomaticComponent implements OnInit {
runMakeData: null runMakeData: null
} }
public sasjsConfig = this.sasService.getSasjsConfig()
/**
* makedata service will be run in a new window
* This is needed to ensure that the user can see the logs
* and the progress of the service execution.
* If this is set to `false`, the service will be run in the same window
* using the adapter request method.
*/
public deployInNewWindow: boolean = true
constructor( constructor(
private eventService: EventService, private eventService: EventService,
private deployService: DeployService, private deployService: DeployService,
@ -246,7 +257,7 @@ export class AutomaticComponent implements OnInit {
} }
public async runAutoDeploy(executeJson: boolean = false) { public async runAutoDeploy(executeJson: boolean = false) {
this.autodeploying = true if (!this.deployInNewWindow) this.autodeploying = true
if (executeJson) { if (executeJson) {
this.executeJson() this.executeJson()
@ -255,7 +266,7 @@ export class AutomaticComponent implements OnInit {
if (this.recreateDatabase) { if (this.recreateDatabase) {
this.createDatabase() this.createDatabase()
} else { } else {
this.autodeployDone = true if (!this.deployInNewWindow) this.autodeployDone = true
} }
} }
@ -296,51 +307,74 @@ export class AutomaticComponent implements OnInit {
debug: true debug: true
} }
this.sasJs if (this.deployInNewWindow) {
.request(`services/admin/makedata`, data, overrideConfig, () => { this.runMakedataInNewWindow(selectedComputeContextName)
this.sasService.shouldLogin.next(true) } else {
}) this.sasJs
.then((res: any) => { .request(`services/admin/makedata`, data, overrideConfig, () => {
this.autodeployDone = true this.sasService.shouldLogin.next(true)
})
.then((res: any) => {
this.autodeployDone = true
try { try {
this.makeDataResponse = JSON.stringify(res) this.makeDataResponse = JSON.stringify(res)
} catch { } catch {
this.makeDataResponse = res this.makeDataResponse = res
} }
if (res.result && res.result.length > 0) { if (res.result && res.result.length > 0) {
this.autoDeployStatus.runMakeData = true this.autoDeployStatus.runMakeData = true
} else { } else {
this.autoDeployStatus.runMakeData = false
}
if (typeof res.sasjsAbort !== 'undefined') {
const abortRes = res
const abortMsg = abortRes.sasjsAbort[0].MSG
const macMsg = abortRes.sasjsAbort[0].MAC
this.eventService.showAbortModal('makedata', abortMsg, {
SYSWARNINGTEXT: abortRes.SYSWARNINGTEXT,
SYSERRORTEXT: abortRes.SYSERRORTEXT,
MAC: macMsg
})
}
if (this.helperService.isStreamingViya())
this.updateIndexHtmlComputeContext()
})
.catch((err: any) => {
this.eventService.showAbortModal('makedata', JSON.stringify(err))
this.autoDeployStatus.runMakeData = false this.autoDeployStatus.runMakeData = false
} this.autodeployDone = true
if (typeof res.sasjsAbort !== 'undefined') { try {
const abortRes = res this.makeDataResponse = JSON.stringify(err)
const abortMsg = abortRes.sasjsAbort[0].MSG } catch {
const macMsg = abortRes.sasjsAbort[0].MAC this.makeDataResponse = err
}
})
}
}
this.eventService.showAbortModal('makedata', abortMsg, { public runMakedataInNewWindow(contextName: string) {
SYSWARNINGTEXT: abortRes.SYSWARNINGTEXT, let serverUrl = this.sasjsConfig.serverUrl
SYSERRORTEXT: abortRes.SYSERRORTEXT, let appLoc = this.sasjsConfig.appLoc
MAC: macMsg const execPath = this.sasService.getExecutionPath()
}) let contextname = `&_contextname=${contextName}`
} let debug = `&_debug=131`
if (this.helperService.isStreamingViya()) let programUrl =
this.updateIndexHtmlComputeContext() serverUrl +
}) execPath +
.catch((err: any) => { '/?_program=' +
this.eventService.showAbortModal('makedata', JSON.stringify(err)) appLoc +
this.autoDeployStatus.runMakeData = false '/services/admin/makedata' +
this.autodeployDone = true contextname +
debug
try { window.open(programUrl)
this.makeDataResponse = JSON.stringify(err)
} catch {
this.makeDataResponse = err
}
})
} }
/** /**