Added header control on generated apps

This commit is contained in:
frikky
2021-05-24 09:54:01 +02:00
parent 86836623cc
commit 08e159d4c2
7 changed files with 129 additions and 13 deletions
+8
View File
@@ -597,6 +597,14 @@ const ParsedAction = (props) => {
return null
}
if (selectedApp.generated && data.name === "headers") {
console.log("HEADER: ", data)
//if (data.value.length === 0) {
//}
//setSelectedActionParameters(selectedActionParameters)
}
if (selectedApp.generated && data.name === "body") {
const regex = /\${(\w+)}/g
const found = placeholder.match(regex)
+3 -3
View File
@@ -149,7 +149,7 @@ const Admin = (props) => {
response.json().then(responseJson => {
console.log("RESP: ", responseJson)
if (responseJson["success"] === false) {
alert.error("Failed stopping schedule")
alert.error("Failed deleting auth")
} else {
getAppAuthentication()
alert.success("Successfully deleted authentication!")
@@ -880,7 +880,7 @@ const Admin = (props) => {
.then((responseJson) => {
if (responseJson.success) {
//console.log(responseJson.data)
console.log(responseJson)
//console.log(responseJson)
setAuthentication(responseJson.data)
} else {
alert.error("Failed getting authentications")
@@ -1001,7 +1001,7 @@ const Admin = (props) => {
6: "categories",
}
const setConfig = (event, newValue) => {
console.log("Value: ", newValue)
//console.log("Value: ", newValue)
setCurTab(parseInt(newValue))
if (newValue === 1) {
+12 -6
View File
@@ -5664,13 +5664,17 @@ const AngularWorkflow = (props) => {
id="webhook_uri_field"
onClick={() => {
var copyText = document.getElementById("webhook_uri_field")
navigator.clipboard.writeText(copyText.value)
copyText.select()
copyText.setSelectionRange(0, 99999) /* For mobile devices */
if (copyText !== undefined && copyText !== null) {
navigator.clipboard.writeText(copyText.value)
copyText.select()
copyText.setSelectionRange(0, 99999) /* For mobile devices */
/* Copy the text inside the text field */
document.execCommand("copy")
alert.success("Copied Webhook URL")
/* Copy the text inside the text field */
document.execCommand("copy")
alert.success("Copied Webhook URL")
} else {
console.log("Couldn't find webhook URI field: ", copyText)
}
}}
InputProps={{
style:{
@@ -6848,6 +6852,8 @@ const AngularWorkflow = (props) => {
/* Copy the text inside the text field */
document.execCommand("copy")
alert.success("Copied data")
} else {
console.log("Failed to copy from "+elementName+": ", copyText)
}
}
+101 -2
View File
@@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/styles';
import {BrowserView, MobileView} from "react-device-detect";
import {Paper, Typography, FormControlLabel, Button, Divider, Select, MenuItem, FormControl, Switch, Dialog, DialogTitle, DialogContent, DialogActions, TextField, Tooltip, Breadcrumbs, CircularProgress, Chip} from '@material-ui/core';
import {CheckCircle as CheckCircleIcon, AttachFile as AttachFileIcon, Apps as AppsIcon, ErrorOutline as ErrorOutlineIcon} from '@material-ui/icons';
import {Add as AddIcon, CheckCircle as CheckCircleIcon, AttachFile as AttachFileIcon, Apps as AppsIcon, ErrorOutline as ErrorOutlineIcon} from '@material-ui/icons';
import {Link} from 'react-router-dom';
@@ -230,6 +230,12 @@ const AppCreator = (props) => {
const [extraBodyFields, setExtraBodyFields] = useState([])
const [fileUploadEnabled, setFileUploadEnabled] = useState(false)
const [actionAmount, setActionAmount] = useState(increaseAmount)
const defaultAuth = {
"name": "",
"type": "header",
"example": "hello",
}
const [extraAuth, setExtraAuth] = useState([defaultAuth])
//const [actions, setActions] = useState([{
// "name": "Get workflows",
@@ -1413,6 +1419,98 @@ const AppCreator = (props) => {
//console.log("Option: ", authenticationOption)
//console.log("Location: ", parameterLocation)
//console.log("Name: ", parameterName)
const extraKeys =
<div style={{marginTop: 25}}>
{extraAuth.map((value, index) => {
return (
<span style={{display: "flex"}}>
<TextField
required
style={{height: 50, flex: 2, backgroundColor: inputColor, marginRight: 5, }}
fullWidth={true}
placeholder="Name"
id="standard-required"
margin="normal"
variant="outlined"
defaultValue={extraAuth[index].name}
onChange={e => {
extraAuth[index].name = e.target.value
setExtraAuth(extraAuth)
}}
InputProps={{
//classes: {
// notchedOutline: classes.notchedOutline,
//},
style:{
color: "white",
minHeight: 50,
marginLeft: 5,
maxWidth: "95%",
fontSize: "1em",
},
}}
/>
<TextField
required
style={{height: 50, flex: 2, backgroundColor: inputColor, marginRight: 5,}}
fullWidth={true}
placeholder="Field Name (not token)"
type="name"
id="standard-required"
margin="normal"
variant="outlined"
defaultValue={extraAuth[index].example}
onChange={e => {
extraAuth[index].example = e.target.value
setExtraAuth(extraAuth)
}}
InputProps={{
style:{
color: "white",
minHeight: 50,
marginLeft: 5,
maxWidth: "95%",
fontSize: "1em",
},
}}
/>
<Select
fullWidth
onChange={(e) => {
//console.log(e.target.value)
//setParameterLocation(e.target.value)
extraAuth[index].type = e.target.value
setExtraAuth(extraAuth)
}}
value={extraAuth[index].type}
style={{flex: 1, backgroundColor: inputColor, paddingLeft: "10px", color: "white", height: 50, borderRadius: 5, }}
inputProps={{
name: 'age',
id: 'outlined-age-simple',
}}
>
<MenuItem key={index} style={{backgroundColor: inputColor, color: "white"}} value={"header"}>
Header
</MenuItem>
<MenuItem key={index} style={{backgroundColor: inputColor, color: "white"}} value={"query"}>
Query
</MenuItem>
</Select>
{index === extraAuth.length-1 ?
<Button color="primary" style={{maxWidth: 50, }} variant="contained" onClick={() => {
console.log("ADD NEW!")
extraAuth.push(defaultAuth)
setExtraAuth(extraAuth)
setUpdate(Math.random())
}}>
<AddIcon style={{}}/>
</Button>
: <span style={{width: 50, }}/>}
</span>
)
})}
</div>
const apiKey = authenticationOption === "API key" ?
<div style={{color: "white", marginTop: 20, }}>
<Typography variant="body1">API key authentication</Typography>
@@ -1447,7 +1545,7 @@ const AppCreator = (props) => {
setParameterLocation(e.target.value)
}}
value={parameterLocation}
style={{backgroundColor: inputColor, paddingLeft: "10px", color: "white", height: "50px"}}
style={{borderRadius: 5, backgroundColor: inputColor, paddingLeft: "10px", color: "white", height: "50px"}}
inputProps={{
name: 'age',
id: 'outlined-age-simple',
@@ -2628,6 +2726,7 @@ const AppCreator = (props) => {
{basicAuth}
{bearerAuth}
{apiKey}
{extraKeys}
{/*authenticationOption === "No authentication" ? null :
<FormControlLabel