diff --git a/api/public/swagger.yaml b/api/public/swagger.yaml index 83e67f2..18e34df 100644 --- a/api/public/swagger.yaml +++ b/api/public/swagger.yaml @@ -92,6 +92,16 @@ components: - clientSecret type: object additionalProperties: false + ExecuteSASCodePayload: + properties: + code: + type: string + description: 'Code of SAS program' + example: '* SAS Code HERE;' + required: + - code + type: object + additionalProperties: false MemberType.folder: enum: - folder @@ -358,16 +368,6 @@ components: - description type: object additionalProperties: false - RunSASPayload: - properties: - code: - type: string - description: 'Code of SAS program' - example: '* SAS Code HERE;' - required: - - code - type: object - additionalProperties: false ExecuteReturnJsonResponse: properties: status: @@ -511,6 +511,30 @@ paths: application/json: schema: $ref: '#/components/schemas/ClientPayload' + /SASjsApi/code/execute: + post: + operationId: ExecuteSASCode + responses: + '200': + description: Ok + content: + application/json: + schema: + type: string + description: 'Execute SAS code.' + summary: 'Run SAS Code and returns log' + tags: + - CODE + security: + - + bearerAuth: [] + parameters: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ExecuteSASCodePayload' /SASjsApi/drive/deploy: post: operationId: Deploy @@ -982,30 +1006,6 @@ paths: format: double type: number example: '6789' - /SASjsApi/run/code: - post: - operationId: RunSAS - responses: - '200': - description: Ok - content: - application/json: - schema: - type: string - description: 'Trigger a SAS program.' - summary: 'Run SAS Program, return raw content' - tags: - - RUN - security: - - - bearerAuth: [] - parameters: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/RunSASPayload' /SASjsApi/session: get: operationId: Session @@ -1107,5 +1107,5 @@ tags: name: STP description: 'Operations about STP' - - name: RUN - description: 'Execute SAS code' + name: CODE + description: 'Operations on SAS code' diff --git a/api/src/routes/api/code.ts b/api/src/routes/api/code.ts index ef4af95..fb751b5 100644 --- a/api/src/routes/api/code.ts +++ b/api/src/routes/api/code.ts @@ -6,7 +6,7 @@ const runRouter = express.Router() const controller = new CodeController() -runRouter.post('/code', async (req, res) => { +runRouter.post('/execute', async (req, res) => { const { error, value: body } = runSASValidation(req.body) if (error) return res.status(400).send(error.details[0].message) diff --git a/web/src/containers/Studio/index.tsx b/web/src/containers/Studio/index.tsx index 0e6d87a..bcb89d0 100644 --- a/web/src/containers/Studio/index.tsx +++ b/web/src/containers/Studio/index.tsx @@ -2,15 +2,32 @@ import React, { useEffect, useRef, useState } from 'react' import axios from 'axios' import Box from '@mui/material/Box' -import { Button, Paper, Stack, Toolbar } from '@mui/material' +import { Button, Paper, Stack, Tab, Toolbar } from '@mui/material' +import { makeStyles } from '@mui/styles' import Editor from '@monaco-editor/react' import { useLocation } from 'react-router-dom' +import { TabContext, TabList, TabPanel } from '@mui/lab' + +const useStyles = makeStyles(() => ({ + root: { + fontSize: '1rem', + color: 'gray', + '&.Mui-selected': { + color: 'black' + } + } +})) const Studio = () => { const location = useLocation() const [fileContent, setFileContent] = useState('') const [log, setLog] = useState('') + const [tab, setTab] = React.useState('1') + const handleTabChange = (_e: any, newValue: string) => { + setTab(newValue) + } + const editorRef = useRef(null) const handleEditorDidMount = (editor: any) => (editorRef.current = editor) @@ -26,15 +43,10 @@ const Studio = () => { const runCode = (code: string) => { axios - .post(`/SASjsApi/stp/run`, { code }) + .post(`/SASjsApi/code/execute`, { code }) .then((res: any) => { - const data = - typeof res.data === 'string' - ? res.data - : `
${JSON.stringify(res.data, null, 4)}`
-
- setLog(data)
- document?.getElementById('sas_log')?.scrollIntoView()
+ setLog(res.data)
+ setTab('2')
})
.catch((err) => console.log(err))
}
@@ -50,48 +62,61 @@ const Studio = () => {
.catch((err) => console.log(err))
}, [location.search])
+ const classes = useStyles()
return (
-