1
0
mirror of https://github.com/kremalicious/umami.git synced 2025-02-14 21:10:34 +01:00

Merge remote-tracking branch 'origin/dev'

This commit is contained in:
Mike Cao 2023-04-23 19:55:35 -07:00
commit 26a9cb67d8
263 changed files with 41 additions and 20 deletions

View File

@ -6,14 +6,15 @@ import usePageQuery from 'hooks/usePageQuery';
import useMessages from 'hooks/useMessages'; import useMessages from 'hooks/useMessages';
import styles from './FilterLink.module.css'; import styles from './FilterLink.module.css';
export function FilterLink({ id, value, label, externalUrl }) { export function FilterLink({ id, value, label, externalUrl, children, className }) {
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
const { resolveUrl, query } = usePageQuery(); const { resolveUrl, query } = usePageQuery();
const active = query[id] !== undefined; const active = query[id] !== undefined;
const selected = query[id] === value; const selected = query[id] === value;
return ( return (
<div className={styles.row}> <div className={classNames(styles.row, className)}>
{children}
{!value && `(${label || formatMessage(labels.unknown)})`} {!value && `(${label || formatMessage(labels.unknown)})`}
{value && ( {value && (
<Link <Link

View File

@ -1,6 +1,7 @@
.row { .row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px;
} }
.row .inactive { .row .inactive {

View File

@ -11,9 +11,14 @@ export function CountriesTable({ websiteId, ...props }) {
function renderLink({ x: code }) { function renderLink({ x: code }) {
return ( return (
<div className={locale}> <FilterLink
<FilterLink id="country" value={countryNames[code] && code} label={countryNames[code]} /> id="country"
</div> className={locale}
value={countryNames[code] && code}
label={countryNames[code]}
>
<img src={`/images/flags/${code.toLowerCase()}.png`} alt={code} />
</FilterLink>
); );
} }

View File

@ -15,11 +15,11 @@ export function RegionsTable({ websiteId, ...props }) {
return regions[x] ? `${regions[x]}, ${countryNames[x.split('-')[0]]}` : x; return regions[x] ? `${regions[x]}, ${countryNames[x.split('-')[0]]}` : x;
}; };
const renderLink = ({ x }) => { const renderLink = ({ x: code }) => {
return ( return (
<div className={locale}> <FilterLink id="region" className={locale} value={code} label={renderLabel(code)}>
<FilterLink id="region" value={x} label={renderLabel(x)} /> <img src={`/images/flags/${code.split('-')[0].toLowerCase()}.png`} alt={code} />
</div> </FilterLink>
); );
}; };

View File

@ -20,14 +20,19 @@ export const useCors = createMiddleware(
); );
export const useSession = createMiddleware(async (req, res, next) => { export const useSession = createMiddleware(async (req, res, next) => {
const session = await findSession(req as NextApiRequestCollect); try {
const session = await findSession(req as NextApiRequestCollect);
if (!session) { if (!session) {
log('useSession: Session not found'); log('useSession: Session not found');
return badRequest(res, 'Session not found.'); return badRequest(res, 'Session not found.');
}
(req as any).session = session;
} catch (e: any) {
return badRequest(res, e.message);
} }
(req as any).session = session;
next(); next();
}); });

View File

@ -11,7 +11,7 @@ export async function findSession(req: NextApiRequestCollect) {
const { payload } = getJsonBody<CollectRequestBody>(req); const { payload } = getJsonBody<CollectRequestBody>(req);
if (!payload) { if (!payload) {
return null; throw new Error('Invalid payload.');
} }
// Check if cache token is passed // Check if cache token is passed
@ -29,14 +29,14 @@ export async function findSession(req: NextApiRequestCollect) {
const { website: websiteId, hostname, screen, language } = payload; const { website: websiteId, hostname, screen, language } = payload;
if (!validate(websiteId)) { if (!validate(websiteId)) {
return null; throw new Error('Invalid website ID.');
} }
// Find website // Find website
const website = await loadWebsite(websiteId); const website = await loadWebsite(websiteId);
if (!website) { if (!website) {
throw new Error(`Website not found: ${websiteId}`); throw new Error(`Website not found: ${websiteId}.`);
} }
const { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device } = const { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device } =

View File

@ -32,7 +32,7 @@
"merge-messages": "node scripts/merge-messages.js", "merge-messages": "node scripts/merge-messages.js",
"generate-lang": "npm-run-all extract-messages merge-messages", "generate-lang": "npm-run-all extract-messages merge-messages",
"format-lang": "node scripts/format-lang.js", "format-lang": "node scripts/format-lang.js",
"compile-lang": "formatjs compile-folder --ast build public/intl/messages", "compile-lang": "formatjs compile-folder --ast build/messages public/intl/messages",
"check-lang": "node scripts/check-lang.js", "check-lang": "node scripts/check-lang.js",
"download-country-names": "node scripts/download-country-names.js", "download-country-names": "node scripts/download-country-names.js",
"download-language-names": "node scripts/download-language-names.js", "download-language-names": "node scripts/download-language-names.js",

BIN
public/images/flags/ad.png Normal file

Binary file not shown.

After

(image error) Size: 235 B

BIN
public/images/flags/ae.png Normal file

Binary file not shown.

After

(image error) Size: 122 B

BIN
public/images/flags/af.png Normal file

Binary file not shown.

After

(image error) Size: 296 B

BIN
public/images/flags/ag.png Normal file

Binary file not shown.

After

(image error) Size: 281 B

BIN
public/images/flags/ai.png Normal file

Binary file not shown.

After

(image error) Size: 245 B

BIN
public/images/flags/al.png Normal file

Binary file not shown.

After

(image error) Size: 183 B

BIN
public/images/flags/am.png Normal file

Binary file not shown.

After

(image error) Size: 110 B

BIN
public/images/flags/ao.png Normal file

Binary file not shown.

After

(image error) Size: 201 B

BIN
public/images/flags/aq.png Normal file

Binary file not shown.

After

(image error) Size: 186 B

BIN
public/images/flags/ar.png Normal file

Binary file not shown.

After

(image error) Size: 141 B

BIN
public/images/flags/as.png Normal file

Binary file not shown.

After

(image error) Size: 237 B

BIN
public/images/flags/at.png Normal file

Binary file not shown.

After

(image error) Size: 102 B

BIN
public/images/flags/au.png Normal file

Binary file not shown.

After

(image error) Size: 211 B

BIN
public/images/flags/aw.png Normal file

Binary file not shown.

After

(image error) Size: 139 B

BIN
public/images/flags/ax.png Normal file

Binary file not shown.

After

(image error) Size: 163 B

BIN
public/images/flags/az.png Normal file

Binary file not shown.

After

(image error) Size: 150 B

BIN
public/images/flags/ba.png Normal file

Binary file not shown.

After

(image error) Size: 175 B

BIN
public/images/flags/bb.png Normal file

Binary file not shown.

After

(image error) Size: 149 B

BIN
public/images/flags/bd.png Normal file

Binary file not shown.

After

(image error) Size: 129 B

BIN
public/images/flags/be.png Normal file

Binary file not shown.

After

(image error) Size: 105 B

BIN
public/images/flags/bf.png Normal file

Binary file not shown.

After

(image error) Size: 140 B

BIN
public/images/flags/bg.png Normal file

Binary file not shown.

After

(image error) Size: 97 B

BIN
public/images/flags/bh.png Normal file

Binary file not shown.

After

(image error) Size: 153 B

BIN
public/images/flags/bi.png Normal file

Binary file not shown.

After

(image error) Size: 264 B

BIN
public/images/flags/bj.png Normal file

Binary file not shown.

After

(image error) Size: 107 B

BIN
public/images/flags/bl.png Normal file

Binary file not shown.

After

(image error) Size: 353 B

BIN
public/images/flags/bm.png Normal file

Binary file not shown.

After

(image error) Size: 286 B

BIN
public/images/flags/bn.png Normal file

Binary file not shown.

After

(image error) Size: 350 B

BIN
public/images/flags/bo.png Normal file

Binary file not shown.

After

(image error) Size: 145 B

BIN
public/images/flags/bq.png Normal file

Binary file not shown.

After

(image error) Size: 321 B

BIN
public/images/flags/br.png Normal file

Binary file not shown.

After

(image error) Size: 260 B

BIN
public/images/flags/bs.png Normal file

Binary file not shown.

After

(image error) Size: 147 B

BIN
public/images/flags/bt.png Normal file

Binary file not shown.

After

(image error) Size: 316 B

BIN
public/images/flags/bv.png Normal file

Binary file not shown.

After

(image error) Size: 150 B

BIN
public/images/flags/bw.png Normal file

Binary file not shown.

After

(image error) Size: 114 B

BIN
public/images/flags/by.png Normal file

Binary file not shown.

After

(image error) Size: 145 B

BIN
public/images/flags/bz.png Normal file

Binary file not shown.

After

(image error) Size: 253 B

BIN
public/images/flags/ca.png Normal file

Binary file not shown.

After

(image error) Size: 171 B

BIN
public/images/flags/cc.png Normal file

Binary file not shown.

After

(image error) Size: 211 B

BIN
public/images/flags/cd.png Normal file

Binary file not shown.

After

(image error) Size: 233 B

BIN
public/images/flags/cf.png Normal file

Binary file not shown.

After

(image error) Size: 206 B

BIN
public/images/flags/cg.png Normal file

Binary file not shown.

After

(image error) Size: 164 B

BIN
public/images/flags/ch.png Normal file

Binary file not shown.

After

(image error) Size: 129 B

BIN
public/images/flags/ci.png Normal file

Binary file not shown.

After

(image error) Size: 114 B

BIN
public/images/flags/ck.png Normal file

Binary file not shown.

After

(image error) Size: 230 B

BIN
public/images/flags/cl.png Normal file

Binary file not shown.

After

(image error) Size: 144 B

BIN
public/images/flags/cm.png Normal file

Binary file not shown.

After

(image error) Size: 135 B

BIN
public/images/flags/cn.png Normal file

Binary file not shown.

After

(image error) Size: 144 B

BIN
public/images/flags/co.png Normal file

Binary file not shown.

After

(image error) Size: 112 B

BIN
public/images/flags/cr.png Normal file

Binary file not shown.

After

(image error) Size: 142 B

BIN
public/images/flags/cu.png Normal file

Binary file not shown.

After

(image error) Size: 163 B

BIN
public/images/flags/cv.png Normal file

Binary file not shown.

After

(image error) Size: 146 B

BIN
public/images/flags/cw.png Normal file

Binary file not shown.

After

(image error) Size: 154 B

BIN
public/images/flags/cx.png Normal file

Binary file not shown.

After

(image error) Size: 240 B

BIN
public/images/flags/cy.png Normal file

Binary file not shown.

After

(image error) Size: 196 B

BIN
public/images/flags/cz.png Normal file

Binary file not shown.

After

(image error) Size: 196 B

BIN
public/images/flags/de.png Normal file

Binary file not shown.

After

(image error) Size: 97 B

BIN
public/images/flags/dj.png Normal file

Binary file not shown.

After

(image error) Size: 234 B

BIN
public/images/flags/dk.png Normal file

Binary file not shown.

After

(image error) Size: 127 B

BIN
public/images/flags/dm.png Normal file

Binary file not shown.

After

(image error) Size: 200 B

BIN
public/images/flags/do.png Normal file

Binary file not shown.

After

(image error) Size: 164 B

BIN
public/images/flags/dz.png Normal file

Binary file not shown.

After

(image error) Size: 160 B

BIN
public/images/flags/ec.png Normal file

Binary file not shown.

After

(image error) Size: 237 B

BIN
public/images/flags/ee.png Normal file

Binary file not shown.

After

(image error) Size: 117 B

BIN
public/images/flags/eg.png Normal file

Binary file not shown.

After

(image error) Size: 160 B

BIN
public/images/flags/eh.png Normal file

Binary file not shown.

After

(image error) Size: 230 B

BIN
public/images/flags/er.png Normal file

Binary file not shown.

After

(image error) Size: 204 B

BIN
public/images/flags/es.png Normal file

Binary file not shown.

After

(image error) Size: 190 B

BIN
public/images/flags/et.png Normal file

Binary file not shown.

After

(image error) Size: 215 B

BIN
public/images/flags/fi.png Normal file

Binary file not shown.

After

(image error) Size: 121 B

BIN
public/images/flags/fj.png Normal file

Binary file not shown.

After

(image error) Size: 257 B

BIN
public/images/flags/fk.png Normal file

Binary file not shown.

After

(image error) Size: 285 B

BIN
public/images/flags/fm.png Normal file

Binary file not shown.

After

(image error) Size: 156 B

BIN
public/images/flags/fo.png Normal file

Binary file not shown.

After

(image error) Size: 147 B

BIN
public/images/flags/fr.png Normal file

Binary file not shown.

After

(image error) Size: 105 B

BIN
public/images/flags/ga.png Normal file

Binary file not shown.

After

(image error) Size: 98 B

Binary file not shown.

After

(image error) Size: 119 B

Binary file not shown.

After

(image error) Size: 169 B

Binary file not shown.

After

(image error) Size: 190 B

Binary file not shown.

After

(image error) Size: 420 B

BIN
public/images/flags/gb.png Normal file

Binary file not shown.

After

(image error) Size: 196 B

BIN
public/images/flags/gd.png Normal file

Binary file not shown.

After

(image error) Size: 228 B

BIN
public/images/flags/ge.png Normal file

Binary file not shown.

After

(image error) Size: 179 B

BIN
public/images/flags/gf.png Normal file

Binary file not shown.

After

(image error) Size: 232 B

BIN
public/images/flags/gg.png Normal file

Binary file not shown.

After

(image error) Size: 154 B

BIN
public/images/flags/gh.png Normal file

Binary file not shown.

After

(image error) Size: 155 B

BIN
public/images/flags/gi.png Normal file

Binary file not shown.

After

(image error) Size: 223 B

BIN
public/images/flags/gl.png Normal file

Binary file not shown.

After

(image error) Size: 190 B

BIN
public/images/flags/gm.png Normal file

Binary file not shown.

After

(image error) Size: 119 B

BIN
public/images/flags/gn.png Normal file

Binary file not shown.

After

(image error) Size: 113 B

BIN
public/images/flags/gp.png Normal file

Binary file not shown.

After

(image error) Size: 299 B

BIN
public/images/flags/gq.png Normal file

Binary file not shown.

After

(image error) Size: 244 B

BIN
public/images/flags/gr.png Normal file

Binary file not shown.

After

(image error) Size: 158 B

Some files were not shown because too many files have changed in this diff Show More