diff --git a/frontend/src/components/ds/grid/GridFilterDrawer.jsx b/frontend/src/components/ds/grid/GridFilterDrawer.jsx index 1337cbba..0314b87d 100644 --- a/frontend/src/components/ds/grid/GridFilterDrawer.jsx +++ b/frontend/src/components/ds/grid/GridFilterDrawer.jsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { Filter, Layers, X, Plus, History, GripVertical } from 'lucide-react'; +import { Filter, Layers, X, Plus, History, GripVertical, Search } from 'lucide-react'; import { Drawer } from '../Drawer'; import { Button } from '@/components/ui/button'; import { Switch } from '@/components/ui/switch'; @@ -11,6 +11,9 @@ import { isDecorative, isFilterable, isSortable, optionsFor, } from './fields'; +// A field search only earns its row once the list is long enough to scan. +const FIELD_SEARCH_MIN = 9; + // Two panes behind one drawer, because they are the two halves of "what am I // looking at": FILTERS decides which rows, FIELDS decides which columns (and in // what order, at what density, with which detail line). The header menu is the @@ -30,6 +33,7 @@ export function GridFilterDrawer({ const { t } = useTranslation(); const [tab, setTab] = useState('filters'); const [dragging, setDragging] = useState(null); + const [fieldQuery, setFieldQuery] = useState(''); const map = byKey(columns); const rules = cfg.filters.rules; @@ -47,6 +51,8 @@ export function GridFilterDrawer({ const namedColumns = columns.filter((column) => !isDecorative(column)); const shownCount = cfg.cols.filter((key) => !isDecorative(map.get(key))).length; const hiddenCount = namedColumns.length - shownCount; + const fieldNeedle = fieldQuery.trim().toLowerCase(); + const fieldMatches = (column) => !fieldNeedle || columnLabel(column).toLowerCase().includes(fieldNeedle); const patchRule = (id, patch) => grid.setRules( rules.map((r) => (r.id === id ? { ...r, ...patch } : r)), @@ -271,23 +277,36 @@ export function GridFilterDrawer({ {tab === 'fields' && ( <> + {namedColumns.length >= FIELD_SEARCH_MIN && ( +
+
+ )} + + {/* In the table, in table order: drag to reorder, switch off to remove. */}
-
{t('app.gridFilterDrawer.columns', 'Columns')}
- - {t('app.gridFilterDrawer.shownOf', '{{shown}} of {{total}} shown', { shown: shownCount, total: namedColumns.length })} - +
{t('app.gridFilterDrawer.shown', 'In the table')}
+ {shownCount}
{ordered.map((key, i) => { const column = map.get(key); - if (!column || isDecorative(column)) return null; - const on = cfg.cols.includes(key); + if (!column || isDecorative(column) || !cfg.cols.includes(key) || !fieldMatches(column)) return null; const locked = !!column.locked || column.hideable === false; return (
setDragging(i)} onDragEnd={() => setDragging(null)} onDragOver={(e) => { @@ -301,9 +320,9 @@ export function GridFilterDrawer({ ? {t('app.gridFilterDrawer.pinned', 'pinned')} : ( grid.toggleColumn(key, allKeys)} - aria-label={t('app.gridFilterDrawer.show', 'Show {{value}}', { value: columnLabel(column) })} + aria-label={t('app.gridFilterDrawer.hide', 'Hide {{value}}', { value: columnLabel(column) })} /> )}
@@ -311,6 +330,37 @@ export function GridFilterDrawer({ })}
+ {/* Everything else the table knows about each row. */} + {hiddenCount > 0 && ( +
+
+
{t('app.gridFilterDrawer.available', 'More fields')}
+ {hiddenCount} +
+
+ {namedColumns.filter((column) => !cfg.cols.includes(column.key) && fieldMatches(column)).map((column) => ( + + ))} +
+
+ )} + + {fieldNeedle && !namedColumns.some(fieldMatches) && ( +
+

+ {t('app.gridFilterDrawer.noFieldMatches', 'No field matches "{{query}}".', { query: fieldQuery.trim() })} +

+
+ )} + {(showRowDetail || showDensity) && (
{showRowDetail && ( diff --git a/frontend/src/components/ds/grid/GridToolsMenu.jsx b/frontend/src/components/ds/grid/GridToolsMenu.jsx index 5cf70cb8..79326989 100644 --- a/frontend/src/components/ds/grid/GridToolsMenu.jsx +++ b/frontend/src/components/ds/grid/GridToolsMenu.jsx @@ -1,25 +1,34 @@ import { useState } from 'react'; -import { MoreVertical, Download, RefreshCw, History, Check, Link2, Rows2, Rows3 } from 'lucide-react'; +import { MoreVertical, ChevronLeft, Download, RefreshCw, History, Check, Link2, Rows2, Rows3 } from 'lucide-react'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { byKey, exportRows } from './fields'; import { useTranslation } from 'react-i18next'; import { Button as SharedButton } from '@/components/ui/button'; -// The toolbar's "⋮" — everything that is neither a filter nor a per-column -// action: export, refresh, row density, and discarding unsaved view changes. -// One button instead of four keeps the top bar the same shape on every page, -// which is the whole point of putting search there. -export function GridToolsMenu({ +// Everything about a table that is neither a filter nor a per-column action: +// copying a link to the view, export, refresh, row density, and discarding +// unsaved view changes. +// +// GridToolsPanel is the content; it is shown either inside its own "⋮" +// popover (GridToolsMenu, below) or inside the view selector's menu +// (GridViewPicker `tools`), where it is `embedded` and reports which pane it +// is on so the host can step aside while the export options are open. +export function GridToolsPanel({ cfg, columns, rows, selectedRows = [], viewName, noun = 'rows', onRefresh, onReset, onDensity, onExported, onCopyLink, // Off for hosts whose table auto-sizes its rows () — showing a // density toggle that changes nothing is worse than not showing one. showDensity = true, + onClose, + embedded = false, + pane: paneProp, + onPaneChange, }) { const { t } = useTranslation(); - const [open, setOpen] = useState(false); - const [pane, setPane] = useState('root'); // root | export + const [ownPane, setOwnPane] = useState('root'); // root | export + const pane = paneProp ?? ownPane; + const setPane = onPaneChange ?? setOwnPane; const [scope, setScope] = useState('view'); const [copied, setCopied] = useState(null); const [allCols, setAllCols] = useState(false); @@ -28,7 +37,7 @@ export function GridToolsMenu({ const set = scope === 'picked' ? selectedRows : rows; const exportCols = allCols ? columns : cfg.cols.map((k) => map.get(k)).filter(Boolean); - const close = () => { setOpen(false); setPane('root'); }; + const close = () => { setPane('root'); onClose?.(); }; const go = (format) => { const n = exportRows( @@ -41,6 +50,115 @@ export function GridToolsMenu({ close(); }; + return pane === 'root' ? ( + <> + {onCopyLink && ( + { + const res = await onCopyLink(); + setCopied(res?.copied ? 'ok' : 'fail'); + setTimeout(() => setCopied(null), 1800); + }} + > + {copied === 'ok' ? : } + {copied === 'ok' ? t('app.gridToolsMenu.linkCopied', 'Link copied') + : copied === 'fail' ? t('app.gridToolsMenu.copyFailed', "Couldn't copy the link. Check clipboard permissions.") + : t('app.gridToolsMenu.copyLinkToThisView', 'Copy link to this view')} + + )} + setPane('export')}> + {t('app.gridToolsMenu.export', 'Export…')} + + {onRefresh && ( + { onRefresh(); close(); }} + > + {t('app.gridToolsMenu.refreshData', 'Refresh data')} + + )} + {showDensity && ( + <> +
+
{t('app.gridToolsMenu.rowDensity', 'Row density')}
+ {[['cozy', 'Cozy', Rows2], ['compact', 'Compact', Rows3]].map(([value, text, Icon]) => ( + onDensity(value)} + > + + {text} + + ))} + + )} +
+ { onReset(); close(); }} + > + {t('app.gridToolsMenu.resetViewChanges', 'Reset view changes')} + + + ) : ( + <> + {embedded ? ( + setPane('root')}> + {t('app.gridToolsMenu.export2', 'Export')} + + ) : ( +
{t('app.gridToolsMenu.export2', 'Export')}
+ )} + setScope('view')} + > + + {t('app.gridToolsMenu.rowsInThisView', 'Rows in this view')} + {rows.length} + + setScope('picked')} + > + + {t('app.gridToolsMenu.selectedRows', 'Selected rows')} + {selectedRows.length} + +
+ setAllCols((v) => !v)} + > + + {t('app.gridToolsMenu.includeHiddenFields', 'Include hidden fields')} + {exportCols.length} + +
+ go('json')}>JSON + go('csv')}>{t('app.gridToolsMenu.downloadCsv', 'Download CSV')} +
+ + ); +} + +// The standalone "⋮" for tables that keep their tools on their own button. +export function GridToolsMenu(props) { + const { t } = useTranslation(); + const [open, setOpen] = useState(false); + const [pane, setPane] = useState('root'); + return ( - {pane === 'root' ? ( - <> - {onCopyLink && ( - { - const res = await onCopyLink(); - setCopied(res?.copied ? 'ok' : 'fail'); - setTimeout(() => setCopied(null), 1800); - }} - > - {copied === 'ok' ? : } - {copied === 'ok' ? t('app.gridToolsMenu.linkCopied', 'Link copied') - : copied === 'fail' ? t('app.gridToolsMenu.copyFailed', "Couldn't copy the link. Check clipboard permissions.") - : t('app.gridToolsMenu.copyLinkToThisView', 'Copy link to this view')} - - )} - setPane('export')}> - {t('app.gridToolsMenu.export', 'Export…')} - - {onRefresh && ( - { onRefresh(); close(); }} - > - {t('app.gridToolsMenu.refreshData', 'Refresh data')} - - )} - {showDensity && ( - <> -
-
{t('app.gridToolsMenu.rowDensity', 'Row density')}
- {[['cozy', 'Cozy', Rows2], ['compact', 'Compact', Rows3]].map(([value, text, Icon]) => ( - onDensity(value)} - > - - {text} - - ))} - - )} -
- { onReset(); close(); }} - > - {t('app.gridToolsMenu.resetViewChanges', 'Reset view changes')} - - - ) : ( - <> -
{t('app.gridToolsMenu.export2', 'Export')}
- setScope('view')} - > - - {t('app.gridToolsMenu.rowsInThisView', 'Rows in this view')} - {rows.length} - - setScope('picked')} - > - - {t('app.gridToolsMenu.selectedRows', 'Selected rows')} - {selectedRows.length} - -
- setAllCols((v) => !v)} - > - - {t('app.gridToolsMenu.includeHiddenFields', 'Include hidden fields')} - {exportCols.length} - -
- go('json')}>JSON - go('csv')}>{t('app.gridToolsMenu.downloadCsv', 'Download CSV')} -
- - )} + setOpen(false)} /> ); diff --git a/frontend/src/components/ds/grid/GridViewPicker.jsx b/frontend/src/components/ds/grid/GridViewPicker.jsx index 84513692..af7445a3 100644 --- a/frontend/src/components/ds/grid/GridViewPicker.jsx +++ b/frontend/src/components/ds/grid/GridViewPicker.jsx @@ -1,11 +1,12 @@ import { useState } from 'react'; import { - ChevronDown, Star, Copy, Trash2, Plus, MoreVertical, Check, History, AlertTriangle, + ChevronDown, Star, Copy, Trash2, Plus, MoreVertical, Check, History, AlertTriangle, SlidersHorizontal, } from 'lucide-react'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; import { Button as SharedButton } from '@/components/ui/button'; +import { GridToolsPanel } from './GridToolsMenu'; // The saved-view selector, rendered as the page's own heading rather than yet // another toolbar button — the view IS what you are looking at, so its name is @@ -21,17 +22,30 @@ import { Button as SharedButton } from '@/components/ui/button'; // there instead (see useTopbarChrome) and passes nothing here; an inner or sub // table, which has no top bar of its own, passes it and keeps it inline. // +// A page can instead fold the table's controls INTO this menu, so the page has +// one place for "what am I looking at and what can I do with it" and its top +// bar keeps only the actions that create or reload things: +// +// filters { count, hidden, onOpen } opens the filters and fields drawer +// tools the GridToolsMenu props copy link, export, reset… +// extra [{ icon, label, onSelect }] page-specific entries (Manage groups) +// // There is deliberately no row count. It was rendered twice on every page that // also had a toolbar underneath — once next to the view name, once on the right // of the second bar — and the footer already says how many rows there are, // under the rows it is counting. -export function GridViewPicker({ views, counts, onCreate, label = 'items', actions }) { +export function GridViewPicker({ views, counts, onCreate, label = 'items', actions, filters, tools, extra }) { const { t } = useTranslation(); const [open, setOpen] = useState(false); const [menuFor, setMenuFor] = useState(null); const [creating, setCreating] = useState(false); const [name, setName] = useState(''); const [fromCurrent, setFromCurrent] = useState(true); + // While the tools section shows its export options, the rest of the menu + // steps aside so the options are not buried under the list of views. + const [toolsPane, setToolsPane] = useState('root'); + const exporting = toolsPane !== 'root'; + const closeMenu = () => { setOpen(false); setMenuFor(null); setToolsPane('root'); }; const active = views.activeView; const activeName = active?.name || `All ${label}`; @@ -101,7 +115,7 @@ export function GridViewPicker({ views, counts, onCreate, label = 'items', actio return (
- + { setOpen(o); if (!o) setToolsPane('root'); }}> {activeName} @@ -110,48 +124,102 @@ export function GridViewPicker({ views, counts, onCreate, label = 'items', actio - {!!builtins.length &&
{t('app.gridViewPicker.builtIn', 'Built in')}
} - {builtins.map(renderRow)} -
{t('app.gridViewPicker.myViews', 'My views')}
- {mine.length ? mine.map(renderRow) : ( -
- {t('app.gridViewPicker.noPersonalViewsYetTuneThe', 'No personal views yet. Tune the grid, then save it here.')} -
- )} -
- {creating ? ( + {!exporting && ( <> -
- setName(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Enter') submitNew(); - if (e.key === 'Escape') setCreating(false); - }} - /> -
+ {!!builtins.length &&
{t('app.gridViewPicker.builtIn', 'Built in')}
} + {builtins.map(renderRow)} +
{t('app.gridViewPicker.myViews', 'My views')}
+ {mine.length ? mine.map(renderRow) : ( +
+ {t('app.gridViewPicker.noPersonalViewsYetTuneThe', 'No personal views yet. Tune the grid, then save it here.')} +
+ )} +
+ {creating ? ( + <> +
+ setName(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') submitNew(); + if (e.key === 'Escape') setCreating(false); + }} + /> +
+ setFromCurrent((v) => !v)} + > + + {t('app.gridViewPicker.startFromCurrentFiltersColumns', 'Start from current filters and columns')} + +
+ setCreating(false)}>{t('common.actions.cancel', 'Cancel')} + + {t('common.actions.create', 'Create')} + +
+ + ) : ( + setCreating(true)}> + {t('app.gridViewPicker.saveCurrentView', 'Save current view…')} + + )} + + )} + + {filters && !exporting && ( + <> +
setFromCurrent((v) => !v)} + className="sk-gridmenu__opt" + onClick={() => { closeMenu(); filters.onOpen(); }} > - - {t('app.gridViewPicker.startFromCurrentFiltersColumns', 'Start from current filters and columns')} + {t('app.gridViewPicker.filtersAndFields', 'Filters and fields')} + {(filters.count > 0 || filters.hidden > 0) && ( + + {[ + filters.count > 0 && t('app.gridViewPicker.filterCount', { count: filters.count, defaultValue_one: '1 filter', defaultValue_other: '{{count}} filters' }), + filters.hidden > 0 && t('app.gridViewPicker.moreFields', '{{count}} more fields', { count: filters.hidden }), + ].filter(Boolean).join(' \u00b7 ')} + + )} -
- setCreating(false)}>{t('common.actions.cancel', 'Cancel')} - - {t('common.actions.create', 'Create')} - -
- ) : ( - setCreating(true)}> - {t('app.gridViewPicker.saveCurrentView', 'Save current view…')} - + )} + + {tools && ( + <> + {!exporting &&
} + + + )} + + {!!extra?.length && !exporting && ( + <> +
+ {extra.map(({ icon: Icon, label: text, onSelect }) => ( + { closeMenu(); onSelect(); }} + > + {Icon && }{text} + + ))} + )} diff --git a/frontend/src/components/ds/grid/useTableChrome.js b/frontend/src/components/ds/grid/useTableChrome.js index ff8e6798..a969f186 100644 --- a/frontend/src/components/ds/grid/useTableChrome.js +++ b/frontend/src/components/ds/grid/useTableChrome.js @@ -31,6 +31,8 @@ const NO_FILTERS = { match: 'all', rules: [] }; * every page, which is what makes a saved view, a shareable link and a guard * one concept instead of eleven. */ +const NO_KEYS = []; + export function useTableChrome({ columns, rows = [], @@ -41,6 +43,10 @@ export function useTableChrome({ setSorts, hiddenKeys = [], setHiddenKeys, + // Columns a fresh table keeps out of sight. "Reset" goes back to THIS set, + // not to "show everything": a table that offers twenty fields does not want + // all twenty on screen the moment someone clears a filter. + defaultHiddenKeys = NO_KEYS, groupBy = null, setGroupBy, pageState, @@ -112,8 +118,8 @@ export function useTableChrome({ ), setSub: () => {}, setDensity: () => {}, - resetToView: () => { clearRules(); setHiddenKeys?.([]); setColumnOrder(null); }, - }), [setMatch, removeRule, clearRules, hiddenKeys, setHiddenKeys]); + resetToView: () => { clearRules(); setHiddenKeys?.([...defaultHiddenKeys]); setColumnOrder(null); }, + }), [setMatch, removeRule, clearRules, hiddenKeys, setHiddenKeys, defaultHiddenKeys]); // The envelope. The column rules are `columnFilters`, never `filters`: // three pages persist a `filters` key of their own meaning a SERVER-side diff --git a/frontend/src/i18n/locales/ar.json b/frontend/src/i18n/locales/ar.json index 630836bc..1b0dcae9 100644 --- a/frontend/src/i18n/locales/ar.json +++ b/frontend/src/i18n/locales/ar.json @@ -5644,7 +5644,6 @@ "groupCreated": "تم إنشاء المجموعة", "groupDeleted": "تم حذف المجموعة", "groupUpdated": "تم تحديث المجموعة", - "groups": "المجموعات", "host": "يستضيف", "hostname": "اسم المضيف:", "lastSeen": "شوهد آخر مرة", diff --git a/frontend/src/i18n/locales/bn.json b/frontend/src/i18n/locales/bn.json index b956a170..6eb80f44 100644 --- a/frontend/src/i18n/locales/bn.json +++ b/frontend/src/i18n/locales/bn.json @@ -5644,7 +5644,6 @@ "groupCreated": "গ্রুপ তৈরি হয়েছে", "groupDeleted": "গ্রুপ মুছে ফেলা হয়েছে", "groupUpdated": "গ্রুপ আপডেট করা হয়েছে", - "groups": "গোষ্ঠী", "host": "হোস্ট", "hostname": "হোস্টনাম:", "lastSeen": "শেষ দেখা", diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.json index 6140e5c9..ff6c205a 100644 --- a/frontend/src/i18n/locales/de.json +++ b/frontend/src/i18n/locales/de.json @@ -5644,7 +5644,6 @@ "groupCreated": "Gruppe erstellt", "groupDeleted": "Gruppe gelöscht", "groupUpdated": "Gruppe aktualisiert", - "groups": "Gruppen", "host": "Gastgeber", "hostname": "Hostname:", "lastSeen": "Zuletzt gesehen", diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 45f6bcd3..2bdff220 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -3044,7 +3044,7 @@ "gridFilterDrawer": { "addCondition": "Add condition", "and": "and", - "columns": "Columns", + "available": "More fields", "combine": "How conditions combine", "countAll": "{{count}} {{noun}}", "countOf": "{{matching}} of {{total}} {{noun}}", @@ -3055,6 +3055,9 @@ "filterBy": "Filter by", "filters": "Filters", "filtersFields": "Filters and fields", + "findField": "Find a field", + "hide": "Hide {{value}}", + "noFieldMatches": "No field matches \"{{query}}\".", "nothingFiltered_one": "The only {{noun}} is showing.", "nothingFiltered_other": "All {{count}} {{noun}} are showing.", "off": "Off", @@ -3065,7 +3068,7 @@ "reset": "Reset", "rowDetail": "Row detail", "show": "Show {{value}}", - "shownOf": "{{shown}} of {{total}} shown" + "shown": "In the table" }, "gridFooter": { "firstPage": "First page", @@ -3099,7 +3102,11 @@ "duplicateView": "Duplicate view", "eGCloudflareProd": "e.g. Cloudflare prod", "enterAViewNameFirst": "Enter a view name first", + "filterCount_one": "1 filter", + "filterCount_other": "{{count}} filters", + "filtersAndFields": "Filters and fields", "makeDefault": "Make default", + "moreFields": "{{count}} more fields", "myViews": "My views", "noPersonalViewsYetTuneThe": "No personal views yet. Tune the grid, then save it here.", "reset": "Reset", @@ -5871,10 +5878,12 @@ "abc123": "ABC-123", "addServer": "Add server", "addYourFirstServer": "Add your first server", + "added": "Added", "adjustTheSearchOrClearThe": "Adjust the search or clear the column filters to see your servers.", "agent": "Agent", "agentFound": "Agent found", "agentPairedSuccessfully": "Agent paired", + "architecture": "Architecture", "autoDetectedFromAgentOptional": "Auto-detected from agent (optional)", "capAllowed": "allowed", "capBlocked": "blocked", @@ -5884,6 +5893,7 @@ "connectionStringReady": "Connection string ready", "couldNotSetTheGroup": "Couldn't set the group.", "couldntLoadServers": "Couldn't load servers.", + "cpuCores": "CPU cores", "curlTarSudoAndSystemd": "curl, tar, sudo, and systemd", "deleteGroup": "Delete group", "deleteServerGroup": "Delete server group", @@ -5899,7 +5909,6 @@ "groupCreated": "Group created", "groupDeleted": "Group deleted", "groupUpdated": "Group updated", - "groups": "Groups", "health": "Health", "healthDegraded": "Degraded", "healthFailing": "Failing", @@ -5925,6 +5934,7 @@ "levelProtectCannot": "Cannot touch Docker, files, packages, services, shell or updates.", "linkPanel": "Link panel", "linux": "Linux", + "manageGroups": "Manage groups", "manageServerGroups": "Manage server groups", "movedServersTo_one": "Moved 1 server to {{groupName}}", "movedServersTo_other": "Moved {{count}} servers to {{groupName}}", @@ -5938,6 +5948,7 @@ "onTheTargetMachineStartThe": "On the target server, start the agent. It will display a 6-character pair code and a passphrase. Enter both below.", "online": "Online", "openTheAgentOnYourTarget": "Open the agent on your target server and paste the connection string.", + "os": "OS", "pairAgentAction": "Pair agent", "pairAnAgentAndTheMachine": "Pair an agent and the server shows up here with its CPU, memory and disk alongside every other server you run.", "pairCode": "Pair code", @@ -5964,6 +5975,7 @@ "stepStartAgent": "Start agent", "sync": "Sync", "syncShort": "Sync", + "tags": "Tags", "theAgentRegistersAutomaticallyAndReports": "The agent registers automatically and reports its hostname back as the server name.", "theCodeIsShownInThe": "The code is shown in the terminal output or system tray.", "theRowInThisListWill": "The row in this list will switch from", diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.json index f760ba0f..2611a787 100644 --- a/frontend/src/i18n/locales/es.json +++ b/frontend/src/i18n/locales/es.json @@ -5645,7 +5645,6 @@ "groupCreated": "Grupo creado", "groupDeleted": "Grupo eliminado", "groupUpdated": "Grupo actualizado", - "groups": "Grupos", "host": "Host", "hostname": "Hostname:", "lastSeen": "Visto por última vez", diff --git a/frontend/src/i18n/locales/fr.json b/frontend/src/i18n/locales/fr.json index 645d215a..d623b59e 100644 --- a/frontend/src/i18n/locales/fr.json +++ b/frontend/src/i18n/locales/fr.json @@ -5644,7 +5644,6 @@ "groupCreated": "Groupe créé", "groupDeleted": "Groupe supprimé", "groupUpdated": "Groupe mis à jour", - "groups": "Groupes", "host": "Hôte", "hostname": "Nom d'hôte :", "lastSeen": "Vu pour la dernière fois", diff --git a/frontend/src/i18n/locales/id.json b/frontend/src/i18n/locales/id.json index 7fb159c1..fa050e53 100644 --- a/frontend/src/i18n/locales/id.json +++ b/frontend/src/i18n/locales/id.json @@ -5644,7 +5644,6 @@ "groupCreated": "Grup dibuat", "groupDeleted": "Grup dihapus", "groupUpdated": "Grup diperbarui", - "groups": "Grup", "host": "Tuan rumah", "hostname": "Nama host:", "lastSeen": "Terakhir terlihat", diff --git a/frontend/src/i18n/locales/it.json b/frontend/src/i18n/locales/it.json index 1daf4f78..03ff3252 100644 --- a/frontend/src/i18n/locales/it.json +++ b/frontend/src/i18n/locales/it.json @@ -5644,7 +5644,6 @@ "groupCreated": "Gruppo creato", "groupDeleted": "Gruppo eliminato", "groupUpdated": "Gruppo aggiornato", - "groups": "Gruppi", "host": "Ospite", "hostname": "Nome host:", "lastSeen": "Visto l'ultima volta", diff --git a/frontend/src/i18n/locales/ko.json b/frontend/src/i18n/locales/ko.json index df2896e8..0a6c505c 100644 --- a/frontend/src/i18n/locales/ko.json +++ b/frontend/src/i18n/locales/ko.json @@ -5644,7 +5644,6 @@ "groupCreated": "그룹이 생성되었습니다.", "groupDeleted": "그룹이 삭제되었습니다.", "groupUpdated": "그룹이 업데이트되었습니다.", - "groups": "그룹", "host": "호스트", "hostname": "호스트 이름:", "lastSeen": "마지막으로 본", diff --git a/frontend/src/i18n/locales/pl.json b/frontend/src/i18n/locales/pl.json index 582e3beb..5bebd452 100644 --- a/frontend/src/i18n/locales/pl.json +++ b/frontend/src/i18n/locales/pl.json @@ -5644,7 +5644,6 @@ "groupCreated": "Grupa utworzona", "groupDeleted": "Grupa usunięta", "groupUpdated": "Grupa zaktualizowana", - "groups": "Grupy", "host": "Gospodarz", "hostname": "Nazwa hosta:", "lastSeen": "Ostatnio widziany", diff --git a/frontend/src/i18n/locales/pt.json b/frontend/src/i18n/locales/pt.json index 614b5c78..27cc7334 100644 --- a/frontend/src/i18n/locales/pt.json +++ b/frontend/src/i18n/locales/pt.json @@ -5644,7 +5644,6 @@ "groupCreated": "Grupo criado", "groupDeleted": "Grupo excluído", "groupUpdated": "Grupo atualizado", - "groups": "Grupos", "host": "Host", "hostname": "Nome do host:", "lastSeen": "Visto pela última vez", diff --git a/frontend/src/i18n/locales/ru.json b/frontend/src/i18n/locales/ru.json index 3d573719..3670a013 100644 --- a/frontend/src/i18n/locales/ru.json +++ b/frontend/src/i18n/locales/ru.json @@ -5644,7 +5644,6 @@ "groupCreated": "Группа создана", "groupDeleted": "Группа удалена", "groupUpdated": "Группа обновлена", - "groups": "Группы", "host": "Хост", "hostname": "Имя хоста:", "lastSeen": "Последняя активность", diff --git a/frontend/src/i18n/locales/th.json b/frontend/src/i18n/locales/th.json index f6cd0d54..8a0d8ec5 100644 --- a/frontend/src/i18n/locales/th.json +++ b/frontend/src/i18n/locales/th.json @@ -5644,7 +5644,6 @@ "groupCreated": "สร้างกลุ่มแล้ว", "groupDeleted": "ลบกลุ่มแล้ว", "groupUpdated": "อัปเดตกลุ่มแล้ว", - "groups": "กลุ่ม", "host": "เจ้าภาพ", "hostname": "ชื่อโฮสต์:", "lastSeen": "เห็นครั้งสุดท้าย", diff --git a/frontend/src/i18n/locales/tr.json b/frontend/src/i18n/locales/tr.json index eff8903c..e8999d40 100644 --- a/frontend/src/i18n/locales/tr.json +++ b/frontend/src/i18n/locales/tr.json @@ -5644,7 +5644,6 @@ "groupCreated": "Grup oluşturuldu", "groupDeleted": "Grup silindi", "groupUpdated": "Grup güncellendi", - "groups": "Gruplar", "host": "Ev sahibi", "hostname": "Ana makine adı:", "lastSeen": "Son görülme", diff --git a/frontend/src/i18n/locales/vi.json b/frontend/src/i18n/locales/vi.json index f17d165f..243fbfc3 100644 --- a/frontend/src/i18n/locales/vi.json +++ b/frontend/src/i18n/locales/vi.json @@ -5644,7 +5644,6 @@ "groupCreated": "Đã tạo nhóm", "groupDeleted": "Đã xóa nhóm", "groupUpdated": "Đã cập nhật nhóm", - "groups": "Nhóm", "host": "Chủ nhà", "hostname": "Tên máy chủ:", "lastSeen": "Nhìn thấy lần cuối", diff --git a/frontend/src/i18n/locales/zh-Hans.json b/frontend/src/i18n/locales/zh-Hans.json index c75b1d70..34a4c06c 100644 --- a/frontend/src/i18n/locales/zh-Hans.json +++ b/frontend/src/i18n/locales/zh-Hans.json @@ -5644,7 +5644,6 @@ "groupCreated": "群组已创建", "groupDeleted": "群组已删除", "groupUpdated": "群组已更新", - "groups": "团体", "host": "主机", "hostname": "主机名:", "lastSeen": "上次在线", diff --git a/frontend/src/i18n/locales/zh-Hant.json b/frontend/src/i18n/locales/zh-Hant.json index 8cfdad6e..7f780bdd 100644 --- a/frontend/src/i18n/locales/zh-Hant.json +++ b/frontend/src/i18n/locales/zh-Hant.json @@ -5644,7 +5644,6 @@ "groupCreated": "群組已建立", "groupDeleted": "群組已刪除", "groupUpdated": "群組已更新", - "groups": "群組", "host": "主機", "hostname": "主機名稱:", "lastSeen": "最後一次見到", diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsx index 3f9daa00..fcfe260c 100644 --- a/frontend/src/pages/Servers.jsx +++ b/frontend/src/pages/Servers.jsx @@ -18,16 +18,16 @@ import { import { DataTable, DataTableFooter, Drawer, Gauge, Pill, SearchField, statusKind, } from '@/components/ds'; -import { useTopbarActions, useTopbarChrome } from '@/hooks/useTopbarActions'; +import { useTopbarActions } from '@/hooks/useTopbarActions'; import { useTableSort } from '@/hooks/useTableSort'; import { useColumnVisibility } from '@/hooks/useColumnVisibility'; import { useConfirm } from '@/hooks/useConfirm'; import CopyField from '../components/CopyField'; import { - useTableChrome, GridViewPicker, GridChips, GridFilterButton, - GridToolsMenu, GridFilterDrawer, + useTableChrome, GridViewPicker, GridChips, GridFilterDrawer, } from '@/components/ds/grid'; import useFocusParam from '@/hooks/useFocusParam'; +import { formatBytes } from '@/utils/formatBytes'; import LinkPanelForm from '../components/servers/LinkPanelForm'; import { useTranslation } from 'react-i18next'; import { t } from '../i18n/t'; @@ -51,13 +51,22 @@ const NO_GROUP = '__none'; // NOTE for anyone adding a metric preset: only ever use `gt` on cpu/memory/disk. // Their sortValue is null for a non-live row, and a `lt` rule would match every // offline and pending server (see the null guard in ds/grid/fields.js). +// Fields a server HAS but the table does not open with. Everything here is one +// switch away in Filters and fields; the default table shows what you scan a +// fleet for (state, health, load, what it runs, when it last answered). +const DEFAULT_HIDDEN = [ + 'host', 'ip', 'group', 'level', 'agent', 'os', 'arch', 'cores', + 'ram', 'diskTotal', 'docker', 'domains', 'tags', 'added', +]; +const hiding = (...extra) => [...DEFAULT_HIDDEN, ...extra]; + const STATUS = (...value) => ({ match: 'all', rules: [{ id: 'st', field: 'status', op: 'any', value }] }); const NO_RULES = { match: 'all', rules: [] }; const SERVER_BUILTIN_VIEWS = [ - { name: 'Online', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: STATUS('online') } }, - { name: 'Offline', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: STATUS('offline') } }, - { name: 'By CPU', state: { search: '', sorts: [{ key: 'cpu', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } }, + { name: 'Online', state: { search: '', sorts: [], hiddenKeys: DEFAULT_HIDDEN, columnFilters: STATUS('online') } }, + { name: 'Offline', state: { search: '', sorts: [], hiddenKeys: DEFAULT_HIDDEN, columnFilters: STATUS('offline') } }, + { name: 'By CPU', state: { search: '', sorts: [{ key: 'cpu', direction: 'desc' }], hiddenKeys: DEFAULT_HIDDEN, columnFilters: NO_RULES } }, { // Machines that HAVE an agent but stopped answering, longest silence // first. `pending` is excluded — that means nobody ever installed one. @@ -67,7 +76,7 @@ const SERVER_BUILTIN_VIEWS = [ state: { search: '', groupBy: null, sorts: [{ key: 'lastSeen', direction: 'asc' }], - hiddenKeys: ['cpu', 'memory', 'disk'], + hiddenKeys: hiding('cpu', 'memory', 'disk'), columnFilters: { match: 'all', rules: [{ id: 'nr1', field: 'status', op: 'any', value: ['offline', 'connecting'] }], @@ -85,7 +94,7 @@ const SERVER_BUILTIN_VIEWS = [ // only ever match a reporting machine. name: 'Under load', state: { - search: '', groupBy: null, hiddenKeys: [], + search: '', groupBy: null, hiddenKeys: DEFAULT_HIDDEN, sorts: [{ key: 'cpu', direction: 'desc' }], columnFilters: { match: 'any', @@ -102,7 +111,7 @@ const SERVER_BUILTIN_VIEWS = [ state: { search: '', groupBy: null, sorts: [{ key: 'disk', direction: 'desc' }], - hiddenKeys: ['agent', 'cpu', 'memory'], + hiddenKeys: hiding('cpu', 'memory'), columnFilters: { match: 'all', rules: [ @@ -119,7 +128,8 @@ const SERVER_BUILTIN_VIEWS = [ // not a sentinel — see the `value` accessor on that column. name: 'Ungrouped', state: { - search: '', groupBy: null, hiddenKeys: [], + // The Group column is the point of this view, so it shows. + search: '', groupBy: null, hiddenKeys: DEFAULT_HIDDEN.filter((key) => key !== 'group'), sorts: [{ key: 'name', direction: 'asc' }], columnFilters: { match: 'all', @@ -169,6 +179,56 @@ const meterColumn = (key, header, metricKey) => ({ // Columns for the shared DataTable. Cell markup and classNames are identical // to the hand-rolled table they replace, so _servers.scss keeps applying // (.sk-cell-name, .sk-cell-mono, .servers-row__*, .servers-table__meter). +// A count column (services, domains): the number, or a dash for none so a +// column of zeros does not read as data. +const countColumn = (key, header, headerKey, field) => ({ + key, + headerKey, header, + sortable: true, + type: 'num', + value: (server) => server[field] ?? 0, + sortValue: (server) => server[field] ?? 0, + width: '96px', + cellClassName: 'sk-cell-dim', + render: (server) => (server[field] ? server[field] : —), +}); + +// A plain text fact about the machine (IP, Docker version): filterable and +// sortable as text, shown in mono. +const factColumn = (key, header, headerKey, read) => ({ + key, + headerKey, header, + sortable: true, + type: 'text', + value: (server) => read(server) || '', + sortValue: (server) => read(server) || '', + cellClassName: 'sk-cell-mono', + render: (server) => read(server) || —, +}); + +// A capacity (total memory, total disk): sorts by bytes, reads as a size. Not +// filterable: a rule would have to be typed in bytes. +const capacityColumn = (key, header, headerKey, field) => ({ + key, + headerKey, header, + sortable: true, + filterable: false, + sortValue: (server) => server[field] ?? null, + width: '112px', + cellClassName: 'sk-cell-dim', + render: (server) => (server[field] + ? formatBytes(server[field]) + : —), +}); + +// Columns for the shared DataTable. Cell markup and classNames are identical +// to the hand-rolled table they replace, so _servers.scss keeps applying +// (.sk-cell-name, .sk-cell-mono, .servers-row__*, .servers-table__meter). +// +// Order is the table's default order: what you scan a fleet for first, then +// the facts about each machine. The second half is hidden until asked for +// (DEFAULT_HIDDEN); every field the list endpoint returns about a server is +// here, so "can I see / filter by X" is answered in Filters and fields. const SERVER_COLUMNS = [ { key: 'name', @@ -191,36 +251,6 @@ const SERVER_COLUMNS = [
), }, - { - key: 'host', - headerKey: 'app.servers.host', header: 'Host', - cellClassName: 'sk-cell-mono', - render: (server) => server.hostname || server.ip_address || '\u2014', - }, - { - key: 'agent', - headerKey: 'app.servers.agent', header: 'Agent', - cellClassName: 'sk-cell-dim servers-row__agent', - // The version is a machine value; the "not installed" fallback is words. - render: (server) => (server.agent_version - ? {server.agent_version} - : 'not installed'), - }, - { - key: 'group', - headerKey: 'app.servers.group', header: 'Group', - sortable: true, - type: 'enum', - // An ungrouped server needs a real LABEL, not null: the enum engine - // compares String(value), so a null would only ever be matchable as the - // literal string 'null'. This label is what the "Ungrouped" preset - // filters on, and what the column menu lists. - value: (server) => server.group_name || 'Ungrouped', - groupable: true, - render: (server) => ( - server.group_name || {t('app.servers.ungrouped', 'Ungrouped')} - ), - }, { key: 'status', headerKey: 'common.labels.status', header: 'Status', @@ -238,6 +268,48 @@ const SERVER_COLUMNS = [ return {status}; }, }, + { + key: 'health', + headerKey: 'app.servers.health', header: 'Health', + sortable: false, + render: (server) => { + const health = serverHealth(server); + const detail = health.failing.length ? ` (${health.failing.join(', ')})` : ''; + return ( + + {healthLabel(health.code) + detail} + + ); + }, + }, + meterColumn('cpu', 'CPU', 'cpu_percent'), + meterColumn('memory', 'Memory', 'memory_percent'), + meterColumn('disk', 'Disk', 'disk_percent'), + countColumn('services', 'Services', 'common.labels.services', 'services_count'), + countColumn('domains', 'Domains', 'common.labels.domains', 'domains_count'), + { + key: 'lastSeen', + headerKey: 'app.servers.lastSeen', header: 'Last seen', + sortable: true, + sortValue: (server) => (server.last_seen ? new Date(server.last_seen).getTime() : null), + cellClassName: 'sk-cell-dim servers-row__seen', + render: (server) => formatLastSeen(server.last_seen), + }, + { + key: 'group', + headerKey: 'app.servers.group', header: 'Group', + sortable: true, + type: 'enum', + // An ungrouped server needs a real LABEL, not null: the enum engine + // compares String(value), so a null would only ever be matchable as the + // literal string 'null'. This label is what the "Ungrouped" preset + // filters on, and what the column menu lists. + value: (server) => server.group_name || 'Ungrouped', + groupable: true, + render: (server) => ( + server.group_name || {t('app.servers.ungrouped', 'Ungrouped')} + ), + }, { key: 'level', headerKey: 'app.servers.levelColumn', header: 'Level', @@ -257,29 +329,80 @@ const SERVER_COLUMNS = [ }, }, { - key: 'health', - headerKey: 'app.servers.health', header: 'Health', - sortable: false, - render: (server) => { - const health = serverHealth(server); - const detail = health.failing.length ? ` (${health.failing.join(', ')})` : ''; - return ( - - {healthLabel(health.code) + detail} - - ); - }, + key: 'host', + headerKey: 'app.servers.host', header: 'Host', + cellClassName: 'sk-cell-mono', + render: (server) => server.hostname || server.ip_address || '\u2014', }, - meterColumn('cpu', 'CPU', 'cpu_percent'), - meterColumn('memory', 'Memory', 'memory_percent'), - meterColumn('disk', 'Disk', 'disk_percent'), + factColumn('ip', 'IP address', 'common.labels.ipAddress', (server) => server.ip_address), { - key: 'lastSeen', - headerKey: 'app.servers.lastSeen', header: 'Last seen', + key: 'agent', + headerKey: 'app.servers.agent', header: 'Agent', sortable: true, - sortValue: (server) => (server.last_seen ? new Date(server.last_seen).getTime() : null), - cellClassName: 'sk-cell-dim servers-row__seen', - render: (server) => formatLastSeen(server.last_seen), + type: 'text', + value: (server) => server.agent_version || 'not installed', + sortValue: (server) => server.agent_version || '', + cellClassName: 'sk-cell-dim servers-row__agent', + // The version is a machine value; the "not installed" fallback is words. + render: (server) => (server.agent_version + ? {server.agent_version} + : 'not installed'), + }, + { + key: 'os', + headerKey: 'app.servers.os', header: 'OS', + sortable: true, + type: 'enum', + groupable: true, + value: (server) => server.os_type || 'unknown', + sortValue: (server) => `${server.os_type || ''} ${server.os_version || ''}`.trim(), + cellClassName: 'sk-cell-dim', + render: (server) => [server.os_type, server.os_version].filter(Boolean).join(' ') + || —, + }, + { + key: 'arch', + headerKey: 'app.servers.architecture', header: 'Architecture', + sortable: true, + type: 'enum', + groupable: true, + value: (server) => server.architecture || 'unknown', + cellClassName: 'sk-cell-mono', + render: (server) => server.architecture || —, + }, + { + key: 'cores', + headerKey: 'app.servers.cpuCores', header: 'CPU cores', + sortable: true, + type: 'num', + value: (server) => server.cpu_cores ?? null, + sortValue: (server) => server.cpu_cores ?? null, + width: '104px', + cellClassName: 'sk-cell-dim', + render: (server) => server.cpu_cores || —, + }, + capacityColumn('ram', 'Total memory', 'app.servers.totalMemory', 'total_memory'), + capacityColumn('diskTotal', 'Total disk', 'app.servers.totalDisk', 'total_disk'), + factColumn('docker', 'Docker', 'common.labels.docker', (server) => server.docker_version), + { + key: 'tags', + headerKey: 'app.servers.tags', header: 'Tags', + sortable: false, + type: 'text', + value: (server) => (server.tags || []).join(', '), + render: (server) => ((server.tags || []).length + ? {server.tags.map((tag) => {tag})} + : —), + }, + { + key: 'added', + headerKey: 'app.servers.added', header: 'Added', + sortable: true, + type: 'date', + value: (server) => (server.created_at || '').slice(0, 10), + sortValue: (server) => (server.created_at ? new Date(server.created_at).getTime() : null), + cellClassName: 'sk-cell-dim', + render: (server) => (server.created_at ? formatDate(server.created_at) : —), }, { key: 'open', @@ -312,7 +435,7 @@ const Servers = () => { const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-servers-sort' }); const { hiddenKeys, setHiddenKeys, - } = useColumnVisibility({ storageKey: 'serverkit-table-servers-cols' }); + } = useColumnVisibility({ storageKey: 'serverkit-table-servers-cols-v2', defaultHidden: DEFAULT_HIDDEN }); const [groupBy, setGroupBy] = useState(() => { try { return window.localStorage.getItem('serverkit-table-servers-group') || null; @@ -381,9 +504,6 @@ const Servers = () => { // The tab-group top bar owns this page's controls, search included. useTopbarActions(() => ( <> - @@ -411,30 +531,22 @@ const Servers = () => { setSorts, hiddenKeys, setHiddenKeys, + defaultHiddenKeys: DEFAULT_HIDDEN, groupBy, setGroupBy: changeGroupBy, pageState: viewPageState, applyPage: applyViewPageState, }); - // Filter + "⋮" ride in the top bar next to the actions and the search box, - // not in a toolbar under the view name. That toolbar was also repeating the - // row count the view row already showed, with an "N online" tacked on that - // no filter, sort or view ever referred to. - const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome( - <> - chrome.setDrawerOpen(true)} - /> - - , - ); + // Filters, the table tools and group management all live in the view + // selector's menu. The top bar keeps what creates or reloads (Sync, Add) + // and search; three more icons there said nothing a menu under the view's + // own name does not say better. + const hiddenFieldCount = SERVER_COLUMNS.filter((column) => column.header && hiddenKeys.includes(column.key)).length; if (loading) { return (
- {topbarChrome}
); @@ -442,13 +554,21 @@ const Servers = () => { return (
- {topbarChrome} chrome.setDrawerOpen(true), + }} + tools={chrome.toolsProps} + extra={[{ + icon: Folder, + label: t('app.servers.manageGroups', 'Manage groups'), + onSelect: () => setShowGroupModal(true), + }]} /> diff --git a/frontend/src/styles/components/_datagrid.scss b/frontend/src/styles/components/_datagrid.scss index c93c111b..7721497c 100644 --- a/frontend/src/styles/components/_datagrid.scss +++ b/frontend/src/styles/components/_datagrid.scss @@ -874,6 +874,35 @@ &__sp { flex: 1; } } +// Field search at the top of the Fields pane. +.sk-gridfind { + display: flex; + align-items: center; + gap: $space-2; + margin: $space-4 $space-5 0; + padding: 0 $space-3; + height: $control-md; + border: 1px solid var(--border); + border-radius: $radius-control; + background: var(--surface-2); + color: var(--text-ghost); + + &:focus-within { border-color: var(--accent-dim); box-shadow: $focus-ring; } + + input { + flex: 1; + min-width: 0; + border: 0; + outline: none; + background: transparent; + color: var(--text); + font-size: $text-sm; + font-family: inherit; + + &::placeholder { color: var(--text-ghost); } + } +} + // Empty filters pane: what is showing, and one tap to start narrowing it. .sk-gridstart { display: flex; diff --git a/frontend/tests/layout-baselines/servers-1440.png b/frontend/tests/layout-baselines/servers-1440.png index b13c8b2c..ce827410 100644 Binary files a/frontend/tests/layout-baselines/servers-1440.png and b/frontend/tests/layout-baselines/servers-1440.png differ diff --git a/frontend/tests/layout-baselines/servers-390.png b/frontend/tests/layout-baselines/servers-390.png index 46d59f3d..35d19e6a 100644 Binary files a/frontend/tests/layout-baselines/servers-390.png and b/frontend/tests/layout-baselines/servers-390.png differ diff --git a/frontend/tests/layout-baselines/servers-768.png b/frontend/tests/layout-baselines/servers-768.png index b51437bc..38decbd5 100644 Binary files a/frontend/tests/layout-baselines/servers-768.png and b/frontend/tests/layout-baselines/servers-768.png differ