Skip to content

Commit

Permalink
Changed trigger to test function
Browse files Browse the repository at this point in the history
  • Loading branch information
z1pti3 committed Oct 4, 2020
1 parent d06cc28 commit 1c95614
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
30 changes: 18 additions & 12 deletions core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def flowLogicEval(data,logicVar):

def getObjectFromCode(codeFunction):
functionName = codeFunction.split("(")[0]
args = regexCommor.split(codeFunction[(len(functionName)+1):-1])
args = regexCommor.split(codeFunction.strip()[(len(functionName)+1):-1])
classObject = model._model().getAsClass(query={ "name" : functionName })[0].classObject()
classObject.enabled = True
members = [attr for attr in dir(classObject) if not callable(getattr(classObject, attr)) and not "__" in attr and attr ]
Expand Down Expand Up @@ -109,12 +109,15 @@ def executeCodifyFlow(eventsData,codifyData):
while True:
if currentObject:
if currentFlow["type"] == "trigger":
outputText+="\nTRIGGER"
outputText+="\n{0}".format(currentFlow["codeLine"])
outputText+="\npre-data={0}".format(data)
if currentObject.name == "":
outputText+="\nTRIGGER"
else:
outputText+="\n(t) - {0}:".format(currentObject.name)
outputText+="\n\t[function]\n\t\t{0}".format(currentFlow["codeLine"])
outputText+="\n\t[pre-data]\n\t\t{0}".format(data)
objectContinue = True
if currentObject.logicString.startswith("if"):
outputText+="\nChecking logic {0} = ".format(currentObject.logicString)
outputText+="\n\t[logic]\n\t\t{0}\n\t\t".format(currentObject.logicString)
if logic.ifEval(currentObject.logicString,{ "data" : data}):
outputText+="Pass"
if currentObject.varDefinitions:
Expand All @@ -133,27 +136,30 @@ def executeCodifyFlow(eventsData,codifyData):
passData = copy.deepcopy(data)
processQueue.append({ "flow" : nextFlow, "data" : passData })
passData = None
outputText+="\npost-data={0}".format(data)
outputText+="\n\t[post-data] - \n\t\t{0}".format(data)
outputText+="\n"
elif currentFlow["type"] == "action":
outputText+="\nACTION"
if currentObject.name == "":
outputText+="\nACTION"
else:
outputText+="\n(a) - {0}:".format(currentObject.name)
if currentObject.enabled:
outputText+="\n{0}".format(currentFlow["codeLine"])
outputText+="\npre-data={0}".format(data)
outputText+="\n\t[function]\n\t\t{0}".format(currentFlow["codeLine"])
outputText+="\n\t[pre-data]\n\t\t{0}".format(data)
logic = currentFlow["logic"][5:]
outputText+="\nChecking Flow logic {0} = ".format(logic)
outputText+="\n\t[link logic]\n\t\t{0}\n\t\t".format(logic)
if flowLogicEval(data,helpers.typeCast(logic)):
outputText+="Pass"
debugText, data["action"] = currentObject.runHandler(data,persistentData,debug=True)
if debugText != "":
outputText+="\n{0}".format(debugText)
outputText+="{0}".format(debugText)
passData = data
for nextFlow in currentFlow["next"]:
if not passData:
passData = copy.deepcopy(data)
processQueue.append({ "flow" : nextFlow, "data" : passData })
passData = None
outputText+="\npost-data={0}".format(data)
outputText+="\n\t[post-data]\n\t\t{0}".format(data)
else:
outputText+="Failed"
outputText+="\n"
Expand Down
3 changes: 1 addition & 2 deletions core/models/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ def runHandler(self,data,persistentData,debug=False):
actionResult = { "result" : False, "rc" : -1, "actionID" : self._id, "data" : {} }
self.runHeader(data,persistentData,actionResult)
if self.logicString.startswith("if"):
debugText="Checking logic ({0}) = ".format(self.logicString)
if debug:
logicDebugText, logicResult = logic.ifEval(self.logicString, { "data" : data }, debug=True)
debugText+="{0}\nLogic Debug ({1})".format(logicResult,logicDebugText)
debugText+="\n\t[action logic]\n\t\t{0}\n\t\t{1}\n\t\t({2})".format(self.logicString,logicResult,logicDebugText)
else:
logicResult = logic.ifEval(self.logicString, { "data" : data })
if logicResult:
Expand Down
5 changes: 5 additions & 0 deletions web/conductEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ def generateFlow(currentFlow,flowDict,triggers,actions):
if flow["type"] == "trigger":
flowCode+=generateFlow(flow,flowDict,triggers,actions)

