mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Chart component. Update web utils.
This commit is contained in:
parent
f947c7770b
commit
590a70c2ff
6 changed files with 159 additions and 8 deletions
10
pages/api/website/[id]/pageviews.js
Normal file
10
pages/api/website/[id]/pageviews.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { getPageviews } from 'lib/db';
|
||||
|
||||
export default async (req, res) => {
|
||||
console.log(req.query);
|
||||
const { id, start_at, end_at } = req.query;
|
||||
|
||||
const pageviews = await getPageviews(+id, new Date(+start_at), new Date(+end_at));
|
||||
|
||||
res.status(200).json({ pageviews });
|
||||
};
|
||||
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import Link from 'next/link';
|
||||
import cookies from 'next-cookies';
|
||||
import Layout from 'components/Layout';
|
||||
import Chart from 'components/Chart';
|
||||
import { verifySecureToken } from 'lib/crypto';
|
||||
|
||||
export default function HomePage({ username }) {
|
||||
|
|
@ -10,6 +11,13 @@ export default function HomePage({ username }) {
|
|||
<h2>
|
||||
You've successfully logged in as <b>{username}</b>.
|
||||
</h2>
|
||||
<div>
|
||||
<Chart
|
||||
websiteId={3}
|
||||
startDate={Date.now() - 1000 * 60 * 60 * 24 * 7}
|
||||
endDate={Date.now()}
|
||||
/>
|
||||
</div>
|
||||
<Link href="/logout">
|
||||
<a>Logout 🡒</a>
|
||||
</Link>
|
||||
|
|
@ -25,7 +33,7 @@ export async function getServerSideProps(context) {
|
|||
|
||||
return {
|
||||
props: {
|
||||
username: payload.username,
|
||||
...payload,
|
||||
},
|
||||
};
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue