mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-04 19:15:09 +01:00
Rename website column. Table component.
This commit is contained in:
parent
a09867f28c
commit
000f84df96
1
assets/pen.svg
Normal file
1
assets/pen.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M493.26 56.26l-37.51-37.51C443.25 6.25 426.87 0 410.49 0s-32.76 6.25-45.25 18.74l-74.49 74.49L256 127.98 12.85 371.12.15 485.34C-1.45 499.72 9.88 512 23.95 512c.89 0 1.79-.05 2.69-.15l114.14-12.61L384.02 256l34.74-34.74 74.49-74.49c25-25 25-65.52.01-90.51zM118.75 453.39l-67.58 7.46 7.53-67.69 231.24-231.24 31.02-31.02 60.14 60.14-31.02 31.02-231.33 231.33zm340.56-340.57l-44.28 44.28-60.13-60.14 44.28-44.28c4.08-4.08 8.84-4.69 11.31-4.69s7.24.61 11.31 4.69l37.51 37.51c6.24 6.25 6.24 16.4 0 22.63z"/></svg>
|
After Width: | Height: | Size: 580 B |
@ -1,10 +1,32 @@
|
|||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import Page from './Page';
|
import Page from './Page';
|
||||||
|
import Table from './Table';
|
||||||
|
import { get } from 'lib/web';
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{ key: 'name', label: 'Name' },
|
||||||
|
{ key: 'domain', label: 'Domain' },
|
||||||
|
];
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
|
const [data, setData] = useState();
|
||||||
|
|
||||||
|
async function loadData() {
|
||||||
|
setData(await get(`/api/website`));
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<h2>Settings</h2>
|
<h2>Settings</h2>
|
||||||
|
<Table columns={columns} rows={data.websites} />
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
25
components/Table.js
Normal file
25
components/Table.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styles from './Table.module.css';
|
||||||
|
|
||||||
|
export default function Table({ columns, rows }) {
|
||||||
|
return (
|
||||||
|
<table className={styles.table}>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{columns.map(({ key, label }) => (
|
||||||
|
<th key={key}>{label}</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{rows.map((row, rowIndex) => (
|
||||||
|
<tr key={rowIndex}>
|
||||||
|
{columns.map(({ key }) => (
|
||||||
|
<td key={`${rowIndex}${key}`}>{row[key]}</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
7
components/Table.module.css
Normal file
7
components/Table.module.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table th {
|
||||||
|
text-align: left;
|
||||||
|
}
|
@ -45,7 +45,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' })
|
|||||||
<Page>
|
<Page>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className={classNames(styles.chart, 'col')}>
|
<div className={classNames(styles.chart, 'col')}>
|
||||||
<h2>{data.label}</h2>
|
<h2>{data.name}</h2>
|
||||||
<WebsiteChart
|
<WebsiteChart
|
||||||
websiteId={websiteId}
|
websiteId={websiteId}
|
||||||
onDataLoad={handleDataLoad}
|
onDataLoad={handleDataLoad}
|
||||||
|
@ -21,27 +21,27 @@ export default function WebsiteList() {
|
|||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
{data &&
|
{data &&
|
||||||
data.websites.map(({ website_id, label }) => (
|
data.websites.map(({ website_id, name }) => (
|
||||||
<div key={website_id} className={styles.website}>
|
<div key={website_id} className={styles.website}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<h2>
|
<h2>
|
||||||
<Link
|
<Link
|
||||||
href="/website/[...id]"
|
href="/website/[...id]"
|
||||||
as={`/website/${website_id}/${label}`}
|
as={`/website/${website_id}/${name}`}
|
||||||
className={styles.title}
|
className={styles.title}
|
||||||
>
|
>
|
||||||
{label}
|
{name}
|
||||||
</Link>
|
</Link>
|
||||||
</h2>
|
</h2>
|
||||||
<Link
|
<Link
|
||||||
href="/website/[...id]"
|
href="/website/[...id]"
|
||||||
as={`/website/${website_id}/${label}`}
|
as={`/website/${website_id}/${name}`}
|
||||||
className={styles.details}
|
className={styles.details}
|
||||||
>
|
>
|
||||||
<Icon icon={<Arrow />} /> View details
|
<Icon icon={<Arrow />} /> View details
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<WebsiteChart key={website_id} title={label} websiteId={website_id} />
|
<WebsiteChart key={website_id} title={name} websiteId={website_id} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -71,9 +71,10 @@ model session {
|
|||||||
model website {
|
model website {
|
||||||
website_id Int @default(autoincrement()) @id
|
website_id Int @default(autoincrement()) @id
|
||||||
website_uuid String @unique
|
website_uuid String @unique
|
||||||
label String
|
name String
|
||||||
created_at DateTime? @default(now())
|
created_at DateTime? @default(now())
|
||||||
user_id Int
|
user_id Int
|
||||||
|
domain String?
|
||||||
account account @relation(fields: [user_id], references: [user_id])
|
account account @relation(fields: [user_id], references: [user_id])
|
||||||
event event[]
|
event event[]
|
||||||
pageview pageview[]
|
pageview pageview[]
|
||||||
|
@ -11,7 +11,8 @@ create table website (
|
|||||||
website_id serial primary key,
|
website_id serial primary key,
|
||||||
website_uuid uuid unique not null,
|
website_uuid uuid unique not null,
|
||||||
user_id int not null references account(user_id) on delete cascade,
|
user_id int not null references account(user_id) on delete cascade,
|
||||||
label varchar(100) not null,
|
name varchar(100) not null,
|
||||||
|
domain varchar(500),
|
||||||
created_at timestamp with time zone default current_timestamp
|
created_at timestamp with time zone default current_timestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user