Skip to content

Commit

Permalink
Merge pull request #1048 from support-project/webhook_test
Browse files Browse the repository at this point in the history
Changed to display WebHook test results
  • Loading branch information
koda-masaru authored Jun 26, 2018
2 parents d43f591 + a984f8e commit 6cfd105
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.support.project.web.dao.ProxyConfigsDao;
import org.support.project.web.entity.ProxyConfigsEntity;

import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -112,9 +114,16 @@ public Boundary test() throws Exception {

WebhookLogic.get().notify(proxyConfig, webhookConfig, json);
addMsgInfo("knowledge.webhook.test.success");
setAttribute("TEST_JSON", json);
} catch (Exception e) {
LOG.error("WebHook test was error.", e);
addMsgError("knowledge.webhook.test.error");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.flush();
String str = sw.toString();
setAttribute("TEST_ERROR_RESULT", str);
}

return config();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ knowledge.webhook.delete.error=Failed to delete the webhook settings.
knowledge.webhook.delete.success=Deleted the setting of Webhooks.
knowledge.webhook.test.error=Failed to test the webhook settings.
knowledge.webhook.test.success=Test send of webhook was successful.
knowledge.webhook.test.result=Sended JSON
knowledge.webhook.customize=Customize
knowledge.webhook.customize.ignore.proxy=Ignore proxy
knowledge.webhook.customize.template=Template of send JSON(When saved as empty it returns to the initial template)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/appresource_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ knowledge.webhook.delete.error=Webhookの設定の削除に失敗しました
knowledge.webhook.delete.success=Webhookの設定を削除しました
knowledge.webhook.test.error=Webhookのテスト送信に失敗しました
knowledge.webhook.test.success=Webhookのテスト送信に成功しました
knowledge.webhook.test.result=テストで送信したJSON
knowledge.webhook.customize=Customize
knowledge.webhook.customize.ignore.proxy=Proxyを使わない
knowledge.webhook.customize.template=送信するJSONのテンプレート(空で保存すると初期値に戻ります)
Expand Down
45 changes: 44 additions & 1 deletion src/main/webapp/WEB-INF/views/admin/webhook/config.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
.pull-right {
margin-left: 5px;
}
.bootbox-form > .bootbox-input-textarea {
height: 300px;
}
</style>
</c:param>

Expand Down Expand Up @@ -93,6 +96,36 @@ function putConfig() {
});
}
<% if (request.getAttribute("TEST_JSON") != null) { %>
var text = $('#TEST_JSON').val();
try {
text = JSON.stringify(JSON.parse(text), null, ' ');
} catch(e) {
}
bootbox.prompt({
title: "<%= jspUtil.label("knowledge.webhook.test.result") %>",
inputType: 'textarea',
value: text,
size: 'large',
callback: function (result) {
console.log(result);
}
});
<% } %>
<% if (request.getAttribute("TEST_ERROR_RESULT") != null) { %>
var text = $('#TEST_ERROR_RESULT').val();
bootbox.prompt({
title: "<%= jspUtil.label("knowledge.webhook.test.error") %>",
inputType: 'textarea',
value: text,
size: 'large',
callback: function (result) {
console.log(result);
}
});
<% } %>
</script>
</c:param>
<c:param name="PARAM_CONTENT">
Expand Down Expand Up @@ -208,7 +241,17 @@ function putConfig() {
</div>



<div style="visibility:hidden">
<% if (request.getAttribute("TEST_JSON") != null) { %>
<textarea id="TEST_JSON">
<%= jspUtil.out("TEST_JSON") %>
</textarea>
<% } %>
<% if (request.getAttribute("TEST_ERROR_RESULT") != null) { %>
<textarea id="TEST_ERROR_RESULT">
<%= jspUtil.out("TEST_ERROR_RESULT") %>
</textarea>
<% } %>


</c:param>
Expand Down

0 comments on commit 6cfd105

Please sign in to comment.