diff options
Diffstat (limited to 'web_src/js/features/comp/WebHookEditor.js')
-rw-r--r-- | web_src/js/features/comp/WebHookEditor.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js new file mode 100644 index 0000000000..6911c6cb16 --- /dev/null +++ b/web_src/js/features/comp/WebHookEditor.js @@ -0,0 +1,40 @@ +const {csrf} = window.config; + +export function initWebHookEditor() { + if ($('.new.webhook').length === 0) { + return; + } + + $('.events.checkbox input').on('change', function () { + if ($(this).is(':checked')) { + $('.events.fields').show(); + } + }); + $('.non-events.checkbox input').on('change', function () { + if ($(this).is(':checked')) { + $('.events.fields').hide(); + } + }); + + const updateContentType = function () { + const visible = $('#http_method').val() === 'POST'; + $('#content_type').parent().parent()[visible ? 'show' : 'hide'](); + }; + updateContentType(); + $('#http_method').on('change', () => { + updateContentType(); + }); + + // Test delivery + $('#test-delivery').on('click', function () { + const $this = $(this); + $this.addClass('loading disabled'); + $.post($this.data('link'), { + _csrf: csrf + }).done( + setTimeout(() => { + window.location.href = $this.data('redirect'); + }, 5000) + ); + }); +} |