fix(ui): distinguish booked traffic balances from the latest sample
parent
2b1f796766
commit
c8201e11a6
@ -0,0 +1,39 @@
|
||||
// Shared by the traffic-pool list and the instance detail status refresh.
|
||||
export function accountingFreshness(pool, catalog = globalThis.VenixUserCopy) {
|
||||
const evidence = pool?.accounting_freshness;
|
||||
const status = ['current', 'delayed', 'attention'].includes(evidence?.status)
|
||||
? evidence.status : 'attention';
|
||||
const sample = Number(evidence?.last_sample_at);
|
||||
const hasSample = Number.isFinite(sample) && sample > 0;
|
||||
return {
|
||||
status,
|
||||
label: catalog.text(`traffic.freshness.${status}`),
|
||||
message: catalog.text(`traffic.freshness.${status}_${hasSample ? 'at' : 'without_time'}`,
|
||||
hasSample ? { sample_time: catalog.date(sample) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function renderAccountingFreshness(pool, document = globalThis.document, catalog = globalThis.VenixUserCopy) {
|
||||
const freshness = accountingFreshness(pool, catalog);
|
||||
function element(tag, className, text) {
|
||||
const node = document.createElement(tag);
|
||||
node.className = className;
|
||||
if (text !== undefined) node.textContent = text;
|
||||
return node;
|
||||
}
|
||||
const box = element('div',
|
||||
`cloud-traffic-accounting cloud-traffic-accounting-${freshness.status}`);
|
||||
const icon = element('span', 'cloud-traffic-accounting-icon');
|
||||
const marker = element('i', freshness.status === 'current'
|
||||
? 'mdi mdi-check-circle-outline'
|
||||
: freshness.status === 'delayed'
|
||||
? 'mdi mdi-clock-alert-outline'
|
||||
: 'mdi mdi-alert-circle-outline');
|
||||
marker.setAttribute('aria-hidden', 'true');
|
||||
icon.append(marker);
|
||||
const copy = element('span', 'cloud-traffic-accounting-copy');
|
||||
copy.append(element('strong', '', freshness.label),
|
||||
element('small', '', freshness.message));
|
||||
box.append(icon, copy);
|
||||
return box;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="cloud-traffic-accounting cloud-traffic-accounting-{$evidence.status|escape:'html'}">
|
||||
<span class="cloud-traffic-accounting-icon" aria-hidden="true"><i class="mdi {if $evidence.status == 'current'}mdi-check-circle-outline{elseif $evidence.status == 'delayed'}mdi-clock-alert-outline{else}mdi-alert-circle-outline{/if}"></i></span>
|
||||
<span class="cloud-traffic-accounting-copy">
|
||||
<strong>{user_copy key=$evidence.label_key}</strong>
|
||||
<small>{if $evidence.sample_display != ''}{user_copy key=$evidence.message_key sample_time=$evidence.sample_display}{else}{user_copy key=$evidence.message_key}{/if}</small>
|
||||
</span>
|
||||
</div>
|
||||
@ -1,2 +1,2 @@
|
||||
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
|
||||
{assign var=venix_asset_version value='2026111701' scope='global'}
|
||||
{assign var=venix_asset_version value='2026111801' scope='global'}
|
||||
|
||||
Loading…
Reference in New Issue