web/admin: show ldap sync status on overview page

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-05 20:36:31 +02:00
parent f0ef2eea4f
commit d48badbca3
6 changed files with 129 additions and 20 deletions

View File

@ -21,6 +21,9 @@ export class AggregateCard extends LitElement {
.pf-c-card.pf-c-card-aggregate {
height: 100%;
}
.pf-c-card__header {
flex-wrap: nowrap;
}
.center-value {
font-size: var(--pf-global--icon--FontSize--lg);
text-align: center;

View File

@ -168,7 +168,7 @@ msgstr "Application's display Name."
msgid "Applications"
msgstr "Applications"
#: src/pages/admin-overview/AdminOverviewPage.ts:39
#: src/pages/admin-overview/AdminOverviewPage.ts:40
msgid "Apps with most usage"
msgstr "Apps with most usage"
@ -356,11 +356,11 @@ msgstr "Build hash: {0}"
msgid "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
msgstr "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
#: src/pages/admin-overview/AdminOverviewPage.ts:54
#: src/pages/admin-overview/AdminOverviewPage.ts:55
msgid "Cached Flows"
msgstr "Cached Flows"
#: src/pages/admin-overview/AdminOverviewPage.ts:52
#: src/pages/admin-overview/AdminOverviewPage.ts:53
msgid "Cached Policies"
msgstr "Cached Policies"
@ -1539,6 +1539,10 @@ msgstr "Kubeconfig"
msgid "LDAP Source {0}"
msgstr "LDAP Source {0}"
#: src/pages/admin-overview/cards/LDAPSyncStatusCardContainer.ts:24
msgid "LDAP Sync status {0}"
msgstr "LDAP Sync status {0}"
#: src/pages/stages/prompt/PromptForm.ts:90
#: src/pages/stages/prompt/PromptListPage.ts:47
msgid "Label"
@ -1661,7 +1665,7 @@ msgstr "Login to continue to {0}."
msgid "Logins"
msgstr "Logins"
#: src/pages/admin-overview/AdminOverviewPage.ts:36
#: src/pages/admin-overview/AdminOverviewPage.ts:37
#: src/pages/applications/ApplicationViewPage.ts:71
msgid "Logins over the last 24 hours"
msgstr "Logins over the last 24 hours"
@ -1922,6 +1926,10 @@ msgstr "Not found"
msgid "Not synced in the last hour, check System tasks."
msgstr "Not synced in the last hour, check System tasks."
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:28
msgid "Not synced."
msgstr "Not synced."
#: src/flows/stages/authenticator_static/AuthenticatorStaticStage.ts:58
#: src/flows/stages/authenticator_totp/AuthenticatorTOTPStage.ts:48
#: src/flows/stages/authenticator_validate/AuthenticatorValidateStageCode.ts:45
@ -2142,7 +2150,7 @@ msgid "Please enter your password"
msgstr "Please enter your password"
#: src/interfaces/AdminInterface.ts:26
#: src/pages/admin-overview/AdminOverviewPage.ts:44
#: src/pages/admin-overview/AdminOverviewPage.ts:45
#: src/pages/flows/FlowListPage.ts:50
#: src/pages/policies/PolicyListPage.ts:38
msgid "Policies"
@ -2292,7 +2300,7 @@ msgid "Provider type"
msgstr "Provider type"
#: src/interfaces/AdminInterface.ts:20
#: src/pages/admin-overview/AdminOverviewPage.ts:42
#: src/pages/admin-overview/AdminOverviewPage.ts:43
#: src/pages/outposts/OutpostForm.ts:82
#: src/pages/outposts/OutpostListPage.ts:50
msgid "Providers"
@ -3073,7 +3081,11 @@ msgstr "Sync users"
msgid "Sync users' passwords"
msgstr "Sync users' passwords"
#: src/pages/admin-overview/AdminOverviewPage.ts:31
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:34
msgid "Synced {0}:{1}:{2}"
msgstr "Synced {0}:{1}:{2}"
#: src/pages/admin-overview/AdminOverviewPage.ts:32
msgid "System Overview"
msgstr "System Overview"
@ -3513,7 +3525,7 @@ msgid "Username: Same as Text input, but checks for and prevents duplicate usern
msgstr "Username: Same as Text input, but checks for and prevents duplicate usernames."
#: src/interfaces/AdminInterface.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:46
#: src/pages/admin-overview/AdminOverviewPage.ts:47
#: src/pages/users/UserListPage.ts:31
msgid "Users"
msgstr "Users"
@ -3546,7 +3558,7 @@ msgstr "Validity days"
msgid "Verification Certificate"
msgstr "Verification Certificate"
#: src/pages/admin-overview/AdminOverviewPage.ts:48
#: src/pages/admin-overview/AdminOverviewPage.ts:49
msgid "Version"
msgstr "Version"
@ -3646,7 +3658,7 @@ msgstr "Whoops!"
msgid "Windows"
msgstr "Windows"
#: src/pages/admin-overview/AdminOverviewPage.ts:50
#: src/pages/admin-overview/AdminOverviewPage.ts:51
msgid "Workers"
msgstr "Workers"

View File

@ -168,7 +168,7 @@ msgstr ""
msgid "Applications"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:39
#: src/pages/admin-overview/AdminOverviewPage.ts:40
msgid "Apps with most usage"
msgstr ""
@ -352,11 +352,11 @@ msgstr ""
msgid "CA which the endpoint's Certificate is verified against. Can be left empty for no validation."
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:54
#: src/pages/admin-overview/AdminOverviewPage.ts:55
msgid "Cached Flows"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:52
#: src/pages/admin-overview/AdminOverviewPage.ts:53
msgid "Cached Policies"
msgstr ""
@ -1535,6 +1535,10 @@ msgstr ""
msgid "LDAP Source {0}"
msgstr ""
#: src/pages/admin-overview/cards/LDAPSyncStatusCardContainer.ts:24
msgid "LDAP Sync status {0}"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts:90
#: src/pages/stages/prompt/PromptListPage.ts:47
msgid "Label"
@ -1657,7 +1661,7 @@ msgstr ""
msgid "Logins"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:36
#: src/pages/admin-overview/AdminOverviewPage.ts:37
#: src/pages/applications/ApplicationViewPage.ts:71
msgid "Logins over the last 24 hours"
msgstr ""
@ -1918,6 +1922,10 @@ msgstr ""
msgid "Not synced in the last hour, check System tasks."
msgstr ""
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:28
msgid "Not synced."
msgstr ""
#: src/flows/stages/authenticator_static/AuthenticatorStaticStage.ts:58
#: src/flows/stages/authenticator_totp/AuthenticatorTOTPStage.ts:48
#: src/flows/stages/authenticator_validate/AuthenticatorValidateStageCode.ts:45
@ -2138,7 +2146,7 @@ msgid "Please enter your password"
msgstr ""
#: src/interfaces/AdminInterface.ts:26
#: src/pages/admin-overview/AdminOverviewPage.ts:44
#: src/pages/admin-overview/AdminOverviewPage.ts:45
#: src/pages/flows/FlowListPage.ts:50
#: src/pages/policies/PolicyListPage.ts:38
msgid "Policies"
@ -2288,7 +2296,7 @@ msgid "Provider type"
msgstr ""
#: src/interfaces/AdminInterface.ts:20
#: src/pages/admin-overview/AdminOverviewPage.ts:42
#: src/pages/admin-overview/AdminOverviewPage.ts:43
#: src/pages/outposts/OutpostForm.ts:82
#: src/pages/outposts/OutpostListPage.ts:50
msgid "Providers"
@ -3069,7 +3077,11 @@ msgstr ""
msgid "Sync users' passwords"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:31
#: src/pages/admin-overview/cards/LDAPSyncStatusCard.ts:34
msgid "Synced {0}:{1}:{2}"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:32
msgid "System Overview"
msgstr ""
@ -3507,7 +3519,7 @@ msgid "Username: Same as Text input, but checks for and prevents duplicate usern
msgstr ""
#: src/interfaces/AdminInterface.ts:32
#: src/pages/admin-overview/AdminOverviewPage.ts:46
#: src/pages/admin-overview/AdminOverviewPage.ts:47
#: src/pages/users/UserListPage.ts:31
msgid "Users"
msgstr ""
@ -3540,7 +3552,7 @@ msgstr ""
msgid "Verification Certificate"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:48
#: src/pages/admin-overview/AdminOverviewPage.ts:49
msgid "Version"
msgstr ""
@ -3640,7 +3652,7 @@ msgstr ""
msgid "Windows"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:50
#: src/pages/admin-overview/AdminOverviewPage.ts:51
msgid "Workers"
msgstr ""

View File

@ -4,8 +4,10 @@ import { CSSResult, customElement, html, LitElement, TemplateResult } from "lit-
import "../../elements/charts/AdminLoginsChart";
import "../../elements/cards/AggregatePromiseCard";
import "./TopApplicationsTable";
import "./cards/AdminStatusCard";
import "./cards/FlowCacheStatusCard";
import "./cards/LDAPSyncStatusCardContainer";
import "./cards/PolicyCacheStatusCard";
import "./cards/PolicyUnboundStatusCard";
import "./cards/ProviderStatusCard";
@ -53,6 +55,8 @@ export class AdminOverviewPage extends LitElement {
</ak-admin-status-card-policy-cache>
<ak-admin-status-card-flow-cache class="pf-l-gallery__item pf-m-4-col" icon="pf-icon pf-icon-server" header=${t`Cached Flows`}>
</ak-admin-status-card-flow-cache>
<ak-admin-status-card-ldap-sync-container >
</ak-admin-status-card-ldap-sync-container>
</div>
</section>`;
}

View File

@ -0,0 +1,48 @@
import { t } from "@lingui/macro";
import { customElement, html, property, TemplateResult } from "lit-element";
import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
import { SourcesApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import "../../../elements/forms/ConfirmationForm";
@customElement("ak-admin-status-card-ldap-sync")
export class LDAPSyncStatusCard extends AdminStatusCard<Date | undefined> {
@property()
slug!: string;
getPrimaryValue(): Promise<Date | undefined> {
return new SourcesApi(DEFAULT_CONFIG).sourcesLdapSyncStatus({
slug: this.slug
}).then((value) => {
return value.lastSync;
});
}
renderValue(): TemplateResult {
return html`${t`Last sync: ${this.value?.toLocaleTimeString()}`}`;
}
getStatus(value: Date | undefined): Promise<AdminStatus> {
const now = new Date().getTime();
const maxDelta = 3600000; // 1 hour
if (!value || (now - value.getTime()) > maxDelta) {
// No sync or last sync was over maxDelta ago
return Promise.resolve<AdminStatus>({
icon: "fa fa-exclamation-triangle pf-m-warning",
message: t`Not synced.`,
});
} else {
return Promise.resolve<AdminStatus>({
icon: "fa fa-check-circle pf-m-success",
});
}
}
renderHeaderLink(): TemplateResult {
return html`<a href="#/core/sources/${this.slug}">
<i class="fa fa-external-link-alt"> </i>
</a>`;
}
}

View File

@ -0,0 +1,30 @@
import { SourcesApi } from "authentik-api";
import { customElement, html, LitElement, TemplateResult } from "lit-element";
import { until } from "lit-html/directives/until";
import "./LDAPSyncStatusCard";
import { t } from "@lingui/macro";
import { DEFAULT_CONFIG } from "../../../api/Config";
@customElement("ak-admin-status-card-ldap-sync-container")
export class LDAPSyncStatusCardContainer extends LitElement {
createRenderRoot(): Element | ShadowRoot {
return this;
}
render(): TemplateResult {
return html`
${until(new SourcesApi(DEFAULT_CONFIG).sourcesLdapList({}).then(sources => {
return sources.results.map(source => {
return html`<ak-admin-status-card-ldap-sync
class="pf-l-gallery__item pf-m-4-col"
icon="fa fa-sync-alt"
header=${t`LDAP Sync status ${source.name}`}
slug=${source.slug}>
</ak-admin-status-card-ldap-sync>`;
});
}))}
`;
}
}