mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Add quick filter buttons.
This commit is contained in:
parent
9beec1b50e
commit
ff4492ffb5
10 changed files with 80 additions and 25 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import PageviewsChart from './PageviewsChart';
|
||||
import { get } from 'lib/web';
|
||||
import { getDateArray, getTimezone } from 'lib/date';
|
||||
import { getDateArray, getDateRange, getTimezone } from 'lib/date';
|
||||
import WebsiteSummary from './WebsiteSummary';
|
||||
import QuickButtons from './QuickButtons';
|
||||
import styles from './WebsiteStats.module.css';
|
||||
|
||||
export default function WebsiteStats({ title, websiteId, startDate, endDate, unit }) {
|
||||
export default function WebsiteStats({ title, websiteId }) {
|
||||
const [data, setData] = useState();
|
||||
const [dateRange, setDateRange] = useState(getDateRange('7day'));
|
||||
const { startDate, endDate, unit } = dateRange;
|
||||
|
||||
const [pageviews, uniques] = useMemo(() => {
|
||||
if (data) {
|
||||
return [
|
||||
|
|
@ -17,6 +21,10 @@ export default function WebsiteStats({ title, websiteId, startDate, endDate, uni
|
|||
return [[], []];
|
||||
}, [data]);
|
||||
|
||||
function handleDateChange(values) {
|
||||
setDateRange(values);
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
setData(
|
||||
await get(`/api/website/${websiteId}/pageviews`, {
|
||||
|
|
@ -35,7 +43,10 @@ export default function WebsiteStats({ title, websiteId, startDate, endDate, uni
|
|||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.title}>{title}</div>
|
||||
<WebsiteSummary websiteId={websiteId} startDate={startDate} endDate={endDate} />
|
||||
<div className={styles.header}>
|
||||
<WebsiteSummary websiteId={websiteId} startDate={startDate} endDate={endDate} />
|
||||
<QuickButtons onChange={handleDateChange} />
|
||||
</div>
|
||||
<PageviewsChart data={{ pageviews, uniques }} unit={unit} />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue