mirror of
https://github.com/MOIS3Y/logs-collector.git
synced 2025-09-13 13:13:01 +02:00
Create: switch ticket status ajax handler
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
$(function () {
|
||||
function deleteArchiveListElement(id) {
|
||||
const archiveList = `#li-archive-${id}`
|
||||
$(archiveList).remove()
|
||||
}
|
||||
$(".btn-archive-eraser").click(function (e) {
|
||||
e.preventDefault();
|
||||
const csrf = $("input[name=csrfmiddlewaretoken]").val()
|
||||
console.log(csrf)
|
||||
const archiveListElement = $(this).attr("data-jq-archive-target");
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: $(this).attr("href"),
|
||||
headers: {
|
||||
'X-CSRFToken':csrf,
|
||||
'Content-Type':'application/json'
|
||||
},
|
||||
// beforeSend: function(xhr) {
|
||||
// xhr.setRequestHeader("X-CSRFToken", csrf);
|
||||
// },
|
||||
success: function (response) {
|
||||
console.log(response)
|
||||
deleteArchiveListElement(archiveListElement);
|
||||
},
|
||||
error: function (response) {
|
||||
console.log(response)
|
||||
}
|
||||
});
|
||||
});
|
||||
console.log("JQ is ready to work");
|
||||
});
|
@@ -0,0 +1,61 @@
|
||||
$(function () {
|
||||
// CSRF token:
|
||||
const csrf = $("input[name=csrfmiddlewaretoken]").val()
|
||||
|
||||
function deleteArchiveListElement(id) {
|
||||
const archiveList = `#li-archive-${id}`
|
||||
$(archiveList).hide(1500);
|
||||
}
|
||||
$(".btn-archive-eraser").click(function (e) {
|
||||
e.preventDefault();
|
||||
const archiveListElement = $(this).attr("data-jq-archive-target");
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: $(this).attr("href"),
|
||||
headers: {
|
||||
'X-CSRFToken':csrf,
|
||||
'Content-Type':'application/json'
|
||||
},
|
||||
// beforeSend: function(xhr) {
|
||||
// xhr.setRequestHeader("X-CSRFToken", csrf);
|
||||
// },
|
||||
success: function (response) {
|
||||
console.log(response.status)
|
||||
deleteArchiveListElement(archiveListElement);
|
||||
},
|
||||
error: function (response) {
|
||||
console.log(response.status)
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#ticket-state").click(function () {
|
||||
console.log('Press');
|
||||
let resolved = false;
|
||||
if ($(this).attr("checked")) {
|
||||
console.log('Find it!!!')
|
||||
resolved = true;
|
||||
} else {
|
||||
resolved = false;
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: $(this).attr("ticket-state-url"),
|
||||
headers: {
|
||||
'X-CSRFToken':csrf,
|
||||
'Content-Type':'application/json'
|
||||
},
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({
|
||||
"resolved": resolved
|
||||
}),
|
||||
success: function (response) {
|
||||
console.log(response.status)
|
||||
},
|
||||
error: function (response) {
|
||||
console.log(response.status)
|
||||
}
|
||||
});
|
||||
});
|
||||
console.log("JQ is ready to work");
|
||||
});
|
Reference in New Issue
Block a user