Skip to content

Commit e09a546

Browse files
committed
Language selector dropdown
1 parent 186ef2f commit e09a546

5 files changed

Lines changed: 109 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

pyproxy/monitoring/static/monitoring.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,16 @@ window.addEventListener('DOMContentLoaded', () => {
351351
fetchAllData();
352352
updateCountdown();
353353
});
354+
355+
function toggleLangDropdown() {
356+
const dropdown = document.getElementById("langDropdown");
357+
dropdown.style.display = dropdown.style.display === "flex" ? "none" : "flex";
358+
}
359+
360+
document.addEventListener("click", (e) => {
361+
const dropdown = document.getElementById("langDropdown");
362+
const selector = document.querySelector(".lang-selector");
363+
if (!selector.contains(e.target)) {
364+
dropdown.style.display = "none";
365+
}
366+
});

pyproxy/monitoring/static/style.css

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ body {
1313
background: white;
1414
border-radius: 10px;
1515
box-shadow: 0 0 10px #ccc;
16+
position: relative;
1617
}
1718

1819
h1 {
@@ -180,4 +181,74 @@ input#connection-search, .connection-table {
180181

181182
.highlight {
182183
background-color: yellow;
183-
}
184+
}
185+
186+
.lang-selector {
187+
position: absolute;
188+
top: 15px;
189+
right: 20px;
190+
display: flex;
191+
flex-direction: column;
192+
align-items: flex-end;
193+
font-family: sans-serif;
194+
z-index: 100;
195+
}
196+
197+
.lang-current {
198+
display: flex;
199+
align-items: center;
200+
gap: 6px;
201+
cursor: pointer;
202+
border: 1px solid #ccc;
203+
border-radius: 6px;
204+
padding: 4px 8px;
205+
background-color: #fff;
206+
transition: background 0.2s;
207+
}
208+
209+
.lang-current:hover {
210+
background-color: #f0f0f0;
211+
}
212+
213+
.lang-current img {
214+
width: 28px;
215+
height: 20px;
216+
object-fit: cover;
217+
border: 1px solid #aaa;
218+
border-radius: 3px;
219+
}
220+
221+
.lang-dropdown {
222+
display: none;
223+
flex-direction: column;
224+
align-items: flex-start;
225+
margin-top: 4px;
226+
background: #fff;
227+
border: 1px solid #ccc;
228+
border-radius: 6px;
229+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
230+
overflow: hidden;
231+
}
232+
233+
.lang-dropdown a {
234+
display: flex;
235+
align-items: center;
236+
gap: 8px;
237+
padding: 6px 10px;
238+
width: 120px;
239+
text-decoration: none;
240+
color: #222;
241+
transition: background 0.2s;
242+
}
243+
244+
.lang-dropdown a:hover {
245+
background-color: #f5f5f5;
246+
}
247+
248+
.lang-dropdown img {
249+
width: 28px;
250+
height: 20px;
251+
object-fit: cover;
252+
border: 1px solid #aaa;
253+
border-radius: 3px;
254+
}

pyproxy/monitoring/templates/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@
1212
</head>
1313
<body>
1414
<div class="container">
15+
<div class="lang-selector">
16+
{% set current = get_locale().language %}
17+
<div class="lang-current" onclick="toggleLangDropdown()">
18+
{% if current == 'fr' %}
19+
<img src="{{ url_for('static', filename='flags/fr.svg') }}" alt="Français">
20+
<span>Français</span>
21+
{% else %}
22+
<img src="{{ url_for('static', filename='flags/en.svg') }}" alt="English">
23+
<span>English</span>
24+
{% endif %}
25+
26+
</div>
27+
<div class="lang-dropdown" id="langDropdown">
28+
<a href="?lang=en">
29+
<img src="{{ url_for('static', filename='flags/en.svg') }}" alt="English"> English
30+
</a>
31+
<a href="?lang=fr">
32+
<img src="{{ url_for('static', filename='flags/fr.svg') }}" alt="Français"> Français
33+
</a>
34+
</div>
35+
</div>
36+
1537
<h1>
1638
<img src="{{ url_for('static', filename='favicon.png') }}" alt="icon" class="favicon" />
1739
PyProxy Monitoring

0 commit comments

Comments
 (0)