mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-22 11:13:30 +00:00
simualtion testing from dashboard
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: 66bdf442d6...c29b53cdd6
@@ -16,10 +16,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary" [disabled]="form.loading" appBlurClick>
|
<button type="submit" class="btn btn-primary" [disabled]="form.loading" appBlurClick>
|
||||||
<span [hidden]="form.loading">
|
|
||||||
<i class="fa fa-sign-in"></i> {{'logIn' | i18n}}
|
|
||||||
</span>
|
|
||||||
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
||||||
|
{{'logIn' | i18n}}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-link" (click)="settings()" appBlurClick>
|
<button type="button" class="btn btn-link" (click)="settings()" appBlurClick>
|
||||||
{{'settings' | i18n}}
|
{{'settings' | i18n}}
|
||||||
|
|||||||
@@ -43,10 +43,8 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
<button type="submit" class="btn btn-primary" [disabled]="form.loading" appBlurClick *ngIf="selectedProviderType != null && selectedProviderType !== providerType.U2f && selectedProviderType !== providerType.Duo &&
|
<button type="submit" class="btn btn-primary" [disabled]="form.loading" appBlurClick *ngIf="selectedProviderType != null && selectedProviderType !== providerType.U2f && selectedProviderType !== providerType.Duo &&
|
||||||
selectedProviderType !== providerType.OrganizationDuo">
|
selectedProviderType !== providerType.OrganizationDuo">
|
||||||
<span [hidden]="form.loading">
|
|
||||||
<i class="fa fa-sign-in"></i> {{'continue' | i18n}}
|
|
||||||
</span>
|
|
||||||
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
||||||
|
{{'continue' | i18n}}
|
||||||
</button>
|
</button>
|
||||||
<a routerLink="/login" class="btn btn-link">{{'cancel' | i18n}}</a>
|
<a routerLink="/login" class="btn btn-link">{{'cancel' | i18n}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,51 @@
|
|||||||
<button (click)="sync()">Sync</button>
|
<div class="card mb-3">
|
||||||
<button (click)="simulate()">Simulate</button>
|
<h3 class="card-header">{{'sync' | i18n}}</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
<button #syncBtn (click)="sync()" [appApiAction]="syncPromise" class="btn btn-primary" [disabled]="syncBtn.loading">
|
||||||
|
<i class="fa fa-spinner fa-spin" [hidden]="!syncBtn.loading"></i>
|
||||||
|
{{'sync' | i18n}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3 class="card-header">Testing</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
<button #simBtn (click)="simulate()" [appApiAction]="simPromise" class="btn btn-primary" [disabled]="simBtn.loading">
|
||||||
|
<i class="fa fa-spinner fa-spin" [hidden]="!simBtn.loading"></i>
|
||||||
|
Simulate
|
||||||
|
</button>
|
||||||
|
<div class="form-check mt-2">
|
||||||
|
<input class="form-check-input" type="checkbox" id="sinceLast" [(ngModel)]="sinceLast">
|
||||||
|
<label class="form-check-label" for="sinceLast">Since the last successful sync</label>
|
||||||
|
</div>
|
||||||
|
<ng-container *ngIf="!simBtn.loading && (simUsers || simGroups)">
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg">
|
||||||
|
<h4>Users</h4>
|
||||||
|
<ul class="fa-ul testing-list" *ngIf="simUsers && simUsers.length">
|
||||||
|
<li *ngFor="let u of simUsers" [ngClass]="{'deleted': u.deleted}" title="{{u.referenceId}}">
|
||||||
|
<i class="fa-li fa fa-user"></i>
|
||||||
|
{{u.displayName}}
|
||||||
|
<i class="fa fa-minus-circle" *ngIf="u.disabled"></i>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p *ngIf="!simUsers || !simUsers.length">No users to list.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">
|
||||||
|
<h4>Groups</h4>
|
||||||
|
<ul class="fa-ul testing-list" *ngIf="simGroups && simGroups.length">
|
||||||
|
<li *ngFor="let g of simGroups" title="{{g.referenceId}}">
|
||||||
|
<i class="fa-li fa fa-sitemap"></i>
|
||||||
|
{{g.displayName}}
|
||||||
|
<ul class="small" *ngIf="g.users && g.users.length">
|
||||||
|
<li *ngFor="let u of g.users" title="{{u.referenceId}}">{{u.displayName}}</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p *ngIf="!simGroups || !simGroups.length">No groups to list.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -7,18 +7,61 @@ import { GSuiteDirectoryService } from '../../services/gsuite-directory.service'
|
|||||||
import { LdapDirectoryService } from '../../services/ldap-directory.service';
|
import { LdapDirectoryService } from '../../services/ldap-directory.service';
|
||||||
import { SyncService } from '../../services/sync.service';
|
import { SyncService } from '../../services/sync.service';
|
||||||
|
|
||||||
|
import { GroupEntry } from '../../models/groupEntry';
|
||||||
|
import { UserEntry } from '../../models/userEntry';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
templateUrl: 'dashboard.component.html',
|
templateUrl: 'dashboard.component.html',
|
||||||
})
|
})
|
||||||
export class DashboardComponent {
|
export class DashboardComponent {
|
||||||
|
simGroups: GroupEntry[];
|
||||||
|
simUsers: UserEntry[];
|
||||||
|
simPromise: Promise<any>;
|
||||||
|
syncPromise: Promise<any>;
|
||||||
|
sinceLast: boolean = false;
|
||||||
|
|
||||||
constructor(private i18nService: I18nService, private syncService: SyncService) { }
|
constructor(private i18nService: I18nService, private syncService: SyncService) { }
|
||||||
|
|
||||||
async sync() {
|
async sync() {
|
||||||
await this.syncService.sync(false, true);
|
this.syncPromise = this.syncService.sync(false, true);
|
||||||
|
await this.syncPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
async simulate() {
|
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<string, UserEntry>();
|
||||||
|
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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,12 @@ export class GroupEntry extends Entry {
|
|||||||
name: string;
|
name: string;
|
||||||
userMemberExternalIds = new Set<string>();
|
userMemberExternalIds = new Set<string>();
|
||||||
groupMemberReferenceIds = new Set<string>();
|
groupMemberReferenceIds = new Set<string>();
|
||||||
|
|
||||||
|
get displayName(): string {
|
||||||
|
if (this.name == null) {
|
||||||
|
return this.referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,12 @@ export class UserEntry extends Entry {
|
|||||||
email: string;
|
email: string;
|
||||||
disabled = false;
|
disabled = false;
|
||||||
deleted = false;
|
deleted = false;
|
||||||
|
|
||||||
|
get displayName(): string {
|
||||||
|
if (this.email == null) {
|
||||||
|
return this.referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.email;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,3 +47,13 @@ app-root > #loading {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: $text-muted;
|
color: $text-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.testing-list {
|
||||||
|
ul {
|
||||||
|
padding-left: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.deleted {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ export class AzureDirectoryService implements DirectoryService {
|
|||||||
while (true) {
|
while (true) {
|
||||||
const groups: graphType.Group[] = res.value;
|
const groups: graphType.Group[] = res.value;
|
||||||
if (groups != null) {
|
if (groups != null) {
|
||||||
groups.forEach(async (group) => {
|
for (const group of groups) {
|
||||||
if (getFullResults) {
|
if (getFullResults) {
|
||||||
if (this.filterOutResult(setFilter, group.displayName)) {
|
if (this.filterOutResult(setFilter, group.displayName)) {
|
||||||
return;
|
return;
|
||||||
@@ -175,7 +175,7 @@ export class AzureDirectoryService implements DirectoryService {
|
|||||||
} else {
|
} else {
|
||||||
changedGroupIds.push(group.id);
|
changedGroupIds.push(group.id);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res[NextLink] == null) {
|
if (res[NextLink] == null) {
|
||||||
@@ -201,14 +201,14 @@ export class AzureDirectoryService implements DirectoryService {
|
|||||||
while (true) {
|
while (true) {
|
||||||
const allGroups: graphType.Group[] = res.value;
|
const allGroups: graphType.Group[] = res.value;
|
||||||
if (allGroups != null) {
|
if (allGroups != null) {
|
||||||
allGroups.forEach(async (group) => {
|
for (const group of allGroups) {
|
||||||
if (this.filterOutResult(setFilter, group.displayName)) {
|
if (this.filterOutResult(setFilter, group.displayName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = await this.buildGroup(group);
|
const entry = await this.buildGroup(group);
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res[NextLink] == null) {
|
if (res[NextLink] == null) {
|
||||||
|
|||||||
@@ -137,14 +137,14 @@ export class GSuiteDirectoryService implements DirectoryService {
|
|||||||
|
|
||||||
const filter = this.createSet(this.syncConfig.groupFilter);
|
const filter = this.createSet(this.syncConfig.groupFilter);
|
||||||
if (res.data.groups != null) {
|
if (res.data.groups != null) {
|
||||||
res.data.groups.forEach(async (group) => {
|
for (const group of res.data.groups) {
|
||||||
if (this.filterOutResult(filter, group.name)) {
|
if (this.filterOutResult(filter, group.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = await this.buildGroup(group);
|
const entry = await this.buildGroup(group);
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
|
|||||||
Reference in New Issue
Block a user