Add links to referrer urls.

This commit is contained in:
Mike Cao 2020-08-23 00:23:47 -07:00
parent 7c0e0dd8c4
commit e7f83c084e
4 changed files with 25 additions and 3 deletions

View File

@ -23,6 +23,7 @@ export default function MetricsTable({
headerComponent, headerComponent,
onDataLoad = () => {}, onDataLoad = () => {},
onExpand = () => {}, onExpand = () => {},
labelRenderer = e => e,
}) { }) {
const [data, setData] = useState(); const [data, setData] = useState();
const [format, setFormat] = useState(true); const [format, setFormat] = useState(true);
@ -65,6 +66,7 @@ export default function MetricsTable({
animate={shouldAnimate} animate={shouldAnimate}
format={formatFunc} format={formatFunc}
onClick={handleSetFormat} onClick={handleSetFormat}
labelRenderer={labelRenderer}
/> />
); );
} }
@ -113,7 +115,7 @@ export default function MetricsTable({
); );
} }
const AnimatedRow = ({ label, value = 0, percent, animate, format, onClick }) => { const AnimatedRow = ({ label, value = 0, percent, animate, format, onClick, labelRenderer }) => {
const props = useSpring({ const props = useSpring({
width: percent, width: percent,
y: value, y: value,
@ -123,7 +125,7 @@ const AnimatedRow = ({ label, value = 0, percent, animate, format, onClick }) =>
return ( return (
<div className={styles.row}> <div className={styles.row}>
<div className={styles.label}>{decodeURI(label)}</div> <div className={styles.label}>{labelRenderer(decodeURI(label))}</div>
<div className={styles.value} onClick={onClick}> <div className={styles.value} onClick={onClick}>
<animated.div className={styles.value}>{props.y?.interpolate(format)}</animated.div> <animated.div className={styles.value}>{props.y?.interpolate(format)}</animated.div>
</div> </div>

View File

@ -45,6 +45,15 @@
flex: 2; flex: 2;
} }
.label a {
color: inherit;
text-decoration: none;
}
.label a:hover {
color: var(--primary400);
}
.label:empty { .label:empty {
color: #b3b3b3; color: #b3b3b3;
} }

View File

@ -13,6 +13,16 @@ export default function Referrers({
}) { }) {
const [filter, setFilter] = useState('Combined'); const [filter, setFilter] = useState('Combined');
const renderLink = url => {
return url.startsWith('http') ? (
<a href={url} target="_blank" rel="noreferrer">
{url}
</a>
) : (
url
);
};
return ( return (
<MetricsTable <MetricsTable
title="Referrers" title="Referrers"
@ -30,6 +40,7 @@ export default function Referrers({
raw: filter === 'Raw', raw: filter === 'Raw',
}} }}
onExpand={onExpand} onExpand={onExpand}
labelRenderer={renderLink}
/> />
); );
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "umami", "name": "umami",
"version": "0.16.0", "version": "0.16.1",
"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",