Skip to content

Commit 7d7c7e7

Browse files
Add notification center in dashboard.
1 parent a8de76d commit 7d7c7e7

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const notificationCenter = {
2+
3+
showInfo: (message, duration = 5000, autoclose = true) => {
4+
notificationCenter.showNotification(message, false, duration, autoclose);
5+
},
6+
showError: (message, duration = 5000, autoclose = false) => {
7+
message = notificationCenter.errorTranslation(message);
8+
notificationCenter.showNotification(message, true, duration, autoclose);
9+
},
10+
11+
showNotification: (message, error, duration = 5000, autoclose = true) => {
12+
document.getElementById('notification-message').textContent = message;
13+
document.getElementById('notification-modal').style.display = 'block';
14+
15+
if (error) {
16+
document.getElementById('notification-content').classList.add('error');
17+
document.getElementById('notification-content').classList.remove('info');
18+
} else {
19+
document.getElementById('notification-content').classList.remove('error');
20+
document.getElementById('notification-content').classList.add('info');
21+
}
22+
23+
if (autoclose) {
24+
setTimeout(notificationCenter.closeNotification, duration);
25+
}
26+
},
27+
28+
closeNotification: () => {
29+
document.getElementById('notification-modal').style.display = 'none';
30+
},
31+
32+
errorTranslation: (errorMessage) => {
33+
if (errorMessage.includes('No Reachy Mini serial port found.')) {
34+
return 'Reachy Mini not detected on USB. Please check that the USB cable is properly connected.';
35+
}
36+
37+
console.log('No translation found for error message:', errorMessage);
38+
return errorMessage;
39+
},
40+
41+
};

src/reachy_mini/daemon/app/dashboard/static/style.css

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,60 @@ body {
9494
font-weight: 400;
9595
color: rgba(0, 0, 0, 0.7);
9696
}
97+
98+
99+
.notification-modal {
100+
position: fixed;
101+
bottom: 24px;
102+
right: 24px;
103+
z-index: 9999;
104+
min-width: 300px;
105+
max-width: 400px;
106+
background: #fff;
107+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
108+
border-radius: 8px;
109+
display: none;
110+
animation: fadeInUp 0.3s;
111+
}
112+
113+
@keyframes fadeInUp {
114+
from {
115+
opacity: 0;
116+
transform: translateY(40px);
117+
}
118+
119+
to {
120+
opacity: 1;
121+
transform: translateY(0);
122+
}
123+
}
124+
125+
.notification-content {
126+
padding: 20px 28px;
127+
border-radius: 8px;
128+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
129+
display: flex;
130+
align-items: center;
131+
justify-content: space-between;
132+
}
133+
134+
/* Notification variants */
135+
.notification-content.info {
136+
background: #fff;
137+
border: 1px solid #e0e0e0;
138+
}
139+
140+
.notification-content.error {
141+
background: #ffeaea;
142+
border: 1px solid #ff4d4f;
143+
color: #b71c1c;
144+
}
145+
146+
147+
.close-btn {
148+
background: none;
149+
border: none;
150+
font-size: 1.5em;
151+
cursor: pointer;
152+
color: #888;
153+
}

src/reachy_mini/daemon/app/dashboard/templates/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{% include "sections/daemon.html" %}
77
{% include "sections/apps.html" %}
88
{% include "sections/appstore.html" %}
9+
{% include "sections/notification.html" %}
910
</div>
1011
{% endblock %}
1112

@@ -14,4 +15,5 @@
1415
<script src="/static/js/apps.js"></script>
1516
<script src="/static/js/appstore.js"></script>
1617
<script src="/static/js/move_player.js"></script>
18+
<script src="/static/js/notification.js"></script>
1719
{% endblock %}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Notification Modal (Bottom Right) -->
2+
<div id="notification-modal" class="notification-modal">
3+
<div class="notification-content" id="notification-content">
4+
<!-- Notification message will appear here -->
5+
<span id="notification-message"></span>
6+
<button class="close-btn" onclick="closeNotification()">×</button>
7+
</div>
8+
</div>
9+
10+
<script>
11+
function showNotification(message) {
12+
document.getElementById('notification-message').textContent = message;
13+
document.getElementById('notification-modal').style.display = 'block';
14+
setTimeout(closeNotification, 5000); // Auto-close after 5s
15+
}
16+
function closeNotification() {
17+
document.getElementById('notification-modal').style.display = 'none';
18+
}
19+
</script>

0 commit comments

Comments
 (0)