mirror of
https://github.com/sasjs/server.git
synced 2025-12-12 20:04:36 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
505f2089c7 | ||
|
|
3344c400a8 | ||
| fa6248e3ef | |||
| 9fb5f1f8e7 | |||
|
|
92e0b8a088 | ||
|
|
b484306ed8 | ||
| 5e08aacc51 | |||
| a9e4eb685d | |||
| 31b09f27cc | |||
| 9f3ec92f8e | |||
| 6c9e449614 | |||
| 68e84b0994 | |||
| f0bb51a0d5 | |||
| b93a0da3a3 | |||
|
|
e5facbf54c | ||
|
|
cb2bebbe76 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.0.52](https://github.com/sasjs/server/compare/v0.0.51...v0.0.52) (2022-04-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add api for getting server info ([9fb5f1f](https://github.com/sasjs/server/commit/9fb5f1f8e7d4e2d767cc1ff7285c99514834cf32))
|
||||||
|
|
||||||
|
### [0.0.51](https://github.com/sasjs/server/compare/v0.0.50...v0.0.51) (2022-04-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* run button running man, sub menu added ([68e84b0](https://github.com/sasjs/server/commit/68e84b0994a3fa6ff56b07635c637c6e3a57bfda))
|
||||||
|
* running code with CTRL+ENTER ([b93a0da](https://github.com/sasjs/server/commit/b93a0da3a380926c87548b69309b2d0c1b7e617f))
|
||||||
|
|
||||||
### [0.0.50](https://github.com/sasjs/server/compare/v0.0.49...v0.0.50) (2022-04-07)
|
### [0.0.50](https://github.com/sasjs/server/compare/v0.0.49...v0.0.50) (2022-04-07)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -52,6 +52,7 @@ Example contents of a `.env` file:
|
|||||||
MODE=
|
MODE=
|
||||||
|
|
||||||
# options: [disable|enable] default: `disable` for `server` & `enable` for `desktop`
|
# options: [disable|enable] default: `disable` for `server` & `enable` for `desktop`
|
||||||
|
# If enabled, be sure to also configure the WHITELIST of third party servers.
|
||||||
CORS=
|
CORS=
|
||||||
|
|
||||||
# options: <http://localhost:3000 https://abc.com ...> space separated urls
|
# options: <http://localhost:3000 https://abc.com ...> space separated urls
|
||||||
@@ -84,6 +85,15 @@ ACCESS_TOKEN_SECRET=<secret>
|
|||||||
REFRESH_TOKEN_SECRET=<secret>
|
REFRESH_TOKEN_SECRET=<secret>
|
||||||
AUTH_CODE_SECRET=<secret>
|
AUTH_CODE_SECRET=<secret>
|
||||||
DB_CONNECT=mongodb+srv://<DB_USERNAME>:<DB_PASSWORD>@<CLUSTER>/<DB_NAME>?retryWrites=true&w=majority
|
DB_CONNECT=mongodb+srv://<DB_USERNAME>:<DB_PASSWORD>@<CLUSTER>/<DB_NAME>?retryWrites=true&w=majority
|
||||||
|
|
||||||
|
# SAS Options
|
||||||
|
# On windows use SAS_OPTIONS and on unix use SASV9_OPTIONS
|
||||||
|
# Any options set here are automatically applied in the SAS session
|
||||||
|
# See: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostunx/p0wrdmqp8k0oyyn1xbx3bp3qy2wl.htm
|
||||||
|
# And: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostwin/p0drw76qo0gig2n1kcoliekh605k.htm#p09y7hx0grw1gin1giuvrjyx61m6
|
||||||
|
SAS_OPTIONS= -NOXCMD
|
||||||
|
SASV9_OPTIONS= -NOXCMD
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Persisting the Session
|
## Persisting the Session
|
||||||
|
|||||||
@@ -418,6 +418,25 @@ components:
|
|||||||
example: /Public/somefolder/some.file
|
example: /Public/somefolder/some.file
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
InfoResponse:
|
||||||
|
properties:
|
||||||
|
mode:
|
||||||
|
type: string
|
||||||
|
cors:
|
||||||
|
type: string
|
||||||
|
whiteList:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
protocol:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- mode
|
||||||
|
- cors
|
||||||
|
- whiteList
|
||||||
|
- protocol
|
||||||
|
type: object
|
||||||
|
additionalProperties: false
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
bearerAuth:
|
bearerAuth:
|
||||||
type: http
|
type: http
|
||||||
@@ -1240,10 +1259,31 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/ExecuteReturnJsonPayload'
|
$ref: '#/components/schemas/ExecuteReturnJsonPayload'
|
||||||
|
/SASjsApi/info:
|
||||||
|
get:
|
||||||
|
operationId: Info
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Ok
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/InfoResponse'
|
||||||
|
examples:
|
||||||
|
'Example 1':
|
||||||
|
value: {mode: desktop, cors: enable, whiteList: ['http://example.com', 'http://example2.com'], protocol: http}
|
||||||
|
summary: 'Get server info (mode, cors, whiteList, protocol).'
|
||||||
|
tags:
|
||||||
|
- Info
|
||||||
|
security: []
|
||||||
|
parameters: []
|
||||||
servers:
|
servers:
|
||||||
-
|
-
|
||||||
url: /
|
url: /
|
||||||
tags:
|
tags:
|
||||||
|
-
|
||||||
|
name: Info
|
||||||
|
description: 'Get Server Info'
|
||||||
-
|
-
|
||||||
name: Session
|
name: Session
|
||||||
description: 'Get Session information'
|
description: 'Get Session information'
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ export * from './group'
|
|||||||
export * from './session'
|
export * from './session'
|
||||||
export * from './stp'
|
export * from './stp'
|
||||||
export * from './user'
|
export * from './user'
|
||||||
|
export * from './info'
|
||||||
|
|||||||
37
api/src/controllers/info.ts
Normal file
37
api/src/controllers/info.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import { Request, Security, Route, Tags, Example, Get } from 'tsoa'
|
||||||
|
|
||||||
|
export interface InfoResponse {
|
||||||
|
mode: string
|
||||||
|
cors: string
|
||||||
|
whiteList: string[]
|
||||||
|
protocol: string
|
||||||
|
}
|
||||||
|
|
||||||
|
@Route('SASjsApi/info')
|
||||||
|
@Tags('Info')
|
||||||
|
export class InfoController {
|
||||||
|
/**
|
||||||
|
* @summary Get server info (mode, cors, whiteList, protocol).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Example<InfoResponse>({
|
||||||
|
mode: 'desktop',
|
||||||
|
cors: 'enable',
|
||||||
|
whiteList: ['http://example.com', 'http://example2.com'],
|
||||||
|
protocol: 'http'
|
||||||
|
})
|
||||||
|
@Get('/')
|
||||||
|
public info(): InfoResponse {
|
||||||
|
const response = {
|
||||||
|
mode: process.env.MODE ?? 'desktop',
|
||||||
|
cors:
|
||||||
|
process.env.CORS ?? process.env.MODE === 'server'
|
||||||
|
? 'disable'
|
||||||
|
: 'enable',
|
||||||
|
whiteList: process.env.WHITELIST?.split(' ') ?? [],
|
||||||
|
protocol: process.env.PROTOCOL ?? 'http'
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
verifyAdmin
|
verifyAdmin
|
||||||
} from '../../middlewares'
|
} from '../../middlewares'
|
||||||
|
|
||||||
|
import infoRouter from './info'
|
||||||
import driveRouter from './drive'
|
import driveRouter from './drive'
|
||||||
import stpRouter from './stp'
|
import stpRouter from './stp'
|
||||||
import codeRouter from './code'
|
import codeRouter from './code'
|
||||||
@@ -20,6 +21,7 @@ import sessionRouter from './session'
|
|||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
|
router.use('/info', infoRouter)
|
||||||
router.use('/session', desktopUsername, authenticateAccessToken, sessionRouter)
|
router.use('/session', desktopUsername, authenticateAccessToken, sessionRouter)
|
||||||
router.use('/auth', desktopRestrict, authRouter)
|
router.use('/auth', desktopRestrict, authRouter)
|
||||||
router.use(
|
router.use(
|
||||||
|
|||||||
16
api/src/routes/api/info.ts
Normal file
16
api/src/routes/api/info.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import { InfoController } from '../../controllers'
|
||||||
|
|
||||||
|
const infoRouter = express.Router()
|
||||||
|
|
||||||
|
infoRouter.get('/', async (req, res) => {
|
||||||
|
const controller = new InfoController()
|
||||||
|
try {
|
||||||
|
const response = controller.info()
|
||||||
|
res.send(response)
|
||||||
|
} catch (err: any) {
|
||||||
|
res.status(403).send(err.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default infoRouter
|
||||||
14
api/src/routes/api/spec/info.spec.ts
Normal file
14
api/src/routes/api/spec/info.spec.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Express } from 'express'
|
||||||
|
import request from 'supertest'
|
||||||
|
import appPromise from '../../../app'
|
||||||
|
|
||||||
|
let app: Express
|
||||||
|
|
||||||
|
describe('Info', () => {
|
||||||
|
it('should should return configured information of the server instance', async () => {
|
||||||
|
await appPromise.then((_app) => {
|
||||||
|
app = _app
|
||||||
|
})
|
||||||
|
request(app).get('/SASjsApi/info').expect(200)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "Info",
|
||||||
|
"description": "Get Server Info"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Session",
|
"name": "Session",
|
||||||
"description": "Get Session information"
|
"description": "Get Session information"
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.50",
|
"version": "0.0.52",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.50",
|
"version": "0.0.52",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^2.3.1",
|
"prettier": "^2.3.1",
|
||||||
"standard-version": "^9.3.2"
|
"standard-version": "^9.3.2"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.0.50",
|
"version": "0.0.52",
|
||||||
"description": "NodeJS wrapper for calling the SAS binary executable",
|
"description": "NodeJS wrapper for calling the SAS binary executable",
|
||||||
"repository": "https://github.com/sasjs/server",
|
"repository": "https://github.com/sasjs/server",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
BIN
web/public/running-sas.png
Normal file
BIN
web/public/running-sas.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -28,10 +28,10 @@ const Header = (props: any) => {
|
|||||||
>
|
>
|
||||||
<Toolbar variant="dense">
|
<Toolbar variant="dense">
|
||||||
<img
|
<img
|
||||||
src="logo-white.png"
|
src="logo.png"
|
||||||
alt="logo"
|
alt="logo"
|
||||||
style={{
|
style={{
|
||||||
width: '50px',
|
width: '35px',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
marginRight: '25px'
|
marginRight: '25px'
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -15,6 +15,17 @@ const useStyles = makeStyles(() => ({
|
|||||||
'&.Mui-selected': {
|
'&.Mui-selected': {
|
||||||
color: 'black'
|
color: 'black'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
subMenu: {
|
||||||
|
marginTop: '25px',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center'
|
||||||
|
},
|
||||||
|
runButton: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
padding: '5px 5px',
|
||||||
|
minWidth: 'unset'
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -22,8 +33,10 @@ const Studio = () => {
|
|||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const [fileContent, setFileContent] = useState('')
|
const [fileContent, setFileContent] = useState('')
|
||||||
const [log, setLog] = useState('')
|
const [log, setLog] = useState('')
|
||||||
|
const [ctrlPressed, setCtrlPressed] = useState(false)
|
||||||
const [webout, setWebout] = useState('')
|
const [webout, setWebout] = useState('')
|
||||||
const [tab, setTab] = React.useState('1')
|
const [tab, setTab] = React.useState('1')
|
||||||
|
|
||||||
const handleTabChange = (_e: any, newValue: string) => {
|
const handleTabChange = (_e: any, newValue: string) => {
|
||||||
setTab(newValue)
|
setTab(newValue)
|
||||||
}
|
}
|
||||||
@@ -61,6 +74,21 @@ const Studio = () => {
|
|||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleKeyDown = (event: any) => {
|
||||||
|
if (event.ctrlKey) {
|
||||||
|
if (event.key === 'v') {
|
||||||
|
setCtrlPressed(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === 'Enter') runCode(getSelection() || fileContent)
|
||||||
|
if (!ctrlPressed) setCtrlPressed(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleKeyUp = (event: any) => {
|
||||||
|
if (!event.ctrlKey && ctrlPressed) setCtrlPressed(false)
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const content = localStorage.getItem('fileContent') ?? ''
|
const content = localStorage.getItem('fileContent') ?? ''
|
||||||
setFileContent(content)
|
setFileContent(content)
|
||||||
@@ -86,7 +114,11 @@ const Studio = () => {
|
|||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: '100%', typography: 'body1', marginTop: '50px' }}>
|
<Box
|
||||||
|
onKeyUp={handleKeyUp}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
sx={{ width: '100%', typography: 'body1', marginTop: '50px' }}
|
||||||
|
>
|
||||||
<TabContext value={tab}>
|
<TabContext value={tab}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -103,12 +135,24 @@ const Studio = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TabList>
|
</TabList>
|
||||||
</Box>
|
</Box>
|
||||||
<TabPanel value="1">
|
|
||||||
|
<TabPanel style={{ paddingBottom: 0 }} value="1">
|
||||||
|
<div className={classes.subMenu}>
|
||||||
|
<Tooltip title="CTRL+ENTER will also run SAS code">
|
||||||
|
<Button onClick={handleRunBtnClick} className={classes.runButton}>
|
||||||
|
<img
|
||||||
|
draggable="false"
|
||||||
|
style={{ width: '25px' }}
|
||||||
|
src="/running-sas.png"
|
||||||
|
></img>
|
||||||
|
<span style={{ fontSize: '12px' }}>RUN</span>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
{/* <Toolbar /> */}
|
{/* <Toolbar /> */}
|
||||||
<Paper
|
<Paper
|
||||||
sx={{
|
sx={{
|
||||||
height: '70vh',
|
height: 'calc(100vh - 170px)',
|
||||||
marginTop: '50px',
|
|
||||||
padding: '10px',
|
padding: '10px',
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
position: 'relative'
|
position: 'relative'
|
||||||
@@ -116,23 +160,27 @@ const Studio = () => {
|
|||||||
elevation={3}
|
elevation={3}
|
||||||
>
|
>
|
||||||
<Editor
|
<Editor
|
||||||
height="95%"
|
height="98%"
|
||||||
value={fileContent}
|
value={fileContent}
|
||||||
onMount={handleEditorDidMount}
|
onMount={handleEditorDidMount}
|
||||||
|
options={{ readOnly: ctrlPressed }}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
if (val) setFileContent(val)
|
if (val) setFileContent(val)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: -10,
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: '13px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Press CTRL + ENTER to run SAS code
|
||||||
|
</p>
|
||||||
</Paper>
|
</Paper>
|
||||||
<Stack
|
|
||||||
spacing={3}
|
|
||||||
direction="row"
|
|
||||||
sx={{ justifyContent: 'center', marginTop: '20px' }}
|
|
||||||
>
|
|
||||||
<Button variant="contained" onClick={handleRunBtnClick}>
|
|
||||||
Run SAS Code
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel value="2">
|
<TabPanel value="2">
|
||||||
<div style={{ marginTop: '50px' }}>
|
<div style={{ marginTop: '50px' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user