|
@@ -0,0 +1,36 @@
|
|
|
+import React, { useState, useEffect } from "react";
|
|
|
+import { UNKNOWN, OK, BAD, FAILED } from "../shared/StatusMessage";
|
|
|
+import Tile from "../shared/Tile";
|
|
|
+
|
|
|
+const update = 1000 * 60 * 20;
|
|
|
+
|
|
|
+export default () => {
|
|
|
+ const [health, setHealth] = useState(UNKNOWN);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const check = async () => {
|
|
|
+ try {
|
|
|
+ const res = await fetch("https://kirkleon.ddns.net/gogs/");
|
|
|
+ if (res.ok) {
|
|
|
+ setHealth(OK);
|
|
|
+ } else {
|
|
|
+ setHealth(BAD);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ setHealth(FAILED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ check();
|
|
|
+
|
|
|
+ const interval = setInterval(check, update);
|
|
|
+
|
|
|
+ return () => clearInterval(interval);
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ return <Tile
|
|
|
+ link="https://kirkleon.ddns.net/gogs/"
|
|
|
+ title="Gogs"
|
|
|
+ health={health}
|
|
|
+ />
|
|
|
+}
|