Skip to content

Commit

Permalink
增加日志天数配置;增加显示链接配置;
Browse files Browse the repository at this point in the history
  • Loading branch information
yb committed Mar 15, 2020
1 parent 9a581f5 commit bb0ad5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
'm784496436-71a4bf7b1e3bdf7756be131b',
],

// 是否显示监测站点的链接
ShowLink: true,

// 日志天数
// 虽然免费版说仅保存60天日志,但测试好像API可以获取90天的
// 不过时间不要设置太长,容易卡,接口请求也容易失败
CountDays: 60,

// 导航栏菜单
Navi: [
{
Expand Down
7 changes: 4 additions & 3 deletions src/components/uptime-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { formatDuration } from '../utils/helper';

const UptimeItem = (props) => {

const { ShowLink, CountDays } = window.Config;
const { monitor } = props;
const initial = monitor.daily[monitor.daily.length - 1].date;
const status = {
Expand All @@ -15,15 +16,15 @@ const UptimeItem = (props) => {
};

const total = monitor.total.times
? `最近 60 天故障 ${monitor.total.times} 次,累计 ${formatDuration(monitor.total.duration)},平均可用率 ${monitor.average}%`
: `最近 60 天可用率 ${monitor.average}%`;
? `最近 ${CountDays} 天故障 ${monitor.total.times} 次,累计 ${formatDuration(monitor.total.duration)},平均可用率 ${monitor.average}%`
: `最近 ${CountDays} 天可用率 ${monitor.average}%`;

return (
<div className="item">
<div className="meta">
<div className="info">
<span className="name">{monitor.name}</span>
<Link className="link" to={monitor.url} text={monitor.name} />
{ShowLink && <Link className="link" to={monitor.url} text={monitor.name} />}
</div>
<div className={`status ${monitor.status}`}>{status[monitor.status]}</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/uptime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { GetMonitors } from '../utils/uptimerobot';

const Uptime = (props) => {

const { CountDays } = window.Config;
const { apikey } = props;
const [ monitors, setMonitors ] = useState(null);

useEffect(() => {
GetMonitors(apikey, 60).then(setMonitors);
GetMonitors(apikey, CountDays).then(setMonitors);
}, [apikey]);

return monitors ? monitors.map(item => (
Expand Down

1 comment on commit bb0ad5e

@vercel
Copy link

@vercel vercel bot commented on bb0ad5e Mar 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.