More generic BinnedBytesForHttpStream, changes for status page
This commit is contained in:
@@ -87,7 +87,7 @@ impl<F> UnwindSafe for Cont<F> {}
|
||||
macro_rules! static_http {
|
||||
($path:expr, $tgt:expr, $tgtex:expr) => {
|
||||
if $path == concat!("/api/4/documentation/", $tgt) {
|
||||
let c = include_bytes!(concat!("../static/documentation/", $tgt, $tgtex));
|
||||
let c = include_bytes!(concat!("../static/documentation/", $tgtex));
|
||||
return Ok(response(StatusCode::OK).body(Body::from(&c[..]))?);
|
||||
}
|
||||
};
|
||||
@@ -141,7 +141,9 @@ async fn data_api_proxy_try(req: Request<Body>, node_config: &NodeConfigCached)
|
||||
} else if path.starts_with("/api/4/documentation/") {
|
||||
if req.method() == Method::GET {
|
||||
static_http!(path, "", "index.html");
|
||||
static_http!(path, "page.css");
|
||||
static_http!(path, "style.css");
|
||||
static_http!(path, "script.js");
|
||||
static_http!(path, "status-main.html");
|
||||
Ok(response(StatusCode::NOT_FOUND).body(Body::empty())?)
|
||||
} else {
|
||||
Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Retrieval Documentation</title>
|
||||
<link rel="stylesheet" href="page.css"/>
|
||||
<link rel="shortcut icon" href="about:blank"/>
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Retrieval 4.0 Documentation</h1>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
body {}
|
||||
|
||||
h1 {
|
||||
color: cadetblue;
|
||||
}
|
||||
86
httpret/static/documentation/script.js
Normal file
86
httpret/static/documentation/script.js
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
function load_status_main(ev) {
|
||||
const ts1 = Date.now();
|
||||
const dom_ev = ev;
|
||||
const b = ev.target;
|
||||
b.classList.remove("loaded");
|
||||
b.classList.add("loading");
|
||||
b.value = b.dataset.btnLabel + "";
|
||||
const query = {
|
||||
hosts: "",
|
||||
};
|
||||
const fetch_init = {
|
||||
method: "get",
|
||||
/*headers: {
|
||||
retrieval_instance: document.getElementById("retrieval_instance").value,
|
||||
},
|
||||
body: JSON.stringify(query),*/
|
||||
};
|
||||
fetch(g_config.api_base + "node_status", fetch_init)
|
||||
.then(x => Promise.all([x.json(), Date.now()]))
|
||||
.then(g_config.ui_delay_test)
|
||||
.then(g_config.ui_delay_blink)
|
||||
.then(kk => {
|
||||
const js = kk[0];
|
||||
const ts2 = kk[1];
|
||||
if (false) {
|
||||
const response = document.getElementById("response");
|
||||
// Different ways to do the same thing:
|
||||
//response.querySelectorAll("*").forEach(n => n.remove());
|
||||
//response.innerHTML = "";
|
||||
response.textContent = "";
|
||||
while (response.firstChild) {
|
||||
response.removeChild(response.lastChild);
|
||||
response.lastChild.remove();
|
||||
}
|
||||
response.replaceChildren();
|
||||
//response.replaceChild();
|
||||
//JSON.stringify(js, null, 2);
|
||||
//for (let machine of js) {
|
||||
// console.log(typeof(machine));
|
||||
//}
|
||||
const dat2 = js.hosts;
|
||||
sort_default(dat2);
|
||||
response.appendChild(render_retrieval_metrics_as_table(dat2));
|
||||
response.appendChild(render_host_memory_as_table(dat2));
|
||||
//response.appendChild(render_host_memStd_as_table(dat2));
|
||||
response.appendChild(render_host_bufferPools_as_table(dat2));
|
||||
}
|
||||
{
|
||||
let b = document.getElementById("load_status");
|
||||
b.innerHTML = "Loaded (" + (ts2 - ts1) + " ms)";
|
||||
}
|
||||
{
|
||||
let b = dom_ev.target;
|
||||
b.classList.remove("loading");
|
||||
b.classList.add("loaded");
|
||||
b.setAttribute("value", b.dataset.btnLabel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var g_config = {
|
||||
api_base: "http://localhost:8059/api/4/",
|
||||
ui_delay_test: x => x,
|
||||
ui_delay_blink: x => new Promise(resolve => setTimeout(() => resolve(x), 50)),
|
||||
//ui_delay_blink: x => x,
|
||||
};
|
||||
|
||||
function config_for_test() {
|
||||
g_config.api_base = "http://localhost:8059/api/4/";
|
||||
}
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
window.addEventListener("load", ev => {
|
||||
if (document.location.href.includes("8060")) {
|
||||
config_for_test();
|
||||
}
|
||||
init();
|
||||
const init_load_ele = document.getElementById("btn_load");
|
||||
if (init_load_ele != null) {
|
||||
init_load_ele.click();
|
||||
}
|
||||
});
|
||||
21
httpret/static/documentation/status-main.html
Normal file
21
httpret/static/documentation/status-main.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Main Status</title>
|
||||
<link rel="shortcut icon" href="about:blank"/>
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>daqbuffer - Main Status</h1>
|
||||
|
||||
<p class="buttonrow">
|
||||
<input type="button" id="btn_load" data-btn-label="Reload Overview" value="Reload" onclick="load_status_main(event)"/>
|
||||
<input id="retrieval_instance" type="text" value="main">
|
||||
</p>
|
||||
|
||||
<p id="load_status"></p>
|
||||
<div id="response" class="prejson"></div>
|
||||
</body>
|
||||
</html>
|
||||
109
httpret/static/documentation/style.css
Normal file
109
httpret/static/documentation/style.css
Normal file
@@ -0,0 +1,109 @@
|
||||
div, h1, h2, h3, h4, h5, pre, code, p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
margin-top: 1.2em;
|
||||
margin-bottom: 0.6em;
|
||||
}
|
||||
|
||||
input {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0.7em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0.4em;
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: monospace;
|
||||
font-size: 80%;
|
||||
line-height: 1.4;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0 1em 0 1em;
|
||||
margin: 0 0em 0 0em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
input[type=button] {
|
||||
background-color: #e7e7e7;
|
||||
border-style: solid;
|
||||
border-radius: 6px;
|
||||
border-color: #e0e0e0;
|
||||
border-width: 2px;
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
padding: 5px 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type=button] {
|
||||
margin-top: 1.4em;
|
||||
}
|
||||
|
||||
input[type=button].loading {
|
||||
background-color: #e7d0d0;
|
||||
}
|
||||
|
||||
input[type=button].loaded {
|
||||
border-color: #c0e7c0;
|
||||
}
|
||||
|
||||
input[type=button].run_example_button {
|
||||
border-color: #b0e7b0;
|
||||
}
|
||||
|
||||
input[type=button].running {
|
||||
border-color: #e7b0b0;
|
||||
}
|
||||
|
||||
code#output {
|
||||
display: block;
|
||||
min-height: 20em;
|
||||
}
|
||||
|
||||
p#load_status {
|
||||
margin-top: 10em;
|
||||
}
|
||||
|
||||
p.buttonrow {
|
||||
position: fixed;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
div#footer {
|
||||
width: 2em;
|
||||
height: 6em;
|
||||
}
|
||||
|
||||
.prejson {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.bytesTB {
|
||||
color: #8b1f8e;
|
||||
}
|
||||
|
||||
.bytesGB {
|
||||
color: #952300;
|
||||
}
|
||||
|
||||
.bytesMB {
|
||||
--ccolor: #255111;
|
||||
color: #12697d;
|
||||
}
|
||||
|
||||
.highlight_error {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
Reference in New Issue
Block a user