web/admin: add status card for https and timedrift

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-26 19:58:26 +02:00
parent b752540800
commit 577aa7ba79
4 changed files with 89 additions and 2 deletions

View file

@ -1424,6 +1424,10 @@ msgstr "Event {0}"
msgid "Events"
msgstr "Events"
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "Everything is ok."
msgstr "Everything is ok."
#: src/pages/events/EventInfo.ts
#: src/pages/events/EventInfo.ts
#: src/pages/events/EventInfo.ts
@ -1773,6 +1777,10 @@ msgstr "HTTP-Basic Password Key"
msgid "HTTP-Basic Username Key"
msgstr "HTTP-Basic Username Key"
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "HTTPS is not detected correctly"
msgstr "HTTPS is not detected correctly"
#: src/pages/outposts/OutpostListPage.ts
msgid "Health and Version"
msgstr "Health and Version"
@ -3320,6 +3328,10 @@ msgstr "Separator: Static Separator Line"
msgid "Server URI"
msgstr "Server URI"
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "Server and client are further than 5 seconds apart."
msgstr "Server and client are further than 5 seconds apart."
#: src/pages/providers/ldap/LDAPProviderForm.ts
msgid "Server name for which this provider's certificate is valid for."
msgstr "Server name for which this provider's certificate is valid for."
@ -3897,6 +3909,10 @@ msgstr "System Overview"
msgid "System Tasks"
msgstr "System Tasks"
#: src/pages/admin-overview/AdminOverviewPage.ts
msgid "System status"
msgstr "System status"
#: src/pages/events/utils.ts
msgid "System task exception"
msgstr "System task exception"
@ -4612,6 +4628,8 @@ msgstr "Wait (max)"
msgid "Wait (min)"
msgstr "Wait (min)"
#: src/pages/admin-overview/cards/SystemStatusCard.ts
#: src/pages/admin-overview/cards/SystemStatusCard.ts
#: src/pages/events/RuleForm.ts
#: src/pages/system-tasks/SystemTaskListPage.ts
msgid "Warning"

View file

@ -1416,6 +1416,10 @@ msgstr ""
msgid "Events"
msgstr ""
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "Everything is ok."
msgstr ""
#: src/pages/events/EventInfo.ts
#: src/pages/events/EventInfo.ts
#: src/pages/events/EventInfo.ts
@ -1765,6 +1769,10 @@ msgstr ""
msgid "HTTP-Basic Username Key"
msgstr ""
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "HTTPS is not detected correctly"
msgstr ""
#: src/pages/outposts/OutpostListPage.ts
msgid "Health and Version"
msgstr ""
@ -3312,6 +3320,10 @@ msgstr ""
msgid "Server URI"
msgstr ""
#: src/pages/admin-overview/cards/SystemStatusCard.ts
msgid "Server and client are further than 5 seconds apart."
msgstr ""
#: src/pages/providers/ldap/LDAPProviderForm.ts
msgid "Server name for which this provider's certificate is valid for."
msgstr ""
@ -3889,6 +3901,10 @@ msgstr ""
msgid "System Tasks"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts
msgid "System status"
msgstr ""
#: src/pages/events/utils.ts
msgid "System task exception"
msgstr ""
@ -4597,6 +4613,8 @@ msgstr ""
msgid "Wait (min)"
msgstr ""
#: src/pages/admin-overview/cards/SystemStatusCard.ts
#: src/pages/admin-overview/cards/SystemStatusCard.ts
#: src/pages/events/RuleForm.ts
#: src/pages/system-tasks/SystemTaskListPage.ts
msgid "Warning"

View file

@ -9,6 +9,7 @@ import "./cards/AdminStatusCard";
import "./cards/BackupStatusCard";
import "./cards/VersionStatusCard";
import "./cards/WorkerStatusCard";
import "./cards/SystemStatusCard";
import "./charts/FlowStatusChart";
import "./charts/LDAPSyncStatusChart";
@ -92,14 +93,18 @@ export class AdminOverviewPage extends LitElement {
<ak-admin-status-version icon="pf-icon pf-icon-bundle" header=${t`Version`} headerLink="https://github.com/goauthentik/authentik/releases">
</ak-admin-status-version>
</div>
<div class="pf-l-grid__item pf-m-6-col pf-m-4-col-on-md pf-m-4-col-on-xl card-container">
<div class="pf-l-grid__item pf-m-6-col pf-m-2-col-on-md pf-m-2-col-on-xl card-container">
<ak-admin-status-card-backup icon="fa fa-database" header=${t`Backup status`} headerLink="#/administration/system-tasks">
</ak-admin-status-card-backup>
</div>
<div class="pf-l-grid__item pf-m-6-col pf-m-4-col-on-md pf-m-4-col-on-xl card-container">
<div class="pf-l-grid__item pf-m-6-col pf-m-3-col-on-md pf-m-3-col-on-xl card-container">
<ak-admin-status-card-workers icon="pf-icon pf-icon-server" header=${t`Workers`}>
</ak-admin-status-card-workers>
</div>
<div class="pf-l-grid__item pf-m-6-col pf-m-3-col-on-md pf-m-3-col-on-xl card-container">
<ak-admin-status-system icon="pf-icon pf-icon-server" header=${t`System status`}>
</ak-admin-status-system>
</div>
<div class="pf-l-grid__item pf-m-12-col row-divider">
<hr>
</div>

View file

@ -0,0 +1,46 @@
import { t } from "@lingui/macro";
import { customElement, html, TemplateResult } from "lit-element";
import { AdminApi, System } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import { AdminStatusCard, AdminStatus } from "./AdminStatusCard";
@customElement("ak-admin-status-system")
export class SystemStatusCard extends AdminStatusCard<System> {
now?: Date;
header = "OK";
getPrimaryValue(): Promise<System> {
this.now = new Date();
return new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve();
}
getStatus(value: System): Promise<AdminStatus> {
if (!value.httpIsSecure && document.location.protocol === "https:") {
this.header = t`Warning`;
return Promise.resolve<AdminStatus>({
icon: "fa fa-exclamation-triangle pf-m-warning",
message: t`HTTPS is not detected correctly`,
});
}
const timeDiff = value.serverTime.getTime() - (this.now || new Date()).getTime();
console.log(`authentik/: timediff ${timeDiff}`);
if (timeDiff > 5000 || timeDiff < -5000) {
this.header = t`Warning`;
return Promise.resolve<AdminStatus>({
icon: "fa fa-exclamation-triangle pf-m-warning",
message: t`Server and client are further than 5 seconds apart.`,
});
}
return Promise.resolve<AdminStatus>({
icon: "fa fa-check-circle pf-m-success",
message: t`Everything is ok.`
});
}
renderValue(): TemplateResult {
return html`${this.header}`;
}
}