File size: 6,757 Bytes
bacb505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!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>