mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Created share token hook.
This commit is contained in:
parent
4119e80a9a
commit
5a73c224b7
22 changed files with 90 additions and 49 deletions
|
|
@ -13,6 +13,7 @@ import useFetch from 'hooks/useFetch';
|
|||
import useLocale from 'hooks/useLocale';
|
||||
import useCountryNames from 'hooks/useCountryNames';
|
||||
import { percentFilter } from 'lib/filters';
|
||||
import { TOKEN_HEADER } from 'lib/constants';
|
||||
import styles from './RealtimeDashboard.module.css';
|
||||
|
||||
const REALTIME_RANGE = 30;
|
||||
|
|
@ -39,7 +40,7 @@ export default function RealtimeDashboard() {
|
|||
params: { start_at: data?.timestamp },
|
||||
disabled: !init?.websites?.length || !data,
|
||||
interval: REALTIME_INTERVAL,
|
||||
headers: { 'x-umami-token': init?.token },
|
||||
headers: { [TOKEN_HEADER]: init?.token },
|
||||
});
|
||||
|
||||
const renderCountryName = useCallback(({ x }) => countryNames[x], []);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import EventsTable from '../metrics/EventsTable';
|
|||
import EventsChart from '../metrics/EventsChart';
|
||||
import useFetch from 'hooks/useFetch';
|
||||
import usePageQuery from 'hooks/usePageQuery';
|
||||
import { DEFAULT_ANIMATION_DURATION } from 'lib/constants';
|
||||
import useShareToken from 'hooks/useShareToken';
|
||||
import { DEFAULT_ANIMATION_DURATION, TOKEN_HEADER } from 'lib/constants';
|
||||
|
||||
const views = {
|
||||
url: PagesTable,
|
||||
|
|
@ -32,8 +33,11 @@ const views = {
|
|||
event: EventsTable,
|
||||
};
|
||||
|
||||
export default function WebsiteDetails({ websiteId, token }) {
|
||||
const { data } = useFetch(`/api/website/${websiteId}`, { params: { token } });
|
||||
export default function WebsiteDetails({ websiteId }) {
|
||||
const shareToken = useShareToken();
|
||||
const { data } = useFetch(`/api/website/${websiteId}`, {
|
||||
headers: { [TOKEN_HEADER]: shareToken?.token },
|
||||
});
|
||||
const [chartLoaded, setChartLoaded] = useState(false);
|
||||
const [countryData, setCountryData] = useState();
|
||||
const [eventsData, setEventsData] = useState();
|
||||
|
|
@ -93,7 +97,6 @@ export default function WebsiteDetails({ websiteId, token }) {
|
|||
|
||||
const tableProps = {
|
||||
websiteId,
|
||||
token,
|
||||
websiteDomain: data?.domain,
|
||||
limit: 10,
|
||||
};
|
||||
|
|
@ -116,7 +119,6 @@ export default function WebsiteDetails({ websiteId, token }) {
|
|||
<div className={classNames(styles.chart, 'col')}>
|
||||
<WebsiteChart
|
||||
websiteId={websiteId}
|
||||
token={token}
|
||||
title={data.name}
|
||||
onDataLoad={handleDataLoad}
|
||||
showLink={false}
|
||||
|
|
@ -159,7 +161,7 @@ export default function WebsiteDetails({ websiteId, token }) {
|
|||
<EventsTable {...tableProps} onDataLoad={setEventsData} />
|
||||
</GridColumn>
|
||||
<GridColumn xs={12} md={12} lg={8}>
|
||||
<EventsChart className={styles.eventschart} websiteId={websiteId} token={token} />
|
||||
<EventsChart className={styles.eventschart} websiteId={websiteId} />
|
||||
</GridColumn>
|
||||
</GridRow>
|
||||
</GridLayout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue