Skip to content

Commit b116829

Browse files
committed
Add free-slot count and nearest term-expiry to Licensing summary
1 parent 259339b commit b116829

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/NetworkOptimizer.Web/Components/Shared/LicensingSettingsCard.razor

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@if (LicenseState.AnyKeysActive)
2121
{
2222
<p class="section-description">
23-
@UsedSlots of @LicenseState.TotalAllowance licensed site slots used.
23+
@UsedSlots of @LicenseState.TotalAllowance licensed site slots used &middot; @FreeSlots free@(SoonestTermExpiry is { } expiry ? $" · earliest term expires {expiry.ToLocalTime():MMM d, yyyy}" : "")
2424
</p>
2525
}
2626
else
@@ -197,6 +197,22 @@
197197
}
198198
}
199199

200+
private int FreeSlots => Math.Max(0, LicenseState.TotalAllowance - UsedSlots);
201+
202+
/// <summary>Soonest paid-through date among active term keys; null when all keys are perpetual.</summary>
203+
private DateTime? SoonestTermExpiry
204+
{
205+
get
206+
{
207+
var now = DateTime.UtcNow;
208+
return _keys
209+
.Where(k => LicenseStateService.IsActiveCurrent(k, now) && k.Model == LicenseKeyModels.Term && k.PaidThrough != null)
210+
.Select(k => k.PaidThrough!.Value)
211+
.DefaultIfEmpty()
212+
.Min() is { } d && d != default ? d : null;
213+
}
214+
}
215+
200216

201217
private DateTime? NewestCheckAt => _keys
202218
.Where(k => k.LastCheckAt != null)

0 commit comments

Comments
 (0)