2022-01-29 02:30:11 +05:30
|
|
|
import $ from 'jquery';
|
2021-10-21 13:07:43 +05:30
|
|
|
const {csrfToken} = window.config;
|
2021-10-16 22:58:04 +05:30
|
|
|
|
2021-11-09 14:57:25 +05:30
|
|
|
export function initCompWebHookEditor() {
|
2021-10-16 22:58:04 +05:30
|
|
|
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'), {
|
2021-10-21 13:07:43 +05:30
|
|
|
_csrf: csrfToken
|
2021-10-16 22:58:04 +05:30
|
|
|
}).done(
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location.href = $this.data('redirect');
|
|
|
|
}, 5000)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|