Relative CLI datetime, cache clear api, work on cache read
This commit is contained in:
@@ -24,29 +24,6 @@ function load_status_main(ev) {
|
||||
.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)";
|
||||
@@ -60,7 +37,78 @@ function load_status_main(ev) {
|
||||
});
|
||||
}
|
||||
|
||||
var g_config = {
|
||||
function clear_element() {
|
||||
// different methods:
|
||||
response.querySelectorAll("*").forEach(n => n.remove());
|
||||
response.innerHTML = "";
|
||||
response.replaceChildren();
|
||||
response.replaceChild();
|
||||
}
|
||||
|
||||
function sort_default(hosts) {
|
||||
hosts.sort((a, b) => {
|
||||
if (a.inst < b.inst) return -1;
|
||||
if (a.inst > b.inst) return +1;
|
||||
if (a.host < b.host) return -1;
|
||||
if (a.host > b.host) return +1;
|
||||
});
|
||||
}
|
||||
|
||||
function show_json_response(js) {
|
||||
const response = document.getElementById("response");
|
||||
response.textContent = "";
|
||||
while (response.firstChild) {
|
||||
response.removeChild(response.lastChild);
|
||||
//response.lastChild.remove();
|
||||
}
|
||||
//JSON.stringify(js, null, 2);
|
||||
//for (let machine of js) {
|
||||
// console.log(typeof(machine));
|
||||
//}
|
||||
//const dat2 = js.hosts;
|
||||
//sort_default(dat2);
|
||||
response.textContent = JSON.stringify(js, null, 2);
|
||||
}
|
||||
|
||||
function clear_cache_all(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 + " (loading)";
|
||||
const body = {
|
||||
hosts: "",
|
||||
};
|
||||
const fetch_init = {
|
||||
method: "get",
|
||||
/*headers: {
|
||||
retrieval_instance: document.getElementById("retrieval_instance").value,
|
||||
},*/
|
||||
/*body: JSON.stringify(body),*/
|
||||
};
|
||||
fetch(g_config.api_base + "gather/clear_cache", 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];
|
||||
show_json_response(js);
|
||||
const ts2 = kk[1];
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const 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)),
|
||||
@@ -72,6 +120,8 @@ function config_for_test() {
|
||||
}
|
||||
|
||||
function init() {
|
||||
// keydown event..
|
||||
document.getElementById("btn_clear_cache").addEventListener("click", clear_cache_all)
|
||||
}
|
||||
|
||||
window.addEventListener("load", ev => {
|
||||
@@ -79,7 +129,7 @@ window.addEventListener("load", ev => {
|
||||
config_for_test();
|
||||
}
|
||||
init();
|
||||
const init_load_ele = document.getElementById("btn_load");
|
||||
const init_load_ele = document.getElementById("none");
|
||||
if (init_load_ele != null) {
|
||||
init_load_ele.click();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user