Added basic debug view

This commit is contained in:
frikky
2020-05-15 12:50:07 +02:00
parent 3a87451beb
commit 9c4527d30a
6 changed files with 110 additions and 31 deletions
+25 -24
View File
@@ -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
+5
View File
@@ -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 == "" {
+1 -1
View File
@@ -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) {
+72 -5
View File
@@ -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 ?
<Draggable>
<div style={{color: "white", position: "fixed", top: appBarSize+65, left: leftBarSize+20, zIndex: 5000, backgroundColor: "rgba(0,0,0,0.1)", minHeight: 100, padding: 15, maxHeight: 100, maxWidth: 500, overflowX: "hidden",}}>
{workflowExecutions.slice(0,25).map(data => {
console.log("DATA: ", data)
return (
<div>
{new Date(data.started_at*1000).toISOString()}
, status: {data.status}
{data.execution_argument.length > 0 ? ", "+data.execution_argument : ", "}
{data.result.length > 0 ? ", "+data.result : ", "}
</div>
)
return
})}
</div>
</Draggable>
: 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 (
<div style={{position: "fixed", width: "100%", top: 300}}>
<div style={{width: 300, margin: "auto"}}>
<h3></h3>
</div>
</div>
)
}
return null
}
const BottomCytoscapeBar = () => {
const boxSize = 100
const executionButton = executionRunning ?
@@ -4166,6 +4231,8 @@ const AngularWorkflow = (props) => {
<RightSideBar />
<BottomCytoscapeBar />
<TopCytoscapeBar />
<NoActionsBar />
{debugView}
</div>
:
<div style={{color: "white"}}>
+1 -1
View File
@@ -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) {
+6
View File
@@ -618,6 +618,12 @@ const Workflows = (props) => {
<div>
Results: {resultsLength}
</div>
<div>
Results: {resultsLength}
</div>
<div>
Result: {selectedExecution.result}
</div>
<div>
Status: {selectedExecution.status}
</div>