datavault-pro / admin.html
raibaebe's picture
i need to have excel import, admin login
bacb505 verified
Raw History Blame Contribute Delete
6.76 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel | DataVault Pro</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
</head>
<body class="bg-gray-50 min-h-screen">
<custom-navbar></custom-navbar>
<main class="container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<div class="bg-white rounded-lg shadow-sm p-6 mb-8">
<div class="flex items-center mb-6">
<i data-feather="shield" class="text-blue-600 mr-3"></i>
<h1 class="text-2xl font-semibold text-gray-800">Admin Panel</h1>
</div>
<div class="grid md:grid-cols-2 gap-6">
<div class="bg-white rounded-lg border border-gray-200 p-6">
<h2 class="text-lg font-medium text-gray-800 mb-4 flex items-center">
<i data-feather="upload" class="text-gray-600 mr-2"></i> Import Data
</h2>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Select Excel File</label>
<input type="file" id="excel-file" accept=".xlsx, .xls" class="block w-full text-sm text-gray-500
file:mr-4 file:py-2 file:px-4
file:rounded-md file:border-0
file:text-sm file:font-semibold
file:bg-blue-50 file:text-blue-700
hover:file:bg-blue-100">
</div>
<button id="import-btn" class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition duration-150 flex items-center justify-center">
<i data-feather="upload" class="mr-2"></i> Import Data
</button>
<div id="import-status" class="mt-4 text-sm hidden"></div>
</div>
<div class="bg-white rounded-lg border border-gray-200 p-6">
<h2 class="text-lg font-medium text-gray-800 mb-4 flex items-center">
<i data-feather="settings" class="text-gray-600 mr-2"></i> Admin Tools
</h2>
<div class="space-y-4">
<a href="#" class="block p-3 bg-gray-50 rounded-md hover:bg-gray-100 transition duration-150">
<div class="flex items-center">
<i data-feather="users" class="text-gray-600 mr-3"></i>
<span>User Management</span>
</div>
</a>
<a href="#" class="block p-3 bg-gray-50 rounded-md hover:bg-gray-100 transition duration-150">
<div class="flex items-center">
<i data-feather="key" class="text-gray-600 mr-3"></i>
<span>Permissions</span>
</div>
</a>
<a href="#" class="block p-3 bg-gray-50 rounded-md hover:bg-gray-100 transition duration-150">
<div class="flex items-center">
<i data-feather="activity" class="text-gray-600 mr-3"></i>
<span>System Logs</span>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script>
feather.replace();
document.getElementById('import-btn').addEventListener('click', function() {
const fileInput = document.getElementById('excel-file');
const statusDiv = document.getElementById('import-status');
if (fileInput.files.length === 0) {
statusDiv.textContent = 'Please select a file first.';
statusDiv.className = 'mt-4 text-sm text-red-600';
statusDiv.classList.remove('hidden');
return;
}
const file = fileInput.files[0];
const reader = new FileReader();
reader.onload = function(e) {
try {
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data, { type: 'array' });
// Get first sheet
const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
const jsonData = XLSX.utils.sheet_to_json(firstSheet);
// In a real app, you would send this to your backend
console.log('Excel data:', jsonData);
statusDiv.textContent = `Successfully imported ${jsonData.length} records from ${file.name}`;
statusDiv.className = 'mt-4 text-sm text-green-600';
statusDiv.classList.remove('hidden');
// Clear file input
fileInput.value = '';
} catch (error) {
statusDiv.textContent = 'Error processing file: ' + error.message;
statusDiv.className = 'mt-4 text-sm text-red-600';
statusDiv.classList.remove('hidden');
}
};
reader.onerror = function() {
statusDiv.textContent = 'Error reading file';
statusDiv.className = 'mt-4 text-sm text-red-600';
statusDiv.classList.remove('hidden');
};
reader.readAsArrayBuffer(file);
});
</script>
</body>
</html>