mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-28 12:44:57 +02:00
Delete individual subscans added
This commit is contained in:
@@ -71,7 +71,7 @@ SubScan History
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<table id="scan_history_table" class="table style-3 table-hover">
|
||||
<table id="subscan_history_table" class="table style-3 table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="checkbox-column text-center">Serial Number</th>
|
||||
@@ -85,7 +85,7 @@ SubScan History
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for subscan in subscans.all %}
|
||||
<tr id="scan_history_table_row_{{subscan.id}}">
|
||||
<tr id="subscan_history_table_row_{{subscan.id}}">
|
||||
<td class="checkbox-column"> {{ subscan.id }} </td>
|
||||
<td class=""> {{ subscan.id }} </td>
|
||||
<td class="">
|
||||
@@ -141,7 +141,7 @@ SubScan History
|
||||
<script src="{% static 'plugins/datatable/datatables.js' %}"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#scan_history_table').DataTable({
|
||||
var table = $('#subscan_history_table').DataTable({
|
||||
headerCallback: function(e, a, t, n, s) {
|
||||
e.getElementsByTagName("th")[0].innerHTML='<div class="form-check mb-2 form-check-primary"><input type="checkbox" class="float-start form-check-input chk-parent" id="head_checkbox" onclick=mainCheckBoxSelected(this)>\n<span class="new-control-indicator"></span><span style="visibility:hidden">c</span></div>\n'
|
||||
},
|
||||
@@ -390,7 +390,7 @@ $(document).ready(function() {
|
||||
}).then(res => res.json())
|
||||
.then(function (response) {
|
||||
if (response['status']) {
|
||||
delete_datatable_rows('#scan_history_table', selectedRows, show_snackbar=true, 'Subscans Deleted!')
|
||||
delete_datatable_rows('#subscan_history_table', selectedRows, show_snackbar=true, `${selectedRows.length} Subscans Deleted!`)
|
||||
}
|
||||
else{
|
||||
Snackbar.show({
|
||||
|
||||
+47
-44
@@ -771,7 +771,7 @@ function mark_important_subdomain(row, subdomain_id, target_summary){
|
||||
}
|
||||
|
||||
|
||||
function delete_scan(id, domain_name)
|
||||
function delete_scan(id)
|
||||
{
|
||||
const delAPI = "../delete/scan/"+id;
|
||||
swal.queue([{
|
||||
@@ -807,48 +807,6 @@ function delete_scan(id, domain_name)
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
function delete_subscan(id, domain_name)
|
||||
{
|
||||
const delAPI = "/api/action/rows/delete/";
|
||||
|
||||
swal.queue([{
|
||||
title: 'Are you sure you want to delete this subscan?',
|
||||
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"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(data) {
|
||||
// TODO Look for better way
|
||||
// delete table rows
|
||||
|
||||
})
|
||||
.catch(function() {
|
||||
swal.insertQueueStep({
|
||||
type: 'error',
|
||||
title: 'Oops! Unable to delete the scan history!'
|
||||
})
|
||||
})
|
||||
}
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
function stop_scan(celery_id, is_scan=true, reload_scan_bar=true, reload_location=false){
|
||||
const stopAPI = "/api/action/stop/scan/";
|
||||
data = {
|
||||
@@ -924,7 +882,7 @@ function delete_datatable_rows(table_id, rows_id, show_snackbar=true, snackbar_t
|
||||
// show_snackbar = bool => whether to show snackbar or not!
|
||||
// snackbar_title: str => snackbar title if show_snackbar = True
|
||||
|
||||
var table = $(scan_history_table).DataTable();
|
||||
var table = $(table_id).DataTable();
|
||||
for (var row in rows_id) {
|
||||
table.row(table_id + '_row_' + rows_id[row]).remove().draw();
|
||||
}
|
||||
@@ -936,3 +894,48 @@ function delete_datatable_rows(table_id, rows_id, show_snackbar=true, snackbar_t
|
||||
backgroundColor: '#e7515a',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function delete_subscan(subscan_id)
|
||||
{
|
||||
// This function will delete the sunscans using rest api
|
||||
// Supported method: POST
|
||||
const delAPI = "/api/action/rows/delete/";
|
||||
|
||||
var data = {'type': 'subscan', 'rows': [subscan_id]}
|
||||
|
||||
swal.queue([{
|
||||
title: 'Are you sure you want to delete this subscan?',
|
||||
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"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response['status']) {
|
||||
delete_datatable_rows('#subscan_history_table', [subscan_id], show_snackbar=true, '1 Subscan Deleted!')
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
swal.insertQueueStep({
|
||||
type: 'error',
|
||||
title: 'Oops! Unable to delete the scan history!'
|
||||
})
|
||||
})
|
||||
}
|
||||
}])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user