Skip to content

Commit 9c0e313

Browse files
committed
feat(ui): Improve device card with collapsible device info and table layout
Refactored the device information section in `device_card.html` to use a table for better alignment and readability. Implemented a collapsible section for device details, controlled by a new toggle button and JavaScript function. Enhanced visual hierarchy by bolding the labels within the device info table. Also, updated German translations to include the new "Device Info" string.
1 parent ccaad48 commit 9c0e313

File tree

5 files changed

+191
-115
lines changed

5 files changed

+191
-115
lines changed

tronbyt_server/static/css/manager.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,3 +1086,46 @@ button.action.w3-button {
10861086
box-sizing: border-box;
10871087
}
10881088
}
1089+
1090+
.device-info-toggle {
1091+
background-color: #f1f1f1;
1092+
color: #333;
1093+
cursor: pointer;
1094+
padding: 10px;
1095+
width: 100%;
1096+
border: none;
1097+
text-align: left;
1098+
outline: none;
1099+
font-size: 15px;
1100+
transition: 0.4s;
1101+
}
1102+
1103+
.device-info-toggle:hover {
1104+
background-color: #ddd;
1105+
}
1106+
1107+
.device-info-content {
1108+
padding: 0 18px;
1109+
background-color: white;
1110+
overflow: hidden;
1111+
transition: max-height 0.2s ease-out;
1112+
}
1113+
1114+
.device-info-table {
1115+
width: 100%;
1116+
border-collapse: collapse;
1117+
}
1118+
1119+
.device-info-table td:first-child {
1120+
font-weight: bold;
1121+
}
1122+
1123+
.device-info-table td {
1124+
padding: 8px;
1125+
border: 1px solid #ddd;
1126+
text-align: left;
1127+
}
1128+
1129+
.device-info-table tr:nth-child(even) {
1130+
background-color: #f2f2f2;
1131+
}

tronbyt_server/static/js/manager.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,17 @@ function handleDropZoneDrop(e) {
903903
// Clean up
904904
zone.classList.remove('active');
905905
}
906+
907+
function toggleDeviceInfo(button) {
908+
const content = button.nextElementSibling;
909+
const icon = button.querySelector('i');
910+
if (content.style.display === 'none') {
911+
content.style.display = 'block';
912+
icon.classList.remove('fa-chevron-down');
913+
icon.classList.add('fa-chevron-up');
914+
} else {
915+
content.style.display = 'none';
916+
icon.classList.remove('fa-chevron-up');
917+
icon.classList.add('fa-chevron-down');
918+
}
919+
}

tronbyt_server/templates/partials/device_card.html

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,31 @@ <h1>
3030
</div>
3131
<div>{{ _('Currently Displaying App') }}</div>
3232
<div class="device-info-box">
33-
{% if device.info.firmware_version %}
34-
<div>{{ _('Firmware Version:') }} {{ device.info.firmware_version }}</div>
35-
{% endif %}
36-
{% if device.info.firmware_type %}
37-
<div>{{ _('Firmware Type:') }} {{ device.info.firmware_type }}</div>
38-
{% endif %}
39-
{% if device.info.protocol_version %}
40-
<div>{{ _('Protocol Version:') }} {{ device.info.protocol_version }}</div>
41-
{% endif %}
42-
{% if device.info.mac_address %}
43-
<div>{{ _('MAC Address:') }} {{ device.info.mac_address }}</div>
44-
{% endif %}
45-
{% if device.info.protocol_type %}
46-
<div>{{ _('Protocol Type:') }} {{ device.info.protocol_type.value }}</div>
47-
{% endif %}
48-
{% if device.last_seen %}
49-
<div>{{ _('Last Seen:') }} {{ device.last_seen.astimezone().strftime('%Y-%m-%d %H:%M:%S') }}</div>
50-
{% endif %}
33+
<button class="device-info-toggle" onclick="toggleDeviceInfo(this)">
34+
<i class="fas fa-chevron-down"></i> {{ _('Device Info') }}
35+
</button>
36+
<div class="device-info-content" style="display: none;">
37+
<table class="device-info-table">
38+
{% if device.info.firmware_version %}
39+
<tr><td>{{ _('Firmware Version:') }}</td><td>{{ device.info.firmware_version }}</td></tr>
40+
{% endif %}
41+
{% if device.info.firmware_type %}
42+
<tr><td>{{ _('Firmware Type:') }}</td><td>{{ device.info.firmware_type }}</td></tr>
43+
{% endif %}
44+
{% if device.info.protocol_version %}
45+
<tr><td>{{ _('Protocol Version:') }}</td><td>{{ device.info.protocol_version }}</td></tr>
46+
{% endif %}
47+
{% if device.info.mac_address %}
48+
<tr><td>{{ _('MAC Address:') }}</td><td>{{ device.info.mac_address }}</td></tr>
49+
{% endif %}
50+
{% if device.info.protocol_type %}
51+
<tr><td>{{ _('Protocol Type:') }}</td><td>{{ device.info.protocol_type.value }}</td></tr>
52+
{% endif %}
53+
{% if device.last_seen %}
54+
<tr><td>{{ _('Last Seen:') }}</td><td>{{ device.last_seen.astimezone().strftime('%Y-%m-%d %H:%M:%S') }}</td></tr>
55+
{% endif %}
56+
</table>
57+
</div>
5158
</div>
5259
</td>
5360
</tr>
180 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)