Add saved filter views, a customisable dashboard, server comparison, row keyboard navigation and share links
- Table search, status, tag and sort live in the address; Save view pins one as a favourite. - Dashboard cards can be moved and hidden per user (users.dashboard_layout, migration 0022). - Compare two to four servers' load, memory or disk on one chart. - j/k move through table rows that open a detail panel. - Share links open a read-only wall without signing in, numbers only or with names (share_links, migration 0023); the wall is split into a shared view over two data sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
906220040e
commit
44e393f172
50 files changed
+6114
-258
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
|
||||
const haystacks = new WeakMap<object, string>();
|
||||
|
||||
@@ -24,9 +25,26 @@ function haystackOf(row: unknown): string {
|
||||
/**
|
||||
* Text search over a table's rows. Several words must all appear (in any column, in any order), so "elsa running" finds a running
|
||||
* container on elsa. Returns the rows unchanged while the box is empty, and `null`/`undefined` as they came while loading.
|
||||
*
|
||||
* The words live in the address (`?q=elsa running`), so a search survives a reload, can be bookmarked or sent on, and can be pinned as
|
||||
* a saved view. A page has one searchable table, so one `q`; other things in the address are left alone.
|
||||
*/
|
||||
export function useTableSearch<T>(items: T[] | null | undefined) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [params, setParams] = useSearchParams();
|
||||
const query = params.get("q") ?? "";
|
||||
const setQuery = useCallback(
|
||||
(value: string) =>
|
||||
setParams(
|
||||
(prev) => {
|
||||
const next = new URLSearchParams(prev);
|
||||
if (value) next.set("q", value);
|
||||
else next.delete("q");
|
||||
return next;
|
||||
},
|
||||
{ replace: true },
|
||||
),
|
||||
[setParams],
|
||||
);
|
||||
const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||
const key = terms.join(" ");
|
||||
|
||||
|
||||
Reference in new issue
Block a user