ENHANCEMENT: removed jquery from index

This commit is contained in:
Jeroen De Meerleer 2021-07-30 14:04:42 +02:00
parent 14a78ad53c
commit bf62350d18
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 40 additions and 43 deletions

View File

@ -148,7 +148,7 @@ function initVarInputs()
function handleSecretCheckbox(event) { function handleSecretCheckbox(event) {
let ischecked = event.target.checked; let ischecked = event.target.checked;
event.target.parentElement.parentElement.querySelector('.var-value').type = ischecked ? 'password' : 'text'; event.target.closest('.var-group').querySelector('.var-value').type = ischecked ? 'password' : 'text';
} }
function initEternalCheckbox() { function initEternalCheckbox() {

View File

@ -1,65 +1,62 @@
import { Modal } from 'bootstrap'; import { Modal } from 'bootstrap';
$(function() { document.addEventListener("readystatechange", event => {
initDeleteButtons(); if(event.target.readyState === 'complete') {
initRunNowButtons(); initDeleteButtons();
}) initRunNowButtons();
}
});
function initDeleteButtons() { function initDeleteButtons() {
$('.delete-btn').on('click', function() { document.querySelectorAll('.delete-btn').forEach(elem => elem.addEventListener("click", event => {
let me = $(this) let me = event.currentTarget;
let href = me.data('href'); let href = me.dataset.href;
let confirmation = me.data('confirmation'); let confirmation = me.dataset.confirmation;
if(confirm(confirmation)) { if(confirm(confirmation)) {
$.ajax({ fetch(href, { method: 'DELETE' })
url: href, .then(response => response.json())
method: 'DELETE', .then(data => {
success: function(data) { window.location.href = data.return_path
window.location.href = data.return_path;
}
}) })
} }
}) }));
} }
function initRunNowButtons() { function initRunNowButtons() {
$('.runnow').on('click', function() { document.querySelectorAll('.runnow').forEach(elem => elem.addEventListener("click", event => {
let me = $(this) let me = event.currentTarget;
let href = me.data('href'); let href = me.dataset.href;
$.ajax({ fetch(href, { method: 'GET' })
url: href, .then(response => response.json())
method: 'GET', .then(data => {
success: function(data) { let modal = document.querySelector('#runnow_result');
let modal = $('#runnow_result'); modal.querySelector('.modal-title').innerHTML = data.title;
modal.find('.modal-title').html(data.title);
if (data.status == 'deferred') { if (data.status == 'deferred') {
modal.find('.modal-body').html(data.message); modal.querySelector('.modal-body').innerHTML = data.message;
me.addClass('disabled'); me.classList.add('disabled');
let td = me.closest('td');
let td = me.parents('td'); td.querySelectorAll('.btn').forEach(btn => {
td.find('.btn').each(function() { btn.classList.add('btn-outline-success');
let btn = $(this); btn.classList.remove('btn-outline-primary');
btn.addClass('btn-outline-success'); btn.classList.remove('btn-outline-danger');
btn.removeClass('btn-outline-primary');
btn.removeClass('btn-outline-danger');
}) })
let tr = me.parents('tr'); let tr = me.closest('tr');
tr.addClass('running'); tr.classList.add('running');
tr.addClass('text-success'); tr.classList.add('text-success');
tr.removeClass('norun'); tr.classList.remove('norun');
tr.removeClass('text-danger'); tr.classList.remove('text-danger');
} else if (data.status == 'ran') { } else if (data.status == 'ran') {
let content = '<p>Cronjob ran in ' + data.runtime.toFixed(3) + ' seconds with exit code ' + data.exitcode +'</p>' let content = '<p>Cronjob ran in ' + data.runtime.toFixed(3) + ' seconds with exit code ' + data.exitcode +'</p>'
content += '<pre>' + data.output + '</pre>' content += '<pre>' + data.output + '</pre>'
modal.find('.modal-body').html(content); modal.querySelector('.modal-body').innerHTML = content;
} }
var bsModal = new Modal('#runnow_result').show();//modal.modal({show: true}) var bsModal = new Modal('#runnow_result').show();
} })
}) })
}) )
} }