-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
169 lines (153 loc) · 7.16 KB
/
dashboard.html
File metadata and controls
169 lines (153 loc) · 7.16 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Scanimal</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Header/Navigation -->
<header class="header">
<nav class="navbar">
<div class="nav-left">
<div class="logo-container">
<img src="/assets/logo.jpg" alt="Scanimal Logo" class="logo-image">
</div>
<button class="mobile-menu-toggle" aria-label="Toggle menu">
<span></span>
<span></span>
<span></span>
</button>
<ul class="nav-links">
<li><a href="index.html" class="nav-link">Home</a></li>
<li><a href="register.html" class="nav-link">Register Animal</a></li>
<li><a href="identify.html" class="nav-link">Identify Animal</a></li>
<li><a href="animals-list.html" class="nav-link">Animals List</a></li>
<li><a href="help-support.html" class="nav-link">Help & Support</a></li>
</ul>
</div>
<div class="nav-right">
<div class="user-menu">
<div class="user-profile">
<div class="profile-circle">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill="currentColor"/>
</svg>
</div>
<span id="userNameDisplay" class="user-name"></span>
</div>
<button id="logoutBtn" class="btn btn-secondary btn-sm">Logout</button>
</div>
</div>
</nav>
</header>
<!-- Main Content -->
<main class="dashboard-page">
<div class="container">
<h1 class="page-title">Dashboard</h1>
<div id="loadingMessage" class="loading-message">Loading dashboard...</div>
<div id="dashboardContent" style="display: none;">
<!-- User Info Card -->
<div class="dashboard-card">
<h2>Profile Information</h2>
<div class="profile-info">
<div class="info-item">
<span class="info-label">Name:</span>
<span id="profileName" class="info-value"></span>
</div>
<div class="info-item">
<span class="info-label">Email:</span>
<span id="profileEmail" class="info-value"></span>
</div>
<div class="info-item">
<span class="info-label">Role:</span>
<span id="profileRole" class="info-value"></span>
</div>
</div>
</div>
<!-- Statistics Card -->
<div class="dashboard-card">
<h2>Your Animals</h2>
<div class="stat-display">
<div class="stat-item">
<div class="stat-value" id="animalsCount">0</div>
<div class="stat-label">Registered Animals</div>
</div>
</div>
<div class="dashboard-actions">
<a href="register.html" class="btn btn-primary">Register New Animal</a>
<a href="animals-list.html" class="btn btn-secondary">View All Animals</a>
</div>
</div>
<!-- Recent Animals Card -->
<div class="dashboard-card">
<h2>Your Registered Animals</h2>
<div id="animalsList" class="animals-list">
<p class="empty-message">No animals registered yet. <a href="register.html">Register your first animal</a></p>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="footer">
<div class="container">
<p>© 2025 Scanimal. All rights reserved.</p>
</div>
</footer>
<script src="localStorage-api.js"></script>
<script src="auth-guard.js"></script>
<script src="script.js"></script>
<script>
// Check authentication
if (!window.localStorageAPI || !window.localStorageAPI.isAuthenticated()) {
window.location.href = 'login.html';
}
// Load dashboard data
function loadDashboard() {
const user = window.localStorageAPI.getCurrentUser();
if (user) {
// Display user info
document.getElementById('profileName').textContent = user.name;
document.getElementById('profileEmail').textContent = user.email;
document.getElementById('profileRole').textContent = user.role.charAt(0).toUpperCase() + user.role.slice(1);
document.getElementById('userNameDisplay').textContent = user.name;
// Get user's animals count
const userAnimals = window.localStorageAPI.getAnimalsByOwner(user.id);
document.getElementById('animalsCount').textContent = userAnimals.length;
// Load user's animals
loadUserAnimals(user.id);
} else {
window.location.href = 'login.html';
}
document.getElementById('loadingMessage').style.display = 'none';
document.getElementById('dashboardContent').style.display = 'block';
}
// Load user's animals
function loadUserAnimals(ownerId) {
const animals = window.localStorageAPI.getAnimalsByOwner(ownerId);
if (animals.length > 0) {
const animalsList = document.getElementById('animalsList');
animalsList.innerHTML = animals.map(animal => `
<div class="animal-item">
<div class="animal-info">
<strong>${animal.animalId || 'N/A'}</strong>
<span>${animal.animalType.charAt(0).toUpperCase() + animal.animalType.slice(1)}</span>
<span>${animal.gender.charAt(0).toUpperCase() + animal.gender.slice(1)}</span>
</div>
<a href="animal-profile.html?id=${animal._id}" class="btn btn-sm">View Details</a>
</div>
`).join('');
}
}
// Logout
document.getElementById('logoutBtn').addEventListener('click', function() {
window.localStorageAPI.logoutUser();
window.location.href = 'index.html';
});
// Load dashboard on page load
loadDashboard();
</script>
</body>
</html>