Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python
2.9 KB
Raw Blame
<!-- Header usage meters: the monthly AI token budget and, when a quota
     applies, storage (#413). Each shows only when its limit is set. -->
<div v-if="tokenBudget && (tokenBudget.has_budget || (tokenBudget.storage && tokenBudget.storage.has_quota))"
     class="hidden sm:flex flex-col justify-center"
     :class="tokenBudget.has_budget && tokenBudget.storage && tokenBudget.storage.has_quota ? 'usage-meters--stacked' : ''">
    <div v-if="tokenBudget.has_budget"
         class="usage-meter flex items-center gap-1.5 px-2 py-1 rounded text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors cursor-default"
         :title="t('usageMeters.tokenTooltip', { used: (tokenBudget.usage || 0).toLocaleString(uiLocale()), budget: (tokenBudget.budget || 0).toLocaleString(uiLocale()) })">
        <i class="fas fa-coins text-[10px]"
           :style="tokenBudget.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.percentage >= 80 ? {color: '#f59e0b'} : {}"></i>
        <span :style="tokenBudget.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.percentage >= 80 ? {color: '#f59e0b'} : {}">${ formatPercent(tokenBudget.percentage) }</span>
        <div class="w-12 h-1 bg-[var(--bg-tertiary)] rounded-full overflow-hidden">
            <div class="h-full rounded-full transition-all duration-300 bg-[var(--text-accent)]"
                 :style="{
                     width: Math.min(tokenBudget.percentage, 100) + '%',
                     backgroundColor: tokenBudget.percentage >= 100 ? '#ef4444' : tokenBudget.percentage >= 80 ? '#f59e0b' : null
                 }">
            </div>
        </div>
    </div>
    <a v-if="tokenBudget.storage && tokenBudget.storage.has_quota" href="/account"
       class="usage-meter flex items-center gap-1.5 px-2 py-1 rounded text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors"
       :title="t('usageMeters.storageTooltip', { used: tokenBudget.storage.used_label, quota: tokenBudget.storage.quota_label })">
        <i class="fas fa-hdd text-[10px]"
           :style="tokenBudget.storage.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.storage.percentage >= 80 ? {color: '#f59e0b'} : {}"></i>
        <span :style="tokenBudget.storage.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.storage.percentage >= 80 ? {color: '#f59e0b'} : {}">${ formatPercent(tokenBudget.storage.percentage) }</span>
        <div class="w-12 h-1 bg-[var(--bg-tertiary)] rounded-full overflow-hidden">
            <div class="h-full rounded-full transition-all duration-300 bg-[var(--text-accent)]"
                 :style="{
                     width: Math.min(tokenBudget.storage.percentage, 100) + '%',
                     backgroundColor: tokenBudget.storage.percentage >= 100 ? '#ef4444' : tokenBudget.storage.percentage >= 80 ? '#f59e0b' : null
                 }">
            </div>
        </div>
    </a>
</div>