35286-vm/assets/js/main.js
Flatlogic Bot 6e132e0b38 0.2
2025-10-27 21:34:11 +00:00

67 lines
2.2 KiB
JavaScript

function updateStatus(id, status) {
if (!confirm(`Are you sure you want to change the status to "${status}"?`)) {
return;
}
fetch('api/update-status.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: id, status: status }),
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.reload();
} else {
alert('Error updating status: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('An unexpected error occurred.');
});
}
document.addEventListener('DOMContentLoaded', function() {
const chartCanvas = document.getElementById('applicationsChart');
if (chartCanvas) {
fetch('/api/chart-data.php')
.then(response => response.json())
.then(data => {
if (data.success) {
const ctx = chartCanvas.getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: [{
label: 'New Applications',
data: data.data,
fill: false,
borderColor: '#0052CC',
tension: 0.1
}]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks: {
stepSize: 1
}
}
},
responsive: true,
maintainAspectRatio: false
}
});
} else {
console.error('Failed to load chart data:', data.message);
}
})
.catch(error => console.error('Error fetching chart data:', error));
}
});