From 9c4527d30a17b85c556e1ffa1aabf93bff04244c Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 15 May 2020 12:50:07 +0200 Subject: [PATCH] Added basic debug view --- backend/go-app/main.go | 49 +++++++++++---------- backend/go-app/walkoff.go | 5 +++ frontend/src/AdminSetup.js | 2 +- frontend/src/AngularWorkflow.js | 77 ++++++++++++++++++++++++++++++--- frontend/src/LoginPage.js | 2 +- frontend/src/Workflows.js | 6 +++ 6 files changed, 110 insertions(+), 31 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 273c3d8b..9cbd9ad0 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -18,7 +18,7 @@ import ( "net/http" "os" "os/exec" - "regexp" + //"regexp" "strconv" "strings" "time" @@ -797,43 +797,44 @@ func parseLoginParameters(resp http.ResponseWriter, request *http.Request) (logi } // Can check against HIBP etc? +// Removed for localhost func checkPasswordStrength(password string) error { // Check password strength here - if len(password) < 10 { - return errors.New("Minimum password length is 10.") - } + //if len(password) < 10 { + // return errors.New("Minimum password length is 10.") + //} - if len(password) > 128 { - return errors.New("Maximum password length is 128.") - } + //if len(password) > 128 { + // return errors.New("Maximum password length is 128.") + //} - re := regexp.MustCompile("[0-9]+") - if len(re.FindAllString(password, -1)) == 0 { - return errors.New("Password must contain a number") - } + //re := regexp.MustCompile("[0-9]+") + //if len(re.FindAllString(password, -1)) == 0 { + // return errors.New("Password must contain a number") + //} - re = regexp.MustCompile("[a-z]+") - if len(re.FindAllString(password, -1)) == 0 { - return errors.New("Password must contain a lower case char") - } + //re = regexp.MustCompile("[a-z]+") + //if len(re.FindAllString(password, -1)) == 0 { + // return errors.New("Password must contain a lower case char") + //} - re = regexp.MustCompile("[A-Z]+") - if len(re.FindAllString(password, -1)) == 0 { - return errors.New("Password must contain an upper case char") - } + //re = regexp.MustCompile("[A-Z]+") + //if len(re.FindAllString(password, -1)) == 0 { + // return errors.New("Password must contain an upper case char") + //} return nil } -// Fuck emails +// No more emails :) func checkUsername(Username string) error { // Stupid first check of email loool - if !strings.Contains(Username, "@") || !strings.Contains(Username, ".") { - return errors.New("Invalid Username") - } + //if !strings.Contains(Username, "@") || !strings.Contains(Username, ".") { + // return errors.New("Invalid Username") + //} if len(Username) < 4 { - return errors.New("Minimum Username length is 2") + return errors.New("Minimum Username length is 4") } return nil diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index b0c95b19..e49a6db7 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -777,16 +777,21 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) { //log.Printf("Checking results %d vs %d", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extraInputs) if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions)+extraInputs { finished := true + lastResult := "" for _, result := range workflowExecution.Results { if result.Status != "SUCCESS" && result.Status != "FINISHED" { finished = false break } + + lastResult = result.Result } if finished { log.Printf("Execution of %s finished.", workflowExecution.ExecutionId) //log.Println("Might be finished based on length of results and everything being SUCCESS or FINISHED - VERIFY THIS. Setting status to finished.") + + workflowExecution.Result = lastResult workflowExecution.Status = "FINISHED" workflowExecution.CompletedAt = int64(time.Now().Unix()) if workflowExecution.LastNode == "" { diff --git a/frontend/src/AdminSetup.js b/frontend/src/AdminSetup.js index ce17db46..11642974 100644 --- a/frontend/src/AdminSetup.js +++ b/frontend/src/AdminSetup.js @@ -49,7 +49,7 @@ const AdminAccount = props => { const [loginInfo, setLoginInfo] = useState(""); const handleValidateForm = () => { - return (username.length > 1 && password.length > 8); + return (username.length > 1 && password.length > 1); } if (isLoggedIn === true) { diff --git a/frontend/src/AngularWorkflow.js b/frontend/src/AngularWorkflow.js index 66d1b81f..46a4870b 100644 --- a/frontend/src/AngularWorkflow.js +++ b/frontend/src/AngularWorkflow.js @@ -155,27 +155,75 @@ const AngularWorkflow = (props) => { const [AppsHoverColor, setAppsHoverColor] = useState(hoverOutColor); const [VariablesHoverColor, setVariablesHoverColor] = useState(hoverOutColor); const [HookHoverColor, setHookHoverColor] = useState(hoverOutColor); + const [appAdded, setAppAdded] = useState(false) const [update, setUpdate] = useState(""); + const [workflowExecutions, setWorkflowExecutions] = React.useState([]); const [elements, setElements] = useState([]) const { start, stop } = useInterval({ duration: 5000, startImmediate: false, callback: () => { - fetchUpdates() + fetchUpdates() } }); - const fetchUpdates = () => { - fetch(globalUrl+"/api/v1/streams/results", { - method: 'POST', + const getWorkflowExecution = (id) => { + fetch(globalUrl+"/api/v1/workflows/"+id+"/executions", { + method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, - body: JSON.stringify(executionRequest), credentials: "include", }) + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for WORKFLOW EXECUTION :O!") + } + + return response.json() + }) + .then((responseJson) => { + if (responseJson.length > 0) { + setWorkflowExecutions(responseJson) + } + //setWorkflowExecutions(responseJson) + }) + .catch(error => { + alert.error(error.toString()) + }); + } + + const debugView = workflowExecutions.length > 0 ? + +
+ {workflowExecutions.slice(0,25).map(data => { + console.log("DATA: ", data) + return ( +
+ {new Date(data.started_at*1000).toISOString()} + , status: {data.status} + {data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "} + {data.result.length > 0 ? ", "+data.result : ", "} +
+ ) + return + })} +
+
+ : null + + const fetchUpdates = () => { + fetch(globalUrl+"/api/v1/streams/results", { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: JSON.stringify(executionRequest), + credentials: "include", + }) .then((response) => { if (response.status !== 200) { console.log("Status not 200 for stream results :O!") @@ -185,6 +233,7 @@ const AngularWorkflow = (props) => { }) .then((responseJson) => { handleUpdateResults(responseJson) + getWorkflowExecution(props.match.params.key) }) .catch(error => { alert.error(error.toString()) @@ -965,6 +1014,7 @@ const AngularWorkflow = (props) => { getWorkflow() getApps() getEnvironments() + getWorkflowExecution(props.match.params.key) return } @@ -4006,6 +4056,21 @@ const AngularWorkflow = (props) => { ) } + const NoActionsBar = () => { + if (workflow.actions.length === 0 || !appAdded) { + return ( +
+
+

+
+
+ ) + } + + return null + } + + const BottomCytoscapeBar = () => { const boxSize = 100 const executionButton = executionRunning ? @@ -4166,6 +4231,8 @@ const AngularWorkflow = (props) => { + + {debugView} :
diff --git a/frontend/src/LoginPage.js b/frontend/src/LoginPage.js index db0a27c0..040aeeac 100644 --- a/frontend/src/LoginPage.js +++ b/frontend/src/LoginPage.js @@ -47,7 +47,7 @@ const LoginDialog = props => { const [loginInfo, setLoginInfo] = useState(""); const handleValidateForm = () => { - return (username.length > 1 && password.length > 8); + return (username.length > 1 && password.length > 1); } if (isLoggedIn === true) { diff --git a/frontend/src/Workflows.js b/frontend/src/Workflows.js index 3be7fa72..78c850fd 100644 --- a/frontend/src/Workflows.js +++ b/frontend/src/Workflows.js @@ -618,6 +618,12 @@ const Workflows = (props) => {
Results: {resultsLength}
+
+ Results: {resultsLength} +
+
+ Result: {selectedExecution.result} +
Status: {selectedExecution.status}