Swift-Query / templates /admin /manage_doctors.html
Darshan Kumar R
Deploy to Hugging Face Spaces (Clean)
ed0b977
Raw History Blame Contribute Delete
13.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Manage Doctors - SWIFT QUERY</title>
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet" />
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
<script>
tailwind.config = {
darkMode: "class",
theme: {
extend: {
colors: {
primary: "#e67e22",
"background-light": "#fef3e9",
"background-dark": "#3c2a1a",
},
fontFamily: {
display: ["Lora", "serif"],
},
borderRadius: {
DEFAULT: "1rem",
},
},
},
};
</script>
<style>
.glass-effect {
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px)
}
.bg-gradient-warm {
background-image: linear-gradient(to right, #f8a65c, #d97706)
}
.bg-gradient-warm:hover {
background-image: linear-gradient(to right, #f9b170, #e67e22)
}
body {
background-image: url(https://images.unsplash.com/photo-1576091160550-2173dba999ef?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D);
background-size: cover;
background-position: center
}
</style>
</head>
<body
class="font-display bg-background-light dark:bg-background-dark text-slate-700 dark:text-slate-300 min-h-screen flex flex-col items-center p-4">
<header
class="w-full max-w-7xl mx-auto p-4 glass-effect bg-white/30 dark:bg-black/20 rounded-xl border border-white/20 dark:border-white/10 shadow-lg">
<nav class="flex justify-between items-center">
<div class="flex items-center gap-3">
<div class="bg-white/40 dark:bg-white/20 p-2 rounded-lg">
<img alt="SWIFT QUERY logo" class="h-6 w-6"
src="https://lh3.googleusercontent.com/aida-public/AB6AXuAo-0VjrEABAroA7y5_lx9DaLNKygExss7Nm-JDYOskVgALV9qdaAPI5i-PZTURZZgEjLr4rtqVCuuFvo2lxrhcPFo5rzzmjEBkaHow8xuV6nOcIWrotNl5ObyyAPl_SXiJf_z6PYLVARd_eU5xPHZZkkrOyx-HUjixqFKF3U_Mso6NjNK16mUpN9HcmNHUPFD1ZbvGwtvyAahfGscP0U9TG7sOTE9543xi7_Fsj819eadeslFzYJzPsdXDFzBMNa_8dNSvC_ka-HY" />
</div>
<span class="font-semibold text-slate-800 dark:text-white text-lg">Swift Query</span>
</div>
<div>
<a href="{{ url_for('admin.dashboard') }}"
class="text-slate-800 dark:text-white font-medium hover:text-primary transition-colors">Back to
Dashboard</a>
</div>
</nav>
</header>
<main class="flex-grow w-full max-w-7xl mx-auto p-8">
<div class="text-center mb-12">
<h1 class="text-4xl font-bold text-slate-900 dark:text-white">Manage Doctors</h1>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div
class="glass-effect bg-white/40 dark:bg-black/30 p-8 rounded-2xl border border-white/30 dark:border-white/10 shadow-lg">
<h2 class="text-2xl font-bold text-slate-900 dark:text-white mb-6">Add Doctor</h2>
<form method="POST" action="{{ url_for('admin.add_doctor') }}" class="space-y-4">
<input
class="w-full px-4 py-3 rounded-lg bg-white/50 dark:bg-black/20 border border-white/30 dark:border-white/10 focus:ring-2 focus:ring-primary focus:border-primary transition-all placeholder-slate-500 dark:placeholder-slate-400 text-slate-800 dark:text-white shadow-sm"
type="text" name="name" placeholder="Name" required>
<input
class="w-full px-4 py-3 rounded-lg bg-white/50 dark:bg-black/20 border border-white/30 dark:border-white/10 focus:ring-2 focus:ring-primary focus:border-primary transition-all placeholder-slate-500 dark:placeholder-slate-400 text-slate-800 dark:text-white shadow-sm"
type="text" name="specialization" placeholder="Specialization" required>
<input
class="w-full px-4 py-3 rounded-lg bg-white/50 dark:bg-black/20 border border-white/30 dark:border-white/10 focus:ring-2 focus:ring-primary focus:border-primary transition-all placeholder-slate-500 dark:placeholder-slate-400 text-slate-800 dark:text-white shadow-sm"
type="email" name="email" placeholder="Email" required>
<input
class="w-full px-4 py-3 rounded-lg bg-white/50 dark:bg-black/20 border border-white/30 dark:border-white/10 focus:ring-2 focus:ring-primary focus:border-primary transition-all placeholder-slate-500 dark:placeholder-slate-400 text-slate-800 dark:text-white shadow-sm"
type="text" name="phone" placeholder="Phone" required>
<input
class="w-full px-4 py-3 rounded-lg bg-white/50 dark:bg-black/20 border border-white/30 dark:border-white/10 focus:ring-2 focus:ring-primary focus:border-primary transition-all placeholder-slate-500 dark:placeholder-slate-400 text-slate-800 dark:text-white shadow-sm"
type="password" name="password" placeholder="Password" required>
<button type="submit"
class="w-full bg-gradient-warm text-white font-bold py-3 px-4 rounded-full shadow-lg hover:shadow-xl transition-all text-lg focus:outline-none focus:ring-4 focus:ring-orange-300 dark:focus:ring-orange-800">Add
Doctor</button>
</form>
</div>
<div
class="glass-effect bg-white/40 dark:bg-black/30 p-8 rounded-2xl border border-white/30 dark:border-white/10 shadow-lg">
<h2 class="text-2xl font-bold text-slate-900 dark:text-white mb-6">Existing Doctors</h2>
<div class="overflow-x-auto">
<table class="w-full text-left text-slate-800 dark:text-slate-200">
<thead class="border-b border-white/20 dark:border-white/10">
<tr>
<th class="p-4">Name</th>
<th class="p-4">Specialization</th>
<th class="p-4">Email</th>
<th class="p-4">Phone</th>
<th class="p-4">Action</th>
</tr>
</thead>
<tbody>
{% for doctor in doctors %}
<tr class="border-b border-white/10 dark:border-white/5">
<td class="p-4">{{ doctor.name }}</td>
<td class="p-4">{{ doctor.specialization }}</td>
<td class="p-4">{{ doctor.email }}</td>
<td class="p-4">{{ doctor.phone }}</td>
<td class="p-4"><a
href="{{ url_for('admin.delete_user', user_type='doctor', user_id=doctor.id) }}"
class="text-red-500 hover:underline">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</main>
<footer
class="w-full max-w-7xl mx-auto p-4 mt-8 text-center glass-effect bg-white/20 dark:bg-black/20 rounded-xl border border-white/20 dark:border-white/10 shadow-lg">
<p class="text-sm text-slate-800 dark:text-slate-200">Copyright © 2025 SWIFT QUERY. All rights reserved.</p>
</footer>
<script>
// --- AI Text Enhancer Logic (Shared - Admin Doctor) ---
function enhanceText(inputId, endpoint) {
const inputEl = document.getElementById(inputId);
if (!inputEl) return;
const originalText = inputEl.value.trim();
if (!originalText) { alert("Please enter text."); return; }
const btn = document.getElementById(`enhance-btn-${inputId}`);
if (btn) btn.innerHTML = '<span class="material-icons-outlined animate-spin text-sm">autorenew</span>';
fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: originalText })
})
.then(r => r.json())
.then(d => {
if (d.enhanced_text) showEnhancementUI(inputId, originalText, d.enhanced_text);
else alert('Enhancement failed: ' + (d.error || 'Unknown'));
})
.catch(e => { console.error(e); alert('Error enhancing text.'); })
.finally(() => { if (btn) btn.innerHTML = '<span class="material-icons-outlined text-sm">auto_fix_high</span>'; });
}
function showEnhancementUI(inputId, originalText, enhancedText) {
const inputEl = document.getElementById(inputId);
inputEl.value = enhancedText;
inputEl.classList.add('ring-2', 'ring-primary', 'bg-orange-50');
let controls = document.getElementById(`enhance-controls-${inputId}`);
if (!controls) {
controls = document.createElement('div');
controls.id = `enhance-controls-${inputId}`;
controls.className = "enhance-controls flex gap-2 mt-2 items-center justify-end animate-fade-in";
controls.innerHTML = `
<span class="text-xs text-primary font-bold mr-auto flex items-center gap-1"><span class="material-icons-outlined text-sm">auto_awesome</span> AI Check</span>
<button type="button" onclick="acceptEnhancement('${inputId}')" class="bg-green-100 text-green-700 p-2 rounded-full hover:bg-green-200"><span class="material-icons-outlined text-lg">check</span></button>
<button type="button" onclick="discardEnhancement('${inputId}')" class="bg-red-100 text-red-700 p-2 rounded-full hover:bg-red-200"><span class="material-icons-outlined text-lg">close</span></button>
<button type="button" onclick="retryEnhancement('${inputId}')" class="bg-blue-100 text-blue-700 p-2 rounded-full hover:bg-blue-200"><span class="material-icons-outlined text-lg">replay</span></button>
`;
controls.dataset.original = originalText;
inputEl.parentNode.insertBefore(controls, inputEl.nextSibling);
} else {
controls.dataset.original = originalText;
controls.style.display = 'flex';
}
}
function acceptEnhancement(id) {
const el = document.getElementById(id);
el.classList.remove('ring-2', 'ring-primary', 'bg-orange-50');
el.classList.add('bg-green-50'); setTimeout(() => el.classList.remove('bg-green-50'), 1000);
document.getElementById(`enhance-controls-${id}`).style.display = 'none';
}
function discardEnhancement(id) {
const c = document.getElementById(`enhance-controls-${id}`);
if (c.dataset.original) document.getElementById(id).value = c.dataset.original;
document.getElementById(id).classList.remove('ring-2', 'ring-primary', 'bg-orange-50');
c.style.display = 'none';
}
function retryEnhancement(id) { enhanceText(id, '/admin/enhance-text'); }
function attachEnhancer(inputId, isTextarea = false) {
const inputEl = document.getElementById(inputId);
if (!inputEl || document.getElementById(`enhance-btn-${inputId}`)) return;
const btn = document.createElement('button');
btn.type = 'button';
btn.id = `enhance-btn-${inputId}`;
btn.className = "absolute right-3 top-1/2 -translate-y-1/2 text-primary hover:text-orange-700 bg-transparent p-1 z-10";
btn.innerHTML = '<span class="material-icons-outlined text-sm">auto_fix_high</span>';
btn.onclick = () => enhanceText(inputId, '/admin/enhance-text');
const parent = inputEl.parentNode;
if (window.getComputedStyle(parent).position === 'static') parent.classList.add('relative');
parent.appendChild(btn);
}
document.addEventListener('DOMContentLoaded', () => {
// Target Add Doctor inputs
const inputs = document.querySelectorAll('form[action*="add_doctor"] input[type="text"]');
inputs.forEach(el => {
if (!el.id) el.id = "admin-doc-" + Math.random().toString(36).substr(2, 9);
attachEnhancer(el.id, false);
});
});
</script>
</body>
</html>