From 6fd6e9cbaa652c93918f47d106f90056ebf006de Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Mon, 9 Nov 2026 16:00:58 +0100 Subject: [PATCH] Feature: Add a group filter to the web console device list Operators running several groups had to scan the whole fleet. The device list now has a group filter: desktop renders the groups as chips in the Total row (click to toggle any number), while touch devices get a compact dropdown with checkbox rows plus Clear/Done. An empty selection means "all groups"; multiple selections are OR-ed and combined with the search box. Hosts without a group appear as "Ungrouped". Groups are derived from the current device snapshot (no admin-only get_groups call, so restricted users can filter too), and the selection persists in localStorage for the browser. The offered list follows the Offline toggle, while a selected group whose devices are temporarily gone stays visible with count 0 instead of being silently dropped. Logout clears the selection so the next account does not inherit it. The Wall view keeps its own search and is unchanged. Verified in headless Chrome at desktop and phone widths: multi-select, counts, dropdown open/close/clear, stale-selection retention, search focus, long names and persistence across reloads. go build and go test ./web/ pass. Co-Authored-By: deepseek-flash --- server/web/index.html | 323 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 322 insertions(+), 1 deletion(-) diff --git a/server/web/index.html b/server/web/index.html index aaec141..65a1ded 100644 --- a/server/web/index.html +++ b/server/web/index.html @@ -860,6 +860,9 @@ } .stats-bar { display: flex; + align-items: center; + flex-wrap: wrap; + position: relative; gap: 20px; margin-bottom: 20px; padding: 12px 16px; @@ -883,6 +886,137 @@ accent-color: #e94560; cursor: pointer; } + /* 分组过滤器:桌面端把各分组平铺在 Total 行(chip),手机端收进下拉面板。 */ + .stats-bar .group-filter { + display: flex; + align-items: center; + gap: 6px; + flex-wrap: wrap; + min-width: 0; + } + .group-filter-label { color: #666; } + .group-chip { + display: inline-flex; + align-items: center; + gap: 5px; + max-width: 220px; + padding: 2px 10px; + border-radius: 999px; + border: 1px solid rgba(255, 255, 255, 0.14); + background: transparent; + color: #bbb; + font-size: 12px; + line-height: 1.6; + cursor: pointer; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .group-chip:hover { border-color: rgba(233, 69, 96, 0.5); color: #fff; } + .group-chip.active { + background: #e94560; + border-color: #e94560; + color: #fff; + } + .group-chip-name { + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .group-chip .group-chip-count { flex: 0 0 auto; font-size: 11px; opacity: 0.65; } + /* 手机端:分组下拉(面板里用按钮行,避免 label+checkbox 的重复触发) */ + .group-dd { display: inline-flex; } + .group-dd-btn { + display: inline-flex; + align-items: center; + gap: 6px; + max-width: 55vw; + padding: 6px 12px; + border-radius: 6px; + border: 1px solid rgba(255, 255, 255, 0.14); + background: rgba(0, 0, 0, 0.2); + color: #bbb; + font-size: 12px; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + } + .group-dd-btn.active { border-color: #e94560; color: #e94560; } + .group-dd-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } + .group-dd-caret { font-size: 10px; opacity: 0.7; } + /* 面板锚在 Total 这一行的左边缘(.stats-bar 为定位祖先),而不是按钮本身: + 按钮在窄屏上常靠右,按按钮定位会让面板探出屏幕右缘。 */ + .group-dd-panel { + position: absolute; + top: calc(100% + 6px); + left: 16px; + right: 16px; + max-width: 320px; + z-index: 60; + max-height: 60vh; + overflow-y: auto; + padding: 6px; + border: 1px solid #0f3460; + border-radius: 8px; + background: #16213e; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); + } + .group-dd-item { + display: flex; + align-items: center; + gap: 8px; + width: 100%; + padding: 9px 8px; + border: none; + border-radius: 6px; + background: transparent; + color: #ddd; + font-size: 13px; + text-align: left; + cursor: pointer; + } + .group-dd-item:active { background: rgba(255, 255, 255, 0.06); } + .group-dd-item.active { color: #fff; } + .group-dd-check { + flex: 0 0 16px; + width: 16px; + height: 16px; + line-height: 16px; + text-align: center; + font-size: 12px; + border-radius: 4px; + border: 1px solid rgba(255, 255, 255, 0.25); + color: #fff; + } + .group-dd-item.active .group-dd-check { background: #e94560; border-color: #e94560; } + .group-dd-name { + flex: 1; + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .group-dd-count { color: #888; font-size: 11px; } + .group-dd-footer { + display: flex; + justify-content: space-between; + gap: 8px; + margin-top: 4px; + padding-top: 6px; + border-top: 1px solid rgba(255, 255, 255, 0.08); + } + .group-dd-clear, + .group-dd-done { + padding: 6px 10px; + border-radius: 6px; + border: 1px solid rgba(255, 255, 255, 0.14); + background: transparent; + color: #bbb; + font-size: 12px; + cursor: pointer; + } + .group-dd-clear:disabled { opacity: 0.4; cursor: default; } + .group-dd-done { border-color: rgba(233, 69, 96, 0.5); color: #e94560; } #screen-page { position: fixed; @@ -1748,6 +1882,7 @@
Total: 0
Showing: 0
+