delete api working

This commit is contained in:
Yogesh Ojha
2020-05-10 15:43:29 +05:30
parent 5f6deabcc9
commit 0e64ae88f7
8 changed files with 2108 additions and 2513 deletions
@@ -1,251 +0,0 @@
$('.widget-content .message').on('click', function () {
swal({
title: 'Saved succesfully',
padding: '2em'
})
})
$('.widget-content .success').on('click', function () {
swal({
title: 'Good job!',
text: "You clicked the!",
type: 'success',
padding: '2em'
})
})
$('.widget-content .html-jquery').on('click', function () {
swal({
title: 'Custom animation with Animate.css',
animation: false,
customClass: 'animated tada',
padding: '2em'
})
})
$('.widget-content .title-text').on('click', function () {
swal({
title: 'The Internet?',
text: "That thing is still around?",
type: 'question',
padding: '2em'
})
})
$('.widget-content .custom-width-padding-background').on('click', function () {
swal({
title: 'Custom width, padding, background.',
width: 600,
padding: "7em",
customClass: "background-modal",
background: '#fff url(assets/img/640x426.jpg) no-repeat 100% 100%',
})
})
$('.widget-content .warning.confirm').on('click', function () {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Delete',
padding: '2em'
}).then(function(result) {
if (result.value) {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
})
})
$('.widget-content .warning.cancel').on('click', function () {
const swalWithBootstrapButtons = swal.mixin({
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger mr-3',
buttonsStyling: false,
})
swalWithBootstrapButtons({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
reverseButtons: true,
padding: '2em'
}).then(function(result) {
if (result.value) {
swalWithBootstrapButtons(
'Deleted!',
'Your file has been deleted.',
'success'
)
} else if (
// Read more about handling dismissals
result.dismiss === swal.DismissReason.cancel
) {
swalWithBootstrapButtons(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
})
$('.widget-content .html').on('click', function () {
swal({
title: '<i>HTML</i> <u>example</u>',
type: 'info',
html:
'You can use <b>bold text</b>, ' +
'<a href="//github.com">links</a> ' +
'and other HTML tags',
showCloseButton: true,
showCancelButton: true,
focusConfirm: false,
confirmButtonText:
'<i class="flaticon-checked-1"></i> Great!',
confirmButtonAriaLabel: 'Thumbs up, great!',
cancelButtonText:
'<i class="flaticon-cancel-circle"></i> Cancel',
cancelButtonAriaLabel: 'Thumbs down',
padding: '2em'
})
})
$('.widget-content .custom-image').on('click', function () {
swal({
title: 'Sweet!',
text: 'Modal with a custom image.',
imageUrl: 'assets/img/300x300.jpg',
imageWidth: 400,
imageHeight: 200,
imageAlt: 'Custom image',
animation: false,
padding: '2em'
})
})
$('.widget-content .timer').on('click', function () {
swal({
title: 'Auto close alert!',
text: 'I will close in 2 seconds.',
timer: 2000,
padding: '2em',
onOpen: function () {
swal.showLoading()
}
}).then(function (result) {
if (
// Read more about handling dismissals
result.dismiss === swal.DismissReason.timer
) {
console.log('I was closed by the timer')
}
})
})
$('.widget-content .chaining-modals').on('click', function () {
swal.mixin({
input: 'text',
confirmButtonText: 'Next &rarr;',
showCancelButton: true,
progressSteps: ['1', '2', '3'],
padding: '2em',
}).queue([
{
title: 'Question 1',
text: 'Chaining swal2 modals is easy'
},
'Question 2',
'Question 3'
]).then(function(result) {
if (result.value) {
swal({
title: 'All done!',
padding: '2em',
html:
'Your answers: <pre>' +
JSON.stringify(result.value) +
'</pre>',
confirmButtonText: 'Lovely!'
})
}
})
})
$('.widget-content .dynamic-queue').on('click', function () {
const ipAPI = 'https://api.ipify.org?format=json'
swal.queue([{
title: 'Your public IP',
confirmButtonText: 'Show my public IP',
text:
'Your public IP will be received ' +
'via AJAX request',
showLoaderOnConfirm: true,
preConfirm: function() {
return fetch(ipAPI)
.then(function (response) {
return response.json();
})
.then(function(data) {
return swal.insertQueueStep(data.ip)
})
.catch(function() {
swal.insertQueueStep({
type: 'error',
title: 'Unable to get your public IP'
})
})
}
}])
})
$('.widget-content .footer').on('click', function () {
swal({
type: 'error',
title: 'Oops...',
text: 'Something went wrong!',
footer: '<a href>Why do I have this issue?</a>',
padding: '2em'
})
})
$('.widget-content .RTL').on('click', function () {
swal({
title: 'هل تريد الاستمرار؟',
confirmButtonText: 'نعم',
cancelButtonText: 'لا',
showCancelButton: true,
showCloseButton: true,
padding: '2em',
target: document.getElementById('rtl-container')
})
})
$('.widget-content .mixin').on('click', function () {
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
padding: '2em'
});
toast({
type: 'success',
title: 'Signed in successfully',
padding: '2em',
})
})
@@ -1,122 +1,103 @@
/*
===============================
@Import Function
===============================
===============================
@Import Function
===============================
*/
/*
===============================
@Import Mixins
===============================
===============================
@Import Mixins
===============================
*/
.widget-content-area {
box-shadow: none !important; }
box-shadow: none !important;
}
table.dataTable {
border-collapse: separate !important;
border-spacing: 0 5px;
margin-top: 50px !important;
margin-bottom: 50px !important;
border-collapse: collapse !important; }
border-collapse: separate !important;
border-spacing: 0 5px;
margin-top: 50px !important;
margin-bottom: 50px !important;
border-collapse: collapse !important;
}
.table-hover:not(.table-dark) tbody tr td:first-child {
border-left: none !important;
border-left: none !important; }
border-left: none !important;
border-left: none !important;
}
.table-hover:not(.table-dark) tbody tr:hover .new-control.new-checkbox .new-control-indicator {
border: 2px solid #1b55e2; }
/*Style. 1*/
.style-1 .user-name {
font-size: 15px;
font-weight: 600;
color: #e2a03f; }
.style-1 .profile-img img {
width: 50px;
height: 50px;
border: 2px solid #d3d3d3;
border-radius: 6px;
box-shadow: 0px 0px 14px 3px rgba(126, 142, 177, 0.24); }
border: 2px solid #1b55e2;
}
/*Style. 2*/
.style-2 .new-control.new-checkbox .new-control-indicator {
top: 1px; }
top: 1px;
}
.style-2 .user-name {
font-size: 15px;
font-weight: 600;
color: #e2a03f; }
font-size: 15px;
font-weight: 600;
color: #e2a03f;
}
.style-2 img.profile-img {
width: 50px;
height: 50px;
border: 2px solid #d3d3d3;
box-shadow: 0px 0px 14px 3px rgba(126, 142, 177, 0.24); }
width: 50px;
height: 50px;
border: 2px solid #d3d3d3;
box-shadow: 0px 0px 14px 3px rgba(126, 142, 177, 0.24);
}
.style-2 .badge {
background: transparent;
transform: none; }
background: transparent;
transform: none;
}
.style-2 .badge-primary {
color: #1b55e2;
border: 2px dashed #1b55e2; }
color: #1b55e2;
border: 2px dashed #1b55e2;
}
.style-2 .badge-warning {
color: #e2a03f;
border: 2px dashed #e2a03f; }
color: #e2a03f;
border: 2px dashed #e2a03f;
}
.style-2 .badge-danger {
color: #e7515a;
border: 2px dashed #e7515a; }
color: #e7515a;
border: 2px dashed #e7515a;
}
/*Style. 3*/
.style-3 .new-control.new-checkbox .new-control-indicator {
top: 1px; }
.table-scan {
color: #888ea8;
margin-right: 6px;
vertical-align: middle;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer;
}
.style-3 .user-name {
font-size: 15px;
font-weight: 600;
color: #e2a03f; }
.table-hover:not(.table-dark) tbody tr:hover .table-scan {
color: #2962FF;
}
.style-3 img.profile-img {
width: 50px;
height: 50px;
border: 2px solid #d3d3d3;
border-radius: 6px;
box-shadow: 0px 0px 14px 3px rgba(126, 142, 177, 0.24); }
.table-edit {
color: #888ea8;
margin-right: 6px;
vertical-align: middle;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer;
}
.style-3 .badge {
background: transparent;
transform: none; }
.table-hover:not(.table-dark) tbody tr:hover .table-edit {
color: #FF6D00;
}
.table-delete {
color: #888ea8;
margin-right: 6px;
vertical-align: middle;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer;
}
.style-3 .badge-primary {
color: #1b55e2;
border: 2px dashed #1b55e2; }
.style-3 .badge-warning {
color: #e2a03f;
border: 2px dashed #e2a03f; }
.style-3 .badge-danger {
color: #e7515a;
border: 2px dashed #e7515a; }
.style-3 .table-controls {
padding: 0; }
.style-3 .table-controls li {
list-style: none;
display: inline; }
.style-3 .table-controls li svg {
color: #888ea8;
vertical-align: middle;
width: 28px;
height: 28px;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer; }
.style-3.table-hover:not(.table-dark) tbody tr:hover .table-controls li svg {
color: #e7515a;
fill: rgba(231, 81, 90, 0.219608); }
.style-3.table-hover:not(.table-dark) tbody tr:hover td:first-child {
color: #1b55e2 !important; }
.table-hover:not(.table-dark) tbody tr:hover .table-delete {
color: #e7515a;
}
File diff suppressed because it is too large Load Diff
@@ -1,203 +0,0 @@
/*
===============================
@Import Function
===============================
*/
/*
===============================
@Import Mixins
===============================
*/
.widget-content-area {
background-color: #3b3f5c;
-webkit-box-shadow: 0 4px 6px 0 rgba(85, 85, 85, 0.0901961), 0 1px 20px 0 rgba(0, 0, 0, 0.08), 0px 1px 11px 0px rgba(0, 0, 0, 0.06);
-moz-box-shadow: 0 4px 6px 0 rgba(85, 85, 85, 0.0901961), 0 1px 20px 0 rgba(0, 0, 0, 0.08), 0px 1px 11px 0px rgba(0, 0, 0, 0.06);
box-shadow: 0 4px 6px 0 rgba(85, 85, 85, 0.0901961), 0 1px 20px 0 rgba(0, 0, 0, 0.08), 0px 1px 11px 0px rgba(0, 0, 0, 0.06); }
.no-content:before, .no-content:after {
display: none !important; }
.new-control.new-checkbox .new-control-indicator {
top: 4px;
height: 22px;
width: 22px;
border-radius: 50%; }
.table > thead {
border-top: 1px solid rgba(136, 142, 168, 0.313725);
border-bottom: 1px solid rgba(136, 142, 168, 0.313725); }
table.dataTable {
border-collapse: separate;
border-spacing: 0 5px;
margin-top: 8px !important;
margin-bottom: 50px !important;
border-collapse: collapse !important; }
table.dataTable thead .sorting:before, table.dataTable thead .sorting:after {
opacity: 1;
color: #d3d3d3; }
table.dataTable thead .sorting_asc:before, table.dataTable thead .sorting_asc:after {
opacity: 1;
color: #d3d3d3; }
table.dataTable thead .sorting_desc:before, table.dataTable thead .sorting_desc:after {
opacity: 1;
color: #d3d3d3; }
table.dataTable thead .sorting_asc_disabled:before, table.dataTable thead .sorting_asc_disabled:after {
opacity: 1;
color: #d3d3d3; }
table.dataTable thead .sorting_desc_disabled:before, table.dataTable thead .sorting_desc_disabled:after {
opacity: 1;
color: #d3d3d3; }
table.dataTable thead .sorting_asc:before, table.dataTable thead .sorting_desc:after {
color: #ffff; }
.table > tbody:before {
line-height: 1em;
content: "_";
color: #3b3f5c;
display: block; }
.table > tbody tr {
border-radius: 4px;
-webkit-transition: all 0.1s ease;
transition: all 0.1s ease;
border-bottom: 1px solid rgba(136, 142, 168, 0.313725); }
.table > thead > tr > th {
color: #fff;
font-weight: 600;
font-size: 13px;
border: none;
letter-spacing: 1px;
text-transform: uppercase; }
.table > tbody > tr > td {
border: none;
color: #d3d3d3;
font-size: 13px;
letter-spacing: 1px; }
.table-striped tbody tr:nth-of-type(odd) {
background-color: transparent !important; }
.table > tfoot > tr > th {
border: none; }
.table-hover:not(.table-dark) tbody tr:hover {
background-color: transparent !important;
-webkit-transform: translateY(-1px) scale(1.01);
transform: translateY(-1px) scale(1.01); }
.table-hover.non-hover:not(.table-dark) tbody tr:hover {
-webkit-transform: none;
transform: none; }
div.dataTables_wrapper div.dataTables_info {
padding-top: 0.85em;
white-space: normal;
color: #acb0c3;
font-weight: 600;
border: 1px solid rgba(136, 142, 168, 0.313725);
display: inline-block;
padding: 10px 16px;
border-radius: 6px;
font-size: 13px; }
div.dataTables_wrapper div.dataTables_filter label {
position: relative; }
div.dataTables_wrapper div.dataTables_filter svg {
position: absolute;
top: 12px;
right: 14px;
width: 20px;
color: #d3d3d3; }
.dataTables_wrapper .form-control {
background: #3b3f5c;
border: none;
margin-top: 5px;
-webkit-box-shadow: 2px 5px 17px 0 rgba(31, 45, 61, 0.1);
box-shadow: 2px 5px 17px 0 rgba(31, 45, 61, 0.1);
border-radius: 6px;
border: 1px solid rgba(136, 142, 168, 0.313725);
padding: 8px 30px 8px 14px;
color: #f1f2f3; }
div.dataTables_wrapper div.dataTables_filter input {
width: 150px; }
.dataTables_wrapper .dataTables_length select.form-control {
padding: 8px 17px 8px 14px;
-moz-appearance: none;
/* Firefox */
-webkit-appearance: none;
/* Safari and Chrome */
appearance: none;
background: #3b3f5c url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23d3d3d3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-chevron-down'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") 50px 9px no-repeat; }
div.dataTables_wrapper div.dataTables_paginate {
margin: 0;
white-space: nowrap;
text-align: right;
display: inline-block; }
.page-link {
margin-right: 5px;
border-radius: 50%;
padding: 8px 12px;
background: rgba(0, 23, 55, 0.08);
border: none;
color: #888ea8; }
.page-link:focus {
box-shadow: none; }
div.dataTables_wrapper div.dataTables_paginate ul.pagination {
margin: 3px 0; }
.page-item.disabled .page-link {
background: #acb0c3; }
.page-item.disabled .page-link svg {
color: #3b3f5c; }
.page-item:first-child .page-link, .page-item:last-child .page-link {
border-radius: 50%;
padding: 5px 9px; }
.page-item:first-child .page-link:hover, .page-item:last-child .page-link:hover {
border-radius: 50%;
padding: 5px 9px;
background: #acb0c3;
color: #3b3f5c; }
.page-item:first-child .page-link svg, .page-item:last-child .page-link svg {
width: 17px; }
.page-item.active .page-link {
background-color: #ebedf2;
color: #3b3f5c; }
#alter_pagination_next a, #alter_pagination_previous a {
border-radius: 50%;
padding: 5px 9px; }
#alter_pagination_next a svg, #alter_pagination_previous a svg {
width: 17px; }
.table-cancel {
color: #888ea8;
margin-right: 6px;
vertical-align: middle;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer; }
.table-hover:not(.table-dark) tbody tr:hover .table-cancel {
color: #e7515a; }
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
.dataTables_wrapper .dataTables_length select.form-control {
background: transparent;
padding: 8px 10px 8px 14px; } }
@media (max-width: 767px) {
div.dataTables_wrapper div.dataTables_info {
margin-bottom: 40px; } }
@@ -179,11 +179,14 @@ div.dataTables_wrapper div.dataTables_paginate ul.pagination {
margin-right: 6px;
vertical-align: middle;
fill: rgba(0, 23, 55, 0.08);
cursor: pointer; }
cursor: pointer;
}
.table-hover:not(.table-dark) tbody tr:hover .table-cancel {
color: #e7515a; }
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
.dataTables_wrapper .dataTables_length select.form-control {
+62 -5
View File
@@ -10,6 +10,10 @@ List all targets
<link rel="stylesheet" type="text/css" href="{% static 'assets/css/forms/theme-checkbox-radio.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'plugins/table/datatable/dt-global_style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'plugins/table/datatable/custom_dt_custom.css' %}">
<script src="{% static 'plugins/sweetalerts/promise-polyfill.js' %}"></script>
<link href="{% static 'plugins/sweetalerts/sweetalert2.min.css' %}" rel="stylesheet" type="text/css" />
<link href="{% static 'plugins/sweetalerts/sweetalert.css' %}" rel="stylesheet" type="text/css" />
<link href="{% static 'assets/css/components/custom-sweetalert.css' %}" rel="stylesheet" type="text/css" />
{% endblock custom_js_css_link %}
{% block breadcrumb_title %}<h3>List all Target for Recon</h3>{% endblock breadcrumb_title %}
@@ -47,18 +51,18 @@ List all targets
<td>{{ domain.insert_date }}</td>
<td class="text-center"><span class="shadow-none badge badge-warning">Never Scanned Before</span></td>
<td class="text-center">
<a href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Scan">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-zap">
<a class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Scan">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-scan feather-zap" id="myInput" value="helloworld">
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
</svg>
</a>
<a href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-edit feather-edit-2">
<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
</svg>
</a>
<a href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-circle">
<a onclick="delete_domain({{ domain.id }}, '{{ domain.domain_name }}')" class="btnDelDomain" href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-delete feather-x-circle">
<circle cx="12" cy="12" r="10"></circle>
<line x1="15" y1="9" x2="9" y2="15"></line>
<line x1="9" y1="9" x2="15" y2="15"></line>
@@ -78,7 +82,60 @@ List all targets
{% block page_level_script %}
<script type="text/javascript">
function delete_domain(id, domain_name)
{
const delAPI = "../delete/"+id;
swal.queue([{
title: 'Are you sure you want to delete '+ domain_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) {
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;
}
</script>
<script src="{% static 'plugins/table/datatable/datatables.js' %}"></script>
<script src="{% static 'plugins/sweetalerts/sweetalert2.min.js' %}"></script>
<script src="{% static 'plugins/sweetalerts/custom-sweetalert.js' %}"></script>
<script>
// var e;
c1 = $('#style-2').DataTable({
+1
View File
@@ -7,4 +7,5 @@ urlpatterns = [
path('', views.index, name='targetIndex'),
path('add/', views.add_target_form, name='add_target_form'),
path('list/', views.list_target, name='list_target'),
path('delete/<int:id>', views.delete_domain, name='delete_domain_url'),
]
+10 -1
View File
@@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django import http
from .models import Domain
from django.contrib import messages
@@ -25,3 +25,12 @@ def list_target(request):
domains = Domain.objects
context = {'list_target_li': 'active', 'target_data_active': 'true', 'domains': domains}
return render(request, 'target/list.html', context)
def delete_domain(request, id):
obj = get_object_or_404(Domain, id=id)
if request.method == "POST":
obj.delete()
responseData = {'status': 'true'}
else:
responseData = {'status': 'false'}
return http.JsonResponse(responseData)