Skip to content

Commit fc4e0ef

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 fc4e0ef

File tree

5 files changed

+189
-115
lines changed

5 files changed

+189
-115
lines changed

tronbyt_server/static/css/manager.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,3 +1086,40 @@ 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 15px;
1109+
overflow: hidden;
1110+
transition: max-height 0.2s ease-out, padding-top 0.2s ease-out, padding-bottom 0.2s ease-out;
1111+
max-height: 0;
1112+
}
1113+
1114+
.device-info-table {
1115+
width: 100%;
1116+
}
1117+
1118+
.device-info-table td:first-child {
1119+
font-weight: bold;
1120+
}
1121+
1122+
.device-info-table td {
1123+
text-align: left;
1124+
font-size: 0.9em;
1125+
}

tronbyt_server/static/js/manager.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,21 @@ 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.maxHeight && content.style.maxHeight !== '0px') {
911+
content.style.maxHeight = '0px';
912+
content.style.paddingTop = '0';
913+
content.style.paddingBottom = '0';
914+
icon.classList.remove('fa-chevron-up');
915+
icon.classList.add('fa-chevron-down');
916+
} else {
917+
content.style.maxHeight = content.scrollHeight + "px";
918+
content.style.paddingTop = '5px';
919+
content.style.paddingBottom = '5px';
920+
icon.classList.remove('fa-chevron-down');
921+
icon.classList.add('fa-chevron-up');
922+
}
923+
}

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">
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)