Files
aiinvoice_pharmacyDashboard/templates/dmh_dashboard.html
T
2026-10-07 17:31:08 +05:30

425 lines
14 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Dashboard - AI Infinite</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Global Styles (unchanged) */
:root {
--primary-color: #007bff;
--background-light: #f8f9fa;
--text-dark: #333;
--white: #fff;
}
body {
font-family: Arial, sans-serif;
color: var(--text-dark);
margin: 0;
padding: 0;
line-height: 1.6;
background-color: var(--background-light);
}
.navbar {
background-color: #f7f7f7;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.navbar-brand {
font-size: 1.5rem;
font-weight: bold;
color: var(--primary-color);
text-decoration: none;
display: flex;
align-items: center;
}
.navbar-toggler {
padding: 0.25rem 0.5rem;
border: none;
}
.navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0, 123, 255, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.main-container {
display: flex;
min-height: calc(100vh - 60px);
}
.sidebar {
width: 250px;
background-color: var(--white);
border-right: 1px solid #dee2e6;
padding: 1.5rem;
position: fixed;
height: 100%;
z-index: 1000;
transform: translateX(-100%);
transition: transform 0.3s ease;
}
.sidebar.active {
transform: translateX(0);
}
.sidebar .nav-link {
display: flex;
align-items: center;
gap: 0.5rem;
color: var(--text-dark);
padding: 0.75rem 1rem;
margin: 0.3rem 0;
border-radius: 5px;
text-decoration: none;
transition: background-color 0.3s;
}
.sidebar .nav-link:hover {
background-color: var(--background-light);
}
.sidebar .nav-link.active {
background-color: #e9ecef;
font-weight: bold;
}
.container {
max-width: 800px;
margin: 2rem auto;
padding: 0 1rem;
flex-grow: 1;
}
.card {
background-color: var(--white);
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
padding: 1.5rem;
margin-top: 1.5rem;
}
.card-title {
font-size: 1.5rem;
margin-bottom: 1rem;
color: var(--text-dark);
}
.form-label {
font-weight: 500;
color: var(--text-dark);
}
.form-control {
border-radius: 5px;
border: 1px solid #ccc;
padding: 0.75rem;
width: 100%;
margin-bottom: 1rem;
}
.btn-primary {
background-color: var(--primary-color);
color: var(--white);
padding: 0.75rem 1.5rem;
border: none;
border-radius: 5px;
font-weight: bold;
transition: background-color 0.3s;
width: 100%;
}
.btn-primary:hover {
background-color: #0056b3;
}
.loading-container {
display: none;
justify-content: center;
align-items: center;
gap: 10px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.dot {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: var(--primary-color);
animation: bounce 1.5s infinite ease-in-out;
}
.dot:nth-child(1) {
animation-delay: 0s;
}
.dot:nth-child(2) {
animation-delay: 0.2s;
}
.dot:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes bounce {
0%,
100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
.modal-body {
padding: 1rem;
max-height: 300px;
overflow-y: auto;
}
.modal-body p {
margin-bottom: 1rem;
}
.btn-secondary {
background-color: #6c757d;
color: var(--white);
padding: 0.5rem 1rem;
border: none;
border-radius: 5px;
transition: background-color 0.3s;
}
.btn-secondary:hover {
background-color: #5a6268;
}
@media (max-width: 768px) {
.sidebar {
width: 220px;
}
.container {
max-width: 90%;
margin: 1rem auto;
}
.navbar {
flex-direction: column;
align-items: flex-start;
}
}
@media (max-width: 480px) {
.card {
padding: 1rem;
}
.card-title {
font-size: 1.25rem;
}
.btn-primary {
padding: 0.5rem 1rem;
}
}
</style>
</head>
<body>
<nav class="navbar navbar-light bg-white shadow-sm">
<div class="container-fluid d-flex align-items-center justify-content-center position-relative">
<!-- Sidebar Toggle (Left) -->
<button class="navbar-toggler position-absolute start-0 ms-3" id="sidebarToggle">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Center Logo -->
<a href="{{ url_for('index') }}" class="navbar-brand m-0">
<img src="{{ url_for('static', filename='logos/logo.png') }}" alt="AI Infinite Logo"
class="navbar-logo">
</a>
</div>
</nav>
<div class="main-container">
<div class="sidebar">
<div class="nav flex-column">
<a class="nav-link" href="{{ url_for('home_logged_in') }}"><i class="fas fa-home"></i> Home
</a>
<a class="nav-link active" href="{{ url_for('dmh_dashboard') }}"><i class="fas fa-tachometer-alt"></i>
Dashboard Overview</a>
<a href="{{ url_for('view_history') }}" class="nav-link"><i class="fas fa-history"></i> View Document
History</a>
<a href="javascript:void(0);" class="nav-link" id="generate-api-key-btn"><i class="fas fa-key"></i>
Generate API Key</a>
<a href="javascript:void(0);" class="nav-link" id="view-api-key-btn"><i class="fas fa-eye"></i> View API
Key</a>
<a class="nav-link" href="{{ url_for('logout') }}"><i class="fas fa-sign-out-alt"></i> Logout</a>
</div>
</div>
<div class="container">
<!-- Flash Messages -->
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
<strong>{{ message }}</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<!-- Upload Document Card -->
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card shadow">
<div class="card-body">
<h4 class="card-title text-center mb-4">
Upload Invoice
</h4>
<form id="upload-form" action="{{ url_for('upload_image') }}" method="POST"
enctype="multipart/form-data">
<!-- hidden document type -->
<input type="hidden" name="doc_type" value="invoice">
<div class="mb-3">
<label for="file" class="form-label">
Choose Invoice File (PDF or Image)
</label>
<input type="file" class="form-control" id="file" name="file"
accept="image/*,application/pdf" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">
Upload and Extract
</button>
</div>
<div class="text-center mt-3" id="loading-container" style="display:none;">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Modal for API Key Display -->
<div class="modal fade" id="apiKeyModal" tabindex="-1" aria-labelledby="apiKeyModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="apiKeyModalLabel">Your API Key</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Your API Key: <span id="api-key-value"></span></p>
<button class="btn btn-secondary" onclick="copyToClipboard()">Copy</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Sidebar Toggle
document.getElementById('sidebarToggle').addEventListener('click', function () {
document.querySelector('.sidebar').classList.toggle('active');
});
// Generate API Key
document.getElementById('generate-api-key-btn').addEventListener('click', function () {
fetch("{{ url_for('generate_api_key') }}", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "same-origin"
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('api-key-value').innerText = data.api_key;
new bootstrap.Modal(document.getElementById('apiKeyModal')).show();
} else {
alert('Error: ' + data.error);
}
})
.catch(error => alert("An error occurred while generating the API key."));
});
// View API Key
document.getElementById('view-api-key-btn').addEventListener('click', function () {
fetch("{{ url_for('get_api_key') }}", {
method: "GET",
credentials: "same-origin"
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('api-key-value').innerText = data.api_key;
new bootstrap.Modal(document.getElementById('apiKeyModal')).show();
} else {
alert('Error: ' + data.error);
}
})
.catch(error => alert("An error occurred while fetching the API key."));
});
// Copy to Clipboard
function copyToClipboard() {
const apiKey = document.getElementById('api-key-value').innerText;
navigator.clipboard.writeText(apiKey).then(() => {
alert('API Key copied to clipboard');
}, () => {
alert('Failed to copy API Key');
});
}
// Loading Animation
document.getElementById("upload-form").addEventListener("submit", function () {
document.getElementById("loading-container").style.display = "block";
});
</script>
</body>
</html>