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
build
Status v1.0.rar
Status v1.1.rar
releases
.vs

View File

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

View File

@ -1,9 +1,8 @@
window.Config = {
// Menu-bar Name
SiteName: 'HLP Status',
SiteName: 'Hosting Status',
// UptimeRobot Api Keys
// Monitor-Specific Read-Only
ApiKeys: [
'm793883641-2edcb5af15f7045abf2c2d24',
'm793883641-2edcb5af15f7045abf2c2d24',
@ -25,15 +24,18 @@ window.Config = {
Navi: [
{
text: 'Homepage',
url: 'https://status.org.cn/'
url: 'https://status.org.cn/',
target: '_self'
},
{
text: 'GitHub',
url: 'https://github.com/yb/uptime-status'
url: 'https://github.com/yb/uptime-status',
target: '_blank'
},
{
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"
/>
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title>HLP Status</title>
<title>Hosting Status</title>
<script src="./config.js"></script>
</head>
<body>

View File

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

View File

@ -23,7 +23,7 @@ function App() {
))}
</div>
<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>
</>

View File

@ -13,7 +13,7 @@ function Header() {
<h1 className='logo'>{window.Config.SiteName}</h1>
<div className='navi'>
{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>

View File

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

View File

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

View File

@ -5,8 +5,3 @@ import './app.scss';
const root = ReactDOM.createRoot(document.getElementById('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();