Files
rengine/scanEngine/static/scanEngine/js/custom_scan_engine.js
T
2020-05-13 19:01:01 +05:30

73 lines
2.2 KiB
JavaScript

$(document).ready(function() {
var table = $('#show-hide-col').DataTable( {
"searching": false,
"scrollY": "280px",
"paging": false,
"info": false,
"ordering": false,
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 7
} );
$('a.toggle-vis').on( 'click', function (e) {
e.preventDefault();
// Get the column API object
var column = table.column( $(this).attr('data-column') );
// Toggle the visibility
column.visible( ! column.visible() );
} );
} );
function delete_engine(id, engine_name)
{
const delAPI = "delete/"+id;
swal.queue([{
title: 'Are you sure you want to delete '+ engine_name +'?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Delete',
padding: '2em',
showLoaderOnConfirm: true,
preConfirm: function() {
return fetch(delAPI, {
method: 'POST',
credentials: "same-origin",
headers: {
"X-CSRFToken": getCookie("csrftoken")
}
})
.then(function (response) {
return response.json();
})
.then(function(data) {
// TODO Look for better way
return location.reload();
})
.catch(function() {
swal.insertQueueStep({
type: 'error',
title: 'Oops! Unable to delete the domain!'
})
})
}
}])
}
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}