-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
316 lines (275 loc) · 9.26 KB
/
Copy pathdashboard.html
File metadata and controls
316 lines (275 loc) · 9.26 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<title>Dashboard - SignSecure</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.dashboard-container {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 24px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 48px;
max-width: 600px;
width: 100%;
text-align: center;
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.avatar {
width: 120px;
height: 120px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 50%;
margin: 0 auto 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 48px;
color: white;
font-weight: 600;
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
h1 {
font-size: 32px;
color: #1f2937;
margin-bottom: 8px;
font-weight: 700;
}
.welcome-text {
font-size: 18px;
color: #6b7280;
margin-bottom: 32px;
}
.user-info {
background: #f9fafb;
border-radius: 16px;
padding: 24px;
margin-bottom: 32px;
text-align: left;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 12px 0;
border-bottom: 1px solid #e5e7eb;
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
font-weight: 600;
color: #374151;
}
.info-value {
color: #6b7280;
}
.button-group {
display: flex;
gap: 16px;
flex-wrap: wrap;
}
.btn {
flex: 1;
min-width: 140px;
padding: 14px 28px;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}
.btn-secondary {
background: white;
color: #667eea;
border: 2px solid #667eea;
}
.btn-secondary:hover {
background: #667eea;
color: white;
transform: translateY(-2px);
}
.btn-logout {
background: #ef4444;
color: white;
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-logout:hover {
background: #dc2626;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}
.loading {
display: none;
text-align: center;
padding: 40px;
}
.spinner {
border: 4px solid #f3f4f6;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@media (max-width: 640px) {
.dashboard-container {
padding: 32px 24px;
}
h1 {
font-size: 24px;
}
.avatar {
width: 100px;
height: 100px;
font-size: 40px;
}
.button-group {
flex-direction: column;
}
.btn {
width: 100%;
}
}
</style>
</head>
<body>
<div class="loading" id="loading">
<div class="spinner"></div>
<p style="margin-top: 20px; color: white; font-size: 16px;">Loading...</p>
</div>
<div class="dashboard-container" id="dashboard" style="display: none;">
<div class="avatar" id="userAvatar">👤</div>
<h1 id="userName">Welcome</h1>
<p class="welcome-text">You have successfully logged in!</p>
<div class="user-info">
<div class="info-row">
<span class="info-label">Name:</span>
<span class="info-value" id="userFullName">-</span>
</div>
<div class="info-row">
<span class="info-label">Email:</span>
<span class="info-value" id="userEmail">-</span>
</div>
<div class="info-row">
<span class="info-label">Status:</span>
<span class="info-value" style="color: #10b981; font-weight: 600;">● Active</span>
</div>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="window.location.href='index.html'">
Back to Home
</button>
<button class="btn btn-logout" id="logoutBtn">
Logout
</button>
</div>
</div>
<script>
// Check authentication on page load
document.addEventListener('DOMContentLoaded', async function() {
const token = localStorage.getItem('token');
const loading = document.getElementById('loading');
const dashboard = document.getElementById('dashboard');
loading.style.display = 'block';
// If no token, redirect to login page
if (!token) {
setTimeout(() => {
alert('Please login to access the dashboard');
window.location.href = 'index.html';
}, 1000);
return;
}
// Try to get user info from localStorage (saved during login/signup)
const userDataStr = localStorage.getItem('userData');
if (userDataStr) {
try {
const userData = JSON.parse(userDataStr);
displayUserInfo(userData);
loading.style.display = 'none';
dashboard.style.display = 'block';
} catch (error) {
console.error('Error parsing user data:', error);
redirectToLogin();
}
} else {
// If no user data in localStorage, try to decode from token or redirect
redirectToLogin();
}
});
function displayUserInfo(userData) {
const userName = document.getElementById('userName');
const userFullName = document.getElementById('userFullName');
const userEmail = document.getElementById('userEmail');
const userAvatar = document.getElementById('userAvatar');
const firstName = userData.firstName || 'User';
const lastName = userData.lastName || '';
const email = userData.email || '';
// Display user information
userName.textContent = `Welcome, ${firstName}!`;
userFullName.textContent = `${firstName} ${lastName}`.trim();
userEmail.textContent = email;
// Set avatar with first letter of first name
userAvatar.textContent = firstName.charAt(0).toUpperCase();
}
function redirectToLogin() {
setTimeout(() => {
alert('Session expired. Please login again.');
localStorage.removeItem('token');
localStorage.removeItem('userData');
window.location.href = 'index.html';
}, 1000);
}
// Logout functionality
document.getElementById('logoutBtn').addEventListener('click', function() {
if (confirm('Are you sure you want to logout?')) {
localStorage.removeItem('token');
localStorage.removeItem('userData');
alert('You have been logged out successfully');
window.location.href = 'index.html';
}
});
</script>
</body>
</html>