mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-05 16:02:03 +00:00
fix(dns): show cache entries and capacity as fact tiles
The cache card shares a row with the ranking card and kept 138px empty under a single "Entries: 97 / 256" line. Entries and capacity now stand as two FactStrip tiles, from the raw UInt64 values, so the card uses the height the row gives it; the no-capacity note is unchanged.
This commit is contained in:
1 parent
c509d2a9f5
commit
ea3a07383e
6 files changed
+23
-10
No files matched your search
@@ -183,7 +183,7 @@ function CacheCard({listed, href}: {listed: boolean; href: string | null}) {
|
||||
{vm.card.usage && (
|
||||
<div className="rp-form">
|
||||
<Bar label={t('dns.chart.usage')} value={vm.card.usage.value} pct={vm.card.usage.pct} color={p.accent} />
|
||||
<span className="rp-label">{vm.card.usage.facts}</span>
|
||||
<FactStrip facts={vm.card.usage.facts} />
|
||||
</div>
|
||||
)}
|
||||
<p className="rp-note">{vm.card.coverage}</p>
|
||||
|
||||
@@ -15,19 +15,23 @@ const list = (usage?: DnsCacheList['usage']) =>
|
||||
usage
|
||||
}) as DnsCacheList;
|
||||
|
||||
it('fills the bar by the entry count, its only limit, and states it as a fraction per locale', async () => {
|
||||
it('fills the bar by the entry count, its only limit, and states entries and capacity apart', async () => {
|
||||
const card = cacheCard(list({entries: '4096', entry_capacity: '100000'}), 'en-US', t)!;
|
||||
expect(card.usage?.pct).toBe(4.1);
|
||||
expect(card.usage?.facts).toBe('Entries: 4,096 / 100,000');
|
||||
expect(card.usage?.facts).toEqual([
|
||||
{label: 'Entries', value: '4,096'},
|
||||
{label: 'Capacity', value: '100,000'}
|
||||
]);
|
||||
expect(card.note).toBeUndefined();
|
||||
expect(card.coverage).toBe('Caches Positive answers; held in memory only, cleared on restart');
|
||||
expect(cacheCard(list({entries: '5', entry_capacity: '100000'}), 'en-US', t)!.usage?.value).toBe('<1%');
|
||||
// Chinese writes the fraction with a full-width slash and no spaces.
|
||||
await Promise.all([loadLanguage('zh-TW'), loadLanguage('zh-CN')]);
|
||||
for (const lang of ['zh-TW', 'zh-CN'] as const)
|
||||
expect(cacheCard(list({entries: '322', entry_capacity: '100000'}), lang, (key, params) => translate(lang, key, params))!.usage?.facts).toMatch(
|
||||
/322\uFF0F100,000$/
|
||||
);
|
||||
// A capacity past Number's exact range keeps every digit.
|
||||
expect(cacheCard(list({entries: '1', entry_capacity: '18446744073709551615'}), 'en-US', t)!.usage?.facts[1].value).toBe('18,446,744,073,709,551,615');
|
||||
await loadLanguage('zh-TW');
|
||||
expect(cacheCard(list({entries: '322', entry_capacity: '100000'}), 'zh-TW', (key, params) => translate('zh-TW', key, params))!.usage?.facts).toEqual([
|
||||
{label: '條目', value: '322'},
|
||||
{label: '容量', value: '100,000'}
|
||||
]);
|
||||
});
|
||||
|
||||
it('claims no capacity when the backend does not report usage', () => {
|
||||
|
||||
@@ -23,7 +23,10 @@ export function cacheCard(list: DnsCacheList | undefined, locale: string, t: Tra
|
||||
pct,
|
||||
// A cache in use never reads as 0%.
|
||||
value: pct > 0 && pct < 0.5 ? '<' + t('ui.percent', {n: 1}) : t('ui.percent', {n: Math.round(pct)}),
|
||||
facts: t('dns.chart.usageFacts', {entries: t('ui.fraction', {part: count(usage.entries), whole: count(capacity)})})
|
||||
facts: [
|
||||
{label: t('dns.chart.entries'), value: count(usage.entries)},
|
||||
{label: t('dns.chart.capacity'), value: count(capacity)}
|
||||
]
|
||||
}
|
||||
: null,
|
||||
coverage: t('dns.chart.coverage', {
|
||||
|
||||
@@ -387,11 +387,13 @@
|
||||
"dns.chart.cache": "Cache",
|
||||
"dns.chart.cacheNote": "Entries: {n}, capacity limit: not reported",
|
||||
"dns.chart.cacheRate": "Cache hit rate",
|
||||
"dns.chart.capacity": "Capacity",
|
||||
"dns.chart.count": {
|
||||
"one": "{n} lookup",
|
||||
"other": "{n} lookups"
|
||||
},
|
||||
"dns.chart.coverage": "Caches {kinds}; {persistent}",
|
||||
"dns.chart.entries": "Entries",
|
||||
"dns.chart.failureRate": "Failure rate",
|
||||
"dns.chart.median": "Median",
|
||||
"dns.chart.medianKey": "Median per upstream",
|
||||
|
||||
@@ -330,8 +330,10 @@
|
||||
"dns.chart.cache": "缓存状态",
|
||||
"dns.chart.cacheNote": "条目:{n},容量上限:未上报",
|
||||
"dns.chart.cacheRate": "缓存命中率",
|
||||
"dns.chart.capacity": "容量",
|
||||
"dns.chart.count": "{n} 条",
|
||||
"dns.chart.coverage": "缓存范围:{kinds};{persistent}",
|
||||
"dns.chart.entries": "条目",
|
||||
"dns.chart.failureRate": "失败率",
|
||||
"dns.chart.median": "中位数",
|
||||
"dns.chart.medianKey": "各上游的中位数",
|
||||
|
||||
@@ -330,8 +330,10 @@
|
||||
"dns.chart.cache": "快取狀態",
|
||||
"dns.chart.cacheNote": "條目:{n},容量上限:未回報",
|
||||
"dns.chart.cacheRate": "快取命中率",
|
||||
"dns.chart.capacity": "容量",
|
||||
"dns.chart.count": "{n} 筆",
|
||||
"dns.chart.coverage": "快取範圍:{kinds};{persistent}",
|
||||
"dns.chart.entries": "條目",
|
||||
"dns.chart.failureRate": "失敗率",
|
||||
"dns.chart.median": "中位數",
|
||||
"dns.chart.medianKey": "各上游的中位數",
|
||||
|
||||
Reference in new issue
Block a user