feat: Add real-time notification center with WebSocket integration

- Add in-app notification system with database storage
- Implement bell icon component with unread count badge in dashboard header
- Add full Notifications page tab with pagination and filtering (All/Unread/Read)
- Implement real-time WebSocket push notifications to all connected clients
- Add notification API endpoints: GET, PUT /read, DELETE, POST /clear
- Fix critical bug in notificationService where 'status' variable was undefined
- Add Notifications route to App.js routing
- Enhanced UI with notification popup in header and dedicated full-page view
- Auto-reconnect WebSocket with 5s timeout on disconnect
- Support rich notification content with resource details and timestamps
This commit is contained in:
nmemmert committed 2026-01-14 14:51:29 -05:00
1 parent 7968c9231e
commit db85573986
37 files changed
+3521 -207

No files matched your search

+262
View File
@@ -0,0 +1,262 @@
.notification-center {
position: relative;
}
.notification-bell-container {
display: flex;
align-items: center;
}
.notification-bell {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
position: relative;
padding: 0.5rem;
transition: transform 0.2s;
}
.notification-bell:hover {
transform: scale(1.1);
}
.notification-badge {
position: absolute;
top: 0;
right: 0;
background: #dc3545;
color: white;
border-radius: 50%;
width: 1.25rem;
height: 1.25rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.65rem;
font-weight: bold;
line-height: 1;
}
.notification-popup {
position: fixed;
top: 60px;
right: 20px;
width: 400px;
max-height: 600px;
background: white;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 1000;
display: flex;
flex-direction: column;
overflow: hidden;
}
.notification-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
border-bottom: 1px solid #eee;
background: #f9f9f9;
}
.notification-header h3 {
margin: 0;
font-size: 1.1rem;
color: #333;
}
.close-btn {
background: none;
border: none;
font-size: 1.25rem;
cursor: pointer;
color: #999;
padding: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
}
.close-btn:hover {
color: #333;
}
.notification-filters {
display: flex;
gap: 0.5rem;
padding: 0.75rem 1rem;
border-bottom: 1px solid #eee;
background: #fafafa;
flex-wrap: wrap;
}
.filter-btn {
padding: 0.4rem 0.75rem;
border: 1px solid #ddd;
background: white;
border-radius: 4px;
cursor: pointer;
font-size: 0.85rem;
transition: all 0.2s;
}
.filter-btn:hover {
border-color: #007bff;
color: #007bff;
}
.filter-btn.active {
background: #007bff;
color: white;
border-color: #007bff;
}
.clear-btn {
margin-left: auto;
background: #dc3545;
color: white;
border-color: #dc3545;
}
.clear-btn:hover {
background: #c82333;
border-color: #c82333;
}
.notification-list {
flex: 1;
overflow-y: auto;
max-height: 450px;
}
.notification-item {
padding: 1rem;
border-bottom: 1px solid #eee;
display: flex;
gap: 0.75rem;
background: white;
transition: background 0.2s;
}
.notification-item:hover {
background: #f9f9f9;
}
.notification-item.unread {
background: #f0f8ff;
font-weight: 500;
}
.notification-content {
flex: 1;
min-width: 0;
}
.notification-title {
font-weight: 600;
margin-bottom: 0.25rem;
font-size: 0.95rem;
color: #333;
}
.notification-message {
font-size: 0.85rem;
color: #666;
margin-bottom: 0.5rem;
word-break: break-word;
}
.notification-meta {
display: flex;
gap: 0.75rem;
font-size: 0.75rem;
color: #999;
flex-wrap: wrap;
}
.notification-resource {
background: #f0f0f0;
padding: 0.2rem 0.5rem;
border-radius: 3px;
}
.notification-time {
white-space: nowrap;
}
.notification-actions {
display: flex;
gap: 0.5rem;
align-items: flex-start;
}
.action-btn {
background: none;
border: none;
cursor: pointer;
font-size: 1rem;
padding: 0.25rem 0.5rem;
color: #999;
transition: color 0.2s;
flex-shrink: 0;
}
.action-btn:hover {
color: #333;
}
.action-btn.mark-read:hover {
color: #28a745;
}
.action-btn.delete:hover {
color: #dc3545;
}
/* Scrollbar styling */
.notification-list::-webkit-scrollbar {
width: 6px;
}
.notification-list::-webkit-scrollbar-track {
background: #f1f1f1;
}
.notification-list::-webkit-scrollbar-thumb {
background: #888;
border-radius: 3px;
}
.notification-list::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Mobile responsive */
@media (max-width: 600px) {
.notification-popup {
position: fixed;
top: 60px;
right: 10px;
left: 10px;
width: auto;
max-height: 70vh;
}
.notification-filters {
flex-direction: column;
}
.filter-btn {
flex: 1;
}
.clear-btn {
margin-left: 0;
}
}