diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/clients-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/clients-table-config.resolver.ts index 4fab82971f..d1d760d908 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/clients-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/clients-table-config.resolver.ts @@ -81,7 +81,7 @@ export class ClientsTableConfigResolver implements Resolve this.oauth2Service.findTenantOAuth2ClientInfos(pageLink); this.config.loadEntity = id => this.oauth2Service.getOAuth2ClientById(id.id); this.config.saveEntity = client => { - return this.oauth2Service.saveOAuth2Client(client as OAuth2Client); + return this.oauth2Service.saveOAuth2Client(client); } this.config.deleteEntity = id => this.oauth2Service.deleteOauth2Client(id.id); } diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain-table-config.resolver.ts index a3cc535d62..4bccc41dc7 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain-table-config.resolver.ts @@ -23,7 +23,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import { Domain, DomainInfo } from '@shared/models/oauth2.models'; +import { DomainInfo } from '@shared/models/oauth2.models'; import { UtilsService } from '@core/services/utils.service'; import { TranslateService } from '@ngx-translate/core'; import { DatePipe } from '@angular/common'; @@ -33,6 +33,7 @@ import { DomainComponent } from '@home/pages/admin/oauth2/domains/domain.compone import { isEqual } from '@core/utils'; import { DomainTableHeaderComponent } from '@home/pages/admin/oauth2/domains/domain-table-header.component'; import { Direction } from '@app/shared/models/page/sort-order'; +import { map } from 'rxjs'; @Injectable() export class DomainTableConfigResolver implements Resolve> { @@ -88,11 +89,17 @@ export class DomainTableConfigResolver implements Resolve this.domainService.getDomainInfoById(id.id); this.config.saveEntity = (domain, originalDomain) => { const clientsIds = domain.oauth2ClientInfos as Array || []; - if (domain.id && !isEqual(domain.oauth2ClientInfos?.sort(), originalDomain.oauth2ClientInfos?.map(info => info.id.id).sort())) { + if (domain.id && !isEqual(domain.oauth2ClientInfos?.sort(), + originalDomain.oauth2ClientInfos?.map(info => info.id ? info.id.id : info).sort())) { this.domainService.updateOauth2Clients(domain.id.id, clientsIds).subscribe(); } delete domain.oauth2ClientInfos; - return this.domainService.saveDomain(domain as Domain, domain.id ? [] : clientsIds); + return this.domainService.saveDomain(domain, domain.id ? [] : clientsIds).pipe( + map(domain => { + (domain as DomainInfo).oauth2ClientInfos = clientsIds; + return domain; + }) + ); } this.config.deleteEntity = id => this.domainService.deleteDomain(id.id); } diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain.component.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain.component.ts index 853bf17e06..d54c969bfe 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/domains/domain.component.ts @@ -73,9 +73,9 @@ export class DomainComponent extends EntityComponent { this.entityForm.patchValue({ name: entity.name, oauth2Enabled: entity.oauth2Enabled, - oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id.id), + oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id ? info.id.id : info), propagateToEdge: entity.propagateToEdge - }) + }); } redirectURI(): string { diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-config.resolver.ts index b4c6c7576d..7585cfff46 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-config.resolver.ts @@ -34,6 +34,7 @@ import { Direction } from '@app/shared/models/page/sort-order'; import { MobileAppService } from '@core/http/mobile-app.service'; import { MobileAppComponent } from '@home/pages/admin/oauth2/mobile-apps/mobile-app.component'; import { MobileAppTableHeaderComponent } from '@home/pages/admin/oauth2/mobile-apps/mobile-app-table-header.component'; +import { map } from 'rxjs'; @Injectable() export class MobileAppTableConfigResolver implements Resolve> { @@ -94,11 +95,17 @@ export class MobileAppTableConfigResolver implements Resolve this.mobileAppService.getMobileAppInfoById(id.id); this.config.saveEntity = (mobileApp, originalMobileApp) => { const clientsIds = mobileApp.oauth2ClientInfos as Array || []; - if (mobileApp.id && !isEqual(mobileApp.oauth2ClientInfos?.sort(), originalMobileApp.oauth2ClientInfos?.map(info => info.id.id).sort())) { + if (mobileApp.id && !isEqual(mobileApp.oauth2ClientInfos?.sort(), + originalMobileApp.oauth2ClientInfos?.map(info => info.id ? info.id.id : info).sort())) { this.mobileAppService.updateOauth2Clients(mobileApp.id.id, clientsIds).subscribe(); } delete mobileApp.oauth2ClientInfos; - return this.mobileAppService.saveMobileApp(mobileApp as MobileApp, mobileApp.id ? [] : clientsIds); + return this.mobileAppService.saveMobileApp(mobileApp as MobileApp, mobileApp.id ? [] : clientsIds).pipe( + map(mobileApp => { + (mobileApp as MobileAppInfo).oauth2ClientInfos = clientsIds; + return mobileApp; + }) + ); } this.config.deleteEntity = id => this.mobileAppService.deleteMobileApp(id.id); } diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.ts index 0baa72f5f7..2cca292fc3 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.ts @@ -67,7 +67,7 @@ export class MobileAppComponent extends EntityComponent { pkgName: entity.pkgName, appSecret: entity.appSecret, oauth2Enabled: entity.oauth2Enabled, - oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id.id) + oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id ? info.id.id : info) }) }