sources/ldap: only save sync state in TaskInfo, return TaskInfo in API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-04-08 23:20:48 +02:00
parent 7b0005ac42
commit d37c33d941
9 changed files with 148 additions and 102 deletions

View File

@ -22,7 +22,7 @@ import "../../../elements/forms/ModalForm";
import "./LDAPSourceForm";
import { Page } from "../../../elements/Page";
import { until } from "lit-html/directives/until";
import { LDAPSource, SourcesApi } from "authentik-api";
import { LDAPSource, SourcesApi, TaskStatusEnum } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import { EVENT_REFRESH } from "../../../constants";
@ -143,16 +143,28 @@ export class LDAPSourceViewPage extends Page {
<p>${t`Sync status`}</p>
</div>
<div class="pf-c-card__body">
<p>
${until(new SourcesApi(DEFAULT_CONFIG).sourcesLdapSyncStatus({
slug: this.source.slug
}).then((ls) => {
if (!ls.lastSync) {
return t`Not synced in the last hour, check System tasks.`;
let header = html``;
if (ls.status === TaskStatusEnum.Warning) {
header = html`<p>${t`Task finished with warnings`}</p>`;
} else if (status === TaskStatusEnum.Error) {
header = html`<p>${t`Task finished with errors`}</p>`;
} else {
header = html`<p>${t`Last sync: ${ls.taskFinishTimestamp.toLocaleString()}`}</p>`;
}
return t`Last sync: ${ls.lastSync.toLocaleString()}`;
return html`
${header}
<ul>
${ls.messages.map(m => {
return html`<li>${m}</li>`;
})}
</ul>
`;
}).catch(() => {
return html`<p>${t`Not synced yet.`}</p>`;
}), "loading")}
</p>
</div>
<div class="pf-c-card__footer">
<ak-action-button