Add scenarioName to run scenario actions and logs
Pass scenarioName from frontend to backend when running scenarios, and include it in log titles, email subjects, and Zulip messages. Also, expand command matching in template utilities and update default '[ENTER]' handling in line_connection. Minor logging improvements included.
This commit is contained in:
parent
76659b3e68
commit
7528da2f00
|
|
@ -494,9 +494,9 @@ export default class LineConnection {
|
|||
}
|
||||
|
||||
if (typeof step.send !== 'undefined') {
|
||||
this.outputScenario += `\n---send-command---"${(step?.send ?? '').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n`
|
||||
this.outputScenario += `\n---send-command---"${(step?.send ?? '[ENTER]').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n`
|
||||
appendLog(
|
||||
`\n---send-command---"${(step?.send ?? '').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n`,
|
||||
`\n---send-command---"${(step?.send ?? '[ENTER]').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n`,
|
||||
this.config.stationId,
|
||||
this.config.stationName,
|
||||
this.config.stationIp,
|
||||
|
|
@ -578,7 +578,7 @@ export default class LineConnection {
|
|||
|
||||
waitForExpect = async (expect: string, timeout = 60000) => {
|
||||
const start = Date.now()
|
||||
console.log('[EXPECT]', expect, timeout)
|
||||
// console.log('[EXPECT]', expect, timeout)
|
||||
while (Date.now() - start < timeout) {
|
||||
if (this.outputBuffer.includes(expect)) {
|
||||
this.outputBuffer = ''
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@ function getStructuredDataTextfsm(output: string, command: string) {
|
|||
case 'sh ver':
|
||||
return showVersion(output)
|
||||
case 'show license':
|
||||
case 'show lic':
|
||||
case 'sh license':
|
||||
case 'sh lic':
|
||||
return showLicense(output)
|
||||
case 'show logging':
|
||||
case 'show log':
|
||||
case 'sh logging':
|
||||
case 'sh log':
|
||||
return showLogging(output)
|
||||
default:
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -558,9 +558,10 @@ export class WebSocketIo {
|
|||
const lineIds = data.lineIds
|
||||
const stationName = data.stationName || ''
|
||||
const stationId = data.stationId || ''
|
||||
const scenarioName = data.scenarioName || ''
|
||||
const station = await Station.find(stationId)
|
||||
// Check station sendWiki flag
|
||||
console.log('[DPELP] Received run all dpelp', station?.send_wiki)
|
||||
console.log('[DPELP] Received run all dpelp', lineIds)
|
||||
if (!station || !station?.send_wiki) return
|
||||
|
||||
const results = await this.waitUntilAllReady(lineIds)
|
||||
|
|
@ -574,11 +575,11 @@ export class WebSocketIo {
|
|||
process.env.LINK_WIKI || 'https://logs.danielvu.com/api/wiki/page/insert?title=Dev_test'
|
||||
await axios.post(linkWiki, {
|
||||
data: tableHTML,
|
||||
titleAuto: `[DPELP] - ${stationName} - ` + dataFormat,
|
||||
titleAuto: `[${scenarioName || 'DPELP'}] - ${stationName} - ` + dataFormat,
|
||||
})
|
||||
await sendMessageToMail(
|
||||
'andrew.ng@apactech.io',
|
||||
`[DPELP] - ${stationName} - ${dataFormat}`,
|
||||
`[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}`,
|
||||
tableHTML,
|
||||
['ips@ipsupply.com.au', 'kay@ipsupply.com.au', 'joseph@apactech.io']
|
||||
)
|
||||
|
|
@ -586,7 +587,8 @@ export class WebSocketIo {
|
|||
'stream',
|
||||
'ATC_Report',
|
||||
station.name,
|
||||
`\n\n---\n**[DPELP] - ${stationName} - ${dataFormat}**\n\n` + zulipMess
|
||||
`\n\n---\n**[${scenarioName || 'DPELP'}] - ${stationName} - ${dataFormat}**\n\n` +
|
||||
zulipMess
|
||||
)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
|
|
|||
|
|
@ -233,6 +233,7 @@ export const ButtonScenario = ({
|
|||
lineIds: selectedLines?.map((el) => el.id),
|
||||
stationName: station?.name,
|
||||
stationId: Number(station?.id),
|
||||
scenarioName: scenario.title,
|
||||
});
|
||||
selectedLines?.forEach((el) => {
|
||||
socket?.emit(
|
||||
|
|
|
|||
|
|
@ -496,6 +496,7 @@ const ModalRunScenario = ({
|
|||
lineIds: selectedLines?.map((el) => el.id),
|
||||
stationName: station.name,
|
||||
stationId: Number(station.id),
|
||||
scenarioName: scenario.title,
|
||||
});
|
||||
|
||||
selectedLines
|
||||
|
|
|
|||
Loading…
Reference in New Issue