Skip to content

Commit 1c95614

Browse files
committed
Changed trigger to test function
1 parent d06cc28 commit 1c95614

File tree

6 files changed

+42
-21
lines changed

6 files changed

+42
-21
lines changed

core/flow.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def flowLogicEval(data,logicVar):
3636

3737
def getObjectFromCode(codeFunction):
3838
functionName = codeFunction.split("(")[0]
39-
args = regexCommor.split(codeFunction[(len(functionName)+1):-1])
39+
args = regexCommor.split(codeFunction.strip()[(len(functionName)+1):-1])
4040
classObject = model._model().getAsClass(query={ "name" : functionName })[0].classObject()
4141
classObject.enabled = True
4242
members = [attr for attr in dir(classObject) if not callable(getattr(classObject, attr)) and not "__" in attr and attr ]
@@ -109,12 +109,15 @@ def executeCodifyFlow(eventsData,codifyData):
109109
while True:
110110
if currentObject:
111111
if currentFlow["type"] == "trigger":
112-
outputText+="\nTRIGGER"
113-
outputText+="\n{0}".format(currentFlow["codeLine"])
114-
outputText+="\npre-data={0}".format(data)
112+
if currentObject.name == "":
113+
outputText+="\nTRIGGER"
114+
else:
115+
outputText+="\n(t) - {0}:".format(currentObject.name)
116+
outputText+="\n\t[function]\n\t\t{0}".format(currentFlow["codeLine"])
117+
outputText+="\n\t[pre-data]\n\t\t{0}".format(data)
115118
objectContinue = True
116119
if currentObject.logicString.startswith("if"):
117-
outputText+="\nChecking logic {0} = ".format(currentObject.logicString)
120+
outputText+="\n\t[logic]\n\t\t{0}\n\t\t".format(currentObject.logicString)
118121
if logic.ifEval(currentObject.logicString,{ "data" : data}):
119122
outputText+="Pass"
120123
if currentObject.varDefinitions:
@@ -133,27 +136,30 @@ def executeCodifyFlow(eventsData,codifyData):
133136
passData = copy.deepcopy(data)
134137
processQueue.append({ "flow" : nextFlow, "data" : passData })
135138
passData = None
136-
outputText+="\npost-data={0}".format(data)
139+
outputText+="\n\t[post-data] - \n\t\t{0}".format(data)
137140
outputText+="\n"
138141
elif currentFlow["type"] == "action":
139-
outputText+="\nACTION"
142+
if currentObject.name == "":
143+
outputText+="\nACTION"
144+
else:
145+
outputText+="\n(a) - {0}:".format(currentObject.name)
140146
if currentObject.enabled:
141-
outputText+="\n{0}".format(currentFlow["codeLine"])
142-
outputText+="\npre-data={0}".format(data)
147+
outputText+="\n\t[function]\n\t\t{0}".format(currentFlow["codeLine"])
148+
outputText+="\n\t[pre-data]\n\t\t{0}".format(data)
143149
logic = currentFlow["logic"][5:]
144-
outputText+="\nChecking Flow logic {0} = ".format(logic)
150+
outputText+="\n\t[link logic]\n\t\t{0}\n\t\t".format(logic)
145151
if flowLogicEval(data,helpers.typeCast(logic)):
146152
outputText+="Pass"
147153
debugText, data["action"] = currentObject.runHandler(data,persistentData,debug=True)
148154
if debugText != "":
149-
outputText+="\n{0}".format(debugText)
155+
outputText+="{0}".format(debugText)
150156
passData = data
151157
for nextFlow in currentFlow["next"]:
152158
if not passData:
153159
passData = copy.deepcopy(data)
154160
processQueue.append({ "flow" : nextFlow, "data" : passData })
155161
passData = None
156-
outputText+="\npost-data={0}".format(data)
162+
outputText+="\n\t[post-data]\n\t\t{0}".format(data)
157163
else:
158164
outputText+="Failed"
159165
outputText+="\n"

