mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Fix webhook patch
This commit is contained in:
parent
14193d1233
commit
2ebbb1fdab
@ -1130,7 +1130,7 @@ class PanelHandler(BaseHandler):
|
||||
page_data["server_stats"][
|
||||
"server_type"
|
||||
] = self.controller.servers.get_server_type_by_id(server_id)
|
||||
page_data["new_webhook"] = True
|
||||
page_data["new_webhook"] = False
|
||||
page_data["webhook"] = self.controller.management.get_webhook_by_id(
|
||||
webhook_id
|
||||
)
|
||||
|
@ -120,6 +120,12 @@ class ApiServersServerWebhooksWebhookIndexHandler(BaseApiHandler):
|
||||
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
|
||||
|
||||
data["server_id"] = server_id
|
||||
if "trigger" in data.keys():
|
||||
triggers = ""
|
||||
for item in data["trigger"]:
|
||||
string = item + ","
|
||||
triggers += string
|
||||
data["trigger"] = triggers
|
||||
self.controller.management.modify_webhook(webhook_id, data)
|
||||
|
||||
self.controller.management.add_to_audit_log(
|
||||
|
@ -40,7 +40,7 @@
|
||||
<form class="forms-sample" method="post" id="new_webhook_form"
|
||||
action="/panel/new_webhook?id={{ data['server_stats']['server_id']['server_id'] }}">
|
||||
{% else %}
|
||||
<form class="forms-sample" method="post" id="schedule_form"
|
||||
<form class="forms-sample" method="post" id="webhook_form"
|
||||
action="/panel/edit_webhook?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{ data['webhook']['id'] }}">
|
||||
{% end %}
|
||||
<select class="form-select form-control form-control-lg select-css" id="webhook_type" name="webhook_type">
|
||||
@ -196,10 +196,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
$("#schedule_form").on("submit", async function (e) {
|
||||
$("#webhook_form").on("submit", async function (e) {
|
||||
e.preventDefault();
|
||||
var token = getCookie("_xsrf");
|
||||
let webhookForm = document.getElementById("new_webhook_form");
|
||||
let webhookForm = document.getElementById("webhook_form");
|
||||
let select_val = JSON.stringify($('#trigger-select').val());
|
||||
select_val = JSON.parse(select_val);
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
// Format the plain form data as JSON
|
||||
let formDataJsonString = JSON.stringify(formDataObject, replacer);
|
||||
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/webhooks/${webhookId}`, {
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/webhook/${webhookId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'X-XSRFToken': token,
|
||||
@ -228,8 +228,8 @@
|
||||
} else {
|
||||
|
||||
bootbox.alert({
|
||||
title: responseData.error,
|
||||
message: responseData.error_data
|
||||
title: responseData.status,
|
||||
message: responseData.error
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user