docs: add report draft and dashboard form refinements
This commit is contained in:
parent
4e0cf0140f
commit
441e709193
26 changed files with 1700 additions and 505 deletions
|
|
@ -58,7 +58,7 @@ export function DashboardShell({
|
|||
</p>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">Operations overview for demos and day-to-day admin tasks</h1>
|
||||
<p className="max-w-2xl text-sm text-muted-foreground">
|
||||
Use this area to review monitored assets, inspect detail states, and stage CRUD forms that can connect to tRPC routers as they are added.
|
||||
Use this area to review monitored assets, inspect detail states, currently used to monitor my homelab setup.
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-3 border-l-0 border-t pt-4 lg:border-l lg:border-t-0 lg:pl-6 lg:pt-0">
|
||||
|
|
@ -91,7 +91,7 @@ export function DashboardShell({
|
|||
</div>
|
||||
<nav className="grid gap-1 p-2">
|
||||
{dashboardLinks.map(({ to, label, description, icon: Icon }) => {
|
||||
const active = pathname === to || pathname.startsWith(`${to}/`);
|
||||
const active = to === "/dashboard" ? pathname === to : pathname === to || pathname.startsWith(`${to}/`);
|
||||
|
||||
return (
|
||||
<Link
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@ import {
|
|||
} from "@minmon/ui/components/card";
|
||||
import { Input } from "@minmon/ui/components/input";
|
||||
import { Label } from "@minmon/ui/components/label";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@minmon/ui/components/select";
|
||||
import { StatusBadge } from "@minmon/ui/components/status-badge";
|
||||
import {
|
||||
Table,
|
||||
|
|
@ -21,8 +28,8 @@ import {
|
|||
} from "@minmon/ui/components/table";
|
||||
import { Textarea } from "@minmon/ui/components/textarea";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import type { ReactNode } from "react";
|
||||
import { Check, ChevronRight, Trash2 } from "lucide-react";
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
|
||||
type BadgeVariant = "neutral" | "success" | "warning" | "destructive" | "info";
|
||||
|
||||
|
|
@ -66,7 +73,7 @@ export function SummaryCard({
|
|||
);
|
||||
}
|
||||
|
||||
export function ResourceListCard<TItem>({
|
||||
export function ResourceListCard<TItem extends { id: string }>({
|
||||
title,
|
||||
description,
|
||||
columns,
|
||||
|
|
@ -82,7 +89,7 @@ export function ResourceListCard<TItem>({
|
|||
emptyDescription: string;
|
||||
}) {
|
||||
return (
|
||||
<Card className="gap-0">
|
||||
<Card className="py-0 pt-4 gap-0">
|
||||
<CardHeader className="border-b">
|
||||
<CardTitle>{title}</CardTitle>
|
||||
<CardDescription>{description}</CardDescription>
|
||||
|
|
@ -101,8 +108,8 @@ export function ResourceListCard<TItem>({
|
|||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{items.map((item, index) => (
|
||||
<TableRow key={index}>
|
||||
{items.map((item) => (
|
||||
<TableRow key={item.id}>
|
||||
{columns.map((column) => (
|
||||
<TableCell key={column.key} className={column.className}>
|
||||
{column.render(item)}
|
||||
|
|
@ -213,6 +220,108 @@ export function TextAreaField(
|
|||
);
|
||||
}
|
||||
|
||||
export function SelectField({
|
||||
label,
|
||||
description,
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
onValueChange,
|
||||
onBlur,
|
||||
placeholder,
|
||||
options,
|
||||
}: {
|
||||
label: string;
|
||||
description?: string;
|
||||
id?: string;
|
||||
name?: string;
|
||||
value: string;
|
||||
onValueChange: (value: string) => void;
|
||||
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
|
||||
placeholder?: string;
|
||||
options: { value: string; label: string }[];
|
||||
}) {
|
||||
const fieldId = id ?? name ?? label;
|
||||
const selectedOption = options.find((option) => option.value === value);
|
||||
|
||||
return (
|
||||
<FieldGroup label={label} htmlFor={fieldId} description={description}>
|
||||
<Select name={name} value={value} onValueChange={(nextValue) => onValueChange(nextValue ?? "")}>
|
||||
<SelectTrigger id={fieldId} className="w-full" onBlur={onBlur}>
|
||||
<SelectValue placeholder={placeholder ?? "Select an option"}>
|
||||
{selectedOption?.label}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</FieldGroup>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConfirmDeleteIconButton({
|
||||
itemLabel,
|
||||
onConfirm,
|
||||
disabled,
|
||||
}: {
|
||||
itemLabel: string;
|
||||
onConfirm: () => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const [isConfirming, setIsConfirming] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isConfirming) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
setIsConfirming(false);
|
||||
}, 4000);
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timeoutId);
|
||||
};
|
||||
}, [isConfirming]);
|
||||
|
||||
useEffect(() => {
|
||||
if (disabled) {
|
||||
setIsConfirming(false);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
return (
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
type="button"
|
||||
variant={isConfirming ? "destructive" : "destructive"}
|
||||
size="icon"
|
||||
className="size-8"
|
||||
disabled={disabled}
|
||||
aria-label={isConfirming ? `Confirm delete ${itemLabel}` : `Delete ${itemLabel}`}
|
||||
onBlur={() => setIsConfirming(false)}
|
||||
onClick={() => {
|
||||
if (isConfirming) {
|
||||
onConfirm();
|
||||
setIsConfirming(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setIsConfirming(true);
|
||||
}}
|
||||
>
|
||||
{isConfirming ? <Check /> : <Trash2 />}
|
||||
<span className="sr-only">{isConfirming ? `Confirm delete ${itemLabel}` : `Delete ${itemLabel}`}</span>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function EmptyState({
|
||||
title,
|
||||
description,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Button } from "@minmon/ui/components/button";
|
|||
import { Input } from "@minmon/ui/components/input";
|
||||
import { Label } from "@minmon/ui/components/label";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import { Link, useNavigate } from "@tanstack/react-router";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { toast } from "sonner";
|
||||
import z from "zod";
|
||||
|
||||
|
|
@ -53,85 +53,84 @@ export default function SignInForm() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto mt-10 grid w-full max-w-md gap-6 border bg-card p-6">
|
||||
<div className="space-y-2 text-center">
|
||||
<p className="text-[11px] uppercase tracking-[0.24em] text-muted-foreground">Admin Access</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight">Sign in to minmon</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Use your administrator account to open the protected monitoring dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
form.handleSubmit();
|
||||
}}
|
||||
className="space-y-4"
|
||||
>
|
||||
<div>
|
||||
<form.Field name="email">
|
||||
{(field) => (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor={field.name}>Email</Label>
|
||||
<Input
|
||||
id={field.name}
|
||||
name={field.name}
|
||||
type="email"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.map((error) => (
|
||||
<p key={error?.message} className="text-xs text-red-500">
|
||||
{error?.message}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</form.Field>
|
||||
<div className="mx-auto flex min-h-[calc(100dvh-8rem)] w-full max-w-5xl items-center justify-center px-4 py-10">
|
||||
<div className="grid w-full max-w-md gap-6 border bg-card p-6">
|
||||
<div className="space-y-2 text-center">
|
||||
<p className="text-[11px] uppercase tracking-[0.24em] text-muted-foreground">Admin Access</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight">Sign in</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Use your administrator account to open the protected monitoring dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form.Field name="password">
|
||||
{(field) => (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor={field.name}>Password</Label>
|
||||
<Input
|
||||
id={field.name}
|
||||
name={field.name}
|
||||
type="password"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.map((error) => (
|
||||
<p key={error?.message} className="text-xs text-red-500">
|
||||
{error?.message}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</form.Field>
|
||||
</div>
|
||||
|
||||
<form.Subscribe
|
||||
selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
form.handleSubmit();
|
||||
}}
|
||||
className="space-y-4"
|
||||
>
|
||||
{({ canSubmit, isSubmitting }) => (
|
||||
<Button type="submit" className="w-full" disabled={!canSubmit || isSubmitting}>
|
||||
{isSubmitting ? "Submitting..." : "Sign In"}
|
||||
</Button>
|
||||
)}
|
||||
</form.Subscribe>
|
||||
</form>
|
||||
<div>
|
||||
<form.Field name="email">
|
||||
{(field) => (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor={field.name}>Email</Label>
|
||||
<Input
|
||||
id={field.name}
|
||||
name={field.name}
|
||||
type="email"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.map((error) => (
|
||||
<p key={error?.message} className="text-xs text-red-500">
|
||||
{error?.message}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</form.Field>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-2 border-t pt-4 text-center text-xs text-muted-foreground">
|
||||
<p>Student demo flow uses administrator sign-in only.</p>
|
||||
<Link to="/dashboard" className="text-primary underline-offset-4 hover:underline">
|
||||
Open dashboard after sign in
|
||||
</Link>
|
||||
<div>
|
||||
<form.Field name="password">
|
||||
{(field) => (
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor={field.name}>Password</Label>
|
||||
<Input
|
||||
id={field.name}
|
||||
name={field.name}
|
||||
type="password"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
{field.state.meta.errors.map((error) => (
|
||||
<p key={error?.message} className="text-xs text-red-500">
|
||||
{error?.message}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</form.Field>
|
||||
</div>
|
||||
|
||||
<form.Subscribe
|
||||
selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}
|
||||
>
|
||||
{({ canSubmit, isSubmitting }) => (
|
||||
<Button type="submit" className="w-full" disabled={!canSubmit || isSubmitting}>
|
||||
{isSubmitting ? "Submitting..." : "Sign In"}
|
||||
</Button>
|
||||
)}
|
||||
</form.Subscribe>
|
||||
</form>
|
||||
|
||||
<div className="grid gap-2 border-t pt-4 text-center text-xs text-muted-foreground">
|
||||
<p>Student demo flow uses administrator sign-in only.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue