diff --git a/ui-ngx/src/app/core/http/domain.service.ts b/ui-ngx/src/app/core/http/domain.service.ts index 206748378e..bb6cd4a16b 100644 --- a/ui-ngx/src/app/core/http/domain.service.ts +++ b/ui-ngx/src/app/core/http/domain.service.ts @@ -37,8 +37,8 @@ export class DomainService { domain, defaultHttpOptionsFromConfig(config)); } - public updateOauth2Clients(id: string, oauth2ClientRegistrationIds: Array, config?: RequestConfig): Observable { - return this.http.put(`/api/domain/${id}/oauth2Clients`, oauth2ClientRegistrationIds, defaultHttpOptionsFromConfig(config)); + public updateOauth2Clients(id: string, oauth2ClientIds: Array, config?: RequestConfig): Observable { + return this.http.put(`/api/domain/${id}/oauth2Clients`, oauth2ClientIds, defaultHttpOptionsFromConfig(config)); } public getTenantDomainInfos(pageLink: PageLink, config?: RequestConfig): Observable> { diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index b5b2b0e796..bc0d810a05 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -96,6 +96,7 @@ import { NotificationType } from '@shared/models/notification.models'; import { UserId } from '@shared/models/id/user-id'; import { AlarmService } from '@core/http/alarm.service'; import { ResourceService } from '@core/http/resource.service'; +import { OAuth2Service } from '@core/http/oauth2.service'; @Injectable({ providedIn: 'root' @@ -125,7 +126,8 @@ export class EntityService { private queueService: QueueService, private notificationService: NotificationService, private alarmService: AlarmService, - private resourceService: ResourceService + private resourceService: ResourceService, + private oauth2Service: OAuth2Service ) { } private getEntityObservable(entityType: EntityType, entityId: string, @@ -272,6 +274,9 @@ export class EntityService { case EntityType.QUEUE_STATS: observable = this.queueService.getQueueStatisticsByIds(entityIds, config); break; + case EntityType.OAUTH2_CLIENT: + observable = this.oauth2Service.findTenantOAuth2ClientInfosByIds(entityIds, config); + break; } return observable; } @@ -452,6 +457,11 @@ export class EntityService { case EntityType.QUEUE_STATS: pageLink.sortOrder.property = 'createdTime'; entitiesObservable = this.queueService.getQueueStatistics(pageLink, config); + break; + case EntityType.OAUTH2_CLIENT: + pageLink.sortOrder.property = 'createdTime'; + entitiesObservable = this.oauth2Service.findTenantOAuth2ClientInfos(pageLink, config); + break; } return entitiesObservable; } diff --git a/ui-ngx/src/app/core/http/oauth2.service.ts b/ui-ngx/src/app/core/http/oauth2.service.ts index 14b853eb93..73a8743a48 100644 --- a/ui-ngx/src/app/core/http/oauth2.service.ts +++ b/ui-ngx/src/app/core/http/oauth2.service.ts @@ -44,6 +44,10 @@ export class OAuth2Service { return this.http.get>(`/api/oauth2/client/infos${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config)); } + public findTenantOAuth2ClientInfosByIds(clientIds: Array, config?: RequestConfig): Observable> { + return this.http.get>(`/api/oauth2/client/infos?clientIds=${clientIds.join(',')}`, defaultHttpOptionsFromConfig(config)) + } + public getOAuth2ClientById(id: string, config?: RequestConfig): Observable { return this.http.get(`/api/oauth2/client/${id}`, defaultHttpOptionsFromConfig(config)); } diff --git a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html index 952e117539..9bf9443404 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html @@ -38,9 +38,7 @@
- - {{ entitiesTableConfig.tableTitle }} - + {{ entitiesTableConfig.tableTitle }} - - + + diff --git a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts index a37b22826b..3ba37d2564 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts @@ -46,8 +46,8 @@ import { ActivatedRoute, QueryParamsHandling, Router } from '@angular/router'; import { CellActionDescriptor, CellActionDescriptorType, - ClientChipsEntityTableColumn, EntityActionTableColumn, + EntityChipsEntityTableColumn, EntityColumn, EntityLinkTableColumn, EntityTableColumn, @@ -616,7 +616,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa columnsUpdated(resetData: boolean = false) { this.entityColumns = this.entitiesTableConfig.columns.filter( (column) => column instanceof EntityTableColumn || column instanceof EntityLinkTableColumn || - column instanceof ClientChipsEntityTableColumn) + column instanceof EntityChipsEntityTableColumn) .map(column => column as EntityTableColumn>); this.actionColumns = this.entitiesTableConfig.columns.filter( (column) => column instanceof EntityActionTableColumn) diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.html b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html similarity index 76% rename from ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.html rename to ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html index 5a1c87b29e..c81857689f 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html @@ -16,7 +16,7 @@ --> - - {{ client.title }} + + {{ subEntity.name }} diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.scss b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss similarity index 97% rename from ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.scss rename to ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss index 6c489effd0..72098fff51 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.scss +++ b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss @@ -19,7 +19,7 @@ flex-wrap: wrap; gap: 8px; margin: 4px 0; - a.tb-client-chip { + a.tb-entity-chip { padding: 4px 8px; border-radius: 12px; line-height: 16px; diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.ts new file mode 100644 index 0000000000..cd9be9d79d --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.ts @@ -0,0 +1,63 @@ +/// +/// Copyright © 2016-2024 The Thingsboard Authors +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +import { Component, Input } from '@angular/core'; +import { BaseData } from '@shared/models/base-data'; +import { EntityId } from '@shared/models/id/entity-id'; +import { baseDetailsPageByEntityType, EntityType } from '@app/shared/public-api'; + +const entityTypeEntitiesPropertyKeyMap = new Map([ + [EntityType.DOMAIN, 'oauth2ClientInfos'], + [EntityType.MOBILE_APP, 'oauth2ClientInfos'] +]); + +@Component({ + selector: 'tb-entity-chips', + templateUrl: './entity-chips.component.html', + styleUrls: ['./entity-chips.component.scss'] +}) +export class EntityChipsComponent { + + @Input() + set entity(value: BaseData) { + this.entityValue = value; + this.update(); + } + + get entity(): BaseData { + return this.entityValue; + } + + entityDetailsPrefixUrl: string; + + subEntities: Array>; + + private entityValue?: BaseData; + + private subEntitiesKey: string; + + update(): void { + if (this.entity && this.entity.id) { + const entityType = this.entity.id.entityType as EntityType; + this.subEntitiesKey = entityTypeEntitiesPropertyKeyMap.get(entityType); + this.subEntities = this.entity?.[this.subEntitiesKey]; + if (this.subEntities.length) { + this.entityDetailsPrefixUrl = baseDetailsPageByEntityType.get(this.subEntities[0].id.entityType as EntityType); + } + } + } + +} diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts index 7afbeafad4..ea1dfbf46d 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts @@ -228,7 +228,7 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV } hideDetailsTabs(): boolean { - return this.entitiesTableConfig.hideDetailsTabs || this.isEditValue && this.entitiesTableConfig.hideDetailsTabsOnEdit; + return this.isEditValue && this.entitiesTableConfig.hideDetailsTabsOnEdit; } reloadEntity(): Observable> { diff --git a/ui-ngx/src/app/modules/home/components/home-components.module.ts b/ui-ngx/src/app/modules/home/components/home-components.module.ts index 74fb826715..9cf8778710 100644 --- a/ui-ngx/src/app/modules/home/components/home-components.module.ts +++ b/ui-ngx/src/app/modules/home/components/home-components.module.ts @@ -171,7 +171,7 @@ import { import { WidgetConfigComponentsModule } from '@home/components/widget/config/widget-config-components.module'; import { BasicWidgetConfigModule } from '@home/components/widget/config/basic/basic-widget-config.module'; import { DeleteTimeseriesPanelComponent } from '@home/components/attribute/delete-timeseries-panel.component'; -import { ClientChipsComponent } from '@home/pages/admin/oauth2/clients/client-chips.component'; +import { EntityChipsComponent } from '@home/components/entity/entity-chips.component'; @NgModule({ declarations: @@ -310,7 +310,7 @@ import { ClientChipsComponent } from '@home/pages/admin/oauth2/clients/client-ch RateLimitsTextComponent, RateLimitsDetailsDialogComponent, SendNotificationButtonComponent, - ClientChipsComponent + EntityChipsComponent ], imports: [ CommonModule, @@ -441,7 +441,8 @@ import { ClientChipsComponent } from '@home/pages/admin/oauth2/clients/client-ch RateLimitsComponent, RateLimitsTextComponent, RateLimitsDetailsDialogComponent, - SendNotificationButtonComponent + SendNotificationButtonComponent, + EntityChipsComponent ], providers: [ WidgetComponentService, diff --git a/ui-ngx/src/app/modules/home/models/entity/entities-table-config.models.ts b/ui-ngx/src/app/modules/home/models/entity/entities-table-config.models.ts index b342fd2e06..417c89434f 100644 --- a/ui-ngx/src/app/modules/home/models/entity/entities-table-config.models.ts +++ b/ui-ngx/src/app/modules/home/models/entity/entities-table-config.models.ts @@ -78,7 +78,7 @@ export interface HeaderActionDescriptor { onAction: ($event: MouseEvent) => void; } -export type EntityTableColumnType = 'content' | 'action' | 'link' | 'clients'; +export type EntityTableColumnType = 'content' | 'action' | 'link' | 'entityChips'; export class BaseEntityTableColumn> { constructor(public type: EntityTableColumnType, @@ -141,15 +141,15 @@ export class DateEntityTableColumn> extends EntityTabl } } -export class ClientChipsEntityTableColumn> extends BaseEntityTableColumn { +export class EntityChipsEntityTableColumn> extends BaseEntityTableColumn { constructor(public key: string, public title: string, public width: string = '0px') { - super('clients', key, title, width, false); + super('entityChips', key, title, width, false); } } -export type EntityColumn> = EntityTableColumn | EntityActionTableColumn | EntityLinkTableColumn | ClientChipsEntityTableColumn; +export type EntityColumn> = EntityTableColumn | EntityActionTableColumn | EntityLinkTableColumn | EntityChipsEntityTableColumn; export class EntityTableConfig, P extends PageLink = PageLink, L extends BaseData = T> { @@ -167,13 +167,11 @@ export class EntityTableConfig, P extends PageLink = P defaultTimewindowInterval = historyInterval(DAY); entityType: EntityType = null; tableTitle = ''; - hideTableTitle = false; selectionEnabled = true; searchEnabled = true; addEnabled = true; entitiesDeleteEnabled = true; detailsPanelEnabled = true; - hideDetailsTabs = false; hideDetailsTabsOnEdit = true; rowPointer = false; actionsColumnTitle = null; diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.ts deleted file mode 100644 index 24611fa581..0000000000 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-chips.component.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -/// Copyright © 2016-2024 The Thingsboard Authors -/// -/// Licensed under the Apache License, Version 2.0 (the "License"); -/// you may not use this file except in compliance with the License. -/// You may obtain a copy of the License at -/// -/// http://www.apache.org/licenses/LICENSE-2.0 -/// -/// Unless required by applicable law or agreed to in writing, software -/// distributed under the License is distributed on an "AS IS" BASIS, -/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -/// See the License for the specific language governing permissions and -/// limitations under the License. -/// - -import { Component, Input } from '@angular/core'; -import { HasOauth2Clients } from '@shared/models/oauth2.models'; - -@Component({ - selector: 'tb-client-chips', - templateUrl: './client-chips.component.html', - styleUrls: ['./client-chips.component.scss'] -}) -export class ClientChipsComponent { - - clientsEntityValue?: HasOauth2Clients; - - clientPrefixUrl = '/security-settings/oauth2/clients/details/'; - - @Input() - set clientsEntity(value: HasOauth2Clients) { - this.clientsEntityValue = value; - } - - get clientsEntity(): HasOauth2Clients { - return this.clientsEntityValue; - } - -} diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-dialog.component.html b/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-dialog.component.html index 1a002020a1..dcce273be2 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/clients/client-dialog.component.html @@ -30,7 +30,7 @@
- +
- +
{{ 'admin.oauth2.edge' | translate }} 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 d41e63fb11..35895661ae 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 @@ -29,6 +29,7 @@ import { isDefinedAndNotNull } from '@core/utils'; import { MatButton } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; import { ClientDialogComponent } from '@home/pages/admin/oauth2/clients/client-dialog.component'; +import { EntityType } from '@shared/models/entity-type.models'; @Component({ selector: 'tb-domain', @@ -39,6 +40,8 @@ export class DomainComponent extends EntityComponent { private loginProcessingUrl: string = ''; + entityType = EntityType; + constructor(protected store: Store, protected translate: TranslateService, private oauth2Service: OAuth2Service, @@ -59,8 +62,8 @@ export class DomainComponent extends EntityComponent { return this.fb.group({ name: [entity?.name ? entity.name : '', [ Validators.required, Validators.maxLength(255), Validators.pattern('^(?:\\w+(?::\\w+)?@)?[^\\s/]+(?::\\d+)?$')]], - oauth2Enabled: isDefinedAndNotNull(entity?.oauth2Enabled) ? entity.oauth2Enabled : false, - oauth2ClientInfos: entity?.oauth2ClientInfos ? entity.oauth2ClientInfos : [], + oauth2Enabled: isDefinedAndNotNull(entity?.oauth2Enabled) ? entity.oauth2Enabled : true, + oauth2ClientInfos: entity?.oauth2ClientInfos ? entity.oauth2ClientInfos.map(info => info.id.id) : [], propagateToEdge: isDefinedAndNotNull(entity?.propagateToEdge) ? entity.propagateToEdge : false }); } @@ -69,7 +72,7 @@ export class DomainComponent extends EntityComponent { this.entityForm.patchValue({ name: entity.name, oauth2Enabled: entity.oauth2Enabled, - oauth2ClientInfos: entity.oauth2ClientInfos, + oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id.id), propagateToEdge: entity.propagateToEdge }) } @@ -84,20 +87,18 @@ export class DomainComponent extends EntityComponent { $event.stopPropagation(); $event.preventDefault(); } - button._elementRef.nativeElement.blur(); this.dialog.open(ClientDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], data: {} }).afterClosed() - .subscribe((res) => { - if (res) { + .subscribe((client) => { + if (client) { const formValue = this.entityForm.get('oauth2ClientInfos').value ? [...this.entityForm.get('oauth2ClientInfos').value] : []; - formValue.push({id: res.id, title: res.title}); + formValue.push(client.id.id); this.entityForm.get('oauth2ClientInfos').patchValue(formValue); this.entityForm.get('oauth2ClientInfos').markAsDirty(); - this.entityForm.updateValueAndValidity(); } }); } 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 c7d5fa0be0..96bd222ed5 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 @@ -18,9 +18,9 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { CellActionDescriptorType, - ClientChipsEntityTableColumn, DateEntityTableColumn, EntityActionTableColumn, + EntityChipsEntityTableColumn, EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; @@ -45,7 +45,6 @@ export class MobileAppTableConfigResolver implements Resolve entity.appSecret, type: CellActionDescriptorType.COPY_BUTTON }), - new ClientChipsEntityTableColumn('oauth2ClientInfos', 'admin.oauth2.clients', '20%'), + new EntityChipsEntityTableColumn('oauth2ClientInfos', 'admin.oauth2.clients', '20%'), new EntityActionTableColumn('oauth2Enabled', 'admin.oauth2.enable', { name: '', @@ -94,9 +92,9 @@ export class MobileAppTableConfigResolver implements Resolve this.translate.instant('admin.oauth2.delete-mobile-app-text'); this.config.entitiesFetchFunction = pageLink => this.mobileAppService.getTenantMobileAppInfos(pageLink); this.config.loadEntity = id => this.mobileAppService.getMobileAppInfoById(id.id); - this.config.saveEntity = (mobileApp, originalEntity) => { - const clientsIds = mobileApp.oauth2ClientInfos ? mobileApp.oauth2ClientInfos.map(clientInfo => clientInfo.id.id) : []; - if (mobileApp.id && !isEqual(mobileApp.oauth2ClientInfos, originalEntity.oauth2ClientInfos)) { + 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())) { this.mobileAppService.updateOauth2Clients(mobileApp.id.id, clientsIds).subscribe(); } delete mobileApp.oauth2ClientInfos; diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-header.component.html b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-header.component.html index f78a483eb0..fd66a026da 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-header.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app-table-header.component.html @@ -15,7 +15,4 @@ limitations under the License. --> -
- {{ entitiesTableConfig.tableTitle }} -
-
+
diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.html b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.html index d5146098fa..449d2c39b1 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/mobile-apps/mobile-app.component.html @@ -57,13 +57,13 @@ {{ 'admin.oauth2.enable' | translate }}
- + - + 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 d46ac8da57..07ee9b7bfc 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 @@ -25,10 +25,11 @@ import { TranslateService } from '@ngx-translate/core'; import { Store } from '@ngrx/store'; import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; import { WINDOW } from '@core/services/window.service'; -import { isDefinedAndNotNull } from '@core/utils'; +import { isDefinedAndNotNull, randomAlphanumeric } from '@core/utils'; import { MatButton } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; import { ClientDialogComponent } from '@home/pages/admin/oauth2/clients/client-dialog.component'; +import { EntityType } from '@shared/models/entity-type.models'; @Component({ selector: 'tb-mobile-app', @@ -37,6 +38,8 @@ import { ClientDialogComponent } from '@home/pages/admin/oauth2/clients/client-d }) export class MobileAppComponent extends EntityComponent { + entityType = EntityType; + constructor(protected store: Store, protected translate: TranslateService, private oauth2Service: OAuth2Service, @@ -52,9 +55,10 @@ export class MobileAppComponent extends EntityComponent { buildForm(entity: MobileAppInfo): UntypedFormGroup { return this.fb.group({ pkgName: [entity?.pkgName ? entity.pkgName : '', [Validators.required]], - appSecret: [entity?.appSecret ? entity.appSecret : '', [Validators.required, this.base64Format]], + appSecret: [entity?.appSecret ? entity.appSecret : btoa(randomAlphanumeric(64)), + [Validators.required, this.base64Format]], oauth2Enabled: isDefinedAndNotNull(entity?.oauth2Enabled) ? entity.oauth2Enabled : false, - oauth2ClientInfos: entity?.oauth2ClientInfos ? entity.oauth2ClientInfos : [] + oauth2ClientInfos: entity?.oauth2ClientInfos ? entity.oauth2ClientInfos.map(info => info.id.id) : [] }); } @@ -63,7 +67,7 @@ export class MobileAppComponent extends EntityComponent { pkgName: entity.pkgName, appSecret: entity.appSecret, oauth2Enabled: entity.oauth2Enabled, - oauth2ClientInfos: entity.oauth2ClientInfos + oauth2ClientInfos: entity.oauth2ClientInfos?.map(info => info.id.id) }) } @@ -72,20 +76,18 @@ export class MobileAppComponent extends EntityComponent { $event.stopPropagation(); $event.preventDefault(); } - button._elementRef.nativeElement.blur(); this.dialog.open(ClientDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], data: {} }).afterClosed() - .subscribe((res) => { - if (res) { + .subscribe((client) => { + if (client) { const formValue = this.entityForm.get('oauth2ClientInfos').value ? [...this.entityForm.get('oauth2ClientInfos').value] : []; - formValue.push({id: res.id, title: res.title}); + formValue.push(client.id.id); this.entityForm.get('oauth2ClientInfos').patchValue(formValue); this.entityForm.get('oauth2ClientInfos').markAsDirty(); - this.entityForm.updateValueAndValidity(); } }); } diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2/oauth2.module.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2/oauth2.module.ts index 8cd1083155..545b9a6a63 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2/oauth2.module.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2/oauth2.module.ts @@ -22,7 +22,6 @@ import { HomeComponentsModule } from '@home/components/home-components.module'; import { CommonModule } from '@angular/common'; import { ClientTableHeaderComponent } from '@home/pages/admin/oauth2/clients/client-table-header.component'; import { DomainComponent } from '@home/pages/admin/oauth2/domains/domain.component'; -import { ClientListComponent } from '@home/pages/admin/oauth2/clients/client-list.component'; import { ClientDialogComponent } from '@home/pages/admin/oauth2/clients/client-dialog.component'; import { DomainTableHeaderComponent } from '@home/pages/admin/oauth2/domains/domain-table-header.component'; import { MobileAppComponent } from '@home/pages/admin/oauth2/mobile-apps/mobile-app.component'; @@ -32,7 +31,6 @@ import { MobileAppTableHeaderComponent } from '@home/pages/admin/oauth2/mobile-a declarations: [ ClientComponent, ClientDialogComponent, - ClientListComponent, ClientTableHeaderComponent, DomainComponent, DomainTableHeaderComponent, diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index 80194ac843..51fefefdf2 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -609,7 +609,9 @@ export const baseDetailsPageByEntityType = new Map([ [EntityType.QUEUE, '/settings/queues'], [EntityType.WIDGETS_BUNDLE, '/resources/widgets-library/widgets-bundles/details'], [EntityType.WIDGET_TYPE, '/resources/widgets-library/widget-types/details'], - [EntityType.OAUTH2_CLIENT, '/security-settings/oauth2/clients/details'] + [EntityType.OAUTH2_CLIENT, '/security-settings/oauth2/clients/details'], + [EntityType.DOMAIN, '/security-settings/oauth2/clients/details'], + [EntityType.MOBILE_APP, '/security-settings/oauth2/clients/details'] ]); export interface EntitySubtype { diff --git a/ui-ngx/src/app/shared/models/oauth2.models.ts b/ui-ngx/src/app/shared/models/oauth2.models.ts index 6ebd12be0e..95453a8ecf 100644 --- a/ui-ngx/src/app/shared/models/oauth2.models.ts +++ b/ui-ngx/src/app/shared/models/oauth2.models.ts @@ -81,11 +81,11 @@ export interface Domain extends BaseData, HasTenantId { } export interface HasOauth2Clients { - oauth2ClientInfos?: Array; + oauth2ClientInfos?: Array | Array; } export interface DomainInfo extends Domain, HasOauth2Clients { - oauth2ClientInfos?: Array; + oauth2ClientInfos?: Array | Array; } export interface MobileApp extends BaseData, HasTenantId { @@ -96,7 +96,7 @@ export interface MobileApp extends BaseData, HasTenantId { } export interface MobileAppInfo extends MobileApp, HasOauth2Clients { - oauth2ClientInfos?: Array; + oauth2ClientInfos?: Array | Array; } export interface OAuth2Client extends BaseData, HasTenantId { @@ -167,6 +167,7 @@ export const platformTypeTranslations = new Map( export interface OAuth2ClientInfo extends BaseData { title: string; + providerName: string; platforms?: Array; } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 1c6a5248b3..ea7bba2c21 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -243,6 +243,7 @@ "no-mobile-apps": "Search mobile applications", "search-mobile-apps": "No mobile applications found", "send-token": "Send token", + "create-new": "Create new", "client-authentication-method": "Client authentication method", "client-id": "Client ID", "client-id-required": "Client ID is required.",