outposts: add better UI for showing mismatched versions (#10885)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { getRelativeTime } from "@goauthentik/common/utils";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/Spinner";
|
||||
|
||||
import { msg, str } from "@lit/localize";
|
||||
import { CSSResult, TemplateResult, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators.js";
|
||||
import { customElement, property, state } from "lit/decorators.js";
|
||||
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
|
||||
@ -17,8 +18,8 @@ export class OutpostHealthSimpleElement extends AKElement {
|
||||
@property()
|
||||
outpostId?: string;
|
||||
|
||||
@property({ attribute: false })
|
||||
outpostHealth?: OutpostHealth;
|
||||
@state()
|
||||
outpostHealths: OutpostHealth[] = [];
|
||||
|
||||
@property({ attribute: false })
|
||||
loaded = false;
|
||||
@ -33,7 +34,7 @@ export class OutpostHealthSimpleElement extends AKElement {
|
||||
constructor() {
|
||||
super();
|
||||
window.addEventListener(EVENT_REFRESH, () => {
|
||||
this.outpostHealth = undefined;
|
||||
this.outpostHealths = [];
|
||||
this.firstUpdated();
|
||||
});
|
||||
}
|
||||
@ -46,9 +47,7 @@ export class OutpostHealthSimpleElement extends AKElement {
|
||||
})
|
||||
.then((health) => {
|
||||
this.loaded = true;
|
||||
if (health.length >= 1) {
|
||||
this.outpostHealth = health[0];
|
||||
}
|
||||
this.outpostHealths = health;
|
||||
});
|
||||
}
|
||||
|
||||
@ -56,11 +55,22 @@ export class OutpostHealthSimpleElement extends AKElement {
|
||||
if (!this.outpostId || !this.loaded) {
|
||||
return html`<ak-spinner></ak-spinner>`;
|
||||
}
|
||||
if (!this.outpostHealth) {
|
||||
if (!this.outpostHealths || this.outpostHealths.length === 0) {
|
||||
return html`<ak-label color=${PFColor.Grey}>${msg("Not available")}</ak-label>`;
|
||||
}
|
||||
const outdatedOutposts = this.outpostHealths.filter((h) => h.versionOutdated);
|
||||
if (outdatedOutposts.length > 0) {
|
||||
return html`<ak-label color=${PFColor.Red}>
|
||||
${msg(
|
||||
str`${outdatedOutposts[0].version}, should be ${outdatedOutposts[0].versionShould}`,
|
||||
)}</ak-label
|
||||
>`;
|
||||
}
|
||||
const lastSeen = this.outpostHealths[0].lastSeen;
|
||||
return html`<ak-label color=${PFColor.Green}>
|
||||
${msg(str`Last seen: ${this.outpostHealth.lastSeen?.toLocaleTimeString()}`)}</ak-label
|
||||
${msg(
|
||||
str`Last seen: ${getRelativeTime(lastSeen)} (${lastSeen.toLocaleTimeString()})`,
|
||||
)}</ak-label
|
||||
>`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user