first qyality report

This commit is contained in:
2025-04-24 06:39:24 +03:00
parent 5526ff5840
commit fd8897aaca
5 changed files with 175 additions and 24 deletions

View File

@@ -128,15 +128,23 @@ document.addEventListener('DOMContentLoaded', () => {
// Handle report button clicks
reportButtons.forEach((button) => {
button.addEventListener('click', () => {
// Get the text label of the button
const reportLabel = button.textContent.trim();
// Update the title dynamically with the button's text label
reportTitle.textContent = `Data for "${reportLabel}"`;
// Fetch data for the selected report
const reportNumber = button.dataset.report;
// Update the title dynamically
reportTitle.textContent = `Data for "Report ${reportNumber}"`;
// Fetch data for the selected report (mocked for now)
fetch(`/get_report_data?report=${reportNumber}`)
.then((response) => response.json())
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then((data) => {
console.log("Fetched data:", data); // Debugging
populateTable(data);
})
.catch((error) => {
@@ -196,4 +204,74 @@ document.addEventListener('DOMContentLoaded', () => {
alert('Exporting current report as PDF...');
// Add logic to export the current report as PDF
});
});
document.addEventListener('DOMContentLoaded', () => {
const reportButtons = document.querySelectorAll('.report-btn');
const reportTitle = document.getElementById('report-title');
const reportTable = document.getElementById('report-table');
// Handle report button clicks
reportButtons.forEach((button) => {
button.addEventListener('click', () => {
const reportNumber = button.dataset.report;
// Get the text label of the button
const reportLabel = button.textContent.trim();
// Update the title dynamically
reportTitle.textContent = `Date pentru "${reportLabel}"`;
// Fetch data for the selected report
fetch(`/get_report_data?report=${reportNumber}`)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then((data) => {
console.log("Fetched data:", data); // Debugging
populateTable(data);
})
.catch((error) => {
console.error('Error fetching report data:', error);
});
});
});
// Populate the table with data
function populateTable(data) {
const tableHead = reportTable.querySelector('thead tr');
const tableBody = reportTable.querySelector('tbody');
// Clear existing table content
tableHead.innerHTML = '';
tableBody.innerHTML = '';
if (data.headers && data.rows) {
// Populate table headers
data.headers.forEach((header) => {
const th = document.createElement('th');
th.textContent = header;
tableHead.appendChild(th);
});
// Populate table rows
data.rows.forEach((row) => {
const tr = document.createElement('tr');
row.forEach((cell) => {
const td = document.createElement('td');
td.textContent = cell;
tr.appendChild(td);
});
tableBody.appendChild(tr);
});
} else {
// No data available
const tr = document.createElement('tr');
const td = document.createElement('td');
td.textContent = 'No data available.';
td.colSpan = data.headers ? data.headers.length : 1;
tr.appendChild(td);
tableBody.appendChild(tr);
}
}
});

View File

@@ -639,4 +639,32 @@ body.dark-mode .dashboard-full-width-card {
.dashboard-full-width-card {
flex: 1 1 100%; /* Ensure the full-width card spans the entire width */
}
}
/* Style for the export description label */
.export-description {
display: block;
margin-bottom: 10px;
font-size: 1em;
font-weight: bold;
color: #333; /* Default color for light mode */
}
/* Dark mode styles for the export description label */
body.dark-mode .export-description {
color: #fefdfd; /* Light color for dark mode */
}
/* Style for the container holding the last two buttons */
.form-centered.last-buttons .button-row {
display: flex;
justify-content: flex-start; /* Align buttons to the left */
gap: 10px; /* Add spacing between the buttons */
}
/* Style for the buttons */
.form-centered.last-buttons .btn {
padding: 5px 10px; /* Make the buttons smaller */
font-size: 0.9em; /* Reduce the font size */
border-radius: 3px; /* Slightly smaller border radius */
}