Skip to content

Commit

Permalink
feat: improve status column
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwitzko committed Feb 7, 2024
1 parent da038a1 commit 7195503
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions webui/app/(dashboard)/peers/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ export function getColumns(): ColumnDef<Peer>[] {
{
id: "badges",
enableHiding: false,
header: () => <span>Status</span>,
cell: ({ row }) => (
<div className="flex items-center gap-2">
{row.original.lastHandshake === 0 ? (
<Badge className="text-destructive">Offline</Badge>
) : null}
) : (
<Badge className="text-online">Online</Badge>
)}
{row.original.isHub ? <Badge>Hub</Badge> : null}
{row.original.isRequester ? <Badge>You</Badge> : null}
</div>
Expand Down Expand Up @@ -71,7 +74,7 @@ export function getColumns(): ColumnDef<Peer>[] {
cell: ({ row }) => {
const lastHandshake = row.getValue("lastHandshake") as Date;
return (
<div className="text-right">
<div className="text-right whitespace-nowrap">
{lastHandshake.getTime() === 0
? "Never"
: formatDistanceToNow(lastHandshake) + " ago"}
Expand Down
3 changes: 3 additions & 0 deletions webui/app/(dashboard)/peers/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export function PeersTable({
getSortedRowModel: getSortedRowModel(),
initialState: {
sorting: [{ id: "publicKey", desc: false }],
columnVisibility: {
endpoint: false,
},
},
});

Expand Down
4 changes: 4 additions & 0 deletions webui/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
--ring: 222.2 84% 4.9%;

--radius: 0.5rem;

--online: 120 84.2% 60.2%;
}

:root[class~="dark"] {
Expand Down Expand Up @@ -63,6 +65,8 @@
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;

--online: 120 62.8% 30.6%;
}
}

Expand Down
2 changes: 1 addition & 1 deletion webui/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function Login() {
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input type="password" {...field} />
<Input type="password" {...field} autoFocus />
</FormControl>
<FormMessage />
</FormItem>
Expand Down
4 changes: 4 additions & 0 deletions webui/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const config = {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
online: {
DEFAULT: "hsl(var(--online))",
foreground: "hsl(var(--destructive-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
Expand Down

0 comments on commit 7195503

Please sign in to comment.