diff --git a/src/app/shared/users/list/userslist.component.ts b/src/app/shared/users/list/userslist.component.ts index 6115bb3588203fe47b6ff244521cfd992aa9e4a4..13b3a39cdf42b5de19cc948bd52fbed0fdc1ef64 100644 --- a/src/app/shared/users/list/userslist.component.ts +++ b/src/app/shared/users/list/userslist.component.ts @@ -8,7 +8,7 @@ import {Observable, of} from 'rxjs'; import {Role, UserRole} from '../../../model/userrole'; import {UserDataService} from '../../../service/userdata.service'; import {AuthService} from '../../../auth/auth.service'; -import {map, shareReplay, take} from 'rxjs/operators'; +import {debounceTime, map, shareReplay, take} from 'rxjs/operators'; import {UntypedFormControl} from '@angular/forms'; import {ComponentMode} from '../../common/componentmode'; import {Router} from '@angular/router'; @@ -93,23 +93,28 @@ export class UsersListComponent extends BaseComponent implements OnInit, OnChang ) this.userDataService.selectedDomainId.subscribe(domain => this.domainId = domain); + this.getAllDomain(); + } ngOnChanges(changes: SimpleChanges): void { this.displayUsers = this.users; + // this.getAllDomain(); + } + + public getAllDomain() { + this.domainService.getAll().subscribe(domains => { + domains.forEach(domain => { + this.domainCache.setData(domain.id, domain) + }) + }) } public getDomainName(domainId: number): Observable<string> { if (this.domainCache.hasData(domainId)) { return of(this.domainCache.getData(domainId).name); } else { - return this.domainService.getOne(domainId).pipe( - map((domain) => { - this.domainCache.setData(domainId, domain); - return domain.name - }), - shareReplay(1), - take(1)); + return new Observable<string>() } } diff --git a/src/app/shared/users/privileges/userprivileges.component.ts b/src/app/shared/users/privileges/userprivileges.component.ts index b7b2423f50c79543347d9d25abf110e7f79f3297..1f65591f962ddcdc5b7ba0f63feaec5a576cc64b 100644 --- a/src/app/shared/users/privileges/userprivileges.component.ts +++ b/src/app/shared/users/privileges/userprivileges.component.ts @@ -10,7 +10,7 @@ import {UntypedFormBuilder, UntypedFormGroup, Validators} from '@angular/forms'; import {Observable, of} from 'rxjs'; import {CacheService} from '../../../service/cache.service'; import {UserDataService} from '../../../service/userdata.service'; -import {map, shareReplay, take} from 'rxjs/operators'; +import {debounceTime, map, shareReplay, take} from 'rxjs/operators'; @Component({ selector: 'nmaas-userprivileges', @@ -103,6 +103,15 @@ export class UserPrivilegesComponent extends BaseComponent implements OnInit { this.domainService.getOne(domainId).subscribe((domain) => this.domains.push(domain)); }); } + this.getAllDomain(); + } + + public getAllDomain() { + this.domainService.getAll().subscribe(domains => { + domains.forEach(domain => { + if (!this.domainCache.hasData(domain.id)) this.domainCache.setData(domain.id, domain) + }) + }) } public add(): void { @@ -124,14 +133,6 @@ export class UserPrivilegesComponent extends BaseComponent implements OnInit { public getDomainName(domainId: number): Observable<string> { if (this.domainCache.hasData(domainId)) { return of(this.domainCache.getData(domainId).name); - } else { - return this.domainService.getOne(domainId).pipe( - map((domain) => { - this.domainCache.setData(domainId, domain); - return domain.name - }), - shareReplay(1), - take(1)); } }