Skip to content

Commit

Permalink
Updated log display.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Oct 14, 2020
1 parent d78f8ed commit 894736d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.DS_Store
.idea
*.iml
*.log
.vscode/*

# debug
Expand Down
1 change: 1 addition & 0 deletions components/common/NoData.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.container {
color: var(--gray500);
font-size: var(--font-size-normal);
position: absolute;
top: 50%;
left: 50%;
Expand Down
12 changes: 8 additions & 4 deletions components/metrics/RealtimeLog.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useMemo, useState } from 'react';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, useIntl } from 'react-intl';
import { FixedSizeList } from 'react-window';
import firstBy from 'thenby';
import { format } from 'date-fns';
import Icon from 'components/common/Icon';
import Tag from 'components/common/Tag';
import Dot from 'components/common/Dot';
import FilterButtons from 'components/common/FilterButtons';
import { devices } from 'components/messages';
import useLocale from 'hooks/useLocale';
import useCountryNames from 'hooks/useCountryNames';
import { BROWSERS } from 'lib/constants';
Expand All @@ -15,6 +16,7 @@ import Visitor from 'assets/visitor.svg';
import Eye from 'assets/eye.svg';
import { stringToColor } from 'lib/format';
import styles from './RealtimeLog.module.css';
import NoData from '../common/NoData';

const TYPE_ALL = 0;
const TYPE_PAGEVIEW = 1;
Expand All @@ -28,6 +30,7 @@ const TYPE_ICONS = {
};

export default function RealtimeLog({ data, websites }) {
const intl = useIntl();
const [locale] = useLocale();
const countryNames = useCountryNames(locale);
const [filter, setFilter] = useState(TYPE_ALL);
Expand Down Expand Up @@ -116,9 +119,9 @@ export default function RealtimeLog({ data, websites }) {
defaultMessage="Visitor from {country} using {browser} on {os} {device}"
values={{
country: <b>{countryNames[country]}</b>,
browser: BROWSERS[browser],
os,
device,
browser: <b>{BROWSERS[browser]}</b>,
os: <b>{os}</b>,
device: <b>{intl.formatMessage(devices[device])?.toLowerCase()}</b>,
}}
/>
);
Expand Down Expand Up @@ -159,6 +162,7 @@ export default function RealtimeLog({ data, websites }) {
<FormattedMessage id="label.realtime-logs" defaultMessage="Realtime logs" />
</div>
<div className={styles.body}>
{logs?.length === 0 && <NoData />}
<FixedSizeList height={400} itemCount={logs.length} itemSize={40}>
{Row}
</FixedSizeList>
Expand Down
6 changes: 6 additions & 0 deletions scripts/check-lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ files.forEach(file => {
const id = file.replace('.json', '');

console.log(chalk.yellowBright(`\n## ${file}`));
let count = 0;
keys.forEach(key => {
const orig = messages[key];
const check = lang[key];
const ignored = ignore[id]?.includes(key);

if (!ignored && (!check || check === orig)) {
console.log(chalk.redBright('*'), chalk.greenBright(`${key}:`), orig);
count++;
}
});

if (count === 0) {
console.log('**👍 Complete!**');
}
}
});
6 changes: 2 additions & 4 deletions scripts/lang-ignore.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"de-DE": [
"label.administrator",
"label.domain",
"label.name",
"metrics.device.desktop",
"metrics.device.laptop",
"metrics.device.tablet",
"metrics.referrers"
],
"fr-FR": [
"metrics.actions",
"metrics.pages"
]
"fr-FR": ["metrics.actions", "metrics.pages"]
}

0 comments on commit 894736d

Please sign in to comment.