Skip to content

Commit

Permalink
feat: ui updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rmrt1n committed Oct 17, 2024
1 parent b662fbc commit 6798a6f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export function Header() {
return (
<header className="border-b">
<nav className="flex items-center justify-between px-3 h-12">
<div className="flex items-center gap-2">
<div className="flex items-center gap-6">
<img src={logoLight} width={32} height={32} className="dark:hidden" />
<img src={logoDark} width={32} height={32} className="hidden dark:block" />
{links.map((link) => (
<Link
key={link.href}
to={link.href}
className={cn(
buttonVariants({ variant: location === link.href ? 'default' : 'outline' }),
'px-4 py-2 h-8',
'text-sm font-medium transition-colors hover:text-primary',
location === link.href ? 'text-primary' : 'text-muted-foreground',
)}
>
{link.title}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ function getDurationMicroSeconds(lookback: string) {
h: 60 * 60,
d: 60 * 60 * 24,
}
const seconds = lookback[lookback.length - 1]
return lookupSeconds[seconds] * 1_000_000
const unit = lookback[lookback.length - 1]
const unitToSeconds = lookupSeconds[unit]
const seconds = parseInt(lookback.slice(0, lookback.length))
return seconds * unitToSeconds * 1_000_000
}

// since we're embedding an iframe, instead of fetching the page here, we're just
Expand Down
2 changes: 1 addition & 1 deletion src/routes/_cardinal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function CardinalLayout() {
const sync = async () => {
try {
// syncs local personas with cardinal's. this is needed for running with `world cardinal start`,
// where the state is persisted accross restarts. this is needed to keep track of the last nonce
// where the state is persisted across restarts. this is needed to keep track of the last nonce
// used by each signer.
const entities = await queryClient.fetchQuery(
syncStateQueryOptions({ cardinalUrl, isCardinalConnected }),
Expand Down
36 changes: 32 additions & 4 deletions src/routes/_jaeger.jaeger.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Button } from '@/components/ui/button'
import { useToast } from '@/components/ui/use-toast'
import { useCardinal } from '@/lib/cardinal-provider'
import { useQuery } from '@tanstack/react-query'
import { createFileRoute } from '@tanstack/react-router'
import { Unlink } from 'lucide-react'
import { Clipboard, Unlink } from 'lucide-react'
import { useEffect, useState } from 'react'

export const Route = createFileRoute('/_jaeger/jaeger')({
Expand All @@ -12,6 +14,7 @@ function Jaeger() {
const { jaegerUrl } = useCardinal()
const { data: url } = useQuery({ queryKey: ['jaegerSearch'], enabled: false })
const [isJaegerRunning, setIsJaegerRunning] = useState(false)
const { toast } = useToast()

useEffect(() => {
const ping = async () => {
Expand All @@ -26,20 +29,45 @@ function Jaeger() {
}, [jaegerUrl])

const defaultUrl = `${jaegerUrl}/?uiEmbed=v0`
const telemetryCommand = 'world cardinal start --telemetry'

const handleCopyToClipboard = () => {
navigator.clipboard.writeText(telemetryCommand).then(() =>
toast({
title: 'Copied to clipboard',
}),
)
}

return (
<>
{!isJaegerRunning ? (
<div className="flex flex-col gap-4 items-center h-full pt-[21.5rem]">
<Unlink size={40} strokeWidth={2.5} className="text-muted-foreground" />
<div className="space-y-2 text-center">
<div className="flex flex-col items-center gap-2 max-w-md">
<p className="text-lg font-semibold">Not Connected</p>
<p className="text-muted-foreground">Make sure you have a running Jaeger instance!</p>
<p className="text-muted-foreground">
To enable Jaeger, set{' '}
<code className="text-sm font-bold">NAKAMA_TRACE_ENABLED=true</code>, in your{' '}
<code className="text-sm font-bold">world.toml</code> file and run this command:
</p>
<pre className="flex items-center justify-between gap-2 w-full px-4 py-2 rounded-lg text-sm bg-primary text-primary-foreground dark:bg-primary-foreground dark:text-primary">
<code>
<code className="select-none text-green-400">$ </code>
{telemetryCommand}
</code>
<Button variant="ghost" size="icon" className="dark" onClick={handleCopyToClipboard}>
<Clipboard size={17} />
</Button>
</pre>
</div>
</div>
) : (
<div className="p-2 bg-white h-full border border-border rounded-md">
<iframe src={url && typeof url === 'string' ? url : defaultUrl} className="w-full h-full" />
<iframe
src={url && typeof url === 'string' ? url : defaultUrl}
className="w-full h-full"
/>
</div>
)}
</>
Expand Down

0 comments on commit 6798a6f

Please sign in to comment.