Major fixes to app creator
This commit is contained in:
@@ -270,7 +270,7 @@ class AppBase:
|
||||
except TypeError:
|
||||
return data
|
||||
|
||||
print("Running %s" % data)
|
||||
#print("Running %s" % data)
|
||||
|
||||
# Look for the INNER wrapper first, then move out
|
||||
wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length"]
|
||||
@@ -337,7 +337,7 @@ class AppBase:
|
||||
if len(newstring) > 0:
|
||||
newdata.append(newstring)
|
||||
|
||||
print(newdata)
|
||||
#print(newdata)
|
||||
parsedlist = []
|
||||
non_string = False
|
||||
for item in newdata:
|
||||
@@ -352,7 +352,7 @@ class AppBase:
|
||||
elif len(parsedlist) == 1 and non_string:
|
||||
return parsedlist[0]
|
||||
else:
|
||||
print("Casting back to string because multi: ", parsedlist)
|
||||
#print("Casting back to string because multi: ", parsedlist)
|
||||
newlist = []
|
||||
for item in parsedlist:
|
||||
try:
|
||||
@@ -870,7 +870,7 @@ class AppBase:
|
||||
if not multiexecution:
|
||||
print("APP_SDK DONE: Starting normal execution of function")
|
||||
newres = await func(**params)
|
||||
print("NEWRES: ", newres)
|
||||
#print("NEWRES: ", newres)
|
||||
if isinstance(newres, str):
|
||||
result += newres
|
||||
else:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
NAME=app_sdk
|
||||
VERSION=0.6.1
|
||||
VERSION=0.6.2
|
||||
|
||||
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
|
||||
docker build . -t frikky/shuffle:$NAME -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/app_sdk:0.6.0
|
||||
docker build . -t frikky/shuffle:$NAME -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
|
||||
|
||||
#docker push frikky/$NAME:$VERSION
|
||||
#docker push docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION
|
||||
|
||||
+106
-9
@@ -253,9 +253,13 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
||||
parameterData := ""
|
||||
if len(optionalQueries) > 0 {
|
||||
queryString += ", "
|
||||
for _, query := range optionalQueries {
|
||||
for index, query := range optionalQueries {
|
||||
// Check if it's a part of the URL already
|
||||
queryString += fmt.Sprintf("%s=\"\", ", query)
|
||||
queryString += fmt.Sprintf("%s=\"\"", query)
|
||||
if index != len(optionalQueries)-1 {
|
||||
queryString += ", "
|
||||
}
|
||||
|
||||
queryData += fmt.Sprintf(`
|
||||
if %s:
|
||||
url += f"&%s={%s}"`, query, query, query)
|
||||
@@ -274,8 +278,8 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
||||
authenticationParameter = ", apikey"
|
||||
authenticationSetup = "if apikey != \" \": headers[\"Authorization\"] = f\"Bearer {apikey}\""
|
||||
} else if swagger.Components.SecuritySchemes["BasicAuth"] != nil {
|
||||
authenticationParameter = ", username, password"
|
||||
authenticationAddin = ", auth=(username, password)"
|
||||
authenticationParameter = ", username_basic, password_basic"
|
||||
authenticationAddin = ", auth=(username_basic, password_basic)"
|
||||
} else if swagger.Components.SecuritySchemes["ApiKeyAuth"] != nil {
|
||||
authenticationParameter = ", apikey"
|
||||
if swagger.Components.SecuritySchemes["ApiKeyAuth"].Value.In == "header" {
|
||||
@@ -401,6 +405,11 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
||||
verifyAddin,
|
||||
)
|
||||
|
||||
if strings.Contains(functionname, "get_returns_the_vuln") {
|
||||
log.Println(data)
|
||||
log.Printf("Queries: %s", queryString)
|
||||
}
|
||||
|
||||
//log.Printf(data)
|
||||
return functionname, data
|
||||
}
|
||||
@@ -553,7 +562,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
||||
})
|
||||
} else if securitySchemes["BasicAuth"] != nil {
|
||||
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||
Name: "username",
|
||||
Name: "username_auth",
|
||||
Value: "",
|
||||
Example: "username",
|
||||
Description: securitySchemes["BasicAuth"].Value.Description,
|
||||
@@ -565,7 +574,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
||||
})
|
||||
|
||||
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||
Name: "password",
|
||||
Name: "password_auth",
|
||||
Value: "",
|
||||
Example: "*****",
|
||||
Description: securitySchemes["BasicAuth"].Value.Description,
|
||||
@@ -577,7 +586,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
||||
})
|
||||
|
||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||
Name: "username",
|
||||
Name: "username_basic",
|
||||
Description: "The username to use",
|
||||
Multiline: false,
|
||||
Required: true,
|
||||
@@ -588,7 +597,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
||||
},
|
||||
})
|
||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||
Name: "password",
|
||||
Name: "password_basic",
|
||||
Description: "The password to use",
|
||||
Multiline: false,
|
||||
Required: true,
|
||||
@@ -846,21 +855,102 @@ func deployAppToDatastore(ctx context.Context, workflowapp WorkflowApp) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
// https://docs.python.org/3.2/reference/lexical_analysis.html#identifiers
|
||||
// This is used to build the python functions.
|
||||
func fixFunctionName(functionName, actualPath string) string {
|
||||
if len(functionName) == 0 {
|
||||
functionName = actualPath
|
||||
}
|
||||
|
||||
// REGEX THIS SHIT
|
||||
// ROFL
|
||||
|
||||
//log.Printf("Fixing function name for %s", functionName)
|
||||
functionName = strings.Replace(functionName, " ", "_", -1)
|
||||
functionName = strings.Replace(functionName, ".", "", -1)
|
||||
functionName = strings.Replace(functionName, ",", "", -1)
|
||||
functionName = strings.Replace(functionName, ".", "", -1)
|
||||
functionName = strings.Replace(functionName, "&", "", -1)
|
||||
functionName = strings.Replace(functionName, "/", "", -1)
|
||||
functionName = strings.Replace(functionName, "\\", "", -1)
|
||||
|
||||
functionName = strings.Replace(functionName, "!", "", -1)
|
||||
functionName = strings.Replace(functionName, "?", "", -1)
|
||||
functionName = strings.Replace(functionName, "@", "", -1)
|
||||
functionName = strings.Replace(functionName, "#", "", -1)
|
||||
functionName = strings.Replace(functionName, "$", "", -1)
|
||||
functionName = strings.Replace(functionName, "&", "", -1)
|
||||
functionName = strings.Replace(functionName, "*", "", -1)
|
||||
functionName = strings.Replace(functionName, "(", "", -1)
|
||||
functionName = strings.Replace(functionName, ")", "", -1)
|
||||
functionName = strings.Replace(functionName, "[", "", -1)
|
||||
functionName = strings.Replace(functionName, "]", "", -1)
|
||||
functionName = strings.Replace(functionName, "{", "", -1)
|
||||
functionName = strings.Replace(functionName, "}", "", -1)
|
||||
functionName = strings.Replace(functionName, `"`, "", -1)
|
||||
functionName = strings.Replace(functionName, `'`, "", -1)
|
||||
functionName = strings.Replace(functionName, `|`, "", -1)
|
||||
functionName = strings.Replace(functionName, `~`, "", -1)
|
||||
|
||||
functionName = strings.Replace(functionName, " ", "_", -1)
|
||||
functionName = strings.Replace(functionName, "-", "_", -1)
|
||||
|
||||
functionName = strings.ToLower(functionName)
|
||||
|
||||
return functionName
|
||||
}
|
||||
|
||||
// Returns a valid param name
|
||||
func validateParameterName(name string) string {
|
||||
invalid := []string{"False",
|
||||
"await",
|
||||
"else",
|
||||
"import",
|
||||
"pass",
|
||||
"None",
|
||||
"break",
|
||||
"except",
|
||||
"in",
|
||||
"raise",
|
||||
"True",
|
||||
"class",
|
||||
"finally",
|
||||
"is",
|
||||
"return",
|
||||
"and",
|
||||
"continue",
|
||||
"for",
|
||||
"lambda",
|
||||
"try",
|
||||
"as",
|
||||
"def",
|
||||
"from",
|
||||
"nonlocal",
|
||||
"while",
|
||||
"assert",
|
||||
"del",
|
||||
"global",
|
||||
"not",
|
||||
"with",
|
||||
"async",
|
||||
"elif",
|
||||
"if",
|
||||
"or",
|
||||
"yield",
|
||||
}
|
||||
|
||||
newname := name
|
||||
for _, item := range invalid {
|
||||
if item == name {
|
||||
//log.Printf("%s is NOT a valid parameter name!", item)
|
||||
newname = fmt.Sprintf("%s_shuffle", item)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return newname
|
||||
}
|
||||
|
||||
func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []WorkflowAppActionParameter, path *openapi3.PathItem, actualPath string) (WorkflowAppAction, string) {
|
||||
// What to do with this, hmm
|
||||
functionName := fixFunctionName(path.Connect.Summary, actualPath)
|
||||
@@ -926,6 +1016,7 @@ func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters [
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Connect.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1074,6 +1165,7 @@ func handleGet(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Get.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1222,6 +1314,7 @@ func handleHead(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Head.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1370,6 +1463,7 @@ func handleDelete(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Delete.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1517,6 +1611,7 @@ func handlePost(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Post.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1664,6 +1759,7 @@ func handlePatch(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []W
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Patch.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
@@ -1811,6 +1907,7 @@ func handlePut(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
|
||||
parsedName = strings.ReplaceAll(parsedName, ",", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, ".", "_")
|
||||
parsedName = strings.ReplaceAll(parsedName, "|", "_")
|
||||
parsedName = validateParameterName(parsedName)
|
||||
param.Value.Name = parsedName
|
||||
path.Put.Parameters[counter].Value.Name = parsedName
|
||||
|
||||
|
||||
+11
-11
@@ -47,7 +47,6 @@ import (
|
||||
// Random
|
||||
xj "github.com/basgys/goxml2json"
|
||||
newscheduler "github.com/carlescere/scheduler"
|
||||
gyaml "github.com/ghodss/yaml"
|
||||
"github.com/satori/go.uuid"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -5545,7 +5544,7 @@ func handleSwaggerValidation(body []byte) (ParsedOpenApi, error) {
|
||||
//log.Printf("Json err: %s", err)
|
||||
err = yaml.Unmarshal(body, &version)
|
||||
if err != nil {
|
||||
log.Printf("Yaml error: %s", err)
|
||||
log.Printf("Yaml error (1): %s", err)
|
||||
} else {
|
||||
//log.Printf("Successfully parsed YAML!")
|
||||
}
|
||||
@@ -5583,9 +5582,9 @@ func handleSwaggerValidation(body []byte) (ParsedOpenApi, error) {
|
||||
err = json.Unmarshal(body, &swagger)
|
||||
if err != nil {
|
||||
//log.Printf("Json error? %s", err)
|
||||
err = gyaml.Unmarshal(body, &swagger)
|
||||
err = yaml.Unmarshal(body, &swagger)
|
||||
if err != nil {
|
||||
log.Printf("Yaml error: %s", err)
|
||||
log.Printf("Yaml error (2): %s", err)
|
||||
return ParsedOpenApi{}, err
|
||||
} else {
|
||||
//log.Printf("Valid yaml!")
|
||||
@@ -5677,7 +5676,7 @@ func validateSwagger(resp http.ResponseWriter, request *http.Request) {
|
||||
log.Printf("Json err: %s", err)
|
||||
err = yaml.Unmarshal(body, &version)
|
||||
if err != nil {
|
||||
log.Printf("Yaml error: %s", err)
|
||||
log.Printf("Yaml error (3): %s", err)
|
||||
//resp.WriteHeader(422)
|
||||
//resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi to json and yaml: %s"}`, err)))
|
||||
//return
|
||||
@@ -5736,17 +5735,18 @@ func validateSwagger(resp http.ResponseWriter, request *http.Request) {
|
||||
//log.Println(string(body))
|
||||
err = json.Unmarshal(body, &swagger)
|
||||
if err != nil {
|
||||
log.Printf("Json error? %s", err)
|
||||
err = gyaml.Unmarshal(body, &swagger)
|
||||
log.Printf("Json error for v2 - trying yaml: %s", err)
|
||||
err = yaml.Unmarshal([]byte(body), &swagger)
|
||||
if err != nil {
|
||||
log.Printf("Yaml error: %s", err)
|
||||
log.Printf("Yaml error (4): %s", err)
|
||||
|
||||
resp.WriteHeader(422)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi2: %s"}`, err)))
|
||||
return
|
||||
} else {
|
||||
log.Printf("Found valid yaml!")
|
||||
}
|
||||
|
||||
resp.WriteHeader(422)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed reading openapi2: %s"}`, err)))
|
||||
return
|
||||
}
|
||||
|
||||
swaggerv3, err := openapi2conv.ToV3Swagger(&swagger)
|
||||
|
||||
@@ -489,7 +489,6 @@ const Admin = (props) => {
|
||||
return response.json()
|
||||
})
|
||||
.then((responseJson) => {
|
||||
console.log(responseJson)
|
||||
setUsers(responseJson)
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -857,9 +856,9 @@ const Admin = (props) => {
|
||||
style={{ minWidth: 180, maxWidth: 180 }}
|
||||
/>
|
||||
</ListItem>
|
||||
{users === undefined ? null : users.map(data => {
|
||||
{users === undefined ? null : users.map((data, index) => {
|
||||
return (
|
||||
<ListItem>
|
||||
<ListItem key={index}>
|
||||
<ListItemText
|
||||
primary={data.username}
|
||||
style={{ minWidth: 200, maxWidth: 200 }}
|
||||
@@ -870,19 +869,15 @@ const Admin = (props) => {
|
||||
/>
|
||||
<ListItemText
|
||||
primary=
|
||||
{<Select
|
||||
PaperProps={{
|
||||
style: {
|
||||
}
|
||||
}}
|
||||
SelectDisplayProps={{
|
||||
style: {
|
||||
marginLeft: 10,
|
||||
}
|
||||
}}
|
||||
value={data.role}
|
||||
fullWidth
|
||||
onChange={(e) => {
|
||||
{<Select
|
||||
SelectDisplayProps={{
|
||||
style: {
|
||||
marginLeft: 10,
|
||||
}
|
||||
}}
|
||||
value={data.role}
|
||||
fullWidth
|
||||
onChange={(e) => {
|
||||
console.log("VALUE: ", e.target.value)
|
||||
setUser(data.id, "role", e.target.value)
|
||||
}}
|
||||
@@ -1131,7 +1126,6 @@ const Admin = (props) => {
|
||||
</div>
|
||||
: null
|
||||
|
||||
console.log("Environments: ", environments)
|
||||
const environmentView = curTab === 2 ?
|
||||
<div>
|
||||
<div style={{marginTop: 20, marginBottom: 20,}}>
|
||||
@@ -1147,13 +1141,14 @@ const Admin = (props) => {
|
||||
Add environment
|
||||
</Button>
|
||||
<Button
|
||||
style={{marginLeft: 5, }}
|
||||
style={{marginLeft: 5, marginRight: 15, }}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() => getEnvironments()}
|
||||
>
|
||||
<CachedIcon />
|
||||
</Button>
|
||||
<Switch checked={showArchived} onChange={() => {setShowArchived(!showArchived)}} /> Show archived
|
||||
<Divider style={{marginTop: 20, marginBottom: 20, backgroundColor: theme.palette.inputColor}}/>
|
||||
<List>
|
||||
<ListItem>
|
||||
@@ -1178,7 +1173,7 @@ const Admin = (props) => {
|
||||
style={{minWidth: 150, maxWidth: 150}}
|
||||
/>
|
||||
</ListItem>
|
||||
{environments === undefined ? null : environments.map(environment => {
|
||||
{environments === undefined ? null : environments.map((environment, index)=> {
|
||||
if (!showArchived && environment.archived) {
|
||||
return null
|
||||
}
|
||||
@@ -1189,7 +1184,7 @@ const Admin = (props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<ListItem>
|
||||
<ListItem key={index}>
|
||||
<ListItemText
|
||||
primary={environment.Name}
|
||||
style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}}
|
||||
|
||||
@@ -118,6 +118,7 @@ const AngularWorkflow = (props) => {
|
||||
const [currentView, setCurrentView] = React.useState(0)
|
||||
const [triggerAuthentication, setTriggerAuthentication] = React.useState({})
|
||||
const [triggerFolders, setTriggerFolders] = React.useState([])
|
||||
const [showEnvironment, setShowEnvironment] = React.useState(false)
|
||||
|
||||
const [workflow, setWorkflow] = React.useState({});
|
||||
const [leftViewOpen, setLeftViewOpen] = React.useState(true);
|
||||
@@ -766,6 +767,13 @@ const AngularWorkflow = (props) => {
|
||||
return data
|
||||
}
|
||||
|
||||
// This can be used to only show prioritzed ones later
|
||||
// Right now, it can prioritize authenticated ones
|
||||
const internalIds = [
|
||||
"Shuffle Tools",
|
||||
"Testing",
|
||||
"Http",
|
||||
]
|
||||
const getAppAuthentication = () => {
|
||||
fetch(globalUrl+"/api/v1/apps/authentication", {
|
||||
method: 'GET',
|
||||
@@ -795,10 +803,6 @@ const AngularWorkflow = (props) => {
|
||||
});
|
||||
}
|
||||
|
||||
const internalIds = [
|
||||
"80a1fdd2-95c2-49ab-81f6-e05689beb745", // Shuffle tools
|
||||
"39c5f8fa-a088-4cdc-826f-19e2e61cb284", // Testing
|
||||
]
|
||||
|
||||
const getApps = () => {
|
||||
fetch(globalUrl+"/api/v1/workflows/apps", {
|
||||
@@ -823,11 +827,10 @@ const AngularWorkflow = (props) => {
|
||||
//tmpapps = tmpapps.concat(getExtraApps())
|
||||
//tmpapps = tmpapps.concat(responseJson)
|
||||
setApps(responseJson)
|
||||
setFilteredApps(responseJson)
|
||||
getAppAuthentication()
|
||||
|
||||
|
||||
setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.id)))
|
||||
setFilteredApps(responseJson.filter(app => !internalIds.includes(app.name)))
|
||||
setPrioritizedApps(responseJson.filter(app => internalIds.includes(app.name)))
|
||||
})
|
||||
.catch(error => {
|
||||
alert.error(error.toString())
|
||||
@@ -931,7 +934,9 @@ const AngularWorkflow = (props) => {
|
||||
|
||||
setSelectedActionEnvironment(env)
|
||||
setSelectedActionName(curaction.name)
|
||||
setRequiresAuthentication(curapp.authentication.required)
|
||||
|
||||
setRequiresAuthentication(curapp.authentication.required && curapp.authentication.parameters !== undefined && curapp.authentication.parameters !== null)
|
||||
|
||||
|
||||
if (curapp.authentication.required) {
|
||||
// Setup auth here :)
|
||||
@@ -1237,12 +1242,20 @@ const AngularWorkflow = (props) => {
|
||||
})
|
||||
.then((responseJson) => {
|
||||
var found = false
|
||||
var showEnvCnt = 0
|
||||
for (var key in responseJson) {
|
||||
if (responseJson[key].default) {
|
||||
setDefaultEnvironmentIndex(key)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
if (responseJson[key].archived === false) {
|
||||
showEnvCnt += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (showEnvCnt > 1) {
|
||||
setShowEnvironment(true)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
@@ -1813,13 +1826,12 @@ const AngularWorkflow = (props) => {
|
||||
<Tabs
|
||||
value={currentView}
|
||||
indicatorColor="primary"
|
||||
textColor="white"
|
||||
onChange={handleSetTab}
|
||||
aria-label="Left sidebar tab"
|
||||
>
|
||||
<Tab label={
|
||||
<Grid container direction="row" alignItems="center">
|
||||
<Grid item>
|
||||
<Grid item>
|
||||
<AppsIcon style={iconStyle} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
@@ -2246,16 +2258,16 @@ const AngularWorkflow = (props) => {
|
||||
<Grid item>
|
||||
<div style={{borderRadius: borderRadius, height: 80, width: 80, backgroundImage: image, backgroundSize: "cover", backgroundRepeat: "no-repeat"}} />
|
||||
</Grid>
|
||||
<Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px"}}>
|
||||
<Grid style={{display: "flex", flexDirection: "column", marginLeft: "20px", minWidth: 185, maxWidth: 185, overflow: "hidden", maxHeight: 80, }}>
|
||||
<Grid item style={{flex: 1}}>
|
||||
<h4 style={{marginBottom: "0px", marginTop: "5px"}}>{newAppname}</h4>
|
||||
</Grid>
|
||||
<Grid item style={{flex: 1, width: "100%", }}>
|
||||
Short description...
|
||||
<h4 style={{marginBottom: 0, marginTop: 5}}>{newAppname}</h4>
|
||||
</Grid>
|
||||
<Grid item style={{flex: 1}}>
|
||||
Version: {app.app_version}
|
||||
</Grid>
|
||||
<Grid item style={{flex: 1, width: "100%", maxHeight: 27, overflow: "hidden",}}>
|
||||
{app.description}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Paper>
|
||||
@@ -2291,12 +2303,12 @@ const AngularWorkflow = (props) => {
|
||||
*/}
|
||||
{prioritizedApps.map((app, index) => {
|
||||
return(
|
||||
<ParsedAppPaper app={app} />
|
||||
<ParsedAppPaper key={index} app={app} />
|
||||
)
|
||||
})}
|
||||
{filteredApps.filter(innerapp => !internalIds.includes(innerapp.id)).map((app, index) => {
|
||||
return(
|
||||
<ParsedAppPaper app={app} />
|
||||
<ParsedAppPaper key={index} app={app} />
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
@@ -2637,6 +2649,9 @@ const AngularWorkflow = (props) => {
|
||||
data.variant = "STATIC_VALUE"
|
||||
}
|
||||
|
||||
|
||||
// selectedAction.selectedAuthentication = e.target.value
|
||||
// selectedAction.authentication_id = e.target.value.id
|
||||
if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined && selectedAction.selectedAuthentication.fields[data.name] !== undefined) {
|
||||
// This sets the placeholder in the frontend. (Replaced in backend)
|
||||
selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
|
||||
@@ -3227,7 +3242,7 @@ const AngularWorkflow = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
: null}
|
||||
{environments !== undefined && environments !== null && environments.length > 1 ?
|
||||
{showEnvironment ?
|
||||
<div style={{marginTop: "20px"}}>
|
||||
<Typography>
|
||||
Environment
|
||||
@@ -5658,7 +5673,7 @@ const AngularWorkflow = (props) => {
|
||||
return null
|
||||
}
|
||||
|
||||
if (selectedApp.authentication.parameters.length === undefined || selectedApp.authentication.parameters.length === 0) {
|
||||
if (selectedApp.authentication.parameters === null || selectedApp.authentication.parameters === undefined || selectedApp.authentication.parameters.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ const AppCreator = (props) => {
|
||||
const [update, setUpdate] = useState("")
|
||||
const [urlPathParameters, ] = useState([]);
|
||||
const [firstrequest, setFirstrequest] = React.useState(true)
|
||||
const [, setBasedata] = React.useState({})
|
||||
const [basedata, setBasedata] = React.useState({})
|
||||
const [actions, setActions] = useState([])
|
||||
const [errorCode, setErrorCode] = useState("")
|
||||
const [appBuilding, setAppBuilding] = useState(false)
|
||||
@@ -394,8 +394,6 @@ const AppCreator = (props) => {
|
||||
setNewWorkflowTags(newWorkflowTags)
|
||||
}
|
||||
|
||||
console.log(data.info)
|
||||
|
||||
// This is annoying (:
|
||||
var securitySchemes = data.components.securityDefinitions
|
||||
if (securitySchemes === undefined) {
|
||||
@@ -431,8 +429,6 @@ const AppCreator = (props) => {
|
||||
continue
|
||||
}
|
||||
|
||||
console.log("Method: ", method)
|
||||
console.log("Methodval: ", methodvalue)
|
||||
var newaction = {
|
||||
"name": methodvalue.summary,
|
||||
"description": methodvalue.description,
|
||||
@@ -604,7 +600,10 @@ const AppCreator = (props) => {
|
||||
"id": props.match.params.appid,
|
||||
}
|
||||
|
||||
if (contact === "") {
|
||||
|
||||
if (basedata.info.contact !== undefined) {
|
||||
data.info["contact"] = basedata.info.contact
|
||||
} else if (contact === "") {
|
||||
data.info["contact"] = {
|
||||
"name": "@frikkylikeme",
|
||||
"url": "https://twitter.com/frikkylikeme",
|
||||
@@ -629,7 +628,7 @@ const AppCreator = (props) => {
|
||||
|
||||
// Handles actions
|
||||
for (var key in actions) {
|
||||
const item = actions[key]
|
||||
var item = actions[key]
|
||||
if (item.errors.length > 0) {
|
||||
alert.error("Saving with error in action "+item.name)
|
||||
}
|
||||
@@ -642,6 +641,12 @@ const AppCreator = (props) => {
|
||||
data.paths[item.url] = {}
|
||||
}
|
||||
|
||||
const regex = /[A-Za-z0-9 _]/g;
|
||||
const found = item.name.match(regex);
|
||||
if (found !== null) {
|
||||
item.name = found.join("")
|
||||
}
|
||||
|
||||
data.paths[item.url][item.method.toLowerCase()] = {
|
||||
"responses": {
|
||||
"default": {
|
||||
@@ -803,8 +808,6 @@ const AppCreator = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("ACTIONS: ", data.paths)
|
||||
|
||||
fetch(globalUrl+"/api/v1/verify_openapi", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -927,6 +930,16 @@ const AppCreator = (props) => {
|
||||
setUrlPathQueries(urlPathQueries)
|
||||
}
|
||||
|
||||
const duplicateAction = (index) => {
|
||||
var newAction = JSON.parse(JSON.stringify(actions[index]))
|
||||
newAction.name = newAction.name+"_copy"
|
||||
newAction.errors.push("Can't have the same name")
|
||||
|
||||
actions.push(newAction)
|
||||
setActions(actions)
|
||||
setUpdate(Math.random())
|
||||
}
|
||||
|
||||
const deleteAction = (index) => {
|
||||
actions.splice(index, 1)
|
||||
setCurrentAction({
|
||||
@@ -942,6 +955,7 @@ const AppCreator = (props) => {
|
||||
})
|
||||
|
||||
setActions(actions)
|
||||
setUpdate(Math.random())
|
||||
}
|
||||
|
||||
//console.log("Option: ", authenticationOption)
|
||||
@@ -1018,7 +1032,7 @@ const AppCreator = (props) => {
|
||||
fullWidth={true}
|
||||
defaultValue={data.name}
|
||||
placeholder={'Query name'}
|
||||
helperText={<div style={{color:"white", marginBottom: "2px",}}>Click required switch</div>}
|
||||
helperText={<span style={{color:"white", marginBottom: "2px",}}>Click required switch</span>}
|
||||
onBlur={(e) => {
|
||||
urlPathQueries[index].name = e.target.value
|
||||
setUrlPathQueries(urlPathQueries)
|
||||
@@ -1059,12 +1073,12 @@ const AppCreator = (props) => {
|
||||
}
|
||||
|
||||
|
||||
const url = baseUrl+data.url
|
||||
const url = data.url
|
||||
return (
|
||||
<Paper style={actionListStyle}>
|
||||
{error}
|
||||
<Tooltip title="Edit action" placement="bottom">
|
||||
<div style={{marginLeft: "5px", width: "100%", cursor: "pointer", maxWidth: 675}} onClick={() => {
|
||||
<div style={{marginLeft: "5px", width: "100%", cursor: "pointer", maxWidth: 725, overflowX: "hidden",}} onClick={() => {
|
||||
setCurrentAction(data)
|
||||
setCurrentActionMethod(data.method)
|
||||
setUrlPathQueries(data.queries)
|
||||
@@ -1081,7 +1095,14 @@ const AppCreator = (props) => {
|
||||
</div>
|
||||
</Tooltip>
|
||||
*/}
|
||||
<Tooltip title="Delete action" placement="bottom">
|
||||
<Tooltip title="Duplicate action" placement="bottom" style={{minWidth: 60}} >
|
||||
<div style={{color: "#f85a3e", cursor: "pointer", marginRight: 15, }} onClick={() => {
|
||||
duplicateAction(index)
|
||||
}}>
|
||||
Duplicate
|
||||
</div>
|
||||
</Tooltip>
|
||||
<Tooltip title="Delete action" placement="bottom" style={{minWidth: 60}} >
|
||||
<div style={{color: "#f85a3e", cursor: "pointer"}} onClick={() => {deleteAction(index)}}>
|
||||
Delete
|
||||
</div>
|
||||
@@ -1094,7 +1115,7 @@ const AppCreator = (props) => {
|
||||
const setActionField = (field, value) => {
|
||||
currentAction[field] = value
|
||||
setCurrentAction(currentAction)
|
||||
console.log("ACTION: ", currentAction)
|
||||
//setUrlPathQueries(currentAction.queries)
|
||||
}
|
||||
|
||||
const bodyInfo = actionBodyRequest.includes(currentActionMethod) ?
|
||||
@@ -1253,7 +1274,7 @@ const AppCreator = (props) => {
|
||||
}
|
||||
|
||||
// FIXME: Frontend isn't updating..
|
||||
if (JSON.stringify(tmpQueries) !== JSON.stringify(urlPathQueries)) {
|
||||
if (tmpQueries.length > 0 && JSON.stringify(tmpQueries) !== JSON.stringify(urlPathQueries)) {
|
||||
setUrlPathQueries(tmpQueries)
|
||||
}
|
||||
|
||||
@@ -1388,7 +1409,7 @@ const AppCreator = (props) => {
|
||||
setUrlPath(e.target.value)
|
||||
console.log(e.target.value)
|
||||
}}
|
||||
helperText={<div style={{color:"white", marginBottom: "2px",}}>The path to use. Must start with /. Use {"{variablename}"} to have path variables</div>}
|
||||
helperText={<span style={{color:"white", marginBottom: "2px",}}>The path to use. Must start with /. Use {"{variablename}"} to have path variables</span>}
|
||||
InputProps={{
|
||||
classes: {
|
||||
notchedOutline: classes.notchedOutline,
|
||||
@@ -1485,7 +1506,7 @@ const AppCreator = (props) => {
|
||||
multiline
|
||||
rows="5"
|
||||
onChange={e => setActionField("headers", e.target.value)}
|
||||
helperText={<div style={{color:"white", marginBottom: "2px",}}>Headers that are part of the request</div>}
|
||||
helperText={<span style={{color:"white", marginBottom: "2px",}}>Headers that are part of the request</span>}
|
||||
InputProps={{
|
||||
classes: {
|
||||
notchedOutline: classes.notchedOutline,
|
||||
@@ -1503,6 +1524,7 @@ const AppCreator = (props) => {
|
||||
Cancel
|
||||
</Button>
|
||||
<Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => {
|
||||
console.log(urlPathQueries)
|
||||
const errors = getActionErrors()
|
||||
addActionToView(errors)
|
||||
setActionsModalOpen(false)
|
||||
@@ -1617,7 +1639,7 @@ const AppCreator = (props) => {
|
||||
img.onload = function() {
|
||||
// img, x, y, width, height
|
||||
//ctx.drawImage(img, 174, 174)
|
||||
console.log("IMG natural: ", img.naturalWidth, img.naturalHeight)
|
||||
//console.log("IMG natural: ", img.naturalWidth, img.naturalHeight)
|
||||
//ctx.drawImage(img, 0, 0, 174, 174)
|
||||
ctx.drawImage(img,
|
||||
0, 0, img.width, img.height,
|
||||
@@ -1626,7 +1648,7 @@ const AppCreator = (props) => {
|
||||
|
||||
const canvasUrl = canvas.toDataURL()
|
||||
if (canvasUrl !== fileBase64) {
|
||||
console.log("SET URL TO: ", canvasUrl)
|
||||
//console.log("SET URL TO: ", canvasUrl)
|
||||
setFileBase64(canvasUrl)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,7 +895,17 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
|
||||
fmt.Sprintf("EXECUTIONID=%s", workflowExecution.ExecutionId),
|
||||
fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization),
|
||||
fmt.Sprintf("CALLBACK_URL=%s", baseUrl),
|
||||
fmt.Sprintf("FULL_EXECUTION=%s", string(executionData)),
|
||||
}
|
||||
|
||||
// Fixes issue:
|
||||
// standard_init_linux.go:185: exec user process caused "argument list too long"
|
||||
// https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083
|
||||
maxSize := 32700 - len(string(actionData)) - 2000
|
||||
if len(executionData) < maxSize {
|
||||
log.Printf("ADDING FULL_EXECUTION because size is larger than %d", maxSize)
|
||||
env = append(env, fmt.Sprintf("FULL_EXECUTION=%s", string(executionData)))
|
||||
} else {
|
||||
log.Printf("Skipping FULL_EXECUTION because size is larger than %d", maxSize)
|
||||
}
|
||||
|
||||
err = deployApp(dockercli, image, identifier, env)
|
||||
|
||||
Reference in New Issue
Block a user