LuCI admin (people, devices, limits, disguise, health, updates, backups) and a personal self-service portal, built as ipk (OpenWrt 24.10) and apk (OpenWrt 25.12) with the OpenWrt SDK. Successor of openwrt-liminal. - install.sh: checks the router, installs AmneziaWG for its firmware, then the release package verified against sha256sums.txt - CI: Prettier, types, tests, committed bundles, ShellCheck, ucode checks; tagged releases build both packages and publish them - Web bundles minified with esbuild (JS and CSS) - README with framed screenshots
This commit is contained in:
commit
a3910f8b97
105 files changed
+22278
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// Tiny SVG bar chart for daily traffic (download stacked over upload).
|
||||
|
||||
import type { DayUsage } from './types';
|
||||
import { bytes } from './format';
|
||||
|
||||
export function trafficChart(series: DayUsage[], height = 120): string {
|
||||
const w = 600;
|
||||
const pad = 2;
|
||||
const n = Math.max(series.length, 1);
|
||||
const bw = w / n;
|
||||
const max = Math.max(1, ...series.map((d) => d.rx + d.tx));
|
||||
let bars = '';
|
||||
series.forEach((d, i) => {
|
||||
const x = i * bw + pad / 2;
|
||||
// From the person's point of view: router tx = download, rx = upload.
|
||||
const hDown = (d.tx / max) * (height - 4);
|
||||
const hUp = (d.rx / max) * (height - 4);
|
||||
const title = `${d.day}: ↓ ${bytes(d.tx)} · ↑ ${bytes(d.rx)}`;
|
||||
bars +=
|
||||
`<g><title>${title}</title>` +
|
||||
`<rect x="${x.toFixed(1)}" y="${(height - hDown - hUp).toFixed(1)}" width="${(bw - pad).toFixed(1)}" height="${hDown.toFixed(1)}" rx="1.5" class="dl-bar-down"/>` +
|
||||
`<rect x="${x.toFixed(1)}" y="${(height - hUp).toFixed(1)}" width="${(bw - pad).toFixed(1)}" height="${hUp.toFixed(1)}" rx="1.5" class="dl-bar-up"/>` +
|
||||
`<rect x="${(i * bw).toFixed(1)}" y="0" width="${bw.toFixed(1)}" height="${height}" fill="transparent"/></g>`;
|
||||
});
|
||||
return `<svg class="dl-chart" viewBox="0 0 ${w} ${height}" preserveAspectRatio="none" role="img" aria-label="Traffic per day">${bars}</svg>`;
|
||||
}
|
||||
Reference in new issue
Block a user