-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
99 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>食堂</title> | ||
<script src="assets/react.js"></script><!-- <script crossorigin src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> --> | ||
<script src="assets/react-dom.js"></script><!-- <script crossorigin src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> --> | ||
<script src="assets/babel.js"></script><!-- <script src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script> --> | ||
<script src="/assets/react.js"></script><!-- <script crossorigin src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> --> | ||
<script src="/assets/react-dom.js"></script><!-- <script crossorigin src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> --> | ||
<script src="/assets/babel.js"></script><!-- <script src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script> --> | ||
<link rel="stylesheet" href="https://fonts.xz.style/serve/inter.css" /> | ||
<link rel="stylesheet" href="assets/new.css" /><!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/[email protected]/new.min.css"> --> | ||
<link rel="stylesheet" href="/assets/new.css" /><!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/[email protected]/new.min.css"> --> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="text/babel" src="app.jsx"></script> | ||
<script type="text/babel" src="./app.jsx"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const { useEffect, useState } = React | ||
|
||
const timeDiffFmt = (dt, now) => { | ||
const ds = (now - dt) / 1000 | ||
if(ds < 0) return "未来" | ||
|
||
const h = Math.trunc(ds / 3600) | ||
const m = Math.trunc((ds - 3600 * h) / 60) | ||
|
||
const date = new Date(dt) | ||
return `${h}時間と${m}分前 (${date.toLocaleString("ja")})` | ||
} | ||
|
||
const Stats = () => { | ||
const [tab, setTab] = useState([]) | ||
|
||
useEffect(async () => { | ||
const dump = await fetch("/api/dump").then(res => res.json()) | ||
dump.sort((a, b) => b.date - a.date) | ||
setTab(dump) | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<header> | ||
<h1>食堂管理システム - 統計情報</h1> | ||
<a href="/">メインUIに戻る</a> | ||
</header> | ||
<main> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>時刻</th> | ||
<th>学籍番号</th> | ||
{/*<th>イベント</th>*/} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{tab.map(({ code, event, date }, i) => ( | ||
<tr key={i}> | ||
<td>{timeDiffFmt(date, Date.now())}</td> | ||
<td>{code}</td> | ||
{/*<td>{event}</td>*/} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</main> | ||
<footer> | ||
<p | ||
style={{ | ||
marginTop: "4rem", | ||
color: "gray", | ||
fontSize: "1.2em", | ||
fontWeight: "bolder", | ||
textAlign: "center", | ||
}}> | ||
https://github.com/KCCTdensan/syokudou | ||
<br /> | ||
© 2022 神戸高専電算部 | ||
</p> | ||
</footer> | ||
</> | ||
) | ||
} | ||
|
||
ReactDOM.render(<Stats />, document.getElementById("root")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../index.html |