commit
63f24e55f1
|
@ -23,6 +23,7 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
|
*.log
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
|
|
|
@ -4,6 +4,7 @@ import styles from './Dot.module.css';
|
||||||
|
|
||||||
export default function Dot({ color, size, className }) {
|
export default function Dot({ color, size, className }) {
|
||||||
return (
|
return (
|
||||||
|
<div className={styles.wrapper}>
|
||||||
<div
|
<div
|
||||||
style={{ background: color }}
|
style={{ background: color }}
|
||||||
className={classNames(styles.dot, className, {
|
className={classNames(styles.dot, className, {
|
||||||
|
@ -11,5 +12,6 @@ export default function Dot({ color, size, className }) {
|
||||||
[styles.large]: size === 'large',
|
[styles.large]: size === 'large',
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
|
.wrapper {
|
||||||
|
background: var(--gray50);
|
||||||
|
margin-right: 10px;
|
||||||
|
border-radius: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.dot {
|
.dot {
|
||||||
background: var(--green400);
|
background: var(--green400);
|
||||||
width: 10px;
|
width: 10px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
margin-right: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot.small {
|
.dot.small {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import React from 'react';
|
||||||
|
import styles from './Favicon.module.css';
|
||||||
|
|
||||||
|
function getHostName(url) {
|
||||||
|
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?=]+)/im);
|
||||||
|
return match && match.length > 1 ? match[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Favicon({ domain, ...props }) {
|
||||||
|
const hostName = domain ? getHostName(domain) : null;
|
||||||
|
|
||||||
|
return hostName ? (
|
||||||
|
<img
|
||||||
|
className={styles.favicon}
|
||||||
|
src={`https://icons.duckduckgo.com/ip3/${hostName}.ico`}
|
||||||
|
height="16"
|
||||||
|
alt=""
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
.favicon {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
.container {
|
.container {
|
||||||
color: var(--gray500);
|
color: var(--gray500);
|
||||||
|
font-size: var(--font-size-normal);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import ReactTooltip from 'react-tooltip';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import ChartJS from 'chart.js';
|
import ChartJS from 'chart.js';
|
||||||
|
import Legend from 'components/metrics/Legend';
|
||||||
import { formatLongNumber } from 'lib/format';
|
import { formatLongNumber } from 'lib/format';
|
||||||
import { dateFormat } from 'lib/lang';
|
import { dateFormat } from 'lib/lang';
|
||||||
import useLocale from 'hooks/useLocale';
|
import useLocale from 'hooks/useLocale';
|
||||||
import useTheme from 'hooks/useTheme';
|
import useTheme from 'hooks/useTheme';
|
||||||
import { DEFAUL_CHART_HEIGHT, DEFAULT_ANIMATION_DURATION, THEME_COLORS } from 'lib/constants';
|
import { DEFAUL_CHART_HEIGHT, DEFAULT_ANIMATION_DURATION, THEME_COLORS } from 'lib/constants';
|
||||||
import styles from './BarChart.module.css';
|
import styles from './BarChart.module.css';
|
||||||
|
import ChartTooltip from './ChartTooltip';
|
||||||
|
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||||
|
|
||||||
export default function BarChart({
|
export default function BarChart({
|
||||||
chartId,
|
chartId,
|
||||||
|
@ -27,6 +29,8 @@ export default function BarChart({
|
||||||
const [tooltip, setTooltip] = useState(null);
|
const [tooltip, setTooltip] = useState(null);
|
||||||
const [locale] = useLocale();
|
const [locale] = useLocale();
|
||||||
const [theme] = useTheme();
|
const [theme] = useTheme();
|
||||||
|
const forceUpdate = useForceUpdate();
|
||||||
|
|
||||||
const colors = {
|
const colors = {
|
||||||
text: THEME_COLORS[theme].gray700,
|
text: THEME_COLORS[theme].gray700,
|
||||||
line: THEME_COLORS[theme].gray200,
|
line: THEME_COLORS[theme].gray200,
|
||||||
|
@ -111,9 +115,7 @@ export default function BarChart({
|
||||||
responsiveAnimationDuration: 0,
|
responsiveAnimationDuration: 0,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
legend: {
|
legend: {
|
||||||
labels: {
|
display: false,
|
||||||
fontColor: colors.text,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
xAxes: [
|
xAxes: [
|
||||||
|
@ -179,6 +181,10 @@ export default function BarChart({
|
||||||
options.tooltips.custom = renderTooltip;
|
options.tooltips.custom = renderTooltip;
|
||||||
|
|
||||||
onUpdate(chart.current);
|
onUpdate(chart.current);
|
||||||
|
|
||||||
|
chart.current.update();
|
||||||
|
|
||||||
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -202,23 +208,8 @@ export default function BarChart({
|
||||||
>
|
>
|
||||||
<canvas ref={canvas} />
|
<canvas ref={canvas} />
|
||||||
</div>
|
</div>
|
||||||
<ReactTooltip id={`${chartId}-tooltip`}>
|
<Legend chart={chart.current} />
|
||||||
{tooltip ? <Tooltip {...tooltip} /> : null}
|
<ChartTooltip chartId={chartId} tooltip={tooltip} />
|
||||||
</ReactTooltip>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tooltip = ({ title, value, label, labelColor }) => (
|
|
||||||
<div className={styles.tooltip}>
|
|
||||||
<div className={styles.content}>
|
|
||||||
<div className={styles.title}>{title}</div>
|
|
||||||
<div className={styles.metric}>
|
|
||||||
<div className={styles.dot}>
|
|
||||||
<div className={styles.color} style={{ backgroundColor: labelColor }} />
|
|
||||||
</div>
|
|
||||||
{value} {label}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
|
@ -1,43 +1,3 @@
|
||||||
.chart {
|
.chart {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip {
|
|
||||||
color: var(--msgColor);
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: var(--font-size-xsmall);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
font-size: var(--font-size-small);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dot {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: 100%;
|
|
||||||
margin-right: 8px;
|
|
||||||
background: var(--gray50);
|
|
||||||
}
|
|
||||||
|
|
||||||
.color {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import React from 'react';
|
||||||
|
import Dot from 'components/common/Dot';
|
||||||
|
import styles from './ChartTooltip.module.css';
|
||||||
|
import ReactTooltip from 'react-tooltip';
|
||||||
|
|
||||||
|
export default function ChartTooltip({ chartId, tooltip }) {
|
||||||
|
if (!tooltip) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { title, value, label, labelColor } = tooltip;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReactTooltip id={`${chartId}-tooltip`}>
|
||||||
|
<div className={styles.tooltip}>
|
||||||
|
<div className={styles.content}>
|
||||||
|
<div className={styles.title}>{title}</div>
|
||||||
|
<div className={styles.metric}>
|
||||||
|
<Dot color={labelColor} />
|
||||||
|
{value} {label}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ReactTooltip>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
.chart {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip {
|
||||||
|
color: var(--msgColor);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: var(--font-size-xsmall);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 100%;
|
||||||
|
margin-right: 8px;
|
||||||
|
background: var(--gray50);
|
||||||
|
}
|
||||||
|
|
||||||
|
.color {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ export default function EventsChart({ websiteId, className, token }) {
|
||||||
const { query } = usePageQuery();
|
const { query } = usePageQuery();
|
||||||
const shareToken = useShareToken();
|
const shareToken = useShareToken();
|
||||||
|
|
||||||
const { data } = useFetch(
|
const { data, loading } = useFetch(
|
||||||
`/api/website/${websiteId}/events`,
|
`/api/website/${websiteId}/events`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
|
@ -31,8 +31,10 @@ export default function EventsChart({ websiteId, className, token }) {
|
||||||
},
|
},
|
||||||
[modified],
|
[modified],
|
||||||
);
|
);
|
||||||
|
|
||||||
const datasets = useMemo(() => {
|
const datasets = useMemo(() => {
|
||||||
if (!data) return [];
|
if (!data) return [];
|
||||||
|
if (loading) return data;
|
||||||
|
|
||||||
const map = data.reduce((obj, { x, t, y }) => {
|
const map = data.reduce((obj, { x, t, y }) => {
|
||||||
if (!obj[x]) {
|
if (!obj[x]) {
|
||||||
|
@ -59,15 +61,7 @@ export default function EventsChart({ websiteId, className, token }) {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}, [data]);
|
}, [data, loading]);
|
||||||
|
|
||||||
function handleCreate(options) {
|
|
||||||
const legend = {
|
|
||||||
position: 'bottom',
|
|
||||||
};
|
|
||||||
|
|
||||||
options.legend = legend;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleUpdate(chart) {
|
function handleUpdate(chart) {
|
||||||
chart.data.datasets = datasets;
|
chart.data.datasets = datasets;
|
||||||
|
@ -85,9 +79,10 @@ export default function EventsChart({ websiteId, className, token }) {
|
||||||
className={className}
|
className={className}
|
||||||
datasets={datasets}
|
datasets={datasets}
|
||||||
unit={unit}
|
unit={unit}
|
||||||
|
height={300}
|
||||||
records={getDateLength(startDate, endDate, unit)}
|
records={getDateLength(startDate, endDate, unit)}
|
||||||
onCreate={handleCreate}
|
|
||||||
onUpdate={handleUpdate}
|
onUpdate={handleUpdate}
|
||||||
|
loading={loading}
|
||||||
stacked
|
stacked
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
import React from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import Dot from 'components/common/Dot';
|
||||||
|
import useLocale from 'hooks/useLocale';
|
||||||
|
import styles from './Legend.module.css';
|
||||||
|
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||||
|
|
||||||
|
export default function Legend({ chart }) {
|
||||||
|
const [locale] = useLocale();
|
||||||
|
const forceUpdate = useForceUpdate();
|
||||||
|
|
||||||
|
function handleClick(index) {
|
||||||
|
const meta = chart.getDatasetMeta(index);
|
||||||
|
|
||||||
|
meta.hidden = meta.hidden === null ? !chart.data.datasets[index].hidden : null;
|
||||||
|
|
||||||
|
chart.update();
|
||||||
|
|
||||||
|
forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chart?.legend?.legendItems.find(({ text }) => text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.legend}>
|
||||||
|
{chart.legend.legendItems.map(({ text, fillStyle, datasetIndex, hidden }) => (
|
||||||
|
<div
|
||||||
|
key={text}
|
||||||
|
className={classNames(styles.label, { [styles.hidden]: hidden })}
|
||||||
|
onClick={() => handleClick(datasetIndex)}
|
||||||
|
>
|
||||||
|
<Dot color={fillStyle} />
|
||||||
|
<span className={locale}>{text}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
.legend {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: var(--font-size-xsmall);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label + .label {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
color: var(--gray400);
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ export default function MetricsBar({ websiteId, className }) {
|
||||||
},
|
},
|
||||||
headers: { [TOKEN_HEADER]: shareToken?.token },
|
headers: { [TOKEN_HEADER]: shareToken?.token },
|
||||||
},
|
},
|
||||||
[modified],
|
[url, modified],
|
||||||
);
|
);
|
||||||
|
|
||||||
const formatFunc = format ? formatLongNumber : formatNumber;
|
const formatFunc = format ? formatLongNumber : formatNumber;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import firstBy from 'thenby';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
import Loading from 'components/common/Loading';
|
import Loading from 'components/common/Loading';
|
||||||
|
@ -55,9 +56,9 @@ export default function MetricsTable({
|
||||||
if (data) {
|
if (data) {
|
||||||
const items = percentFilter(dataFilter ? dataFilter(data, filterOptions) : data);
|
const items = percentFilter(dataFilter ? dataFilter(data, filterOptions) : data);
|
||||||
if (limit) {
|
if (limit) {
|
||||||
return items.filter((e, i) => i < limit);
|
return items.filter((e, i) => i < limit).sort(firstBy('y', -1).thenBy('x'));
|
||||||
}
|
}
|
||||||
return items;
|
return items.sort(firstBy('y', -1).thenBy('x'));
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}, [data, error, dataFilter, filterOptions]);
|
}, [data, error, dataFilter, filterOptions]);
|
||||||
|
|
|
@ -45,8 +45,6 @@ export default function PageviewsChart({
|
||||||
id: 'metrics.page-views',
|
id: 'metrics.page-views',
|
||||||
defaultMessage: 'Page views',
|
defaultMessage: 'Page views',
|
||||||
});
|
});
|
||||||
|
|
||||||
chart.update();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
.metrics {
|
.metrics {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useMemo, useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { FixedSizeList } from 'react-window';
|
import { FixedSizeList } from 'react-window';
|
||||||
import firstBy from 'thenby';
|
import firstBy from 'thenby';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
@ -7,6 +7,7 @@ import Icon from 'components/common/Icon';
|
||||||
import Tag from 'components/common/Tag';
|
import Tag from 'components/common/Tag';
|
||||||
import Dot from 'components/common/Dot';
|
import Dot from 'components/common/Dot';
|
||||||
import FilterButtons from 'components/common/FilterButtons';
|
import FilterButtons from 'components/common/FilterButtons';
|
||||||
|
import { devices } from 'components/messages';
|
||||||
import useLocale from 'hooks/useLocale';
|
import useLocale from 'hooks/useLocale';
|
||||||
import useCountryNames from 'hooks/useCountryNames';
|
import useCountryNames from 'hooks/useCountryNames';
|
||||||
import { BROWSERS } from 'lib/constants';
|
import { BROWSERS } from 'lib/constants';
|
||||||
|
@ -15,6 +16,7 @@ import Visitor from 'assets/visitor.svg';
|
||||||
import Eye from 'assets/eye.svg';
|
import Eye from 'assets/eye.svg';
|
||||||
import { stringToColor } from 'lib/format';
|
import { stringToColor } from 'lib/format';
|
||||||
import styles from './RealtimeLog.module.css';
|
import styles from './RealtimeLog.module.css';
|
||||||
|
import NoData from '../common/NoData';
|
||||||
|
|
||||||
const TYPE_ALL = 0;
|
const TYPE_ALL = 0;
|
||||||
const TYPE_PAGEVIEW = 1;
|
const TYPE_PAGEVIEW = 1;
|
||||||
|
@ -28,6 +30,7 @@ const TYPE_ICONS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RealtimeLog({ data, websites }) {
|
export default function RealtimeLog({ data, websites }) {
|
||||||
|
const intl = useIntl();
|
||||||
const [locale] = useLocale();
|
const [locale] = useLocale();
|
||||||
const countryNames = useCountryNames(locale);
|
const countryNames = useCountryNames(locale);
|
||||||
const [filter, setFilter] = useState(TYPE_ALL);
|
const [filter, setFilter] = useState(TYPE_ALL);
|
||||||
|
@ -116,9 +119,9 @@ export default function RealtimeLog({ data, websites }) {
|
||||||
defaultMessage="Visitor from {country} using {browser} on {os} {device}"
|
defaultMessage="Visitor from {country} using {browser} on {os} {device}"
|
||||||
values={{
|
values={{
|
||||||
country: <b>{countryNames[country]}</b>,
|
country: <b>{countryNames[country]}</b>,
|
||||||
browser: BROWSERS[browser],
|
browser: <b>{BROWSERS[browser]}</b>,
|
||||||
os,
|
os: <b>{os}</b>,
|
||||||
device,
|
device: <b>{intl.formatMessage(devices[device])?.toLowerCase()}</b>,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -159,6 +162,7 @@ export default function RealtimeLog({ data, websites }) {
|
||||||
<FormattedMessage id="label.realtime-logs" defaultMessage="Realtime logs" />
|
<FormattedMessage id="label.realtime-logs" defaultMessage="Realtime logs" />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.body}>
|
<div className={styles.body}>
|
||||||
|
{logs?.length === 0 && <NoData />}
|
||||||
<FixedSizeList height={400} itemCount={logs.length} itemSize={40}>
|
<FixedSizeList height={400} itemCount={logs.length} itemSize={40}>
|
||||||
{Row}
|
{Row}
|
||||||
</FixedSizeList>
|
</FixedSizeList>
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { TOKEN_HEADER } from '../../lib/constants';
|
||||||
export default function WebsiteChart({
|
export default function WebsiteChart({
|
||||||
websiteId,
|
websiteId,
|
||||||
title,
|
title,
|
||||||
|
domain,
|
||||||
stickyHeader = false,
|
stickyHeader = false,
|
||||||
showLink = false,
|
showLink = false,
|
||||||
onDataLoad = () => {},
|
onDataLoad = () => {},
|
||||||
|
@ -47,7 +48,7 @@ export default function WebsiteChart({
|
||||||
onDataLoad,
|
onDataLoad,
|
||||||
headers: { [TOKEN_HEADER]: shareToken?.token },
|
headers: { [TOKEN_HEADER]: shareToken?.token },
|
||||||
},
|
},
|
||||||
[modified],
|
[url, modified],
|
||||||
);
|
);
|
||||||
|
|
||||||
const chartData = useMemo(() => {
|
const chartData = useMemo(() => {
|
||||||
|
@ -66,7 +67,7 @@ export default function WebsiteChart({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<WebsiteHeader websiteId={websiteId} title={title} showLink={showLink} />
|
<WebsiteHeader websiteId={websiteId} title={title} domain={domain} showLink={showLink} />
|
||||||
<div className={classNames(styles.header, 'row')}>
|
<div className={classNames(styles.header, 'row')}>
|
||||||
<StickyHeader
|
<StickyHeader
|
||||||
className={classNames(styles.metrics, 'col row')}
|
className={classNames(styles.metrics, 'col row')}
|
||||||
|
|
|
@ -4,14 +4,18 @@ import Link from 'components/common/Link';
|
||||||
import PageHeader from 'components/layout/PageHeader';
|
import PageHeader from 'components/layout/PageHeader';
|
||||||
import RefreshButton from 'components/common/RefreshButton';
|
import RefreshButton from 'components/common/RefreshButton';
|
||||||
import ButtonLayout from 'components/layout/ButtonLayout';
|
import ButtonLayout from 'components/layout/ButtonLayout';
|
||||||
|
import Favicon from 'components/common/Favicon';
|
||||||
import ActiveUsers from './ActiveUsers';
|
import ActiveUsers from './ActiveUsers';
|
||||||
import Arrow from 'assets/arrow-right.svg';
|
import Arrow from 'assets/arrow-right.svg';
|
||||||
import styles from './WebsiteHeader.module.css';
|
import styles from './WebsiteHeader.module.css';
|
||||||
|
|
||||||
export default function WebsiteHeader({ websiteId, title, showLink = false }) {
|
export default function WebsiteHeader({ websiteId, title, domain, showLink = false }) {
|
||||||
return (
|
return (
|
||||||
<PageHeader>
|
<PageHeader>
|
||||||
<div className={styles.title}>{title}</div>
|
<div className={styles.title}>
|
||||||
|
<Favicon domain={domain} />
|
||||||
|
{title}
|
||||||
|
</div>
|
||||||
<ActiveUsers className={styles.active} websiteId={websiteId} />
|
<ActiveUsers className={styles.active} websiteId={websiteId} />
|
||||||
<ButtonLayout align="right">
|
<ButtonLayout align="right">
|
||||||
<RefreshButton websiteId={websiteId} />
|
<RefreshButton websiteId={websiteId} />
|
||||||
|
|
|
@ -82,7 +82,12 @@ export default function TestConsole() {
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<WebsiteChart websiteId={website.website_id} title={website.name} showLink />
|
<WebsiteChart
|
||||||
|
websiteId={website.website_id}
|
||||||
|
title={website.name}
|
||||||
|
domain={website.domain}
|
||||||
|
showLink
|
||||||
|
/>
|
||||||
<PageHeader>Events</PageHeader>
|
<PageHeader>Events</PageHeader>
|
||||||
<EventsChart websiteId={website.website_id} />
|
<EventsChart websiteId={website.website_id} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -120,6 +120,7 @@ export default function WebsiteDetails({ websiteId }) {
|
||||||
<WebsiteChart
|
<WebsiteChart
|
||||||
websiteId={websiteId}
|
websiteId={websiteId}
|
||||||
title={data.name}
|
title={data.name}
|
||||||
|
domain={data.domain}
|
||||||
onDataLoad={handleDataLoad}
|
onDataLoad={handleDataLoad}
|
||||||
showLink={false}
|
showLink={false}
|
||||||
stickyHeader
|
stickyHeader
|
||||||
|
|
|
@ -31,5 +31,5 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.eventschart {
|
.eventschart {
|
||||||
padding: 30px 0;
|
padding-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ export default function WebsiteList({ userId }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
{data.map(({ website_id, name }) => (
|
{data.map(({ website_id, name, domain }) => (
|
||||||
<div key={website_id} className={styles.website}>
|
<div key={website_id} className={styles.website}>
|
||||||
<WebsiteChart websiteId={website_id} title={name} showLink />
|
<WebsiteChart websiteId={website_id} title={name} domain={domain} showLink />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{data.length === 0 && (
|
{data.length === 0 && (
|
||||||
|
|
|
@ -13,6 +13,7 @@ import ShareUrlForm from 'components/forms/ShareUrlForm';
|
||||||
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
||||||
import ButtonLayout from 'components/layout/ButtonLayout';
|
import ButtonLayout from 'components/layout/ButtonLayout';
|
||||||
import Toast from 'components/common/Toast';
|
import Toast from 'components/common/Toast';
|
||||||
|
import Favicon from 'components/common/Favicon';
|
||||||
import Pen from 'assets/pen.svg';
|
import Pen from 'assets/pen.svg';
|
||||||
import Trash from 'assets/trash.svg';
|
import Trash from 'assets/trash.svg';
|
||||||
import Plus from 'assets/plus.svg';
|
import Plus from 'assets/plus.svg';
|
||||||
|
@ -60,8 +61,9 @@ export default function WebsiteSettings() {
|
||||||
</ButtonLayout>
|
</ButtonLayout>
|
||||||
);
|
);
|
||||||
|
|
||||||
const DetailsLink = ({ website_id, name }) => (
|
const DetailsLink = ({ website_id, name, domain }) => (
|
||||||
<Link href="/website/[...id]" as={`/website/${website_id}/${name}`}>
|
<Link href="/website/[...id]" as={`/website/${website_id}/${name}`}>
|
||||||
|
<Favicon domain={domain} />
|
||||||
{name}
|
{name}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import firstBy from 'thenby';
|
|
||||||
import { BROWSERS } from './constants';
|
import { BROWSERS } from './constants';
|
||||||
import { removeTrailingSlash, removeWWW, getDomainName } from './url';
|
import { removeTrailingSlash, removeWWW, getDomainName } from './url';
|
||||||
|
|
||||||
|
@ -43,9 +42,7 @@ export const urlFilter = (data, { raw }) => {
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return Object.keys(map)
|
return Object.keys(map).map(key => ({ x: key, y: map[key] }));
|
||||||
.map(key => ({ x: key, y: map[key] }))
|
|
||||||
.sort(firstBy('y', -1).thenBy('x'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const refFilter = (data, { domain, domainOnly, raw }) => {
|
export const refFilter = (data, { domain, domainOnly, raw }) => {
|
||||||
|
@ -70,7 +67,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domainOnly && hostname) {
|
if (domainOnly && hostname) {
|
||||||
return hostname;
|
return removeWWW(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!origin || origin === 'null') {
|
if (!origin || origin === 'null') {
|
||||||
|
@ -113,9 +110,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return Object.keys(map)
|
return Object.keys(map).map(key => ({ x: key, y: map[key], w: links[key] }));
|
||||||
.map(key => ({ x: key, y: map[key], w: links[key] }))
|
|
||||||
.sort(firstBy('y', -1).thenBy('x'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const browserFilter = data =>
|
export const browserFilter = data =>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.96.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const messages = require('../lang/en-US.json');
|
const messages = require('../lang/en-US.json');
|
||||||
const ignore = require('./lang-ignore.json');
|
const ignore = require('../lang-ignore.json');
|
||||||
|
|
||||||
const dir = path.resolve(__dirname, '../lang');
|
const dir = path.resolve(__dirname, '../lang');
|
||||||
const files = fs.readdirSync(dir);
|
const files = fs.readdirSync(dir);
|
||||||
|
@ -13,7 +13,8 @@ files.forEach(file => {
|
||||||
const lang = require(`../lang/${file}`);
|
const lang = require(`../lang/${file}`);
|
||||||
const id = file.replace('.json', '');
|
const id = file.replace('.json', '');
|
||||||
|
|
||||||
console.log(chalk.yellowBright(`\n## ${file}`));
|
console.log(chalk.yellowBright(`\n## ${file.replace('.json', '')}`));
|
||||||
|
let count = 0;
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
const orig = messages[key];
|
const orig = messages[key];
|
||||||
const check = lang[key];
|
const check = lang[key];
|
||||||
|
@ -21,7 +22,12 @@ files.forEach(file => {
|
||||||
|
|
||||||
if (!ignored && (!check || check === orig)) {
|
if (!ignored && (!check || check === orig)) {
|
||||||
console.log(chalk.redBright('*'), chalk.greenBright(`${key}:`), orig);
|
console.log(chalk.redBright('*'), chalk.greenBright(`${key}:`), orig);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (count === 0) {
|
||||||
|
console.log('**👍 Complete!**');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue