created quality page
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import mariadb
|
||||
from flask import Blueprint, render_template, redirect, url_for, request, flash, session, current_app
|
||||
from flask import Blueprint, render_template, redirect, url_for, request, flash, session, current_app, jsonify
|
||||
from .models import User
|
||||
from . import db
|
||||
|
||||
@@ -249,4 +249,17 @@ def save_external_db():
|
||||
f.write(f"password={password}\n")
|
||||
|
||||
flash('External database settings saved/updated successfully.')
|
||||
return redirect(url_for('main.settings'))
|
||||
return redirect(url_for('main.settings'))
|
||||
|
||||
@bp.route('/get_report_data')
|
||||
def get_report_data():
|
||||
report = request.args.get('report')
|
||||
# Mock data for demonstration
|
||||
data = {
|
||||
"headers": ["Column 1", "Column 2", "Column 3"],
|
||||
"rows": [
|
||||
[f"Row 1, Col 1 (Report {report})", "Row 1, Col 2", "Row 1, Col 3"],
|
||||
[f"Row 2, Col 1 (Report {report})", "Row 2, Col 2", "Row 2, Col 3"],
|
||||
],
|
||||
}
|
||||
return jsonify(data)
|
||||
@@ -120,4 +120,80 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
deleteUserPopup.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
// 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((data) => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Export buttons
|
||||
const exportCsvButton = document.getElementById('export-csv');
|
||||
const exportPdfButton = document.getElementById('export-pdf');
|
||||
|
||||
exportCsvButton.addEventListener('click', () => {
|
||||
alert('Exporting current report as CSV...');
|
||||
// Add logic to export the current report as CSV
|
||||
});
|
||||
|
||||
exportPdfButton.addEventListener('click', () => {
|
||||
alert('Exporting current report as PDF...');
|
||||
// Add logic to export the current report as PDF
|
||||
});
|
||||
});
|
||||
@@ -556,4 +556,87 @@ body.dark-mode .scan-table tr:nth-child(odd) {
|
||||
.scan-form-card, .scan-table-card {
|
||||
width: 100%; /* Make both cards take full width */
|
||||
}
|
||||
}
|
||||
|
||||
/* Dashboard container */
|
||||
.dashboard-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* Allow wrapping to the next row if needed */
|
||||
justify-content: space-between; /* Distribute cards evenly */
|
||||
gap: 20px; /* Add spacing between the cards */
|
||||
margin: 20px auto; /* Center the container */
|
||||
max-width: 1200px; /* Optional: Limit the maximum width of the container */
|
||||
}
|
||||
|
||||
/* Full-width card for the dashboard */
|
||||
.dashboard-full-width-card {
|
||||
flex: 0 0 100%; /* Take up the full width of the container */
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
/* Individual cards for the dashboard */
|
||||
.dashboard-card {
|
||||
flex: 1 1 calc(25% - 20px); /* Ensure cards are evenly distributed */
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
text-align: center;
|
||||
transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
/* Light mode styles for dashboard cards */
|
||||
body.light-mode .dashboard-card,
|
||||
body.light-mode .dashboard-full-width-card {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* Dark mode styles for dashboard cards */
|
||||
body.dark-mode .dashboard-card,
|
||||
body.dark-mode .dashboard-full-width-card {
|
||||
background: #1e1e1e;
|
||||
color: #fff;
|
||||
border: 1px solid #444;
|
||||
}
|
||||
|
||||
/* Ensure cards have consistent height */
|
||||
.dashboard-card h3 {
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.dashboard-card p {
|
||||
margin-bottom: 20px;
|
||||
color: inherit; /* Inherit text color from the card */
|
||||
}
|
||||
|
||||
.dashboard-card .btn {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
font-size: 1em;
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.dashboard-card .btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
/* Responsive design for smaller screens */
|
||||
@media (max-width: 768px) {
|
||||
.dashboard-card {
|
||||
flex: 1 1 100%; /* Stack cards vertically on smaller screens */
|
||||
}
|
||||
|
||||
.dashboard-full-width-card {
|
||||
flex: 1 1 100%; /* Ensure the full-width card spans the entire width */
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,28 @@
|
||||
{% block title %}Dashboard{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card-container">
|
||||
<div class="card">
|
||||
<div class="dashboard-container">
|
||||
|
||||
<!-- Row of evenly distributed cards -->
|
||||
<div class="dashboard-card">
|
||||
<h3>Accesare modul scanare</h3>
|
||||
<p>Modul de scanare finala a comenzilor de productie</p>
|
||||
<a href="{{ url_for('main.scan') }}" class="btn">Lansare modul de scanare</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="dashboard-card">
|
||||
<h3>Accesare modul calitate</h3>
|
||||
<p>Modul de verificare si configurare setari calitate.</p>
|
||||
<a href="{{ url_for('main.quality') }}" class="btn">Lansare modul calitate</a>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-card">
|
||||
<h3>Accesare modul magazie</h3>
|
||||
<p>Modul pentru managementul magaziei</p>
|
||||
<a href="{{ url_for('main.warehouse') }}" class="btn">Lansare modul Magazie</a>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-card">
|
||||
<h3>Manage Settings</h3>
|
||||
<p>Access and manage application settings.</p>
|
||||
<a href="{{ url_for('main.settings') }}" class="btn">Access Settings Page</a>
|
||||
|
||||
@@ -1,6 +1,36 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Quality Module{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Quality Module</h2>
|
||||
<p>Welcome to the Quality Module.</p>
|
||||
<div class="scan-container">
|
||||
<!-- Reports Card -->
|
||||
<div class="card scan-form-card">
|
||||
<h3>Rapoarte</h3>
|
||||
<div class="form-centered">
|
||||
<button class="btn report-btn" data-report="1">Report 1</button>
|
||||
<button class="btn report-btn" data-report="2">Report 2</button>
|
||||
<button class="btn report-btn" data-report="3">Report 3</button>
|
||||
<button class="btn report-btn" data-report="4">Report 4</button>
|
||||
<button class="btn report-btn" data-report="5">Report 5</button>
|
||||
</div>
|
||||
<div class="form-centered">
|
||||
<button class="btn export-btn" id="export-csv">Export the current report as CSV</button>
|
||||
<button class="btn export-btn" id="export-pdf">Export the current report as PDF</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Data Display Card -->
|
||||
<div class="card scan-table-card">
|
||||
<h3 id="report-title">No data to display, please select a report.</h3>
|
||||
<table class="scan-table" id="report-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- Table headers will be dynamically populated -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Table data will be dynamically populated -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user