web/admin: fix cert expiry coloring (#5354)

This commit is contained in:
Jens L 2023-04-23 19:16:50 +03:00 committed by GitHub
parent 5970a6e2a2
commit 158fe2f9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -95,17 +95,25 @@ export class CertificateKeyPairListPage extends TablePage<CertificateKeyPair> {
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`<div>${item.name}</div>
${item.managed ? html`<small>${managedSubText}</small>` : html``}`,
html`<ak-label color=${item.privateKeyAvailable ? PFColor.Green : PFColor.Grey}>
${item.privateKeyAvailable ? t`Yes (${item.privateKeyType?.toUpperCase()})` : t`No`}
</ak-label>`,
html`<ak-label
color=${item.certExpiry || new Date() > new Date() ? PFColor.Green : PFColor.Orange}
>
${item.certExpiry?.toLocaleString()}
</ak-label>`,
html`<ak-label color=${color}> ${item.certExpiry?.toLocaleString()} </ak-label>`,
html`<ak-forms-modal>
<span slot="submit"> ${t`Update`} </span>
<span slot="header"> ${t`Update Certificate-Key Pair`} </span>