Files
2026-05-16 17:20:12 -05:00

50 lines
2.6 KiB
HTML

{{ define "storage_stats" }}
<div class="space-y-2">
{{ if .Tier }}
<div class="flex justify-between items-center">
<span class="text-base-content/60">Tier:</span>
{{/* Whitelist known tier names so an unrecognized tier falls back to
a safe neutral badge instead of producing a broken class. */}}
{{ if eq .Tier "deckhand" }}
<span class="badge badge-xs badge-deckhand font-semibold">{{ .Tier }}</span>
{{ else if eq .Tier "bosun" }}
<span class="badge badge-xs badge-bosun font-semibold">{{ .Tier }}</span>
{{ else if eq .Tier "quartermaster" }}
<span class="badge badge-xs badge-quartermaster font-semibold">{{ .Tier }}</span>
{{ else }}
<span class="badge badge-xs badge-ghost font-semibold">{{ .Tier }}</span>
{{ end }}
</div>
{{ end }}
<div class="flex justify-between items-center">
<span class="text-base-content/60">Storage:</span>
<span class="font-semibold font-mono">
{{ if .HasLimit }}
{{ .HumanSize }} / {{ .HumanLimit }}
{{ else }}
{{ .HumanSize }} <span class="badge badge-xs badge-success">Unlimited</span>
{{ end }}
</span>
</div>
{{ if .HasLimit }}
<div class="flex items-center gap-2 py-2">
<progress class="progress {{ if ge .UsagePercent 95 }}progress-error{{ else if ge .UsagePercent 80 }}progress-warning{{ else }}progress-success{{ end }} w-full" value="{{ .UsagePercent }}" max="100" aria-label="Storage used: {{ .UsagePercent }} percent"></progress>
<span class="text-sm text-base-content/60 whitespace-nowrap">{{ .UsagePercent }}% used</span>
</div>
{{/* Color alone on the progress bar doesn't meet AAA — repeat the warning
as an alert block once usage crosses the threshold. */}}
{{ if ge .UsagePercent 100 }}
{{ template "alert" (dict "Type" "error" "Message" "You've exceeded your storage limit. New pushes will be rejected until you delete images to free space.") }}
{{ else if ge .UsagePercent 95 }}
{{ template "alert" (dict "Type" "error" "Message" "You're nearly at your storage limit. Pushes may fail once you exceed it.") }}
{{ else if ge .UsagePercent 80 }}
{{ template "alert" (dict "Type" "warning" "Message" "You're using most of your storage quota. Consider cleaning up untagged images.") }}
{{ end }}
{{ end }}
<div class="flex justify-between items-center">
<span class="text-base-content/60">Unique Blobs:</span>
<span class="font-semibold font-mono">{{ .UniqueBlobs }}</span>
</div>
</div>
{{ end }}