Add persistent device traffic history charts
Build and Deploy Gateway / build-and-push (push) Successful in 14s
Build and Deploy Gateway / deploy (push) Successful in 6s

This commit is contained in:
2026-08-07 19:34:59 +03:00
parent cf90fd5b4e
commit ef4847a3e1
7 changed files with 174 additions and 45 deletions
+5 -2
View File
@@ -37,13 +37,16 @@ export function positiveByteDelta(previous, current) {
return after > before ? formatByteString((after - before).toString()) : '';
}
export function trafficSampleMetrics(gatewayValue, proxyValue, maxValue) {
export function trafficSampleMetrics(gatewayValue, proxyValue, maxValue, scale = 'linear') {
const gateway = byteString(gatewayValue);
const proxy = byteString(proxyValue);
const total = gateway + proxy;
const max = byteString(maxValue);
const ratio = scale === 'log'
? Math.log1p(Number(total)) / Math.log1p(Number(max))
: Number(total * 100n / (max || 1n)) / 100;
return {
height: max && total ? Math.max(10, Math.min(100, Number(total * 100n / max))) : 0,
height: max && total ? Math.max(10, Math.min(100, Math.round(ratio * 100))) : 0,
gatewayShare: total ? Number(gateway * 100n / total) : 0,
};
}