From 158fe2f9bb72b652b59f788c558bcafdb3f32c62 Mon Sep 17 00:00:00 2001 From: Jens L Date: Sun, 23 Apr 2023 19:16:50 +0300 Subject: [PATCH] web/admin: fix cert expiry coloring (#5354) --- .../admin/crypto/CertificateKeyPairListPage.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/web/src/admin/crypto/CertificateKeyPairListPage.ts b/web/src/admin/crypto/CertificateKeyPairListPage.ts index ad0f066a1..911f0069a 100644 --- a/web/src/admin/crypto/CertificateKeyPairListPage.ts +++ b/web/src/admin/crypto/CertificateKeyPairListPage.ts @@ -95,17 +95,25 @@ export class CertificateKeyPairListPage extends TablePage { if (item.managed && item.managed.startsWith("goauthentik.io/crypto/discovered")) { managedSubText = t`Managed by authentik (Discovered)`; } + let color = PFColor.Green; + if (item.certExpiry) { + const now = new Date(); + const inAMonth = new Date(); + inAMonth.setDate(inAMonth.getDate() + 30); + if (item.certExpiry <= inAMonth) { + color = PFColor.Orange; + } + if (item.certExpiry <= now) { + color = PFColor.Red; + } + } return [ html`
${item.name}
${item.managed ? html`${managedSubText}` : html``}`, html` ${item.privateKeyAvailable ? t`Yes (${item.privateKeyType?.toUpperCase()})` : t`No`} `, - html` new Date() ? PFColor.Green : PFColor.Orange} - > - ${item.certExpiry?.toLocaleString()} - `, + html` ${item.certExpiry?.toLocaleString()} `, html` ${t`Update`} ${t`Update Certificate-Key Pair`}