Skip to content

Commit

Permalink
Merge pull request #2959 from SCADA-LTS/fix/#2824_Fixed_event_handler…
Browse files Browse the repository at this point in the history
…s_new_xid_not_displaying_after_saving_edit_form2

#2824 Fixed event handlers new xid not displaying after saving edit form
  • Loading branch information
Limraj authored Jul 24, 2024
2 parents bcd7892 + dbd759d commit 7b25463
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 21 deletions.
23 changes: 13 additions & 10 deletions WebContent/WEB-INF/jsp/eventHandlers.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -456,36 +456,39 @@
var xid = $get("xid");
var alias = $get("alias");
var disabled = $get("disabled");
if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_EMAIL %>"/>) {
if (isEmpty(xid) && handlerId !== ${NEW_ID}){
let message = createValidationMessage("xid", "<fmt:message key='validate.valueRestored'/>");
$set("xid", selectedHandlerNode.object.xid);
stopImageFader("saveImg");
showDwrMessages([message]);
} else {
if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_EMAIL %>"/>) {
var emailList = emailRecipients.createRecipientArray();
var escalList = escalRecipients.createRecipientArray();
var inactiveList = inactiveRecipients.createRecipientArray();
EventHandlersDwr.saveEmailEventHandler(selectedEventTypeNode.object.typeId,
selectedEventTypeNode.object.typeRef1, selectedEventTypeNode.object.typeRef2, handlerId, xid, alias,
disabled, emailList, $get("sendEscalation"), $get("escalationDelayType"), $get("escalationDelay"),
escalList, $get("sendInactive"), $get("inactiveOverride"), inactiveList, saveEventHandlerCB);
}
else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SMS %>"/>) {
} else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SMS %>"/>) {
var smsList = smsRecipients.createRecipientArray();
EventHandlersDwr.saveSmsEventHandler(selectedEventTypeNode.object.typeId,
selectedEventTypeNode.object.typeRef1, selectedEventTypeNode.object.typeRef2, handlerId, xid, alias, disabled, smsList, saveEventHandlerCB);
}
else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SET_POINT %>"/>) {
} else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SET_POINT %>"/>) {
EventHandlersDwr.saveSetPointEventHandler(selectedEventTypeNode.object.typeId,
selectedEventTypeNode.object.typeRef1, selectedEventTypeNode.object.typeRef2, handlerId, xid, alias,
disabled, $get("targetPointSelect"), $get("activeAction"), $get("setPointValueActive"),
$get("activePointId"), $get("inactiveAction"), $get("setPointValueInactive"),
$get("inactivePointId"), saveEventHandlerCB);
}
else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_PROCESS %>"/>) {
} else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_PROCESS %>"/>) {
EventHandlersDwr.saveProcessEventHandler(selectedEventTypeNode.object.typeId,
selectedEventTypeNode.object.typeRef1, selectedEventTypeNode.object.typeRef2, handlerId, xid,
alias, disabled, $get("activeProcessCommand"), $get("inactiveProcessCommand"), saveEventHandlerCB);
}
else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SCRIPT %>"/>) {
} else if (handlerType == <c:out value="<%= EventHandlerVO.TYPE_SCRIPT %>"/>) {
EventHandlersDwr.saveScriptEventHandler(selectedEventTypeNode.object.typeId,
selectedEventTypeNode.object.typeRef1, selectedEventTypeNode.object.typeRef2, handlerId, xid,
alias, disabled, $get("activeScriptCommand"), $get("inactiveScriptCommand"), saveEventHandlerCB);
}
}
}
Expand All @@ -496,7 +499,6 @@
showDwrMessages(response.messages, $("genericMessages"));
else {
var handler = response.data.handler;
setUserMessage("<fmt:message key="eventHandlers.saved"/>");
if (!selectedHandlerNode) {
selectedHandlerNode = createHandlerNode(handler);
selectedEventTypeNode.addChild(selectedHandlerNode);
Expand All @@ -506,6 +508,7 @@
else
$set(handler.id +"Msg", handler.message);
setUserMessage("<fmt:message key="eventHandlers.saved"/>");
selectedHandlerNode.object = handler;
}
}
Expand Down
4 changes: 4 additions & 0 deletions WebContent/resources/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,3 +1260,7 @@ function OnListWebsocketStats() {
console.log("message[/app/websocketStats]:\n" + message.body);
} );
}

function isEmpty(value) {
return !value || (typeof value === "string" && value.trim() === "");
}
2 changes: 1 addition & 1 deletion src/com/serotonin/mango/web/dwr/EventHandlersDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private DwrResponseI18n save(int eventSourceId, int eventTypeRef1,
EventService eventService = new EventService();

vo.setId(handlerId);
vo.setXid(StringUtils.isEmpty(xid) ? eventService.generateUniqueXid() : xid);
vo.setXid(StringUtils.isEmpty(xid) && handlerId == Common.NEW_ID ? eventService.generateUniqueXid() : xid);
vo.setAlias(alias);
vo.setDisabled(disabled);

Expand Down
3 changes: 2 additions & 1 deletion webapp-resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3344,4 +3344,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3347,4 +3347,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3387,4 +3387,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3472,4 +3472,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3341,4 +3341,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3360,4 +3360,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3462,4 +3462,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
1 change: 1 addition & 0 deletions webapp-resources/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3485,3 +3485,4 @@ event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3499,4 +3499,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3495,4 +3495,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored
3 changes: 2 additions & 1 deletion webapp-resources/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3447,4 +3447,5 @@ dsEdit.sql.statementLimit.warning=Setting the value 0 in the Statement limit fie
event.sms.failure=Failed to send sms titled "{0}" to "{1}". Message: "{2}"
event.script.failure=Failed execute script: "{0}", Message: "{1}"
event.system.sms=Sms send failure
event.system.script=Script event handler failure
event.system.script=Script event handler failure
validate.valueRestored=Previous value restored

0 comments on commit 7b25463

Please sign in to comment.