From 4fb6ad3f695a5c8b1f53c9c7d3232ccce52a4342 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Mon, 19 Oct 2020 15:48:00 +0200 Subject: [PATCH] fix(console): idp create, table, i18n (#870) * fix idp removal, add, links * confirm deletion * stylelint * confirmation on multiple delete * clear after confirm --- .../idp-create/idp-create.component.html | 36 +++++----- .../idp-create/idp-create.component.ts | 42 +++++++----- .../modules/idp-create/idp-create.module.ts | 4 +- .../idp-table/idp-table.component.html | 41 +++++++----- .../idp-table/idp-table.component.scss | 14 ++++ .../modules/idp-table/idp-table.component.ts | 67 ++++++++++++++++--- .../iam-policy-grid.component.html | 50 +++++++------- .../src/app/pages/orgs/orgs-routing.module.ts | 3 +- console/src/assets/i18n/de.json | 12 +++- console/src/assets/i18n/en.json | 12 +++- 10 files changed, 191 insertions(+), 90 deletions(-) diff --git a/console/src/app/modules/idp-create/idp-create.component.html b/console/src/app/modules/idp-create/idp-create.component.html index 645281f86b..d6f33a4b31 100644 --- a/console/src/app/modules/idp-create/idp-create.component.html +++ b/console/src/app/modules/idp-create/idp-create.component.html @@ -11,6 +11,8 @@

{{'IDP.CREATE.TITLE' | translate}}

{{'IDP.CREATE.DESCRIPTION' | translate}}

+ +
@@ -48,22 +50,22 @@
- - {{ 'IDP.IDPDISPLAYNAMMAPPING' | translate }} - - - {{ 'IDP.MAPPINTFIELD.'+field | translate }} - - - - - {{ 'IDP.USERNAMEMAPPING' | translate }} - - - {{ 'IDP.MAPPINTFIELD.'+field | translate }} - - - + + {{ 'IDP.IDPDISPLAYNAMMAPPING' | translate }} + + + {{ 'IDP.MAPPINTFIELD.'+field | translate }} + + + + + {{ 'IDP.USERNAMEMAPPING' | translate }} + + + {{ 'IDP.MAPPINTFIELD.'+field | translate }} + + +
@@ -71,4 +73,4 @@ {{ 'ACTIONS.SAVE' | translate }}
- + \ No newline at end of file diff --git a/console/src/app/modules/idp-create/idp-create.component.ts b/console/src/app/modules/idp-create/idp-create.component.ts index ee7350137a..fa50fc612a 100644 --- a/console/src/app/modules/idp-create/idp-create.component.ts +++ b/console/src/app/modules/idp-create/idp-create.component.ts @@ -7,18 +7,18 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; import { Subscription } from 'rxjs'; import { take } from 'rxjs/operators'; import { - OidcIdpConfigCreate as AdminOidcIdpConfigCreate, - OIDCMappingField as authMappingFields, + OidcIdpConfigCreate as AdminOidcIdpConfigCreate, + OIDCMappingField as authMappingFields, } from 'src/app/proto/generated/admin_pb'; import { AdminService } from 'src/app/services/admin.service'; import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; -import { PolicyComponentServiceType } from '../policies/policy-component-types.enum'; import { - OidcIdpConfigCreate as MgmtOidcIdpConfigCreate, - OIDCMappingField as mgmtMappingFields, + OidcIdpConfigCreate as MgmtOidcIdpConfigCreate, + OIDCMappingField as mgmtMappingFields, } from '../../proto/generated/management_pb'; +import { PolicyComponentServiceType } from '../policies/policy-component-types.enum'; @Component({ selector: 'app-idp-create', @@ -37,7 +37,7 @@ export class IdpCreateComponent implements OnInit, OnDestroy { public formGroup!: FormGroup; public createSteps: number = 1; public currentCreateStep: number = 1; - + public loading: boolean = false; constructor( private router: Router, private route: ActivatedRoute, @@ -68,8 +68,8 @@ export class IdpCreateComponent implements OnInit, OnDestroy { case PolicyComponentServiceType.ADMIN: this.service = this.injector.get(AdminService as Type); this.mappingFields = [ - authMappingFields.OIDCMAPPINGFIELD_PREFERRED_USERNAME, - authMappingFields.OIDCMAPPINGFIELD_EMAIL]; + authMappingFields.OIDCMAPPINGFIELD_PREFERRED_USERNAME, + authMappingFields.OIDCMAPPINGFIELD_EMAIL]; break; } }); @@ -91,12 +91,12 @@ export class IdpCreateComponent implements OnInit, OnDestroy { let req: AdminOidcIdpConfigCreate | MgmtOidcIdpConfigCreate; switch (this.serviceType) { - case PolicyComponentServiceType.MGMT: - req = new MgmtOidcIdpConfigCreate(); - break; - case PolicyComponentServiceType.ADMIN: - req = new AdminOidcIdpConfigCreate(); - break; + case PolicyComponentServiceType.MGMT: + req = new MgmtOidcIdpConfigCreate(); + break; + case PolicyComponentServiceType.ADMIN: + req = new AdminOidcIdpConfigCreate(); + break; } req.setName(this.name?.value); @@ -107,9 +107,15 @@ export class IdpCreateComponent implements OnInit, OnDestroy { req.setScopesList(this.scopesList?.value); req.setIdpDisplayNameMapping(this.idpDisplayNameMapping?.value); req.setUsernameMapping(this.usernameMapping?.value); - + this.loading = true; this.service.CreateOidcIdp(req).then((idp) => { - this.router.navigate(['idp', idp.getId()]); + setTimeout(() => { + this.loading = false; + this.router.navigate([ + this.serviceType === PolicyComponentServiceType.MGMT ? 'org' : + this.serviceType === PolicyComponentServiceType.ADMIN ? 'iam' : '', + 'idp', idp.getId()]); + }, 2000); }).catch(error => { this.toast.showError(error); }); @@ -163,7 +169,7 @@ export class IdpCreateComponent implements OnInit, OnDestroy { return this.formGroup.get('issuer'); } public get scopesList(): AbstractControl | null { - return this.formGroup.get('scopesList'); + return this.formGroup.get('scopesList'); } public get idpDisplayNameMapping(): AbstractControl | null { @@ -171,7 +177,7 @@ export class IdpCreateComponent implements OnInit, OnDestroy { } public get usernameMapping(): AbstractControl | null { - return this.formGroup.get('usernameMapping'); + return this.formGroup.get('usernameMapping'); } } diff --git a/console/src/app/modules/idp-create/idp-create.module.ts b/console/src/app/modules/idp-create/idp-create.module.ts index c952ec4741..43028c9be6 100644 --- a/console/src/app/modules/idp-create/idp-create.module.ts +++ b/console/src/app/modules/idp-create/idp-create.module.ts @@ -6,12 +6,13 @@ import { MatChipsModule } from '@angular/material/chips'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatSelectModule } from '@angular/material/select'; import { MatTooltipModule } from '@angular/material/tooltip'; import { TranslateModule } from '@ngx-translate/core'; import { IdpCreateRoutingModule } from './idp-create-routing.module'; import { IdpCreateComponent } from './idp-create.component'; -import {MatSelectModule} from '@angular/material/select'; @NgModule({ declarations: [IdpCreateComponent], @@ -28,6 +29,7 @@ import {MatSelectModule} from '@angular/material/select'; MatChipsModule, MatTooltipModule, TranslateModule, + MatProgressBarModule, ], }) export class IdpCreateModule { } diff --git a/console/src/app/modules/idp-table/idp-table.component.html b/console/src/app/modules/idp-table/idp-table.component.html index 9b528a60ae..850168cc6c 100644 --- a/console/src/app/modules/idp-table/idp-table.component.html +++ b/console/src/app/modules/idp-table/idp-table.component.html @@ -2,18 +2,15 @@ emitRefreshOnPreviousRoute="/iam/idp/create" [timestamp]="idpResult?.viewTimestamp" [selection]="selection"> @@ -27,11 +24,13 @@ + [indeterminate]="selection.hasValue() && !isAllSelected()" + [disabled]="serviceType==PolicyComponentServiceType.MGMT"> ipp logo {{idp?.name}} @@ -46,12 +45,12 @@ {{ 'IDP.NAME' | translate }} - {{idp?.name}} + {{idp?.name}} {{ 'IDP.CONFIG' | translate }} - +
{{elem.key}}: {{elem.value}} @@ -61,35 +60,45 @@ {{ 'IDP.STATE' | translate }} - {{ 'IDP.STATES.'+idp.state | translate }} + + {{ 'IDP.STATES.'+idp.state | translate }} {{ 'IDP.CREATIONDATE' | translate }} - + {{idp.creationDate | timestampToDate | localizedDate: 'dd. MMM, HH:mm' }} {{ 'IDP.CHANGEDATE' | translate }} - + {{idp.changeDate | timestampToDate | localizedDate: 'dd. MMM, HH:mm' }} {{ 'IDP.TYPE' | translate }} - + {{'IDP.TYPES.'+idp.providerType | translate }} + + + + + + + mat-row *matRowDef="let row; columns: displayedColumns;"> -
> = new EventEmitter(); - constructor(public translate: TranslateService, private toast: ToastService) { + constructor(public translate: TranslateService, private toast: ToastService, private dialog: MatDialog) { this.selection.changed.subscribe(() => { this.changedSelection.emit(this.selection.selected); }); @@ -48,6 +50,10 @@ export class IdpTableComponent implements OnInit { if (this.serviceType === PolicyComponentServiceType.MGMT) { this.displayedColumns = ['select', 'name', 'config', 'creationDate', 'changeDate', 'state', 'type']; } + + if (!this.disabled) { + this.displayedColumns.push('actions'); + } } public isAllSelected(): boolean { @@ -68,29 +74,70 @@ export class IdpTableComponent implements OnInit { } public deactivateSelectedIdps(): void { + this.selection.clear(); Promise.all(this.selection.selected.map(value => { return this.service.DeactivateIdpConfig(value.id); })).then(() => { - this.toast.showInfo('USER.TOAST.SELECTEDDEACTIVATED', true); - this.getData(10, 0); + this.toast.showInfo('IDP.TOAST.SELECTEDDEACTIVATED', true); + this.refreshPage(); }); } public reactivateSelectedIdps(): void { + this.selection.clear(); Promise.all(this.selection.selected.map(value => { return this.service.ReactivateIdpConfig(value.id); })).then(() => { - this.toast.showInfo('USER.TOAST.SELECTEDREACTIVATED', true); - this.getData(10, 0); + this.toast.showInfo('IDP.TOAST.SELECTEDREACTIVATED', true); + this.refreshPage(); }); } public removeSelectedIdps(): void { - Promise.all(this.selection.selected.map(value => { - return this.service.RemoveIdpConfig(value.id); - })).then(() => { - this.toast.showInfo('USER.TOAST.SELECTEDDEACTIVATED', true); - this.getData(10, 0); + const dialogRef = this.dialog.open(WarnDialogComponent, { + data: { + confirmKey: 'ACTIONS.DELETE', + cancelKey: 'ACTIONS.CANCEL', + titleKey: 'IDP.DELETE_SELECTION_TITLE', + descriptionKey: 'IDP.DELETE_SELECTION_DESCRIPTION', + }, + width: '400px', + }); + + dialogRef.afterClosed().subscribe(resp => { + if (resp) { + this.selection.clear(); + + Promise.all(this.selection.selected.map(value => { + return this.service.RemoveIdpConfig(value.id); + })).then(() => { + this.toast.showInfo('IDP.TOAST.SELECTEDDEACTIVATED', true); + this.refreshPage(); + }); + } + }); + } + + public removeIdp(idp: AdminIdpView.AsObject | MgmtIdpView.AsObject): void { + const dialogRef = this.dialog.open(WarnDialogComponent, { + data: { + confirmKey: 'ACTIONS.DELETE', + cancelKey: 'ACTIONS.CANCEL', + titleKey: 'IDP.DELETE_TITLE', + descriptionKey: 'IDP.DELETE_DESCRIPTION', + }, + width: '400px', + }); + + dialogRef.afterClosed().subscribe(resp => { + if (resp) { + this.service.RemoveIdpConfig(idp.id).then(() => { + this.toast.showInfo('IDP.TOAST.REMOVED', true); + setTimeout(() => { + this.refreshPage(); + }, 1000); + }); + } }); } diff --git a/console/src/app/pages/iam/iam-policy-grid/iam-policy-grid.component.html b/console/src/app/pages/iam/iam-policy-grid/iam-policy-grid.component.html index d4e0045e2d..569ae70199 100644 --- a/console/src/app/pages/iam/iam-policy-grid/iam-policy-grid.component.html +++ b/console/src/app/pages/iam/iam-policy-grid/iam-policy-grid.component.html @@ -26,31 +26,6 @@
- -
-
- -
-
- {{'ORG.POLICY.LOGIN_POLICY.TITLE' | translate}} - -
- -

- {{'ORG.POLICY.LOGIN_POLICY.DESCRIPTION' | translate}}

- - -
- - - -
-
-
-
@@ -75,4 +50,29 @@
+ + +
+
+ +
+
+ {{'ORG.POLICY.LOGIN_POLICY.TITLE' | translate}} + +
+ +

+ {{'ORG.POLICY.LOGIN_POLICY.DESCRIPTION' | translate}}

+ + +
+ + + +
+
+
\ No newline at end of file diff --git a/console/src/app/pages/orgs/orgs-routing.module.ts b/console/src/app/pages/orgs/orgs-routing.module.ts index e0f849189a..0484c2676d 100644 --- a/console/src/app/pages/orgs/orgs-routing.module.ts +++ b/console/src/app/pages/orgs/orgs-routing.module.ts @@ -25,6 +25,7 @@ const routes: Routes = [ canActivate: [RoleGuard], data: { roles: ['org.idp.write'], + serviceType: PolicyComponentServiceType.MGMT, }, }, { @@ -33,7 +34,7 @@ const routes: Routes = [ canActivate: [RoleGuard], data: { roles: ['iam.idp.read'], - serviceType: PolicyComponentServiceType.ADMIN, + serviceType: PolicyComponentServiceType.MGMT, }, }, ], diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index ab4da822da..3775e3d350 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -730,8 +730,18 @@ "DEACTIVATE":"Deaktivieren", "ACTIVATE":"Aktivieren", "DELETE":"Löschen", + "DELETE_TITLE":"Idp löschen", + "DELETE_DESCRIPTION":"Sie sind im Begriff einen Identity Provider zu löschen. Die daruch hervorgerufenen Änderungen sind unwiederruflich. Wollen Sie dies wirklich tun?", + "DELETE_SELECTION_TITLE":"Identity Providers löschen", + "DELETE_SELECTION_DESCRIPTION":"Sie sind im Begriff mehrere Identity Provider zu löschen. Die daruch hervorgerufenen Änderungen sind unwiederruflich. Wollen Sie dies wirklich tun?", "TOAST": { - "SAVED": "Erfolgreich gespeichert." + "SAVED": "Erfolgreich gespeichert.", + "REACTIVATED":"Idp reaktiviert.", + "DEACTIVATED":"Idp deaktiviert.", + "SELECTEDREACTIVATED":"Selektierte Idps reaktiviert.", + "SELECTEDDEACTIVATED":"Selektierte Idps deaktiviert.", + "SELECTEDKEYSDELETED":"Selektierte Idps gelöscht.", + "DELETED":"Idp erfolgreich gelöscht!" } }, "LOGINPOLICY": { diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 76d977afbb..d37e65cd35 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -730,8 +730,18 @@ "DEACTIVATE":"Deactivate", "ACTIVATE":"Activate", "DELETE":"Delete", + "DELETE_TITLE":"Delete Idp", + "DELETE_DESCRIPTION":"You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?", + "DELETE_SELECTION_TITLE":"Delete Idp", + "DELETE_SELECTION_DESCRIPTION":"You are about to delete an identity provider. The resulting changes are irrevocable. Do you really want to do this?", "TOAST": { - "SAVED": "Successfully saved." + "SAVED": "Successfully saved.", + "REACTIVATED":"Idp reactivated.", + "DEACTIVATED":"Idp deactivated.", + "SELECTEDREACTIVATED":"Selected idps reactivated.", + "SELECTEDDEACTIVATED":"Selected idps deactivated.", + "SELECTEDKEYSDELETED":"Selected idps deleted.", + "DELETED":"Idp removed successfully!" } }, "LOGINPOLICY": {