core/models/action.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ def runHandler(self,data,persistentData,debug=False):
6161
actionResult = { "result" : False, "rc" : -1, "actionID" : self._id, "data" : {} }
6262
self.runHeader(data,persistentData,actionResult)
6363
if self.logicString.startswith("if"):
64-
debugText="Checking logic ({0}) = ".format(self.logicString)
6564
if debug:
6665
logicDebugText, logicResult = logic.ifEval(self.logicString, { "data" : data }, debug=True)
67-
debugText+="{0}\nLogic Debug ({1})".format(logicResult,logicDebugText)
66+
debugText+="\n\t[action logic]\n\t\t{0}\n\t\t{1}\n\t\t({2})".format(self.logicString,logicResult,logicDebugText)
6867
else:
6968
logicResult = logic.ifEval(self.logicString, { "data" : data })
7069
if logicResult:

web/conductEditor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ def generateFlow(currentFlow,flowDict,triggers,actions):
394394
if flow["type"] == "trigger":
395395
flowCode+=generateFlow(flow,flowDict,triggers,actions)
396396

397+
data = request.args
398+
if data:
399+
if "json" in data:
400+
return { "result" : flowCode, "CSRF" : api.g.sessionData["CSRF"] }, 200
401+
397402
return render_template("blank.html",content=flowCode, CSRF=api.g.sessionData["CSRF"]), 200
398403

399404
@api.webServer.route("/conductEditor/<conductID>/flow/<flowID>/", methods=["DELETE"])

web/static/css/objectProperties.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
width: 100%;
4545
}
4646

47+
.inputExpand {
48+
height: 80%;
49+
}
50+
4751
.existingPropertiesPanel-SearchResults {
4852
display: flex;
4953
flex-wrap: wrap;

web/static/javascript/triggerObject.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ var triggerObjectHTML = `
55
<label id="title"></label>
66
</div>
77
<div class="propertiesPanel-body theme-panelBody">
8-
<textarea id="triggerValue" type="text" class="inputFullWidth theme-panelTextArea"></textarea>
8+
Events:<br>
9+
<textarea id="triggerValue" type="text" class="inputFullWidth theme-panelTextArea"></textarea><br>
10+
Output:<br>
11+
<textarea id="triggerOutput" readonly="true" type="text" class="inputFullWidth inputExpand theme-panelTextArea"></textarea>
912
</div>
1013
<div class="propertiesPanel-footer theme-panelFooter">
11-
<button id="trigger" class="btn btn-primary theme-panelButton">Trigger</button>
14+
<button id="trigger" class="btn btn-primary theme-panelButton">Test</button>
1215
<button id="close" class="btn btn-primary theme-panelButton">Close</button>
1316
</div>
1417
</div>
@@ -18,10 +21,14 @@ var triggerExistingPanels = {}
1821

1922
function triggerTriggerObjectPanel(panel,flowID) {
2023
var conductID = GetURLParameter("conductID")
21-
$.ajax({url: "/conduct/"+conductID+"/forceTrigger/"+flowID+"/", type:"POST", data:JSON.stringify({events: panel.find("#triggerValue").val(), CSRF: CSRF }), contentType:"application/json", success: function ( result ) {
22-
dropdownAlert(panel,"success","Triggered",1000);
23-
}
24-
});
24+
$('#triggerOutput').text("");
25+
$.ajax({url: "/conductEditor/"+conductID+"/codify/?json=True", type:"GET", contentType:"application/json", success: function(result) {
26+
$.ajax({url: "/codify/", type:"POST", data:JSON.stringify({ events: $('#triggerValue').val(), code: result["result"], CSRF: CSRF }), contentType:"application/json", success: function(result) {
27+
$('#triggerOutput').text(result["result"]);
28+
}
29+
});
30+
}
31+
});
2532
}
2633

2734
function createTriggerObjectPanel(flowID) {

web/templates/conductEditor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<li class="divider"></li>
5151
<li><a tabindex="-1" onclick="duplicateFlowObject()">Duplicate</a></li>
5252
<li class="divider"></li>
53-
<li><a tabindex="-1" onclick="triggerFlowObject()">Trigger</a></li>
53+
<li><a tabindex="-1" onclick="triggerFlowObject()">Test</a></li>
5454
<li class="divider"></li>
5555
<li><a tabindex="-1" onclick="editFlowACL()">Modify UI ACL</a></li>
5656
<li class="divider"></li>

0 commit comments

Comments
 (0)