web/admin: fix ldap sync status for new API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-17 16:46:18 +02:00
parent b775e7f4d3
commit 763d3ae76a
1 changed files with 13 additions and 11 deletions

View File

@ -38,19 +38,21 @@ export class LDAPSyncStatusChart extends AKChart<LDAPSyncStats> {
await Promise.all( await Promise.all(
sources.results.map(async (element) => { sources.results.map(async (element) => {
try { try {
const health = await api.sourcesLdapSyncStatusRetrieve({ const health = await api.sourcesLdapSyncStatusList({
slug: element.slug, slug: element.slug,
}); });
if (health.status !== StatusEnum.Successful) { health.forEach(task => {
failed += 1; if (task.status !== StatusEnum.Successful) {
} failed += 1;
const now = new Date().getTime(); }
const maxDelta = 3600000; // 1 hour const now = new Date().getTime();
if (!health || now - health.taskFinishTimestamp.getTime() > maxDelta) { const maxDelta = 3600000; // 1 hour
unsynced += 1; if (!health || now - task.taskFinishTimestamp.getTime() > maxDelta) {
} else { unsynced += 1;
healthy += 1; } else {
} healthy += 1;
}
})
} catch { } catch {
unsynced += 1; unsynced += 1;
} }