data = request.args
if data:
if "json" in data:
return { "result" : flowCode, "CSRF" : api.g.sessionData["CSRF"] }, 200

return render_template("blank.html",content=flowCode, CSRF=api.g.sessionData["CSRF"]), 200

@api.webServer.route("/conductEditor/<conductID>/flow/<flowID>/", methods=["DELETE"])
Expand Down
4 changes: 4 additions & 0 deletions web/static/css/objectProperties.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
width: 100%;
}

.inputExpand {
height: 80%;
}

.existingPropertiesPanel-SearchResults {
display: flex;
flex-wrap: wrap;
Expand Down
19 changes: 13 additions & 6 deletions web/static/javascript/triggerObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ var triggerObjectHTML = `
<label id="title"></label>
</div>
<div class="propertiesPanel-body theme-panelBody">
<textarea id="triggerValue" type="text" class="inputFullWidth theme-panelTextArea"></textarea>
Events:<br>
<textarea id="triggerValue" type="text" class="inputFullWidth theme-panelTextArea"></textarea><br>
Output:<br>
<textarea id="triggerOutput" readonly="true" type="text" class="inputFullWidth inputExpand theme-panelTextArea"></textarea>
</div>
<div class="propertiesPanel-footer theme-panelFooter">
<button id="trigger" class="btn btn-primary theme-panelButton">Trigger</button>
<button id="trigger" class="btn btn-primary theme-panelButton">Test</button>
<button id="close" class="btn btn-primary theme-panelButton">Close</button>
</div>
</div>
Expand All @@ -18,10 +21,14 @@ var triggerExistingPanels = {}

function triggerTriggerObjectPanel(panel,flowID) {
var conductID = GetURLParameter("conductID")
$.ajax({url: "/conduct/"+conductID+"/forceTrigger/"+flowID+"/", type:"POST", data:JSON.stringify({events: panel.find("#triggerValue").val(), CSRF: CSRF }), contentType:"application/json", success: function ( result ) {
dropdownAlert(panel,"success","Triggered",1000);
}
});
$('#triggerOutput').text("");
$.ajax({url: "/conductEditor/"+conductID+"/codify/?json=True", type:"GET", contentType:"application/json", success: function(result) {
$.ajax({url: "/codify/", type:"POST", data:JSON.stringify({ events: $('#triggerValue').val(), code: result["result"], CSRF: CSRF }), contentType:"application/json", success: function(result) {
$('#triggerOutput').text(result["result"]);
}
});
}
});
}

function createTriggerObjectPanel(flowID) {
Expand Down
2 changes: 1 addition & 1 deletion web/templates/conductEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<li class="divider"></li>
<li><a tabindex="-1" onclick="duplicateFlowObject()">Duplicate</a></li>
<li class="divider"></li>
<li><a tabindex="-1" onclick="triggerFlowObject()">Trigger</a></li>
<li><a tabindex="-1" onclick="triggerFlowObject()">Test</a></li>
<li class="divider"></li>
<li><a tabindex="-1" onclick="editFlowACL()">Modify UI ACL</a></li>
<li class="divider"></li>
Expand Down

0 comments on commit 1c95614

Please sign in to comment.