fix realtime logs for mobile
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run

This commit is contained in:
Francis Cao 2025-11-10 01:07:11 -08:00
parent f3e246c64b
commit 64a6379c3c
3 changed files with 35 additions and 14 deletions

View file

@ -9,6 +9,7 @@ import {
useCountryNames, useCountryNames,
useLocale, useLocale,
useMessages, useMessages,
useMobile,
useNavigation, useNavigation,
useTimezone, useTimezone,
useWebsite, useWebsite,
@ -40,6 +41,7 @@ export function RealtimeLog({ data }: { data: any }) {
const { countryNames } = useCountryNames(locale); const { countryNames } = useCountryNames(locale);
const [filter, setFilter] = useState(TYPE_ALL); const [filter, setFilter] = useState(TYPE_ALL);
const { updateParams } = useNavigation(); const { updateParams } = useNavigation();
const { isPhone } = useMobile();
const buttons = [ const buttons = [
{ {
@ -123,12 +125,18 @@ export function RealtimeLog({ data }: { data: any }) {
const row = logs[index]; const row = logs[index];
return ( return (
<Row alignItems="center" style={style} gap> <Row alignItems="center" style={style} gap>
<Link href={updateParams({ session: row.sessionId })}> <Row minWidth="30px">
<Avatar seed={row.sessionId} size={32} /> <Link href={updateParams({ session: row.sessionId })}>
</Link> <Avatar seed={row.sessionId} size={32} />
<Row width="100px">{getTime(row)}</Row> </Link>
</Row>
<Row minWidth="100px">
<Text wrap="nowrap">{getTime(row)}</Text>
</Row>
<IconLabel icon={getIcon(row)}> <IconLabel icon={getIcon(row)}>
<Text>{getDetail(row)}</Text> <Text style={{ maxWidth: isPhone ? '400px' : null }} truncate>
{getDetail(row)}
</Text>
</IconLabel> </IconLabel>
</Row> </Row>
); );
@ -168,10 +176,22 @@ export function RealtimeLog({ data }: { data: any }) {
return ( return (
<Column gap> <Column gap>
<Heading size="2">{formatMessage(labels.activity)}</Heading> <Heading size="2">{formatMessage(labels.activity)}</Heading>
<Row alignItems="center" justifyContent="space-between"> {isPhone ? (
<SearchField value={search} onSearch={setSearch} /> <>
<FilterButtons items={buttons} value={filter} onChange={setFilter} /> <Row>
</Row> <SearchField value={search} onSearch={setSearch} />
</Row>
<Row>
<FilterButtons items={buttons} value={filter} onChange={setFilter} />
</Row>
</>
) : (
<Row alignItems="center" justifyContent="space-between">
<SearchField value={search} onSearch={setSearch} />
<FilterButtons items={buttons} value={filter} onChange={setFilter} />
</Row>
)}
<Column> <Column>
{logs?.length === 0 && <Empty />} {logs?.length === 0 && <Empty />}
{logs?.length > 0 && ( {logs?.length > 0 && (

View file

@ -6,7 +6,7 @@ import { PageBody } from '@/components/common/PageBody';
import { Panel } from '@/components/common/Panel'; import { Panel } from '@/components/common/Panel';
import { RealtimeChart } from '@/components/metrics/RealtimeChart'; import { RealtimeChart } from '@/components/metrics/RealtimeChart';
import { WorldMap } from '@/components/metrics/WorldMap'; import { WorldMap } from '@/components/metrics/WorldMap';
import { useRealtimeQuery } from '@/components/hooks'; import { useMobile, useRealtimeQuery } from '@/components/hooks';
import { RealtimeLog } from './RealtimeLog'; import { RealtimeLog } from './RealtimeLog';
import { RealtimeHeader } from './RealtimeHeader'; import { RealtimeHeader } from './RealtimeHeader';
import { RealtimePaths } from './RealtimePaths'; import { RealtimePaths } from './RealtimePaths';
@ -16,6 +16,7 @@ import { percentFilter } from '@/lib/filters';
export function RealtimePage({ websiteId }: { websiteId: string }) { export function RealtimePage({ websiteId }: { websiteId: string }) {
const { data, isLoading, error } = useRealtimeQuery(websiteId); const { data, isLoading, error } = useRealtimeQuery(websiteId);
const { isMobile } = useMobile();
if (isLoading || error) { if (isLoading || error) {
return <PageBody isLoading={isLoading} error={error} />; return <PageBody isLoading={isLoading} error={error} />;
@ -48,7 +49,7 @@ export function RealtimePage({ websiteId }: { websiteId: string }) {
<Panel> <Panel>
<RealtimeCountries data={countries} /> <RealtimeCountries data={countries} />
</Panel> </Panel>
<Panel gridColumn="span 2" padding="0"> <Panel gridColumn={isMobile ? null : 'span 2'} padding="0">
<WorldMap data={countries} /> <WorldMap data={countries} />
</Panel> </Panel>
</GridRow> </GridRow>

View file

@ -57,7 +57,7 @@ export function ListTable({
showPercentage={showPercentage} showPercentage={showPercentage}
change={renderChange ? renderChange(row, index) : null} change={renderChange ? renderChange(row, index) : null}
currency={currency} currency={currency}
isMobile={isPhone} isPhone={isPhone}
/> />
); );
}; };
@ -101,7 +101,7 @@ const AnimatedRow = ({
animate, animate,
showPercentage = true, showPercentage = true,
currency, currency,
isMobile, isPhone,
}) => { }) => {
const props = useSpring({ const props = useSpring({
width: percent, width: percent,
@ -120,7 +120,7 @@ const AnimatedRow = ({
gap gap
> >
<Row alignItems="center"> <Row alignItems="center">
<Text truncate={true} style={{ maxWidth: isMobile ? '200px' : '400px' }}> <Text truncate={true} style={{ maxWidth: isPhone ? '200px' : '400px' }}>
{label} {label}
</Text> </Text>
</Row> </Row>