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")) { if (item.managed && item.managed.startsWith("goauthentik.io/crypto/discovered")) {
managedSubText = t`Managed by authentik (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 [ return [
html`<div>${item.name}</div> html`<div>${item.name}</div>
${item.managed ? html`<small>${managedSubText}</small>` : html``}`, ${item.managed ? html`<small>${managedSubText}</small>` : html``}`,
html`<ak-label color=${item.privateKeyAvailable ? PFColor.Green : PFColor.Grey}> html`<ak-label color=${item.privateKeyAvailable ? PFColor.Green : PFColor.Grey}>
${item.privateKeyAvailable ? t`Yes (${item.privateKeyType?.toUpperCase()})` : t`No`} ${item.privateKeyAvailable ? t`Yes (${item.privateKeyType?.toUpperCase()})` : t`No`}
</ak-label>`, </ak-label>`,
html`<ak-label html`<ak-label color=${color}> ${item.certExpiry?.toLocaleString()} </ak-label>`,
color=${item.certExpiry || new Date() > new Date() ? PFColor.Green : PFColor.Orange}
>
${item.certExpiry?.toLocaleString()}
</ak-label>`,
html`<ak-forms-modal> html`<ak-forms-modal>
<span slot="submit"> ${t`Update`} </span> <span slot="submit"> ${t`Update`} </span>
<span slot="header"> ${t`Update Certificate-Key Pair`} </span> <span slot="header"> ${t`Update Certificate-Key Pair`} </span>