mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-06 01:15:42 +01:00
Fixed session properties.
This commit is contained in:
parent
5feae93162
commit
c7d39a3e94
@ -1,19 +1,16 @@
|
|||||||
import { Loading, TextOverflow } from 'react-basics';
|
import { TextOverflow } from 'react-basics';
|
||||||
import { useMessages, useSessionData } from 'components/hooks';
|
import { useMessages, useSessionData } from 'components/hooks';
|
||||||
import Empty from 'components/common/Empty';
|
import Empty from 'components/common/Empty';
|
||||||
import { DATA_TYPES } from 'lib/constants';
|
import { DATA_TYPES } from 'lib/constants';
|
||||||
import styles from './SessionData.module.css';
|
import styles from './SessionData.module.css';
|
||||||
|
import { LoadingPanel } from 'components/common/LoadingPanel';
|
||||||
|
|
||||||
export function SessionData({ websiteId, sessionId }: { websiteId: string; sessionId: string }) {
|
export function SessionData({ websiteId, sessionId }: { websiteId: string; sessionId: string }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { data, isLoading } = useSessionData(websiteId, sessionId);
|
const { data, ...query } = useSessionData(websiteId, sessionId);
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Loading icon="dots" size="sm" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.data}>
|
<LoadingPanel className={styles.data} {...query} data={data}>
|
||||||
<div className={styles.header}>{formatMessage(labels.properties)}</div>
|
<div className={styles.header}>{formatMessage(labels.properties)}</div>
|
||||||
{!data?.length && <Empty className={styles.empty} />}
|
{!data?.length && <Empty className={styles.empty} />}
|
||||||
{data?.map(({ dataKey, dataType, stringValue }) => {
|
{data?.map(({ dataKey, dataType, stringValue }) => {
|
||||||
@ -29,6 +26,6 @@ export function SessionData({ websiteId, sessionId }: { websiteId: string; sessi
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</LoadingPanel>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
import WebsiteHeader from '../../WebsiteHeader';
|
import WebsiteHeader from '../../WebsiteHeader';
|
||||||
import SessionInfo from './SessionInfo';
|
import SessionInfo from './SessionInfo';
|
||||||
import { useWebsiteSession } from 'components/hooks';
|
import { useWebsiteSession } from 'components/hooks';
|
||||||
import { Loading } from 'react-basics';
|
|
||||||
import Avatar from 'components/common/Avatar';
|
import Avatar from 'components/common/Avatar';
|
||||||
import { SessionActivity } from './SessionActivity';
|
import { SessionActivity } from './SessionActivity';
|
||||||
import { SessionStats } from './SessionStats';
|
import { SessionStats } from './SessionStats';
|
||||||
import { SessionData } from './SessionData';
|
import { SessionData } from './SessionData';
|
||||||
import styles from './SessionDetailsPage.module.css';
|
import styles from './SessionDetailsPage.module.css';
|
||||||
|
import { LoadingPanel } from 'components/common/LoadingPanel';
|
||||||
|
|
||||||
export default function SessionDetailsPage({
|
export default function SessionDetailsPage({
|
||||||
websiteId,
|
websiteId,
|
||||||
@ -16,14 +16,10 @@ export default function SessionDetailsPage({
|
|||||||
websiteId: string;
|
websiteId: string;
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
}) {
|
}) {
|
||||||
const { data, isLoading } = useWebsiteSession(websiteId, sessionId);
|
const { data, ...query } = useWebsiteSession(websiteId, sessionId);
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Loading position="page" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<LoadingPanel {...query} loadingIcon="spinner" data={data}>
|
||||||
<WebsiteHeader websiteId={websiteId} />
|
<WebsiteHeader websiteId={websiteId} />
|
||||||
<div className={styles.page}>
|
<div className={styles.page}>
|
||||||
<div className={styles.sidebar}>
|
<div className={styles.sidebar}>
|
||||||
@ -38,6 +34,6 @@ export default function SessionDetailsPage({
|
|||||||
<SessionData websiteId={websiteId} sessionId={sessionId} />
|
<SessionData websiteId={websiteId} sessionId={sessionId} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</LoadingPanel>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export function LoadingPanel({
|
|||||||
className?: string;
|
className?: string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const isEmpty = !data?.length && !isLoading && isFetched;
|
const isEmpty = !isLoading && isFetched && data && Array.isArray(data) && data.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.panel, className)}>
|
<div className={classNames(styles.panel, className)}>
|
||||||
|
@ -6,7 +6,7 @@ export function useSessionData(websiteId: string, sessionId: string) {
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['session:data', { websiteId, sessionId }],
|
queryKey: ['session:data', { websiteId, sessionId }],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return get(`/sessions/${sessionId}/data`, { websiteId });
|
return get(`/websites/${websiteId}/sessions/${sessionId}/properties`, { websiteId });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user