Phones: a bar under the thumb, and one-tap and swipe acknowledge and snooze
Below tablet width a bottom bar holds Dashboard, Alerts (with its count), Servers and Menu. On the Alerts page an operator can acknowledge with one tap or snooze for an hour, or swipe a row right to acknowledge and left to snooze; each has an Undo, a scroll never triggers a swipe, and every swipe is also a button. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a69d0a611d
commit
939ebf8d83
8 files changed
+425
-4
No files matched your search
@@ -917,6 +917,8 @@ exists; it can be hidden, and brought back from the search box.
|
||||
|
||||
**Small trends in lists.** The rows of three lists carry a small line for which way things are going: each **server's card** (Infrastructure → Servers) has its load and memory over the last 24 hours and its **fullest disk over the last week** (a disk moves too slowly to show in a day; the line says which mount it is, and turns orange from 80% and red from 90%), and the admin table behind *Manage servers* has the same three lines side by side in a *Load and disk* column (load and memory turn orange from 75% and red from 90%), each **endpoint check** has how long it took to answer over the last day, with a red tick under each stretch in which a check failed, and each **integration** that keeps a history (Integrations, as cards or table, with a *Last week* column) has the figure it is known for over the last week — DNS queries for AdGuard, the queue for Sonarr, photos for Immich, the monthly cost for Hetzner. A gap in the data is a gap in the line, the newest reading is a dot, and each line is a picture with a sentence for a screen reader (*CPU load, last 24 hours: 12% now, between 3% and 40%*). They are drawn from the history the app already keeps (nothing new is stored), come from one request for the whole list, refresh every five minutes and are simply left out where there is no history. A line fitted to its own data makes a small change look steep — the sentence and the numbers beside it say how big it really is. The full charts are one click away on each page.
|
||||
|
||||
**On a phone, under the thumb.** Below tablet width a **bar along the bottom** holds the places used most — Dashboard, Alerts (with how many are active, red when one is critical), Servers — and **Menu**, which opens the full menu; it keeps clear of the home bar and a page you have hidden is not offered. On the Alerts page an operator can **acknowledge with one tap** (*✓ I'm on it*: acknowledged until the alert is gone, no note) or **snooze for an hour** (*Snooze 1 h*), and **swipe a row**: to the right acknowledges, to the left snoozes — the row follows the finger, says what letting go will do, and does it only once it has been dragged far enough, and a drag that is mostly up or down (a scroll) never does anything. Each of these has an **Undo** in the toast that follows, nothing can be done only by swiping (the buttons are there too, and *Acknowledge…* and *Snooze…* open the full forms for a note, a person or another time), and an alert that is silenced, snoozed, closed or already taken is not offered the same again.
|
||||
|
||||
**On a phone.** Below desktop width the top bar (logo and menu button) stays at the top of the screen so the menu is always within reach, with a menu button of at least 44 px; an open menu scrolls by itself (it no longer pushes the page down), its rows are finger-sized and the favourite stars are always visible; text is a little larger on a small screen, toasts run across the width and drawers fill it. The page asks for the whole screen (`viewport-fit=cover`) and keeps clear of the notch, the rounded corners and the home bar, which matters when it is installed to the home screen (the status bar then sits over the app). Tables turn into stacked cards, form fields are 16 px so a phone does not zoom in on them, and what is pressed does not wait for a second tap. Checked at 375 px: no page scrolls sideways.
|
||||
|
||||
**Swedish interface.** Press *Svenska* under *Language* in the user menu and the whole screen is drawn again in Swedish at once; the choice is kept on your account and follows you to any browser (without a choice the browser's language decides, and that guess is not stored). Swedish covers the menu, the shared parts (search, tables, dialogs, "5 min ago"), the sign-in page, and the headings, buttons, table columns, filters and messages of the pages used every day — Dashboard, Alerts, Servers, Updates, Maintenance, My work, Coming up, To do, Integrations and Settings → Display. Text with no Swedish yet is shown in English, so nothing looks broken. Not yet translated: what the server writes (alert messages, notifications, digests, reports, e-mail), the long page introductions and the less-used pages. How to add more is in docs/LANGUAGES.md.
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* What a finger dragged across an alert row means: a sideways swipe (far enough, clearly more sideways than up or down) acknowledges or snoozes; a scroll never does; a direction with
|
||||
* nothing bound to it does nothing. And the bar under the thumb that the page and its style sheet promise on a phone.
|
||||
*
|
||||
* Run with: npm test --workspace server
|
||||
*/
|
||||
import { test, describe } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { swipeCommits, swipeDirection, swipeOffset, SWIPE_COMMIT, SWIPE_MAX, SWIPE_START } from "../../web/src/utils/swipe.js";
|
||||
|
||||
const both = { right: true, left: true };
|
||||
|
||||
describe("is it a swipe", () => {
|
||||
test("not until it has gone a little way, and then only if it is clearly sideways", () => {
|
||||
assert.equal(swipeDirection(SWIPE_START - 1, 0), null, "a finger resting");
|
||||
assert.equal(swipeDirection(30, 0), "right");
|
||||
assert.equal(swipeDirection(-30, 0), "left");
|
||||
assert.equal(swipeDirection(40, 30), null, "mostly down: a scroll");
|
||||
assert.equal(swipeDirection(60, 40), "right", "sideways by half as much again as down");
|
||||
assert.equal(swipeDirection(60, 41), null, "just short of it");
|
||||
assert.equal(swipeDirection(-60, -20), "left", "up and left is still sideways enough");
|
||||
assert.equal(swipeDirection(5, 200), null, "a plain scroll");
|
||||
});
|
||||
});
|
||||
|
||||
describe("where the row sits while it is held, and what letting go does", () => {
|
||||
test("it follows the finger, but no further than the limit, and not at all where nothing is bound", () => {
|
||||
assert.equal(swipeOffset(40, both), 40);
|
||||
assert.equal(swipeOffset(-40, both), -40);
|
||||
assert.equal(swipeOffset(500, both), SWIPE_MAX);
|
||||
assert.equal(swipeOffset(-500, both), -SWIPE_MAX);
|
||||
assert.equal(swipeOffset(60, { right: false, left: true }), 0, "nothing to the right");
|
||||
assert.equal(swipeOffset(-60, { right: true, left: false }), 0, "nothing to the left");
|
||||
assert.equal(swipeOffset(60, { right: true, left: false }), 60);
|
||||
});
|
||||
|
||||
test("letting go does it only past the commit distance, in a direction that has something, on a sideways drag", () => {
|
||||
assert.equal(swipeCommits(SWIPE_COMMIT, 0, both), "right");
|
||||
assert.equal(swipeCommits(-SWIPE_COMMIT, 0, both), "left");
|
||||
assert.equal(swipeCommits(SWIPE_COMMIT - 1, 0, both), null, "not far enough");
|
||||
assert.equal(swipeCommits(-200, 10, { right: true, left: false }), null, "nothing bound to the left");
|
||||
assert.equal(swipeCommits(200, 10, { right: false, left: true }), null, "nothing bound to the right");
|
||||
assert.equal(swipeCommits(100, 100, both), null, "diagonal: a scroll that wandered");
|
||||
assert.equal(swipeCommits(0, 0, both), null);
|
||||
});
|
||||
|
||||
test("it takes more than a nudge, and less than the whole width of a phone", () => {
|
||||
assert.ok(SWIPE_COMMIT >= 60 && SWIPE_COMMIT < 150);
|
||||
assert.ok(SWIPE_MAX > SWIPE_COMMIT);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the bar under the thumb", () => {
|
||||
const css = readFileSync(new URL("../../web/src/styles.css", import.meta.url), "utf8");
|
||||
const shell = readFileSync(new URL("../../web/src/layout/AppShell.tsx", import.meta.url), "utf8");
|
||||
const alerts = readFileSync(new URL("../../web/src/pages/Alerts.tsx", import.meta.url), "utf8");
|
||||
|
||||
test("it is not there on a wide screen, and on a phone it is fixed to the bottom, above the page, clear of the home bar", () => {
|
||||
assert.match(css, /\.thumb-bar \{\s*display: none;\s*\}/);
|
||||
assert.match(css, /@media \(max-width: 767\.98px\) \{\s*\.thumb-bar \{\s*position: fixed;\s*inset: auto 0 0 0;\s*z-index: 1025;\s*display: flex;\s*padding-bottom: env\(safe-area-inset-bottom\);/);
|
||||
});
|
||||
|
||||
test("its buttons are at least as tall as a finger, and the page and the toasts leave room for it", () => {
|
||||
assert.match(css, /\.thumb-item \{[^}]*min-height: 3\.5rem;/);
|
||||
assert.match(css, /\.page-body \{\s*padding-bottom: calc\(4\.5rem \+ env\(safe-area-inset-bottom\)\);/);
|
||||
assert.match(css, /\.toast-stack \{\s*bottom: calc\(4\.75rem \+ env\(safe-area-inset-bottom\)\);/);
|
||||
});
|
||||
|
||||
test("it holds the dashboard, the alerts (with how many), the servers and the menu — and a page the person has hidden is not offered", () => {
|
||||
for (const piece of ['to: "/", label: t("Dashboard")', 'to: "/alerts", label: t("Alerts")', 'to: "/servers", label: t("Servers")', "navHas(nav, item.to)", 'aria-label={t("Quick links")}', "thumb-badge"]) assert.ok(shell.includes(piece), piece);
|
||||
});
|
||||
|
||||
test("an alert can be taken or snoozed with one tap or one swipe, each with an Undo, and only while it is live and the person can", () => {
|
||||
for (const piece of ["async function quickAck", "async function quickSnooze", 'label: t("Undo")', "api.alerts.unack(a.id)", "api.alerts.unsnooze(a.id)", "onRight={canSilence && !a.silenced && !a.closed && !a.snoozed && !a.ack?.active", "onLeft={canSilence && !a.silenced && !a.closed && !a.snoozed"]) assert.ok(alerts.includes(piece), piece);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { useRef, useState, type HTMLAttributes, type ReactNode } from "react";
|
||||
import { swipeCommits, swipeDirection, swipeOffset, SWIPE_COMMIT } from "../utils/swipe";
|
||||
|
||||
/**
|
||||
* A table row that can be swiped sideways with a finger: to the right does one thing, to the left another (an alert: acknowledge, snooze). The row follows the finger, says what letting go
|
||||
* will do, and does it only once it has been dragged far enough; a vertical drag is left alone, so scrolling the list never triggers it. Touch only — a mouse never swipes — and every
|
||||
* swipe is also a button, so nothing can be done only by swiping.
|
||||
*/
|
||||
export default function SwipeRow({
|
||||
onRight,
|
||||
onLeft,
|
||||
rightHint,
|
||||
leftHint,
|
||||
children,
|
||||
className = "",
|
||||
style,
|
||||
...rest
|
||||
}: {
|
||||
onRight?: () => void;
|
||||
onLeft?: () => void;
|
||||
/** What letting go will do, said while the row is held that way ("Acknowledge"). */
|
||||
rightHint?: string;
|
||||
leftHint?: string;
|
||||
children: ReactNode;
|
||||
} & Omit<HTMLAttributes<HTMLTableRowElement>, "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel">) {
|
||||
const allowed = { right: !!onRight, left: !!onLeft };
|
||||
const start = useRef<{ x: number; y: number } | null>(null);
|
||||
const [drag, setDrag] = useState(0);
|
||||
const [held, setHeld] = useState(false);
|
||||
const dir = swipeDirection(drag, 0);
|
||||
const ready = Math.abs(drag) >= SWIPE_COMMIT;
|
||||
|
||||
const reset = () => {
|
||||
start.current = null;
|
||||
setDrag(0);
|
||||
setHeld(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<tr
|
||||
{...rest}
|
||||
className={`${className} swipe-row${held ? " swipe-held" : ""}${dir && held ? ` swipe-${dir}${ready ? " swipe-ready" : ""}` : ""}`}
|
||||
style={{ ...style, transform: held && drag !== 0 ? `translateX(${drag}px)` : undefined }}
|
||||
data-hint={dir === "right" ? rightHint : dir === "left" ? leftHint : undefined}
|
||||
onTouchStart={(e) => {
|
||||
if (e.touches.length !== 1) return;
|
||||
start.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
|
||||
}}
|
||||
onTouchMove={(e) => {
|
||||
if (!start.current || e.touches.length !== 1) return;
|
||||
const dx = e.touches[0].clientX - start.current.x;
|
||||
const dy = e.touches[0].clientY - start.current.y;
|
||||
if (!held) {
|
||||
// undecided until it is clearly sideways; a scroll never becomes a swipe
|
||||
if (!swipeDirection(dx, dy)) return;
|
||||
setHeld(true);
|
||||
}
|
||||
setDrag(swipeOffset(dx, allowed));
|
||||
}}
|
||||
onTouchEnd={(e) => {
|
||||
const s = start.current;
|
||||
const t = e.changedTouches[0];
|
||||
const commit = s && t ? swipeCommits(t.clientX - s.x, t.clientY - s.y, allowed) : null;
|
||||
reset();
|
||||
if (commit === "right") onRight?.();
|
||||
else if (commit === "left") onLeft?.();
|
||||
}}
|
||||
onTouchCancel={reset}
|
||||
>
|
||||
{children}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
@@ -72,6 +72,7 @@ export const sv: Record<string, string> = {
|
||||
"Acknowledge…": "Kvittera…",
|
||||
"Acknowledged": "Kvitterad",
|
||||
"Acknowledged or not": "Kvitterad eller inte",
|
||||
"Acknowledged.": "Kvitterat.",
|
||||
"Actions": "Åtgärder",
|
||||
"Active": "Aktiv",
|
||||
"Add {name} to favourites": "Lägg till {name} i favoriter",
|
||||
@@ -312,6 +313,7 @@ export const sv: Record<string, string> = {
|
||||
"How this server is": "Hur servern mår",
|
||||
"How tightly pages are packed": "Hur tätt sidorna packas",
|
||||
"How to show the integrations": "Hur integrationerna visas",
|
||||
"I'm on it": "Jag tar det",
|
||||
"If the server then says a restart is due, the restart playbook runs, and the server is checked to have started again.": "Om servern sedan säger att en omstart behövs körs omstarts-playbooken, och servern kontrolleras så att den har startat om.",
|
||||
"Image": "Avbild",
|
||||
"Import from Uptime Kuma": "Importera från Uptime Kuma",
|
||||
@@ -381,6 +383,7 @@ export const sv: Record<string, string> = {
|
||||
"Media managers": "Mediahanterare",
|
||||
"Mem": "Minne",
|
||||
"Memory": "Minne",
|
||||
"Menu": "Meny",
|
||||
"Monitoring": "Övervakning",
|
||||
"Most in an hour": "Flest på en timme",
|
||||
"most recent first": "senaste först",
|
||||
@@ -524,6 +527,7 @@ export const sv: Record<string, string> = {
|
||||
"Proxy hosts": "Proxyvärdar",
|
||||
"Put back.": "Återlagd.",
|
||||
"Queries, 24 h": "Frågor, 24 tim",
|
||||
"Quick links": "Snabblänkar",
|
||||
"Raised and cleared again and again within an hour — its messages are held back until it has been calm for an hour": "Larmat och släckts om och om igen inom en timme — dess meddelanden hålls tillbaka tills det har varit lugnt i en timme",
|
||||
"Raised and cleared often enough within an hour to count as flapping": "Larmat och släckts tillräckligt ofta inom en timme för att räknas som fladdrande",
|
||||
"Reachable": "Nåbar",
|
||||
@@ -629,7 +633,9 @@ export const sv: Record<string, string> = {
|
||||
"Since you last looked": "Sedan du senast tittade",
|
||||
"size goes up and down": "storleken går upp och ned",
|
||||
"Skip to content": "Hoppa till innehållet",
|
||||
"Snooze 1 h": "Påminn om 1 tim",
|
||||
"Snooze…": "Påminn senare…",
|
||||
"Snoozed for an hour.": "Snoozat i en timme.",
|
||||
"Somebody is watching.": "Någon tittar.",
|
||||
"someone": "någon",
|
||||
"Source": "Källa",
|
||||
@@ -696,6 +702,7 @@ export const sv: Record<string, string> = {
|
||||
"Turn on": "Slå på",
|
||||
"Type a tag and press Enter — e.g. prod, media, rack-1": "Skriv en tagg och tryck Enter — till exempel prod, media, rack-1",
|
||||
"Under a maintenance window — notifications for this are held back": "Under ett underhållsfönster — notiser för den här hålls tillbaka",
|
||||
"Undo": "Ångra",
|
||||
"Uninstall": "Avinstallera",
|
||||
"Uninstall agent from": "Avinstallera agenten från",
|
||||
"Unlink": "Koppla bort",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { Link, NavLink, useLocation } from "react-router-dom";
|
||||
import { IconPlaneDeparture, IconKey, IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop, IconChevronsLeft, IconChevronsRight } from "@tabler/icons-react";
|
||||
import { IconLayoutDashboard, IconAlertTriangle, IconServer2, IconPlaneDeparture, IconKey, IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop, IconChevronsLeft, IconChevronsRight } from "@tabler/icons-react";
|
||||
import { api, type AwayView, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { isCurrent, isGroup, visibleNav, type NavGroup } from "./nav";
|
||||
import { isCurrent, isGroup, visibleNav, type NavEntry, type NavGroup } from "./nav";
|
||||
import SidebarNav, { type NavBadge } from "./SidebarNav";
|
||||
import { initFavorites } from "../utils/favorites";
|
||||
import { initDashboardLayout } from "../utils/dashboardLayout";
|
||||
@@ -450,6 +450,37 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{/* On a phone: the three places used most, and the menu, under the thumb (hidden from tablet width up, where the sidebar is always there). */}
|
||||
<nav className="thumb-bar" aria-label={t("Quick links")}>
|
||||
{([
|
||||
{ to: "/", label: t("Dashboard"), icon: <IconLayoutDashboard size={22} />, end: true, badge: null as string | null, level: "" },
|
||||
{ to: "/alerts", label: t("Alerts"), icon: <IconAlertTriangle size={22} />, end: false, badge: alerts ? String(alerts.count) : null, level: alerts?.level ?? "" },
|
||||
{ to: "/servers", label: t("Servers"), icon: <IconServer2 size={22} />, end: false, badge: null as string | null, level: "" },
|
||||
] as const)
|
||||
.filter((item) => item.to === "/" || item.to === "/alerts" || navHas(nav, item.to))
|
||||
.map((item) => (
|
||||
<NavLink key={item.to} to={item.to} end={item.end} className="thumb-item" onClick={() => setSidebarOpen(false)}>
|
||||
<span className="thumb-icon" aria-hidden="true">
|
||||
{item.icon}
|
||||
{item.badge && <span className={`thumb-badge ${item.level === "critical" ? "thumb-badge-critical" : ""}`}>{item.badge}</span>}
|
||||
</span>
|
||||
<span className="thumb-label">{item.label}</span>
|
||||
{item.badge && <span className="visually-hidden">{tn(Number(item.badge), "{n} active alert", "{n} active alerts")}</span>}
|
||||
</NavLink>
|
||||
))}
|
||||
<button type="button" className="thumb-item" aria-expanded={sidebarOpen} onClick={() => setSidebarOpen((open) => !open)}>
|
||||
<span className="thumb-icon" aria-hidden="true">
|
||||
<IconMenu2 size={22} />
|
||||
</span>
|
||||
<span className="thumb-label">{t("Menu")}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether the menu has this page for this person (a page they hid, or whose role they lack, is not there). */
|
||||
function navHas(nav: NavEntry[], path: string): boolean {
|
||||
return nav.some((entry) => (isGroup(entry) ? entry.items.some((i) => i.to === path) : entry.to === path));
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import IncidentHistory, { incidentPath } from "../components/IncidentHistory";
|
||||
import ViewTabs from "../components/ViewTabs";
|
||||
import AlertNoise from "../components/AlertNoise";
|
||||
import BulkBar from "../components/BulkBar";
|
||||
import SwipeRow from "../components/SwipeRow";
|
||||
import { AckBulkDrawer, SilenceBulkDrawer } from "../components/BulkDrawers";
|
||||
import { doBulk, plural } from "../utils/bulk";
|
||||
import { t, tn } from "../i18n";
|
||||
@@ -281,6 +282,54 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
toast.error(readableError(err));
|
||||
}
|
||||
}
|
||||
/** One tap: "I'm on it" — acknowledged until the alert is gone, with no note, and an Undo for a tap that was a slip. */
|
||||
async function quickAck(a: AlertItem) {
|
||||
try {
|
||||
await api.alerts.ack({ alertId: a.id, note: "", assigneeId: null, hours: null });
|
||||
toast.success(t("Acknowledged."), {
|
||||
label: t("Undo"),
|
||||
onClick: async () => {
|
||||
try {
|
||||
await api.alerts.unack(a.id);
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
} finally {
|
||||
await load(true);
|
||||
reloadBadge();
|
||||
}
|
||||
},
|
||||
});
|
||||
await load(true);
|
||||
reloadBadge();
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
/** One tap: snooze for an hour — hidden for now and announced again then if it is still there — with an Undo. */
|
||||
async function quickSnooze(a: AlertItem) {
|
||||
try {
|
||||
await api.alerts.snooze(a.id, new Date(Date.now() + 3600_000).toISOString());
|
||||
toast.success(t("Snoozed for an hour."), {
|
||||
label: t("Undo"),
|
||||
onClick: async () => {
|
||||
try {
|
||||
await api.alerts.unsnooze(a.id);
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
} finally {
|
||||
await load(true);
|
||||
reloadBadge();
|
||||
}
|
||||
},
|
||||
});
|
||||
await load(true);
|
||||
reloadBadge();
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
async function wake(a: AlertItem) {
|
||||
try {
|
||||
await api.alerts.unsnooze(a.id);
|
||||
@@ -550,7 +599,15 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
<AlertGroupRow key={a.id} group={a} colSpan={canSilence ? 5 : 4} canPick={canSilence} allPicked={a.pickable.length > 0 && a.pickable.every((id) => picked.has(id))} onToggle={() => toggleGroup(a.id)} onPick={() => pickGroup(a.pickable)} />
|
||||
) : (
|
||||
<Fragment key={a.id}>
|
||||
<tr className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`} style={a.silenced ? { opacity: 0.65 } : undefined}>
|
||||
<SwipeRow
|
||||
className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`}
|
||||
style={a.silenced ? { opacity: 0.65 } : undefined}
|
||||
// On a phone: a finger swiped right acknowledges, left snoozes for an hour (both are buttons below as well). Only an alert that is live and not yet taken.
|
||||
onRight={canSilence && !a.silenced && !a.closed && !a.snoozed && !a.ack?.active ? () => void quickAck(a) : undefined}
|
||||
onLeft={canSilence && !a.silenced && !a.closed && !a.snoozed ? () => void quickSnooze(a) : undefined}
|
||||
rightHint={`✓ ${t("I'm on it")}`}
|
||||
leftHint={`💤 ${t("Snooze 1 h")}`}
|
||||
>
|
||||
<td>
|
||||
{canSilence && (
|
||||
<input type="checkbox" className="form-check-input me-2 align-middle" aria-label={`Pick: ${a.message}`} checked={picked.has(a.id)} onChange={() => togglePicked(a.id)} />
|
||||
@@ -647,6 +704,16 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
{canSilence && (
|
||||
<td className="text-nowrap stack-wide">
|
||||
<div className="btn-list flex-nowrap">
|
||||
{!a.silenced && !a.closed && !a.snoozed && !a.ack?.active && (
|
||||
<button type="button" className="btn btn-sm btn-primary d-md-none" onClick={() => void quickAck(a)}>
|
||||
✓ {t("I'm on it")}
|
||||
</button>
|
||||
)}
|
||||
{!a.silenced && !a.closed && !a.snoozed && (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary d-md-none" onClick={() => void quickSnooze(a)}>
|
||||
{t("Snooze 1 h")}
|
||||
</button>
|
||||
)}
|
||||
{!a.silenced && (
|
||||
<button type="button" className={`btn btn-sm ${a.ack?.active ? "btn-outline-primary" : "btn-outline-secondary"}`} onClick={() => setAcking(a)}>
|
||||
{a.ack?.active ? t("Acknowledged") : t("Acknowledge…")}
|
||||
@@ -677,7 +744,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
</div>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
</SwipeRow>
|
||||
{open.has(a.id) &&
|
||||
(childrenOf.get(a.id) ?? []).map((c) => (
|
||||
<tr key={c.id} className="alert-row alert-row-child text-secondary">
|
||||
|
||||
@@ -2377,3 +2377,133 @@ select,
|
||||
color: #e6edf7;
|
||||
opacity: 0.18;
|
||||
}
|
||||
|
||||
/* ── The phone's bar under the thumb (layout/AppShell) and swiped alert rows ── */
|
||||
.thumb-bar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.thumb-bar {
|
||||
position: fixed;
|
||||
inset: auto 0 0 0;
|
||||
z-index: 1025;
|
||||
display: flex;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
padding-left: env(safe-area-inset-left);
|
||||
padding-right: env(safe-area-inset-right);
|
||||
background: var(--tblr-bg-surface, #fff);
|
||||
border-top: 1px solid var(--tblr-border-color);
|
||||
}
|
||||
|
||||
.thumb-item {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1 1 0;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.1rem;
|
||||
min-height: 3.5rem;
|
||||
padding: 0.35rem 0.25rem;
|
||||
font-size: 0.72rem;
|
||||
color: var(--tblr-secondary);
|
||||
text-decoration: none;
|
||||
background: none;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.thumb-item.active,
|
||||
.thumb-item[aria-expanded="true"] {
|
||||
color: var(--tblr-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.thumb-icon {
|
||||
position: relative;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.thumb-badge {
|
||||
position: absolute;
|
||||
top: -0.35rem;
|
||||
left: 55%;
|
||||
min-width: 1.05rem;
|
||||
padding: 0 0.28rem;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.05rem;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background: var(--tblr-yellow, #f59f00);
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
.thumb-badge-critical {
|
||||
background: var(--tblr-red, #d63939);
|
||||
}
|
||||
|
||||
/* room under the page and the toasts for the bar */
|
||||
.page-body {
|
||||
padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.toast-stack {
|
||||
bottom: calc(4.75rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.detail-drawer,
|
||||
.modal {
|
||||
z-index: 1060;
|
||||
}
|
||||
}
|
||||
|
||||
/* a row being swiped: it follows the finger and says what letting go will do */
|
||||
tr.swipe-row {
|
||||
position: relative;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-held {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
tr.swipe-row:not(.swipe-held) {
|
||||
transition: transform 0.18s ease-out;
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-right {
|
||||
background: color-mix(in srgb, var(--tblr-green, #2fb344) 16%, var(--tblr-bg-surface, transparent));
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-left {
|
||||
background: color-mix(in srgb, var(--tblr-azure, #4299e1) 16%, var(--tblr-bg-surface, transparent));
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-held::after {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
z-index: 1;
|
||||
padding: 0.2rem 0.6rem;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
content: attr(data-hint);
|
||||
background: var(--tblr-bg-surface, #fff);
|
||||
border-radius: 1rem;
|
||||
opacity: 0.7;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-right.swipe-held::after {
|
||||
left: 0.5rem;
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-left.swipe-held::after {
|
||||
right: 0.5rem;
|
||||
}
|
||||
|
||||
tr.swipe-row.swipe-ready::after {
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/** What a finger dragged across a row means. Pure, so it can be tested without a touch screen. */
|
||||
|
||||
/** How far a row must be dragged sideways before letting go does something, in pixels. */
|
||||
export const SWIPE_COMMIT = 90;
|
||||
/** How far it may follow the finger (a little more than it takes to commit, so it feels held). */
|
||||
export const SWIPE_MAX = 130;
|
||||
/** Below this the finger is just resting or scrolling: nothing moves yet. */
|
||||
export const SWIPE_START = 12;
|
||||
|
||||
export type SwipeDirection = "right" | "left";
|
||||
|
||||
/**
|
||||
* Whether a drag is a sideways swipe at all: far enough, and clearly more sideways than up or down (so scrolling the list with a finger is never taken for it). Null while it is still
|
||||
* undecided or is a scroll.
|
||||
*/
|
||||
export function swipeDirection(dx: number, dy: number): SwipeDirection | null {
|
||||
if (Math.abs(dx) < SWIPE_START) return null;
|
||||
if (Math.abs(dx) < Math.abs(dy) * 1.5) return null;
|
||||
return dx > 0 ? "right" : "left";
|
||||
}
|
||||
|
||||
/** Where the row sits while dragged: it follows the finger but no further than SWIPE_MAX, and not at all in a direction nothing is bound to. */
|
||||
export function swipeOffset(dx: number, allowed: { right: boolean; left: boolean }): number {
|
||||
if (dx > 0 && !allowed.right) return 0;
|
||||
if (dx < 0 && !allowed.left) return 0;
|
||||
return Math.max(-SWIPE_MAX, Math.min(SWIPE_MAX, dx));
|
||||
}
|
||||
|
||||
/** Whether letting go here does the thing: dragged far enough, in a direction something is bound to. */
|
||||
export function swipeCommits(dx: number, dy: number, allowed: { right: boolean; left: boolean }): SwipeDirection | null {
|
||||
const dir = swipeDirection(dx, dy);
|
||||
if (!dir || !allowed[dir]) return null;
|
||||
return Math.abs(dx) >= SWIPE_COMMIT ? dir : null;
|
||||
}
|
||||
Reference in new issue
Block a user