pull/47/head
Ilya 2023-03-12 15:36:09 +02:00
parent d617892029
commit 3115d8a324
11 changed files with 31 additions and 28 deletions

4
.gitignore vendored
View File

@ -1,4 +1,4 @@
node_modules node_modules
build build
Status v1.0.rar releases
Status v1.1.rar .vs

View File

@ -4,7 +4,8 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build" "build": "react-scripts build",
"test": "node test.js"
}, },
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",

View File

@ -1,9 +1,8 @@
window.Config = { window.Config = {
// Menu-bar Name // Menu-bar Name
SiteName: 'HLP Status', SiteName: 'Hosting Status',
// UptimeRobot Api Keys // UptimeRobot Api Keys
// Monitor-Specific Read-Only
ApiKeys: [ ApiKeys: [
'm793883641-2edcb5af15f7045abf2c2d24', 'm793883641-2edcb5af15f7045abf2c2d24',
'm793883641-2edcb5af15f7045abf2c2d24', 'm793883641-2edcb5af15f7045abf2c2d24',
@ -25,15 +24,18 @@ window.Config = {
Navi: [ Navi: [
{ {
text: 'Homepage', text: 'Homepage',
url: 'https://status.org.cn/' url: 'https://status.org.cn/',
target: '_self'
}, },
{ {
text: 'GitHub', text: 'GitHub',
url: 'https://github.com/yb/uptime-status' url: 'https://github.com/yb/uptime-status',
target: '_blank'
}, },
{ {
text: 'Blog', text: 'Blog',
url: 'https://abo.xyz/' url: 'https://abo.xyz/',
target: '_self'
}, },
], ],
}; };

View File

@ -7,7 +7,7 @@
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/> />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title>HLP Status</title> <title>Hosting Status</title>
<script src="./config.js"></script> <script src="./config.js"></script>
</head> </head>
<body> <body>

View File

@ -14,8 +14,8 @@ export function formatDuration(seconds) {
m = parseInt(m % 60); m = parseInt(m % 60);
} }
} }
let text = `${s} s`; let text = `${s}s`;
if (m > 0) text = `${m} m ${text}`; if (m > 0) text = `${m}m ${text}`;
if (h > 0) text = `${h} h ${text}`; if (h > 0) text = `${h}h ${text}`;
return text; return text;
} }

View File

@ -23,7 +23,7 @@ function App() {
))} ))}
</div> </div>
<div id='footer'> <div id='footer'>
<p>2023 - <Link to='https://hostlike.pro/' text='HostLikePro' /> - hosting provider.</p> <p>2023 - <Link to='https://hostlike.pro/' text='HostLikePro' /> - hosting provider</p>
</div> </div>
</div> </div>
</> </>

View File

@ -13,7 +13,7 @@ function Header() {
<h1 className='logo'>{window.Config.SiteName}</h1> <h1 className='logo'>{window.Config.SiteName}</h1>
<div className='navi'> <div className='navi'>
{window.Config.Navi.map((item, index) => ( {window.Config.Navi.map((item, index) => (
<Link key={index} to={item.url} text={item.text} /> <Link key={index} to={item.url} tar={item.target} text={item.text} />
))} ))}
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
function Link(props = { text, to }) { function Link(props = { text, to, tar }) {
return ( return (
<a {...props} href={props.to}> <a {...props} href={props.to} target={props.tar}>
{props.text} {props.text}
</a> </a>
); );

View File

@ -1,4 +1,4 @@
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { GetMonitors } from '../common/uptimerobot'; import { GetMonitors } from '../common/uptimerobot';
import { formatDuration, formatNumber } from '../common/helper'; import { formatDuration, formatNumber } from '../common/helper';
@ -7,8 +7,8 @@ import Link from './link';
function UptimeRobot({ apikey }) { function UptimeRobot({ apikey }) {
const status = { const status = {
ok: 'Ok', ok: 'Online',
down: 'Down', down: 'Offline',
unknow: 'Unknown' unknow: 'Unknown'
}; };
@ -33,7 +33,7 @@ function UptimeRobot({ apikey }) {
let text = data.date.format('YYYY-MM-DD '); let text = data.date.format('YYYY-MM-DD ');
if (data.uptime >= 100) { if (data.uptime >= 100) {
status = 'ok'; status = 'ok';
text += `Uptime ${formatNumber(data.uptime)}%`; text += `| Uptime: ${formatNumber(data.uptime)}%`;
} }
else if (data.uptime <= 0 && data.down.times === 0) { else if (data.uptime <= 0 && data.down.times === 0) {
status = 'none'; status = 'none';
@ -41,7 +41,7 @@ function UptimeRobot({ apikey }) {
} }
else { else {
status = 'down'; status = 'down';
text += `Times Down ${data.down.times} Duration ${formatDuration(data.down.duration)}Uptime ${formatNumber(data.uptime)}%`; text += `| Times Down: ${data.down.times}Duration: ${formatDuration(data.down.duration)}Uptime: ${formatNumber(data.uptime)}%`;
} }
return (<i key={index} className={status} data-tip={text} />) return (<i key={index} className={status} data-tip={text} />)
})} })}
@ -50,8 +50,8 @@ function UptimeRobot({ apikey }) {
<span>Today</span> <span>Today</span>
<span> <span>
{site.total.times {site.total.times
? `Days ${CountDays} Times ${site.total.times} Duration ${formatDuration(site.total.duration)}Uptime ${site.average}%` ? `Times down: ${site.total.times}Duration: ${formatDuration(site.total.duration)}Uptime: ${site.average}%`
: `Days ${CountDays} Uptime ${site.average}%`} : `Uptime: ${site.average}%`}
</span> </span>
<span>{site.daily[site.daily.length - 1].date.format('YYYY-MM-DD')}</span> <span>{site.daily[site.daily.length - 1].date.format('YYYY-MM-DD')}</span>
</div> </div>

View File

@ -5,8 +5,3 @@ import './app.scss';
const root = ReactDOM.createRoot(document.getElementById('app')); const root = ReactDOM.createRoot(document.getElementById('app'));
root.render(<App />); root.render(<App />);
// root.render(
// <React.StrictMode>
// <App />
// </React.StrictMode>
// );

5
test.js Normal file
View File

@ -0,0 +1,5 @@
function main() {
return 'Hello, World!';
}
main();