diff --git a/jslib b/jslib index 66bdf442..c29b53cd 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 66bdf442d6f809487f674fecae325ddef0c8470f +Subproject commit c29b53cdd62369de59f6ae483b78b9bcc67d9238 diff --git a/src/app/accounts/login.component.html b/src/app/accounts/login.component.html index d9710893..2117c8df 100644 --- a/src/app/accounts/login.component.html +++ b/src/app/accounts/login.component.html @@ -16,10 +16,8 @@ - - {{'logIn' | i18n}} - + {{'logIn' | i18n}} {{'settings' | i18n}} diff --git a/src/app/accounts/two-factor.component.html b/src/app/accounts/two-factor.component.html index 528b2658..4c370f5d 100644 --- a/src/app/accounts/two-factor.component.html +++ b/src/app/accounts/two-factor.component.html @@ -43,10 +43,8 @@ - - {{'continue' | i18n}} - + {{'continue' | i18n}} {{'cancel' | i18n}} diff --git a/src/app/tabs/dashboard.component.html b/src/app/tabs/dashboard.component.html index 81345fca..d5ecb1af 100644 --- a/src/app/tabs/dashboard.component.html +++ b/src/app/tabs/dashboard.component.html @@ -1,2 +1,51 @@ -Sync -Simulate + + {{'sync' | i18n}} + + + + {{'sync' | i18n}} + + + + + Testing + + + + Simulate + + + + Since the last successful sync + + + + + + Users + + + + {{u.displayName}} + + + + No users to list. + + + Groups + + + + {{g.displayName}} + + {{u.displayName}} + + + + No groups to list. + + + + + diff --git a/src/app/tabs/dashboard.component.ts b/src/app/tabs/dashboard.component.ts index 24b4cf87..a1c2e88b 100644 --- a/src/app/tabs/dashboard.component.ts +++ b/src/app/tabs/dashboard.component.ts @@ -7,18 +7,61 @@ import { GSuiteDirectoryService } from '../../services/gsuite-directory.service' import { LdapDirectoryService } from '../../services/ldap-directory.service'; import { SyncService } from '../../services/sync.service'; +import { GroupEntry } from '../../models/groupEntry'; +import { UserEntry } from '../../models/userEntry'; + @Component({ selector: 'app-dashboard', templateUrl: 'dashboard.component.html', }) export class DashboardComponent { + simGroups: GroupEntry[]; + simUsers: UserEntry[]; + simPromise: Promise; + syncPromise: Promise; + sinceLast: boolean = false; + constructor(private i18nService: I18nService, private syncService: SyncService) { } async sync() { - await this.syncService.sync(false, true); + this.syncPromise = this.syncService.sync(false, true); + await this.syncPromise; } async simulate() { - await this.syncService.sync(true, false); + this.simPromise = new Promise(async (resolve, reject) => { + try { + const result = await this.syncService.sync(!this.sinceLast, false); + this.simUsers = result[1]; + this.simGroups = result[0]; + } catch (e) { + reject(e || 'Sync error.'); + } + + const userMap = new Map(); + if (this.simUsers != null) { + this.simUsers.forEach((u) => { + userMap.set(u.externalId, u); + }); + } + + if (userMap.size > 0 && this.simGroups != null) { + this.simGroups.forEach((g) => { + if (g.userMemberExternalIds == null) { + return; + } + + g.userMemberExternalIds.forEach((uid) => { + if (userMap.has(uid)) { + if ((g as any).users == null) { + (g as any).users = []; + } + (g as any).users.push(userMap.get(uid)); + } + }); + }); + } + resolve(); + }); } } diff --git a/src/models/groupEntry.ts b/src/models/groupEntry.ts index 12169692..207699a6 100644 --- a/src/models/groupEntry.ts +++ b/src/models/groupEntry.ts @@ -4,4 +4,12 @@ export class GroupEntry extends Entry { name: string; userMemberExternalIds = new Set(); groupMemberReferenceIds = new Set(); + + get displayName(): string { + if (this.name == null) { + return this.referenceId; + } + + return this.name; + } } diff --git a/src/models/userEntry.ts b/src/models/userEntry.ts index 51c5e2b5..a0ca272e 100644 --- a/src/models/userEntry.ts +++ b/src/models/userEntry.ts @@ -4,4 +4,12 @@ export class UserEntry extends Entry { email: string; disabled = false; deleted = false; + + get displayName(): string { + if (this.email == null) { + return this.referenceId; + } + + return this.email; + } } diff --git a/src/scss/misc.scss b/src/scss/misc.scss index 1af1b43c..5497b1fd 100644 --- a/src/scss/misc.scss +++ b/src/scss/misc.scss @@ -47,3 +47,13 @@ app-root > #loading { margin-top: 20px; color: $text-muted; } + +ul.testing-list { + ul { + padding-left: 18px; + } + + li.deleted { + text-decoration: line-through; + } +} diff --git a/src/services/azure-directory.service.ts b/src/services/azure-directory.service.ts index eb1e0f2e..4cfa30e8 100644 --- a/src/services/azure-directory.service.ts +++ b/src/services/azure-directory.service.ts @@ -164,7 +164,7 @@ export class AzureDirectoryService implements DirectoryService { while (true) { const groups: graphType.Group[] = res.value; if (groups != null) { - groups.forEach(async (group) => { + for (const group of groups) { if (getFullResults) { if (this.filterOutResult(setFilter, group.displayName)) { return; @@ -175,7 +175,7 @@ export class AzureDirectoryService implements DirectoryService { } else { changedGroupIds.push(group.id); } - }); + } } if (res[NextLink] == null) { @@ -201,14 +201,14 @@ export class AzureDirectoryService implements DirectoryService { while (true) { const allGroups: graphType.Group[] = res.value; if (allGroups != null) { - allGroups.forEach(async (group) => { + for (const group of allGroups) { if (this.filterOutResult(setFilter, group.displayName)) { return; } const entry = await this.buildGroup(group); entries.push(entry); - }); + } } if (res[NextLink] == null) { diff --git a/src/services/gsuite-directory.service.ts b/src/services/gsuite-directory.service.ts index 3bac0ef0..940550f2 100644 --- a/src/services/gsuite-directory.service.ts +++ b/src/services/gsuite-directory.service.ts @@ -137,14 +137,14 @@ export class GSuiteDirectoryService implements DirectoryService { const filter = this.createSet(this.syncConfig.groupFilter); if (res.data.groups != null) { - res.data.groups.forEach(async (group) => { + for (const group of res.data.groups) { if (this.filterOutResult(filter, group.name)) { return; } const entry = await this.buildGroup(group); entries.push(entry); - }); + } } return entries;
No users to list.
No groups to list.