1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 19:44:35 +00:00

feat(editor): parse print output in response payload

This commit is contained in:
Yury Shkoda
2023-05-01 08:18:49 +03:00
parent d2de9dc13e
commit eb42683fff

View File

@@ -39,14 +39,14 @@ const useEditor = ({
const { Snackbar, setOpenSnackbar, setSnackbarMessage, setSnackbarSeverity } = const { Snackbar, setOpenSnackbar, setSnackbarMessage, setSnackbarSeverity } =
useSnackbar() useSnackbar()
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)
const [prevFileContent, setPrevFileContent] = useStateWithCallback('') const [prevFileContent, setPrevFileContent] = useStateWithCallback('')
const [fileContent, setFileContent] = useState('') const [fileContent, setFileContent] = useState('')
const [log, setLog] = useState<LogObject | string>() const [log, setLog] = useState<LogObject | string>()
const [webout, setWebout] = useState('') const [webout, setWebout] = useState<string>()
const [printOutput, setPrintOutput] = useState<string>()
const [runTimes, setRunTimes] = useState<string[]>([]) const [runTimes, setRunTimes] = useState<string[]>([])
const [selectedRunTime, setSelectedRunTime] = useState<RunTimeType | string>( const [selectedRunTime, setSelectedRunTime] = useState<RunTimeType>(
'' RunTimeType.SAS
) )
const [selectedFileExtension, setSelectedFileExtension] = useState('') const [selectedFileExtension, setSelectedFileExtension] = useState('')
const [openFilePathInputModal, setOpenFilePathInputModal] = useState(false) const [openFilePathInputModal, setOpenFilePathInputModal] = useState(false)
@@ -169,25 +169,29 @@ const useEditor = ({
), ),
runTime: selectedRunTime runTime: selectedRunTime
}) })
.then((res: any) => { .then((res: { data: string }) => {
if (selectedRunTime === RunTimeType.SAS) { const resDataSplitted = res.data.split(SASJS_LOGS_SEPARATOR)
const { errors, warnings, logLines } = parseErrorsAndWarnings( const webout = resDataSplitted[0]
res.data.split(SASJS_LOGS_SEPARATOR)[1] const log = resDataSplitted[1]
) const printOutput = resDataSplitted[2]
const log: LogObject = { if (selectedRunTime === RunTimeType.SAS) {
const { errors, warnings, logLines } = parseErrorsAndWarnings(log)
const logObject: LogObject = {
body: logLines.join(`\n`), body: logLines.join(`\n`),
errors, errors,
warnings, warnings,
linesCount: logLines.length linesCount: logLines.length
} }
setLog(log) setLog(logObject)
} else { } else {
setLog(res.data.split(SASJS_LOGS_SEPARATOR)[1] ?? '') setLog(log)
} }
setWebout(res.data.split(SASJS_LOGS_SEPARATOR)[0] ?? '') setWebout(webout)
setPrintOutput(printOutput)
setTab('log') setTab('log')
// Scroll to bottom of log // Scroll to bottom of log
@@ -335,6 +339,7 @@ const useEditor = ({
selectedRunTime, selectedRunTime,
showDiff, showDiff,
webout, webout,
printOutput,
Dialog, Dialog,
handleChangeRunTime, handleChangeRunTime,
handleDiffEditorDidMount, handleDiffEditorDidMount,