add health check page

This commit is contained in:
AJ ONeal 2020-09-30 02:14:33 -06:00
parent 669adc65ba
commit f5174a124c
3 changed files with 143 additions and 1 deletions

View File

@ -1 +1,82 @@
Hello, World! <!DOCTYPE htmtl>
<html>
<head>
<meta charset="UTF-8" />
<title>Example</title>
<link
rel="stylesheet"
href="./vendor/css/bootswatch.com/4/materia/bootstrap.min.css"
/>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#">Example</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarColor01"
aria-controls="navbarColor01"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#nav-foobar">Foobar</a>
</li>
</ul>
<form class="js-signin form-inline my-2 my-lg-0">
<input
class="form-control mr-sm-2"
type="email"
name="email"
placeholder="email"
/>
<button
class="btn btn-secondary my-2 my-sm-0"
type="submit"
>
Sign in
</button>
</form>
</div>
</nav>
<div class="container">
<div class="row">
<div class="pocket"></div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="card border-primary mb-6">
<a id="nav-foobar"
><h3 class="card-header">
Server Health
<form class="js-healthcheck">
<button
type="submit"
class="float-right btn btn-primary"
>
Check
</button>
</form>
</h3></a
>
<div class="card-body">
<h5 class="card-title">Check Server Status</h5>
<div class="card-text">
<pre><code>curl https://example.com/api/public/status</code></pre>
<pre><code class="js-server-health">-</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://mock.pocketid.app/pocket/consumer.js"></script>
<script src="./js/app.js"></script>
</body>
</html>

49
public/js/app.js Normal file
View File

@ -0,0 +1,49 @@
(function () {
"use strict";
// AJQuery
function $(sel, el) {
if (!el) {
el = document;
}
return el.querySelector(sel);
}
function $$(sel, el) {
if (!el) {
el = document;
}
return el.querySelectorAll(sel);
}
function displayToken(token) {
$$(".js-token").forEach(function (el) {
el.innerText = token;
});
}
Pocket.onToken(function (token) {
// TODO Pocket v1.0 will make this obsolete
localStorage.setItem("pocket-token", token);
displayToken();
});
displayToken(localStorage.getItem("pocket-token"));
// requires div with class 'pocket'
$("form.js-signin").addEventListener("submit", function (ev) {
ev.preventDefault();
ev.stopPropagation();
var email = $("[name=email]").value;
Pocket.openSignin(ev, { email: email });
});
$("form.js-healthcheck").addEventListener("submit", function (ev) {
ev.preventDefault();
ev.stopPropagation();
window.fetch("/api/public/status").then(async function (resp) {
var res = await resp.json();
$(".js-server-health").innerText = JSON.stringify(res, null, 2);
});
});
})();

File diff suppressed because one or more lines are too long