webcron/assets/job/index.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

import 'bootstrap';
2021-05-24 14:08:30 +02:00
$(function() {
initDeleteButtons();
2021-06-01 20:21:47 +02:00
initRunNowButtons();
2021-05-24 14:08:30 +02:00
})
function initDeleteButtons() {
$('.delete-btn').on('click', function() {
let me = $(this)
let href = me.data('href');
let confirmation = me.data('confirmation');
if(confirm(confirmation)) {
$.ajax({
url: href,
method: 'DELETE',
success: function(data) {
window.location.href = data.return_path;
}
})
}
})
2021-06-01 20:21:47 +02:00
}
function initRunNowButtons() {
$('.runnow').on('click', function() {
let me = $(this)
let href = me.data('href');
$.ajax({
url: href,
method: 'GET',
success: function(data) {
let modal = $('#runnow_result');
modal.find('.modal-title').html(data.title);
if (data.status == 'deferred') {
modal.find('.modal-body').html(data.message);
} else if (data.status == 'ran') {
let content = '<p>Cronjob ran in ' + data.runtime + 'seconds with exit code ' + data.exitcode +'</p>'
content += '<pre>' + data.output + '</pre>'
modal.find('.modal-body').html(content);
}
modal.modal({show: true})
}
})
})
2021-05-24 14:08:30 +02:00
}