v0.26.7
This commit is contained in:
1 parent
5d2aaeabe6
commit
9d6614c1b4
62 files changed
+558
-230
No files matched your search
@@ -10,6 +10,19 @@
|
||||
const scope = () => $("cache-scope").value;
|
||||
const domainFilter = () => $("cache-domain-filter").value;
|
||||
const number = v => fmt(v ?? 0);
|
||||
const occupancy = (used, limit) => {
|
||||
const boundedLimit = Number(limit) || 0;
|
||||
if (boundedLimit <= 0) return 0;
|
||||
return Math.min(100, Math.max(0, (Number(used) || 0) / boundedLimit * 100));
|
||||
};
|
||||
const setMeter = (id, used, limit) => {
|
||||
const value = occupancy(used, limit), meter = $(id);
|
||||
if (meter) {
|
||||
meter.value = value;
|
||||
meter.setAttribute("aria-valuetext", `${value.toFixed(1)}%`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
const operationMessage = (id, value = "", error = false) => {
|
||||
const box = $(id);
|
||||
if (!box) return;
|
||||
@@ -111,18 +124,27 @@
|
||||
const total = field => groups.reduce((n, row) => n + (row[field] || 0), 0), all = scope() === "*";
|
||||
const hits = total("hits"), misses = total("misses");
|
||||
const hotEntries = all ? (m.entries || 0) : total("hot_entries"), coldEntries = all ? (m.cold_entries || 0) : total("cold_entries");
|
||||
const hotEntryLimit = Number(data.settings?.max_entries) || 0;
|
||||
const hotEntryPercent = setMeter("cp-hot-entries-meter", hotEntries, hotEntryLimit);
|
||||
$("cp-entries").textContent = number(hotEntries);
|
||||
$("cp-capacity").textContent = `${t("cacheGlobalLimit")}: ${number(data.settings?.max_entries)}`;
|
||||
$("cp-capacity").textContent = `${t("cacheGlobalLimit")}: ${number(hotEntryLimit)} · ${hotEntryPercent.toFixed(1)}%`;
|
||||
const resident = all ? (m.hot_allocated_bytes ?? m.resident_bytes ?? 0) : total("resident_bytes");
|
||||
const logical = all ? (m.hot_logical_bytes ?? 0) : total("logical_bytes");
|
||||
const hotLimit = m.hot_limit_bytes ?? data.settings?.max_bytes ?? 0;
|
||||
$("cp-bytes").textContent = fmtBytes(resident); $("cp-memory").value = resident / Math.max(1, hotLimit) * 100;
|
||||
$("cp-memory-detail").textContent = `${t("cacheLogicalShort")}: ${fmtBytes(logical)} · ${t("cacheLimitShort")}: ${fmtBytes(hotLimit)}`;
|
||||
const hotPercent = setMeter("cp-memory", resident, hotLimit);
|
||||
$("cp-bytes").textContent = fmtBytes(resident);
|
||||
$("cp-memory-detail").textContent = `${t("cacheLogicalShort")}: ${fmtBytes(logical)} · ${t("cacheLimitShort")}: ${fmtBytes(hotLimit)} · ${hotPercent.toFixed(1)}%`;
|
||||
$("cp-transient").textContent = `${fmtBytes(m.transient_bytes)} / ${fmtBytes(m.transient_limit_bytes ?? data.settings?.transient_max_bytes)}`;
|
||||
$("cp-transient-detail").textContent = `${t("cacheFillShort")}: ${fmtBytes(m.fill_bytes_active)} · ${t("cacheQueueShort")}: ${fmtBytes(m.cold_queue_bytes)} / ${fmtBytes(m.cold_queue_limit_bytes ?? data.settings?.cold_queue_max_bytes)} · ${t("cacheIoShort")}: ${fmtBytes((Number(m.cold_write_bytes_active) || 0) + (Number(m.cold_read_bytes_active) || 0))}`;
|
||||
const coldBytes = all ? (m.cold_bytes || 0) : total("cold_bytes");
|
||||
$("cp-cold-entries").textContent = number(coldEntries); $("cp-cold-capacity").textContent = `${t("cacheGlobalLimit")}: ${number(data.settings?.cold_max_entries || 0)}`;
|
||||
$("cp-cold-bytes").textContent = fmtBytes(coldBytes); $("cp-cold-disk").value = coldBytes / Math.max(1, data.settings?.cold_max_bytes || 1) * 100;
|
||||
const coldEntryLimit = Number(data.settings?.cold_max_entries) || 0;
|
||||
const coldEntryPercent = setMeter("cp-cold-entries-meter", coldEntries, coldEntryLimit);
|
||||
$("cp-cold-entries").textContent = number(coldEntries);
|
||||
$("cp-cold-capacity").textContent = `${t("cacheGlobalLimit")}: ${number(coldEntryLimit)} · ${coldEntryPercent.toFixed(1)}%`;
|
||||
const coldLimit = Number(data.settings?.cold_max_bytes) || 0;
|
||||
const coldPercent = setMeter("cp-cold-disk", coldBytes, coldLimit);
|
||||
$("cp-cold-bytes").textContent = fmtBytes(coldBytes);
|
||||
$("cp-cold-disk-detail").textContent = `${t("cacheLimitShort")}: ${fmtBytes(coldLimit)} · ${coldPercent.toFixed(1)}%`;
|
||||
$("cp-ratio").textContent = `${fmt((all ? (m.hit_ratio || 0) : (hits + misses ? hits / (hits + misses) : 0)) * 100, 1)}%`;
|
||||
$("cp-requests").textContent = `${number(all ? m.hits : hits)} HIT / ${number(all ? m.misses : misses)} MISS`;
|
||||
const bypasses = all ? (Number(m.bypasses) || 0) : total("bypasses");
|
||||
|
||||
Reference in new issue
Block a user