diff --git a/src/Yavsc.Org/Views/Client/Details.cshtml b/src/Yavsc.Org/Views/Client/Details.cshtml index 188f4269..b39a3f70 100644 --- a/src/Yavsc.Org/Views/Client/Details.cshtml +++ b/src/Yavsc.Org/Views/Client/Details.cshtml @@ -1,71 +1,296 @@ @model Client +@using Microsoft.AspNetCore.Html +@using System.Text + +@functions { + // Lifetimes in IdentityServer are stored as seconds (int). Render them + // in a human-friendly way: "5 min", "2 h", "30 d", "—" for 0/negative. + // Zero typically means "use the global default" — show it as such so + // an admin isn't misled into thinking the value is unset. + static string HumanLifetime(int? seconds) + { + if (!seconds.HasValue) return "—"; + var s = seconds.Value; + if (s <= 0) return "default"; + if (s < 60) return $"{s} s"; + if (s < 3600) return $"{s / 60} min"; + if (s < 86400) return $"{s / 3600} h"; + if (s < 86400 * 30) return $"{s / 86400} d"; + return $"{s / 86400} d ({s / 86400 / 30} mo)"; + } + + // IdentityServer8 stores enum-valued config columns as plain `int` + // (no enum type metadata at the storage layer). Render the numeric + // value directly. The matching enum name lives on the wire side + // (Discovery / token claims), not in this admin view. + static string IntOrZero(int value) => value.ToString(); + + static IHtmlContent BoolBadge(bool value) => + new HtmlString(value + ? "yes" + : "no"); + + static IHtmlContent EnabledBadge(bool value) => + new HtmlString(value + ? "enabled" + : "disabled"); + + // IdentityServer8: ClientSecret.Expiration is DateTime? (null = no + // expiry). ClientSecret.Created is DateTime, defaulted to UtcNow by + // the framework, so it never carries a MinValue sentinel — we render + // it as-is. + static string DateOrDash(DateTime? value) => + value?.ToString("yyyy-MM-dd HH:mm") ?? "—"; +}
@Model.ClientId
+ @EnabledBadge(Model.Enabled)
+ @if (!string.IsNullOrWhiteSpace(Model.ClientName))
+ {
+ — @Model.ClientName
+ }
+- @Localizer["Edit"] | - @Localizer["Regenerate secret"] | - @Localizer["Back to List"] + @Localizer["Edit"] + @Localizer["Regenerate secret"] + @Localizer["Back to List"]