mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
New components, convert hooks to components, bug fixes.
This commit is contained in:
parent
a2db27894f
commit
9d8a2406e1
21 changed files with 330 additions and 181 deletions
|
|
@ -3,7 +3,6 @@ import classNames from 'classnames';
|
|||
import WebsiteChart from './WebsiteChart';
|
||||
import RankingsChart from './RankingsChart';
|
||||
import WorldMap from './WorldMap';
|
||||
import CheckVisible from './CheckVisible';
|
||||
import { getDateRange } from 'lib/date';
|
||||
import { get } from 'lib/web';
|
||||
import { browserFilter, urlFilter, refFilter, deviceFilter, countryFilter } from 'lib/filters';
|
||||
|
|
@ -14,6 +13,7 @@ const sessionClasses = 'col-12 col-lg-4';
|
|||
|
||||
export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) {
|
||||
const [data, setData] = useState();
|
||||
const [chartLoaded, setChartLoaded] = useState(false);
|
||||
const [countryData, setCountryData] = useState();
|
||||
const [dateRange, setDateRange] = useState(getDateRange(defaultDateRange));
|
||||
const { startDate, endDate } = dateRange;
|
||||
|
|
@ -22,6 +22,10 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' })
|
|||
setData(await get(`/api/website/${websiteId}`));
|
||||
}
|
||||
|
||||
function handleDataLoad() {
|
||||
if (!chartLoaded) setTimeout(() => setChartLoaded(true), 300);
|
||||
}
|
||||
|
||||
function handleDateChange(values) {
|
||||
setTimeout(() => setDateRange(values), 300);
|
||||
}
|
||||
|
|
@ -41,84 +45,93 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' })
|
|||
<div className="row">
|
||||
<div className={classNames(styles.chart, 'col')}>
|
||||
<h2>{data.label}</h2>
|
||||
<WebsiteChart websiteId={websiteId} onDateChange={handleDateChange} stickHeader />
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className={pageviewClasses}>
|
||||
<RankingsChart
|
||||
title="Pages"
|
||||
type="url"
|
||||
heading="Views"
|
||||
<WebsiteChart
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={urlFilter}
|
||||
/>
|
||||
</div>
|
||||
<div className={pageviewClasses}>
|
||||
<RankingsChart
|
||||
title="Referrers"
|
||||
type="referrer"
|
||||
heading="Views"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={refFilter}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Browsers"
|
||||
type="browser"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={browserFilter}
|
||||
/>
|
||||
</div>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Operating system"
|
||||
type="os"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
/>
|
||||
</div>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Devices"
|
||||
type="screen"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={deviceFilter}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className="col-12 col-md-12 col-lg-8">
|
||||
<WorldMap data={countryData} />
|
||||
</div>
|
||||
<div className="col-12 col-md-12 col-lg-4">
|
||||
<RankingsChart
|
||||
title="Countries"
|
||||
type="country"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={countryFilter}
|
||||
onDataLoad={data => setCountryData(data)}
|
||||
onDataLoad={handleDataLoad}
|
||||
onDateChange={handleDateChange}
|
||||
stickyHeader
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{chartLoaded && (
|
||||
<>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className={pageviewClasses}>
|
||||
<RankingsChart
|
||||
title="Pages"
|
||||
type="url"
|
||||
heading="Views"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={urlFilter}
|
||||
/>
|
||||
</div>
|
||||
<div className={pageviewClasses}>
|
||||
<RankingsChart
|
||||
title="Referrers"
|
||||
type="referrer"
|
||||
heading="Views"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={refFilter}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Browsers"
|
||||
type="browser"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={browserFilter}
|
||||
/>
|
||||
</div>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Operating system"
|
||||
type="os"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
/>
|
||||
</div>
|
||||
<div className={sessionClasses}>
|
||||
<RankingsChart
|
||||
title="Devices"
|
||||
type="screen"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={deviceFilter}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(styles.row, 'row')}>
|
||||
<div className="col-12 col-md-12 col-lg-8">
|
||||
<WorldMap data={countryData} />
|
||||
</div>
|
||||
<div className="col-12 col-md-12 col-lg-4">
|
||||
<RankingsChart
|
||||
title="Countries"
|
||||
type="country"
|
||||
heading="Visitors"
|
||||
websiteId={websiteId}
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
dataFilter={countryFilter}
|
||||
onDataLoad={data => setCountryData(data)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue