verben-authentication-ui 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +8 -0
- package/package.json +10 -15
- package/src/lib/base/base-data.component.ts +86 -0
- package/src/lib/base/base-data.facade.ts +157 -0
- package/src/lib/base/base-data.service.ts +49 -0
- package/src/lib/base/base-data.state.ts +94 -0
- package/src/lib/base/models.ts +14 -0
- package/src/lib/components/auth-callback/auth-callback.component.css +30 -0
- package/src/lib/components/auth-callback/auth-callback.component.html +6 -0
- package/src/lib/components/auth-callback/auth-callback.component.spec.ts +23 -0
- package/src/lib/components/auth-callback/auth-callback.component.ts +56 -0
- package/src/lib/components/auth-callback/auth-callback.module.ts +10 -0
- package/src/lib/components/button/button.component.css +3 -0
- package/src/lib/components/button/button.component.html +13 -0
- package/src/lib/components/button/button.component.spec.ts +23 -0
- package/src/lib/components/button/button.component.ts +24 -0
- package/src/lib/components/button/button.module.ts +11 -0
- package/{lib/components/forgot-password/ForgotPasswordData.d.ts → src/lib/components/forgot-password/ForgotPasswordData.ts} +1 -1
- package/src/lib/components/forgot-password/forgot-password.component.css +46 -0
- package/src/lib/components/forgot-password/forgot-password.component.html +19 -0
- package/src/lib/components/forgot-password/forgot-password.component.spec.ts +23 -0
- package/src/lib/components/forgot-password/forgot-password.component.ts +88 -0
- package/src/lib/components/forgot-password/forgot-password.module.ts +18 -0
- package/src/lib/components/mail/mail.component.css +0 -0
- package/src/lib/components/mail/mail.component.html +11 -0
- package/src/lib/components/mail/mail.component.spec.ts +23 -0
- package/src/lib/components/mail/mail.component.ts +47 -0
- package/src/lib/components/mail/mail.module.ts +13 -0
- package/src/lib/components/mail-validation/mail-validation.component.css +59 -0
- package/src/lib/components/mail-validation/mail-validation.component.html +37 -0
- package/src/lib/components/mail-validation/mail-validation.component.spec.ts +23 -0
- package/src/lib/components/mail-validation/mail-validation.component.ts +66 -0
- package/src/lib/components/mail-validation/mail-validation.module.ts +18 -0
- package/src/lib/components/o-auth/o-auth.component.css +26 -0
- package/src/lib/components/o-auth/o-auth.component.html +26 -0
- package/src/lib/components/o-auth/o-auth.component.spec.ts +23 -0
- package/src/lib/components/o-auth/o-auth.component.ts +115 -0
- package/src/lib/components/o-auth/o-auth.module.ts +11 -0
- package/src/lib/components/otp-input/otp-input.component.css +19 -0
- package/src/lib/components/otp-input/otp-input.component.html +15 -0
- package/src/lib/components/otp-input/otp-input.component.spec.ts +23 -0
- package/src/lib/components/otp-input/otp-input.component.ts +88 -0
- package/src/lib/components/otp-input/otp-input.module.ts +15 -0
- package/src/lib/components/reset-password/ResetPasswordData.ts +5 -0
- package/src/lib/components/reset-password/reset-password.component.css +29 -0
- package/src/lib/components/reset-password/reset-password.component.html +24 -0
- package/src/lib/components/reset-password/reset-password.component.spec.ts +23 -0
- package/src/lib/components/reset-password/reset-password.component.ts +108 -0
- package/src/lib/components/reset-password/reset-password.module.ts +18 -0
- package/src/lib/components/role-control/ChildrenType.ts +4 -0
- package/{lib/components/role-control/MappedRole.d.ts → src/lib/components/role-control/MappedRole.ts} +3 -2
- package/{lib/components/role-control/MappedRoleAction.d.ts → src/lib/components/role-control/MappedRoleAction.ts} +2 -1
- package/{lib/components/role-control/MappedRoleContext.d.ts → src/lib/components/role-control/MappedRoleContext.ts} +4 -3
- package/src/lib/components/role-control/UIActions.ts +5 -0
- package/src/lib/components/role-control/UIs.ts +38 -0
- package/src/lib/components/role-control/base-table-style.ts +52 -0
- package/src/lib/components/role-control/role-control.component.css +55 -0
- package/src/lib/components/role-control/role-control.component.html +571 -0
- package/src/lib/components/role-control/role-control.component.spec.ts +23 -0
- package/src/lib/components/role-control/role-control.component.ts +1817 -0
- package/src/lib/components/role-control/role-control.module.ts +10 -0
- package/src/lib/components/role-control/role-control.service.spec.ts +16 -0
- package/src/lib/components/role-control/role-control.service.ts +53 -0
- package/src/lib/components/sign-in/sign-in.component.css +21 -0
- package/src/lib/components/sign-in/sign-in.component.html +83 -0
- package/src/lib/components/sign-in/sign-in.component.spec.ts +23 -0
- package/src/lib/components/sign-in/sign-in.component.ts +267 -0
- package/src/lib/components/sign-in/sign-in.module.ts +17 -0
- package/src/lib/components/sign-up/sign-up.component.css +36 -0
- package/src/lib/components/sign-up/sign-up.component.html +132 -0
- package/src/lib/components/sign-up/sign-up.component.spec.ts +23 -0
- package/src/lib/components/sign-up/sign-up.component.ts +180 -0
- package/src/lib/components/sign-up/sign-up.module.ts +15 -0
- package/src/lib/components/sso/base-table-style.ts +52 -0
- package/src/lib/components/sso/helper.ts +17 -0
- package/src/lib/components/sso/sso-form/sso-form.component.css +13 -0
- package/src/lib/components/sso/sso-form/sso-form.component.html +109 -0
- package/src/lib/components/sso/sso-form/sso-form.component.spec.ts +23 -0
- package/src/lib/components/sso/sso-form/sso-form.component.ts +70 -0
- package/src/lib/components/sso/sso.columns.ts +32 -0
- package/src/lib/components/sso/sso.component.css +47 -0
- package/src/lib/components/sso/sso.component.html +208 -0
- package/src/lib/components/sso/sso.component.spec.ts +23 -0
- package/src/lib/components/sso/sso.component.ts +261 -0
- package/src/lib/components/sso/sso.module.ts +40 -0
- package/src/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.css +8 -0
- package/src/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.html +30 -0
- package/src/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.spec.ts +23 -0
- package/src/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.ts +155 -0
- package/src/lib/components/two-factor-auth-otp/two-factor-auth-otp.module.ts +15 -0
- package/src/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.css +17 -0
- package/src/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.html +45 -0
- package/src/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.spec.ts +23 -0
- package/src/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.ts +57 -0
- package/src/lib/components/two-factor-auth-setup/two-factor-auth-setup.module.ts +11 -0
- package/src/lib/components/user-management/base-table-style.ts +52 -0
- package/src/lib/components/user-management/facades/user-management.facades.ts +133 -0
- package/src/lib/components/user-management/helper.ts +38 -0
- package/src/lib/components/user-management/index.ts +4 -0
- package/src/lib/components/user-management/services/user-management.service.spec.ts +16 -0
- package/src/lib/components/user-management/services/user-management.service.ts +111 -0
- package/src/lib/components/user-management/states/user-management.state.ts +65 -0
- package/src/lib/components/user-management/user-management-form/use-management-form.component.ts +73 -0
- package/src/lib/components/user-management/user-management-form/user-management-form.component.css +0 -0
- package/src/lib/components/user-management/user-management-form/user-management-form.component.html +80 -0
- package/src/lib/components/user-management/user-management-form/user-management-form.component.spec.ts +23 -0
- package/src/lib/components/user-management/user-management.columns.ts +51 -0
- package/src/lib/components/user-management/user-management.component.css +31 -0
- package/src/lib/components/user-management/user-management.component.html +319 -0
- package/src/lib/components/user-management/user-management.component.spec.ts +23 -0
- package/src/lib/components/user-management/user-management.component.ts +604 -0
- package/src/lib/components/user-management/user-management.module.ts +56 -0
- package/src/lib/components/user-management/user-status-badge/user-status-badge.component.css +0 -0
- package/src/lib/components/user-management/user-status-badge/user-status-badge.component.html +8 -0
- package/src/lib/components/user-management/user-status-badge/user-status-badge.component.spec.ts +22 -0
- package/src/lib/components/user-management/user-status-badge/user-status-badge.component.ts +22 -0
- package/src/lib/components/user-request/user-request.component.css +91 -0
- package/src/lib/components/user-request/user-request.component.html +137 -0
- package/src/lib/components/user-request/user-request.component.spec.ts +23 -0
- package/src/lib/components/user-request/user-request.component.ts +306 -0
- package/src/lib/components/user-request/user-request.module.ts +20 -0
- package/src/lib/components/user-request-approval/access-request.columns.ts +31 -0
- package/src/lib/components/user-request-approval/base-table-style.ts +52 -0
- package/src/lib/components/user-request-approval/facades/user-access-request.facade.ts +324 -0
- package/src/lib/components/user-request-approval/helper.ts +61 -0
- package/src/lib/components/user-request-approval/services/user-access-request.service.spec.ts +16 -0
- package/src/lib/components/user-request-approval/services/user-access-request.service.ts +122 -0
- package/src/lib/components/user-request-approval/states/user-access-request.state.ts +109 -0
- package/src/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.css +0 -0
- package/src/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.html +8 -0
- package/src/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.spec.ts +23 -0
- package/src/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.ts +22 -0
- package/src/lib/components/user-request-approval/user-request-approval.component.css +6 -0
- package/src/lib/components/user-request-approval/user-request-approval.component.html +269 -0
- package/src/lib/components/user-request-approval/user-request-approval.component.spec.ts +23 -0
- package/src/lib/components/user-request-approval/user-request-approval.component.ts +326 -0
- package/src/lib/components/user-request-approval/user-request-approval.module.ts +54 -0
- package/src/lib/components/user-request-approval/user-request-form/use-request-form.component.ts +98 -0
- package/src/lib/components/user-request-approval/user-request-form/user-request-form.component.css +0 -0
- package/src/lib/components/user-request-approval/user-request-form/user-request-form.component.html +94 -0
- package/src/lib/components/user-request-approval/user-request-form/user-request-form.component.spec.ts +23 -0
- package/src/lib/components/user-request-process/user-request-process.component.css +0 -0
- package/src/lib/components/user-request-process/user-request-process.component.html +1 -0
- package/src/lib/components/user-request-process/user-request-process.component.spec.ts +23 -0
- package/src/lib/components/user-request-process/user-request-process.component.ts +12 -0
- package/src/lib/components/user-request-process/user-request-process.module.ts +12 -0
- package/src/lib/models/ApplicationRoleAction.ts +10 -0
- package/{lib/models/ApplicationRoleContext.d.ts → src/lib/models/ApplicationRoleContext copy.ts } +6 -5
- package/src/lib/models/ApplicationRoleContext.ts +10 -0
- package/src/lib/models/ErrorResponse.ts +7 -0
- package/src/lib/models/FilterTypes.ts +8 -0
- package/src/lib/models/MailConfig.ts +13 -0
- package/src/lib/models/MessageConfig.ts +5 -0
- package/src/lib/models/MessageMedium.ts +4 -0
- package/src/lib/models/OAuthParam.ts +10 -0
- package/src/lib/models/OAuthType.ts +7 -0
- package/src/lib/models/PagedResult.ts +9 -0
- package/src/lib/models/PasswordRequestParam.ts +5 -0
- package/src/lib/models/PeriodMode.ts +10 -0
- package/{lib/models/PermissionConfig.d.ts → src/lib/models/PermissionConfig.ts} +4 -3
- package/src/lib/models/ReportSchedule.ts +23 -0
- package/src/lib/models/ReportType.ts +5 -0
- package/src/lib/models/ResponseKeyValue.ts +5 -0
- package/{lib/models/Role.d.ts → src/lib/models/Role.ts} +6 -5
- package/src/lib/models/RoleAction.ts +11 -0
- package/src/lib/models/RoleContext.ts +11 -0
- package/src/lib/models/SMSConfig.ts +11 -0
- package/{lib/models/SearchDynamicWrapper.d.ts → src/lib/models/SearchDynamicWrapper.ts} +3 -2
- package/src/lib/models/SearchOperator.ts +4 -0
- package/src/lib/models/SearchPropertySign.ts +9 -0
- package/{lib/models/SearchPropertyValue.d.ts → src/lib/models/SearchPropertyValue.ts} +7 -6
- package/src/lib/models/SearchPropertyValueType.ts +9 -0
- package/src/lib/models/SortDirection.ts +5 -0
- package/{lib/models/Tag.d.ts → src/lib/models/Tag.ts} +4 -3
- package/src/lib/models/TaskNotification.ts +14 -0
- package/src/lib/models/TaskNotificationMessageType.ts +4 -0
- package/src/lib/models/TaskNotificationType.ts +4 -0
- package/src/lib/models/Tenant.ts +22 -0
- package/src/lib/models/TenantConfig.ts +19 -0
- package/src/lib/models/UserRequest.ts +38 -0
- package/src/lib/models/auth-mechanism.ts +15 -0
- package/src/lib/models/base.ts +13 -0
- package/src/lib/models/conditions.ts +11 -0
- package/src/lib/models/log-in.ts +8 -0
- package/{lib/models/mainUser.d.ts → src/lib/models/mainUser.ts} +3 -2
- package/src/lib/models/oauth-resp.ts +6 -0
- package/{lib/models/oauth-response.d.ts → src/lib/models/oauth-response.ts} +1 -1
- package/src/lib/models/object-state.ts +6 -0
- package/{lib/models/otpValue.d.ts → src/lib/models/otpValue.ts} +4 -2
- package/src/lib/models/paged.ts +9 -0
- package/src/lib/models/query-params.ts +9 -0
- package/src/lib/models/request-status.ts +4 -0
- package/src/lib/models/resend-otp-data.ts +8 -0
- package/src/lib/models/resource.ts +27 -0
- package/src/lib/models/sign-up.ts +11 -0
- package/src/lib/models/single-sign-on.ts +9 -0
- package/src/lib/models/status.ts +5 -0
- package/src/lib/models/user-access-request-status.ts +5 -0
- package/{lib/models/user-access-request.d.ts → src/lib/models/user-access-request.ts} +5 -4
- package/src/lib/models/user-object-state.ts +6 -0
- package/src/lib/models/user.ts +19 -0
- package/src/lib/pipes/async-label.pipe.spec.ts +8 -0
- package/src/lib/pipes/async-label.pipe.ts +20 -0
- package/src/lib/services/authorization.service.spec.ts +16 -0
- package/src/lib/services/authorization.service.ts +24 -0
- package/src/lib/services/encryption.service.ts +57 -0
- package/src/lib/services/environment.service.spec.ts +16 -0
- package/src/lib/services/environment.service.ts +30 -0
- package/src/lib/services/http-web-request.service.spec.ts +16 -0
- package/src/lib/services/http-web-request.service.ts +114 -0
- package/src/lib/services/label.service.spec.ts +16 -0
- package/src/lib/services/label.service.ts +177 -0
- package/src/lib/services/util.service.spec.ts +16 -0
- package/src/lib/services/util.service.ts +49 -0
- package/src/lib/shared/shared.module.ts +55 -0
- package/{public-api.d.ts → src/public-api.ts} +24 -0
- package/src/styles.css +96 -0
- package/src/theme/tailwind-setup.css +3 -0
- package/src/theme/tailwind.css +1030 -0
- package/src/utils/components/base-data-view.component.ts +131 -0
- package/src/utils/models/DataViewConfig.ts +19 -0
- package/tailwind.config.js +20 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/esm2022/lib/components/auth-callback/auth-callback.component.mjs +0 -57
- package/esm2022/lib/components/auth-callback/auth-callback.module.mjs +0 -18
- package/esm2022/lib/components/button/button.component.mjs +0 -46
- package/esm2022/lib/components/button/button.module.mjs +0 -20
- package/esm2022/lib/components/forgot-password/ForgotPasswordData.mjs +0 -2
- package/esm2022/lib/components/forgot-password/forgot-password.component.mjs +0 -89
- package/esm2022/lib/components/forgot-password/forgot-password.module.mjs +0 -34
- package/esm2022/lib/components/mail/mail.component.mjs +0 -69
- package/esm2022/lib/components/mail/mail.module.mjs +0 -21
- package/esm2022/lib/components/mail-validation/mail-validation.component.mjs +0 -108
- package/esm2022/lib/components/mail-validation/mail-validation.module.mjs +0 -34
- package/esm2022/lib/components/o-auth/o-auth.component.mjs +0 -107
- package/esm2022/lib/components/o-auth/o-auth.module.mjs +0 -19
- package/esm2022/lib/components/otp-input/otp-input.component.mjs +0 -86
- package/esm2022/lib/components/otp-input/otp-input.module.mjs +0 -23
- package/esm2022/lib/components/reset-password/ResetPasswordData.mjs +0 -2
- package/esm2022/lib/components/reset-password/reset-password.component.mjs +0 -108
- package/esm2022/lib/components/reset-password/reset-password.module.mjs +0 -34
- package/esm2022/lib/components/role-control/ChildrenType.mjs +0 -6
- package/esm2022/lib/components/role-control/MappedRole.mjs +0 -2
- package/esm2022/lib/components/role-control/MappedRoleAction.mjs +0 -2
- package/esm2022/lib/components/role-control/MappedRoleContext.mjs +0 -2
- package/esm2022/lib/components/role-control/UIActions.mjs +0 -7
- package/esm2022/lib/components/role-control/UIs.mjs +0 -40
- package/esm2022/lib/components/role-control/base-table-style.mjs +0 -53
- package/esm2022/lib/components/role-control/role-control.component.mjs +0 -1364
- package/esm2022/lib/components/role-control/role-control.module.mjs +0 -18
- package/esm2022/lib/components/role-control/role-control.service.mjs +0 -54
- package/esm2022/lib/components/sign-in/sign-in.component.mjs +0 -318
- package/esm2022/lib/components/sign-in/sign-in.module.mjs +0 -24
- package/esm2022/lib/components/sign-up/sign-up.component.mjs +0 -229
- package/esm2022/lib/components/sign-up/sign-up.module.mjs +0 -24
- package/esm2022/lib/components/sso/base-table-style.mjs +0 -53
- package/esm2022/lib/components/sso/helper.mjs +0 -16
- package/esm2022/lib/components/sso/sso-form/sso-form.component.mjs +0 -74
- package/esm2022/lib/components/sso/sso.columns.mjs +0 -29
- package/esm2022/lib/components/sso/sso.component.mjs +0 -236
- package/esm2022/lib/components/sso/sso.module.mjs +0 -63
- package/esm2022/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.mjs +0 -209
- package/esm2022/lib/components/two-factor-auth-otp/two-factor-auth-otp.module.mjs +0 -22
- package/esm2022/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.mjs +0 -90
- package/esm2022/lib/components/two-factor-auth-setup/two-factor-auth-setup.module.mjs +0 -19
- package/esm2022/lib/components/user-management/base-table-style.mjs +0 -53
- package/esm2022/lib/components/user-management/services/user-management.service.mjs +0 -88
- package/esm2022/lib/components/user-management/user-management-form/use-management-form.component.mjs +0 -71
- package/esm2022/lib/components/user-management/user-management.columns.mjs +0 -47
- package/esm2022/lib/components/user-management/user-management.component.mjs +0 -475
- package/esm2022/lib/components/user-management/user-management.module.mjs +0 -79
- package/esm2022/lib/components/user-management/user-status-badge/user-status-badge.component.mjs +0 -26
- package/esm2022/lib/components/user-request/user-request.component.mjs +0 -320
- package/esm2022/lib/components/user-request/user-request.module.mjs +0 -38
- package/esm2022/lib/components/user-request-approval/access-request.columns.mjs +0 -29
- package/esm2022/lib/components/user-request-approval/base-table-style.mjs +0 -53
- package/esm2022/lib/components/user-request-approval/facades/user-access-request.facade.mjs +0 -260
- package/esm2022/lib/components/user-request-approval/helper.mjs +0 -56
- package/esm2022/lib/components/user-request-approval/services/user-access-request.service.mjs +0 -93
- package/esm2022/lib/components/user-request-approval/states/user-access-request.state.mjs +0 -92
- package/esm2022/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.mjs +0 -26
- package/esm2022/lib/components/user-request-approval/user-request-approval.component.mjs +0 -270
- package/esm2022/lib/components/user-request-approval/user-request-approval.module.mjs +0 -80
- package/esm2022/lib/components/user-request-approval/user-request-form/use-request-form.component.mjs +0 -86
- package/esm2022/lib/models/ApplicationRoleAction.mjs +0 -2
- package/esm2022/lib/models/ApplicationRoleContext.mjs +0 -2
- package/esm2022/lib/models/ErrorResponse.mjs +0 -11
- package/esm2022/lib/models/OAuthParam.mjs +0 -2
- package/esm2022/lib/models/OAuthType.mjs +0 -9
- package/esm2022/lib/models/PagedResult.mjs +0 -2
- package/esm2022/lib/models/PasswordRequestParam.mjs +0 -2
- package/esm2022/lib/models/PermissionConfig.mjs +0 -2
- package/esm2022/lib/models/ResponseKeyValue.mjs +0 -2
- package/esm2022/lib/models/Role.mjs +0 -2
- package/esm2022/lib/models/RoleAction.mjs +0 -2
- package/esm2022/lib/models/RoleContext.mjs +0 -2
- package/esm2022/lib/models/SearchDynamicWrapper.mjs +0 -2
- package/esm2022/lib/models/SearchOperator.mjs +0 -6
- package/esm2022/lib/models/SearchPropertySign.mjs +0 -11
- package/esm2022/lib/models/SearchPropertyValue.mjs +0 -2
- package/esm2022/lib/models/SearchPropertyValueType.mjs +0 -11
- package/esm2022/lib/models/SortDirection.mjs +0 -7
- package/esm2022/lib/models/Tag.mjs +0 -2
- package/esm2022/lib/models/TenantConfig.mjs +0 -2
- package/esm2022/lib/models/UserRequest.mjs +0 -2
- package/esm2022/lib/models/auth-mechanism.mjs +0 -8
- package/esm2022/lib/models/base.mjs +0 -2
- package/esm2022/lib/models/conditions.mjs +0 -13
- package/esm2022/lib/models/log-in.mjs +0 -2
- package/esm2022/lib/models/mainUser.mjs +0 -2
- package/esm2022/lib/models/oauth-resp.mjs +0 -2
- package/esm2022/lib/models/oauth-response.mjs +0 -2
- package/esm2022/lib/models/object-state.mjs +0 -8
- package/esm2022/lib/models/otpValue.mjs +0 -2
- package/esm2022/lib/models/paged.mjs +0 -2
- package/esm2022/lib/models/query-params.mjs +0 -2
- package/esm2022/lib/models/request-status.mjs +0 -5
- package/esm2022/lib/models/resend-otp-data.mjs +0 -2
- package/esm2022/lib/models/sign-up.mjs +0 -2
- package/esm2022/lib/models/single-sign-on.mjs +0 -2
- package/esm2022/lib/models/status.mjs +0 -6
- package/esm2022/lib/models/user-access-request-status.mjs +0 -7
- package/esm2022/lib/models/user-access-request.mjs +0 -2
- package/esm2022/lib/models/user.mjs +0 -2
- package/esm2022/lib/pipes/async-label.pipe.mjs +0 -25
- package/esm2022/lib/services/authorization.service.mjs +0 -26
- package/esm2022/lib/services/encryption.service.mjs +0 -52
- package/esm2022/lib/services/environment.service.mjs +0 -26
- package/esm2022/lib/services/http-web-request.service.mjs +0 -85
- package/esm2022/lib/services/label.service.mjs +0 -134
- package/esm2022/lib/services/util.service.mjs +0 -55
- package/esm2022/lib/shared/shared.module.mjs +0 -84
- package/esm2022/public-api.mjs +0 -48
- package/esm2022/verben-authentication-ui.mjs +0 -5
- package/fesm2022/verben-authentication-ui.mjs +0 -6299
- package/fesm2022/verben-authentication-ui.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components/auth-callback/auth-callback.component.d.ts +0 -17
- package/lib/components/auth-callback/auth-callback.module.d.ts +0 -8
- package/lib/components/button/button.component.d.ts +0 -17
- package/lib/components/button/button.module.d.ts +0 -10
- package/lib/components/forgot-password/forgot-password.component.d.ts +0 -29
- package/lib/components/forgot-password/forgot-password.module.d.ts +0 -10
- package/lib/components/mail/mail.component.d.ts +0 -32
- package/lib/components/mail/mail.module.d.ts +0 -11
- package/lib/components/mail-validation/mail-validation.component.d.ts +0 -42
- package/lib/components/mail-validation/mail-validation.module.d.ts +0 -10
- package/lib/components/o-auth/o-auth.component.d.ts +0 -30
- package/lib/components/o-auth/o-auth.module.d.ts +0 -9
- package/lib/components/otp-input/otp-input.component.d.ts +0 -21
- package/lib/components/otp-input/otp-input.module.d.ts +0 -13
- package/lib/components/reset-password/ResetPasswordData.d.ts +0 -5
- package/lib/components/reset-password/reset-password.component.d.ts +0 -30
- package/lib/components/reset-password/reset-password.module.d.ts +0 -10
- package/lib/components/role-control/ChildrenType.d.ts +0 -4
- package/lib/components/role-control/UIActions.d.ts +0 -5
- package/lib/components/role-control/UIs.d.ts +0 -38
- package/lib/components/role-control/base-table-style.d.ts +0 -1
- package/lib/components/role-control/role-control.component.d.ts +0 -121
- package/lib/components/role-control/role-control.module.d.ts +0 -8
- package/lib/components/role-control/role-control.service.d.ts +0 -9
- package/lib/components/sign-in/sign-in.component.d.ts +0 -95
- package/lib/components/sign-in/sign-in.module.d.ts +0 -13
- package/lib/components/sign-up/sign-up.component.d.ts +0 -68
- package/lib/components/sign-up/sign-up.module.d.ts +0 -13
- package/lib/components/sso/base-table-style.d.ts +0 -1
- package/lib/components/sso/helper.d.ts +0 -2
- package/lib/components/sso/sso-form/sso-form.component.d.ts +0 -21
- package/lib/components/sso/sso.columns.d.ts +0 -3
- package/lib/components/sso/sso.component.d.ts +0 -54
- package/lib/components/sso/sso.module.d.ts +0 -11
- package/lib/components/two-factor-auth-otp/two-factor-auth-otp.component.d.ts +0 -67
- package/lib/components/two-factor-auth-otp/two-factor-auth-otp.module.d.ts +0 -12
- package/lib/components/two-factor-auth-setup/two-factor-auth-setup.component.d.ts +0 -39
- package/lib/components/two-factor-auth-setup/two-factor-auth-setup.module.d.ts +0 -9
- package/lib/components/user-management/base-table-style.d.ts +0 -1
- package/lib/components/user-management/services/user-management.service.d.ts +0 -44
- package/lib/components/user-management/user-management-form/use-management-form.component.d.ts +0 -22
- package/lib/components/user-management/user-management.columns.d.ts +0 -3
- package/lib/components/user-management/user-management.component.d.ts +0 -123
- package/lib/components/user-management/user-management.module.d.ts +0 -14
- package/lib/components/user-management/user-status-badge/user-status-badge.component.d.ts +0 -12
- package/lib/components/user-request/user-request.component.d.ts +0 -80
- package/lib/components/user-request/user-request.module.d.ts +0 -11
- package/lib/components/user-request-approval/access-request.columns.d.ts +0 -3
- package/lib/components/user-request-approval/base-table-style.d.ts +0 -1
- package/lib/components/user-request-approval/facades/user-access-request.facade.d.ts +0 -39
- package/lib/components/user-request-approval/helper.d.ts +0 -7
- package/lib/components/user-request-approval/services/user-access-request.service.d.ts +0 -65
- package/lib/components/user-request-approval/states/user-access-request.state.d.ts +0 -35
- package/lib/components/user-request-approval/user-access-request-status-badge/user-access-request-status-badge.component.d.ts +0 -12
- package/lib/components/user-request-approval/user-request-approval.component.d.ts +0 -69
- package/lib/components/user-request-approval/user-request-approval.module.d.ts +0 -12
- package/lib/components/user-request-approval/user-request-form/use-request-form.component.d.ts +0 -25
- package/lib/models/ApplicationRoleAction.d.ts +0 -9
- package/lib/models/ErrorResponse.d.ts +0 -6
- package/lib/models/OAuthParam.d.ts +0 -9
- package/lib/models/OAuthType.d.ts +0 -7
- package/lib/models/PagedResult.d.ts +0 -9
- package/lib/models/PasswordRequestParam.d.ts +0 -5
- package/lib/models/ResponseKeyValue.d.ts +0 -5
- package/lib/models/RoleAction.d.ts +0 -10
- package/lib/models/RoleContext.d.ts +0 -10
- package/lib/models/SearchOperator.d.ts +0 -4
- package/lib/models/SearchPropertySign.d.ts +0 -9
- package/lib/models/SearchPropertyValueType.d.ts +0 -9
- package/lib/models/SortDirection.d.ts +0 -5
- package/lib/models/TenantConfig.d.ts +0 -18
- package/lib/models/UserRequest.d.ts +0 -32
- package/lib/models/auth-mechanism.d.ts +0 -14
- package/lib/models/base.d.ts +0 -12
- package/lib/models/conditions.d.ts +0 -11
- package/lib/models/log-in.d.ts +0 -8
- package/lib/models/oauth-resp.d.ts +0 -6
- package/lib/models/object-state.d.ts +0 -6
- package/lib/models/paged.d.ts +0 -9
- package/lib/models/query-params.d.ts +0 -8
- package/lib/models/request-status.d.ts +0 -3
- package/lib/models/resend-otp-data.d.ts +0 -8
- package/lib/models/sign-up.d.ts +0 -9
- package/lib/models/single-sign-on.d.ts +0 -7
- package/lib/models/status.d.ts +0 -4
- package/lib/models/user-access-request-status.d.ts +0 -5
- package/lib/models/user.d.ts +0 -18
- package/lib/pipes/async-label.pipe.d.ts +0 -11
- package/lib/services/authorization.service.d.ts +0 -14
- package/lib/services/encryption.service.d.ts +0 -13
- package/lib/services/environment.service.d.ts +0 -22
- package/lib/services/http-web-request.service.d.ts +0 -23
- package/lib/services/label.service.d.ts +0 -15
- package/lib/services/util.service.d.ts +0 -11
- package/lib/shared/shared.module.d.ts +0 -10
|
@@ -0,0 +1,1817 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Component,
|
|
4
|
+
Input,
|
|
5
|
+
OnInit,
|
|
6
|
+
QueryList,
|
|
7
|
+
ViewChild,
|
|
8
|
+
ViewChildren,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { RoleControlService } from './role-control.service';
|
|
11
|
+
import {
|
|
12
|
+
CardData,
|
|
13
|
+
CardDataViewComponent,
|
|
14
|
+
ColumnDefinition,
|
|
15
|
+
DataFilterType,
|
|
16
|
+
DataTableComponent,
|
|
17
|
+
DataViewComponent,
|
|
18
|
+
IDataFilter,
|
|
19
|
+
VerbenPopUpComponent,
|
|
20
|
+
} from 'verben-ng-ui';
|
|
21
|
+
import { Role } from '../../models/Role';
|
|
22
|
+
import { baseStyle } from './base-table-style';
|
|
23
|
+
import { ObjectState } from '../../models/object-state';
|
|
24
|
+
import { RoleContext } from '../../models/RoleContext';
|
|
25
|
+
import { UIs } from './UIs';
|
|
26
|
+
import { RoleAction } from '../../models/RoleAction';
|
|
27
|
+
import { UIActions } from './UIActions';
|
|
28
|
+
import { MappedRole } from './MappedRole';
|
|
29
|
+
import {
|
|
30
|
+
AuthorizationConfig,
|
|
31
|
+
AuthorizationService,
|
|
32
|
+
} from '../../services/authorization.service';
|
|
33
|
+
import { MappedRoleContext } from './MappedRoleContext';
|
|
34
|
+
import { MappedRoleAction } from './MappedRoleAction';
|
|
35
|
+
import { ChildrenType } from './ChildrenType';
|
|
36
|
+
import {
|
|
37
|
+
FormBuilder,
|
|
38
|
+
FormControl,
|
|
39
|
+
FormGroup,
|
|
40
|
+
Validators,
|
|
41
|
+
} from '@angular/forms';
|
|
42
|
+
import { UtilService } from '../../services/util.service';
|
|
43
|
+
import { HttpWebRequestService } from '../../services/http-web-request.service';
|
|
44
|
+
import { ErrorResponse } from '../../models/ErrorResponse';
|
|
45
|
+
import { PagedResult } from '../../models/PagedResult';
|
|
46
|
+
import { SearchPropertyValue } from '../../models/SearchPropertyValue';
|
|
47
|
+
import { SearchOperator } from '../../models/SearchOperator';
|
|
48
|
+
import { SearchPropertySign } from '../../models/SearchPropertySign';
|
|
49
|
+
import { EnvironmentService } from '../../services/environment.service';
|
|
50
|
+
import { ApplicationRoleContext } from '../../models/ApplicationRoleContext';
|
|
51
|
+
import { ApplicationRoleAction } from '../../models/ApplicationRoleAction';
|
|
52
|
+
import { SearchPropertyValueType } from '../../models/SearchPropertyValueType';
|
|
53
|
+
import { debounceTime, Subject } from 'rxjs';
|
|
54
|
+
import { SortDirection } from '../../models/SortDirection';
|
|
55
|
+
import { PermissionConfig } from '../../models/PermissionConfig';
|
|
56
|
+
|
|
57
|
+
enum DateFilterTypes {
|
|
58
|
+
Before = SearchPropertySign.LT,
|
|
59
|
+
On = SearchPropertySign.EQ,
|
|
60
|
+
After = SearchPropertySign.GT,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Component({
|
|
64
|
+
selector: 'lib-role-control',
|
|
65
|
+
templateUrl: './role-control.component.html',
|
|
66
|
+
styleUrl: './role-control.component.css',
|
|
67
|
+
})
|
|
68
|
+
export class RoleControlComponent implements OnInit {
|
|
69
|
+
visibleColumnDef: ColumnDefinition<MappedRole>[] = [];
|
|
70
|
+
styles = baseStyle;
|
|
71
|
+
data: MappedRole[] = [];
|
|
72
|
+
cardData: CardData[] = [];
|
|
73
|
+
currentData: CardData | null = null;
|
|
74
|
+
currentExpandedCard: CardData | null = null;
|
|
75
|
+
cardContext: CardData | null = null;
|
|
76
|
+
cardContextHistory: CardData[] = [];
|
|
77
|
+
cardContextHistoryData: CardData[][] = [];
|
|
78
|
+
@ViewChild('vdcv') cardDataView!: CardDataViewComponent;
|
|
79
|
+
@ViewChild('vdv') dataView!: DataViewComponent;
|
|
80
|
+
@ViewChildren('popup') popUps!: QueryList<VerbenPopUpComponent>;
|
|
81
|
+
@ViewChild('dt') tableView!: DataTableComponent<MappedRole>;
|
|
82
|
+
@Input() isGlobal: boolean = true;
|
|
83
|
+
@Input() serviceName: string | null = null;
|
|
84
|
+
@Input() application: string | null = null;
|
|
85
|
+
@Input() pageSize: number = 10;
|
|
86
|
+
@Input() searchDebounceTime: number = 500;
|
|
87
|
+
@Input() permissionConfig: PermissionConfig | null = null;
|
|
88
|
+
pageState: PagedResult<Role> | null = null;
|
|
89
|
+
sourceData: AuthorizationConfig[] = [];
|
|
90
|
+
isOpen: boolean = false;
|
|
91
|
+
openDropdownId: string | null = null;
|
|
92
|
+
currentFilters: IDataFilter[] = [];
|
|
93
|
+
currentSorts: IDataFilter[] = [];
|
|
94
|
+
searchTerm$ = new Subject<string>();
|
|
95
|
+
|
|
96
|
+
visibleColumns: IDataFilter[] = [];
|
|
97
|
+
|
|
98
|
+
filterArray: IDataFilter[] = [
|
|
99
|
+
{
|
|
100
|
+
name: 'CreatedAt',
|
|
101
|
+
type: DataFilterType.Date,
|
|
102
|
+
checked: false,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'UpdatedAt',
|
|
106
|
+
type: DataFilterType.Date,
|
|
107
|
+
checked: false,
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
sortOptions: IDataFilter[] = [
|
|
112
|
+
{
|
|
113
|
+
name: 'CreatedAt',
|
|
114
|
+
type: DataFilterType.Date,
|
|
115
|
+
checked: false,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'UpdatedAt',
|
|
119
|
+
type: DataFilterType.Date,
|
|
120
|
+
checked: false,
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
// private _searchItem: string = '';
|
|
125
|
+
// get searchItem(): string {
|
|
126
|
+
// return this._searchItem
|
|
127
|
+
// }
|
|
128
|
+
// set searchItem(value: string) {
|
|
129
|
+
// this._searchItem = value;
|
|
130
|
+
// this.searchTerm$.next(value);
|
|
131
|
+
// }
|
|
132
|
+
|
|
133
|
+
// form: FormGroup;
|
|
134
|
+
childPermissionRef: ChildrenType = ChildrenType.Permission;
|
|
135
|
+
|
|
136
|
+
roleContextsStore: ApplicationRoleContext[] = [];
|
|
137
|
+
roleActionsStore: ApplicationRoleAction[] = [];
|
|
138
|
+
private currentSearchTerm: string = '';
|
|
139
|
+
|
|
140
|
+
constructor(
|
|
141
|
+
private authService: AuthorizationService,
|
|
142
|
+
private roleControlSvc: RoleControlService,
|
|
143
|
+
private utilService: UtilService,
|
|
144
|
+
private server: HttpWebRequestService,
|
|
145
|
+
private cdr: ChangeDetectorRef,
|
|
146
|
+
private fb: FormBuilder,
|
|
147
|
+
private envSvc: EnvironmentService
|
|
148
|
+
) {
|
|
149
|
+
this.visibleColumnDef = roleControlSvc.roleColumns;
|
|
150
|
+
this.visibleColumns = roleControlSvc.roleColumns.map((col) => ({
|
|
151
|
+
checked: true,
|
|
152
|
+
name: typeof col.header === 'string' ? col.header : col.id,
|
|
153
|
+
type: DataFilterType.Bool,
|
|
154
|
+
}));
|
|
155
|
+
// this.form = this.fb.group({
|
|
156
|
+
// Name: new FormControl<string | null>(null, Validators.required),
|
|
157
|
+
// });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async ngOnInit(): Promise<void> {
|
|
161
|
+
const mockData = this.getMockRoles();
|
|
162
|
+
const roles = await this.getAllRoles();
|
|
163
|
+
if (this.isGlobal) {
|
|
164
|
+
const contextsRes = await this.getSavedContexts();
|
|
165
|
+
if (contextsRes) {
|
|
166
|
+
this.roleContextsStore = contextsRes;
|
|
167
|
+
this.roleActionsStore = contextsRes.flatMap((x) => x.RoleActions);
|
|
168
|
+
const authConfig: AuthorizationConfig[] = contextsRes.map((x) => {
|
|
169
|
+
return {
|
|
170
|
+
Name: x.Name,
|
|
171
|
+
Actions: x.RoleActions.map((y) => {
|
|
172
|
+
return y.Name;
|
|
173
|
+
}),
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
this.sourceData = authConfig;
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
this.sourceData = this.authService.authorizationConfig;
|
|
180
|
+
}
|
|
181
|
+
if (roles) {
|
|
182
|
+
this.setUpMappedData(roles);
|
|
183
|
+
this.setUpCardData();
|
|
184
|
+
}
|
|
185
|
+
this.searchTerm$
|
|
186
|
+
.pipe(debounceTime(this.searchDebounceTime)) // Adjust debounce time here (in ms)
|
|
187
|
+
.subscribe(async (searchTerm) => {
|
|
188
|
+
this.currentSearchTerm = searchTerm;
|
|
189
|
+
this.updateFiltersAndSorts(true);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async getSavedContexts(): Promise<ApplicationRoleContext[] | undefined> {
|
|
194
|
+
if (!this.isGlobal || !this.application) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
var payload: SearchPropertyValue[] = [
|
|
198
|
+
{
|
|
199
|
+
PropertyName: 'Application',
|
|
200
|
+
EntityValue: this.application,
|
|
201
|
+
Operator: SearchOperator.And,
|
|
202
|
+
Sign: SearchPropertySign.EQ,
|
|
203
|
+
},
|
|
204
|
+
// {
|
|
205
|
+
// PropertyName: 'APIKey',
|
|
206
|
+
// EntityValue: this.envSvc.environment.APIKey,
|
|
207
|
+
// Operator: SearchOperator.And,
|
|
208
|
+
// Sign: SearchPropertySign.EQ,
|
|
209
|
+
// },
|
|
210
|
+
];
|
|
211
|
+
this.utilService.sendBI(true);
|
|
212
|
+
const res = await this.server.post(
|
|
213
|
+
`Application/SearchApplicationRoleContexts/0/0`,
|
|
214
|
+
payload
|
|
215
|
+
);
|
|
216
|
+
this.utilService.sendBI(false);
|
|
217
|
+
if (res instanceof ErrorResponse) {
|
|
218
|
+
return undefined;
|
|
219
|
+
} else {
|
|
220
|
+
var result = (res as PagedResult<ApplicationRoleContext>).Result;
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async getAllRoles(): Promise<Role[] | undefined> {
|
|
225
|
+
// var payload: SearchPropertyValue[] = [
|
|
226
|
+
// {
|
|
227
|
+
// PropertyName: 'APIKey',
|
|
228
|
+
// EntityValue: this.envSvc.environment.APIKey,
|
|
229
|
+
// Operator: SearchOperator.And,
|
|
230
|
+
// Sign: SearchPropertySign.EQ
|
|
231
|
+
// }
|
|
232
|
+
// ]
|
|
233
|
+
this.utilService.sendBI(true);
|
|
234
|
+
const res = await this.server.get(`Role/GetRoles/0/${this.pageSize}`);
|
|
235
|
+
this.utilService.sendBI(false);
|
|
236
|
+
if (res instanceof ErrorResponse) {
|
|
237
|
+
return undefined;
|
|
238
|
+
} else {
|
|
239
|
+
this.pageState = res as PagedResult<Role>;
|
|
240
|
+
var result = (res as PagedResult<Role>).Result;
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async loadMore() {
|
|
246
|
+
if (!this.pageState) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.utilService.sendBI(true);
|
|
250
|
+
const res =
|
|
251
|
+
this.currentFilters.length > 0 ||
|
|
252
|
+
this.currentSorts.length > 0 ||
|
|
253
|
+
this.currentSearchTerm.trim().length > 0
|
|
254
|
+
? await this.loadMoreFiltersAndSorts()
|
|
255
|
+
: await this.server.get(
|
|
256
|
+
`Role/GetRoles/${this.pageState.Skip}/${this.pageSize}`
|
|
257
|
+
);
|
|
258
|
+
this.utilService.sendBI(false);
|
|
259
|
+
if (res instanceof ErrorResponse) {
|
|
260
|
+
return;
|
|
261
|
+
} else {
|
|
262
|
+
this.pageState = res as PagedResult<Role>;
|
|
263
|
+
var result = (res as PagedResult<Role>).Result;
|
|
264
|
+
const data = this.setUpMappedDataExtra(result);
|
|
265
|
+
this.data = this.data.concat(data);
|
|
266
|
+
this.setUpCardDataExtra(data);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
getApplicationContextCode(name: string): string {
|
|
271
|
+
const item = this.roleContextsStore.find((x) => x.Name == name);
|
|
272
|
+
return item ? item.Code : '';
|
|
273
|
+
}
|
|
274
|
+
getApplicationActionCode(name: string): string {
|
|
275
|
+
const item = this.roleActionsStore.find((x) => x.Name == name);
|
|
276
|
+
return item ? item.Code : '';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
findParent(cardData: CardData[], target: CardData): CardData | null {
|
|
280
|
+
for (const item of cardData) {
|
|
281
|
+
if (item.children.includes(target)) {
|
|
282
|
+
return item; // Immediate parent found
|
|
283
|
+
}
|
|
284
|
+
const parent = this.findParent(item.children, target);
|
|
285
|
+
if (parent) {
|
|
286
|
+
return parent;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return null; // Not found
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
isAllSelected(item: CardData): boolean {
|
|
293
|
+
const parent =
|
|
294
|
+
this.cardContextHistoryData.length > 0
|
|
295
|
+
? this.findParent(this.cardContextHistoryData[0], item)
|
|
296
|
+
: this.findParent(this.cardData, item);
|
|
297
|
+
if (
|
|
298
|
+
parent &&
|
|
299
|
+
parent.data.ChildrenType &&
|
|
300
|
+
parent.data.ChildrenType == ChildrenType.Action &&
|
|
301
|
+
(parent.data as MappedRoleContext).RoleActions.some((y) => !y.Selected)
|
|
302
|
+
) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (
|
|
307
|
+
parent &&
|
|
308
|
+
parent.data.ChildrenType &&
|
|
309
|
+
parent.data.ChildrenType == ChildrenType.Permission &&
|
|
310
|
+
(parent.data as MappedRole).RoleContexts.some((y) => !y.Selected)
|
|
311
|
+
) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
isCheckboxDisabled(item: CardData): boolean {
|
|
318
|
+
const parent =
|
|
319
|
+
this.cardContextHistoryData.length > 0
|
|
320
|
+
? this.findParent(this.cardContextHistoryData[0], item)
|
|
321
|
+
: this.findParent(this.cardData, item);
|
|
322
|
+
if (
|
|
323
|
+
parent &&
|
|
324
|
+
parent.data.ChildrenType &&
|
|
325
|
+
parent.data.ChildrenType == ChildrenType.Action &&
|
|
326
|
+
(parent.data.Selected == false ||
|
|
327
|
+
(this.permissionConfig != null &&
|
|
328
|
+
!this.permissionConfig.Actions['AddAction']))
|
|
329
|
+
) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (
|
|
334
|
+
parent &&
|
|
335
|
+
parent.data.ChildrenType &&
|
|
336
|
+
parent.data.ChildrenType == ChildrenType.Permission &&
|
|
337
|
+
this.permissionConfig != null &&
|
|
338
|
+
!this.permissionConfig.Actions['AddContext']
|
|
339
|
+
) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
setUpMappedData(data: Role[]) {
|
|
346
|
+
this.data = data.map((x) => {
|
|
347
|
+
return {
|
|
348
|
+
...x,
|
|
349
|
+
Id: x.Code,
|
|
350
|
+
ChildrenType: ChildrenType.Permission,
|
|
351
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
352
|
+
const existingId = x.RoleContexts.findIndex(
|
|
353
|
+
(y) => y.Name == config.Name
|
|
354
|
+
);
|
|
355
|
+
var context: MappedRoleContext = {
|
|
356
|
+
ChildrenType: ChildrenType.Action,
|
|
357
|
+
Selected: existingId > -1 ? true : false,
|
|
358
|
+
RoleActions: config.Actions.map((action) => {
|
|
359
|
+
const existingAction =
|
|
360
|
+
existingId > -1
|
|
361
|
+
? x.RoleContexts[existingId].RoleActions.findIndex(
|
|
362
|
+
(c) => c.Name == action
|
|
363
|
+
)
|
|
364
|
+
: -1;
|
|
365
|
+
|
|
366
|
+
var act: MappedRoleAction = {
|
|
367
|
+
Selected: existingAction > -1 ? true : false,
|
|
368
|
+
Name: action,
|
|
369
|
+
Role: x.Code,
|
|
370
|
+
Context: '',
|
|
371
|
+
id:
|
|
372
|
+
existingAction > -1
|
|
373
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
374
|
+
.Code
|
|
375
|
+
: '',
|
|
376
|
+
Id:
|
|
377
|
+
existingAction > -1
|
|
378
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
379
|
+
.Code
|
|
380
|
+
: '',
|
|
381
|
+
CreatedAt: new Date(),
|
|
382
|
+
UpdatedAt: new Date(),
|
|
383
|
+
DataState: ObjectState.New,
|
|
384
|
+
TenantId: x.TenantId,
|
|
385
|
+
Code:
|
|
386
|
+
existingAction > -1
|
|
387
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
388
|
+
.Code
|
|
389
|
+
: '',
|
|
390
|
+
ServiceName:
|
|
391
|
+
existingAction > -1
|
|
392
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
393
|
+
.ServiceName
|
|
394
|
+
: '',
|
|
395
|
+
APIKey:
|
|
396
|
+
existingAction > -1
|
|
397
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
398
|
+
.APIKey
|
|
399
|
+
: this.envSvc.environment.APIKey,
|
|
400
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
401
|
+
};
|
|
402
|
+
return act;
|
|
403
|
+
}),
|
|
404
|
+
Name: config.Name,
|
|
405
|
+
Role: x.Code,
|
|
406
|
+
id: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
407
|
+
Id: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
408
|
+
CreatedAt: new Date(),
|
|
409
|
+
UpdatedAt: new Date(),
|
|
410
|
+
DataState: ObjectState.New,
|
|
411
|
+
TenantId: x.TenantId,
|
|
412
|
+
Code: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
413
|
+
ServiceName:
|
|
414
|
+
existingId > -1 ? x.RoleContexts[existingId].ServiceName : '',
|
|
415
|
+
APIKey:
|
|
416
|
+
existingId > -1
|
|
417
|
+
? x.RoleContexts[existingId].APIKey
|
|
418
|
+
: this.envSvc.environment.APIKey,
|
|
419
|
+
ApplicationRoleContext: this.getApplicationContextCode(config.Name),
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
return context;
|
|
423
|
+
}),
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
setUpMappedDataExtra(data: Role[]): MappedRole[] {
|
|
428
|
+
return data.map((x) => {
|
|
429
|
+
return {
|
|
430
|
+
...x,
|
|
431
|
+
Id: x.Code,
|
|
432
|
+
ChildrenType: ChildrenType.Permission,
|
|
433
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
434
|
+
const existingId = x.RoleContexts.findIndex(
|
|
435
|
+
(y) => y.Name == config.Name
|
|
436
|
+
);
|
|
437
|
+
var context: MappedRoleContext = {
|
|
438
|
+
ChildrenType: ChildrenType.Action,
|
|
439
|
+
Selected: existingId > -1 ? true : false,
|
|
440
|
+
RoleActions: config.Actions.map((action) => {
|
|
441
|
+
const existingAction =
|
|
442
|
+
existingId > -1
|
|
443
|
+
? x.RoleContexts[existingId].RoleActions.findIndex(
|
|
444
|
+
(c) => c.Name == action
|
|
445
|
+
)
|
|
446
|
+
: -1;
|
|
447
|
+
|
|
448
|
+
var act: MappedRoleAction = {
|
|
449
|
+
Selected: existingAction > -1 ? true : false,
|
|
450
|
+
Name: action,
|
|
451
|
+
Role: x.Code,
|
|
452
|
+
Context: '',
|
|
453
|
+
id:
|
|
454
|
+
existingAction > -1
|
|
455
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
456
|
+
.Code
|
|
457
|
+
: '',
|
|
458
|
+
Id:
|
|
459
|
+
existingAction > -1
|
|
460
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
461
|
+
.Code
|
|
462
|
+
: '',
|
|
463
|
+
CreatedAt: new Date(),
|
|
464
|
+
UpdatedAt: new Date(),
|
|
465
|
+
DataState: ObjectState.New,
|
|
466
|
+
TenantId: x.TenantId,
|
|
467
|
+
Code:
|
|
468
|
+
existingAction > -1
|
|
469
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
470
|
+
.Code
|
|
471
|
+
: '',
|
|
472
|
+
ServiceName:
|
|
473
|
+
existingAction > -1
|
|
474
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
475
|
+
.ServiceName
|
|
476
|
+
: '',
|
|
477
|
+
APIKey:
|
|
478
|
+
existingAction > -1
|
|
479
|
+
? x.RoleContexts[existingId].RoleActions[existingAction]
|
|
480
|
+
.APIKey
|
|
481
|
+
: this.envSvc.environment.APIKey,
|
|
482
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
483
|
+
};
|
|
484
|
+
return act;
|
|
485
|
+
}),
|
|
486
|
+
Name: config.Name,
|
|
487
|
+
Role: x.Code,
|
|
488
|
+
id: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
489
|
+
Id: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
490
|
+
CreatedAt: new Date(),
|
|
491
|
+
UpdatedAt: new Date(),
|
|
492
|
+
DataState: ObjectState.New,
|
|
493
|
+
TenantId: x.TenantId,
|
|
494
|
+
Code: existingId > -1 ? x.RoleContexts[existingId].Code : '',
|
|
495
|
+
ServiceName:
|
|
496
|
+
existingId > -1 ? x.RoleContexts[existingId].ServiceName : '',
|
|
497
|
+
APIKey:
|
|
498
|
+
existingId > -1
|
|
499
|
+
? x.RoleContexts[existingId].APIKey
|
|
500
|
+
: this.envSvc.environment.APIKey,
|
|
501
|
+
ApplicationRoleContext: this.getApplicationContextCode(config.Name),
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
return context;
|
|
505
|
+
}),
|
|
506
|
+
};
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
setUpCardData() {
|
|
511
|
+
const cardData: CardData[] = this.data.map((x) => {
|
|
512
|
+
return {
|
|
513
|
+
selected: false,
|
|
514
|
+
title: x.Name,
|
|
515
|
+
data: x,
|
|
516
|
+
body: [],
|
|
517
|
+
children: x.RoleContexts.map((c) => {
|
|
518
|
+
return {
|
|
519
|
+
selected: false,
|
|
520
|
+
title: this.getFormattedName(c.Name),
|
|
521
|
+
data: c,
|
|
522
|
+
body: [],
|
|
523
|
+
children: c.RoleActions.map((a) => {
|
|
524
|
+
return {
|
|
525
|
+
selected: false,
|
|
526
|
+
title: this.getFormattedName(a.Name),
|
|
527
|
+
data: a,
|
|
528
|
+
body: [],
|
|
529
|
+
children: [],
|
|
530
|
+
};
|
|
531
|
+
}),
|
|
532
|
+
};
|
|
533
|
+
}),
|
|
534
|
+
};
|
|
535
|
+
});
|
|
536
|
+
this.cardData = cardData;
|
|
537
|
+
}
|
|
538
|
+
setUpCardDataExtra(baseData: MappedRole[]) {
|
|
539
|
+
const cardData: CardData[] = baseData.map((x) => {
|
|
540
|
+
return {
|
|
541
|
+
selected: false,
|
|
542
|
+
title: x.Name,
|
|
543
|
+
data: x,
|
|
544
|
+
body: [],
|
|
545
|
+
children: x.RoleContexts.map((c) => {
|
|
546
|
+
return {
|
|
547
|
+
selected: false,
|
|
548
|
+
title: this.getFormattedName(c.Name),
|
|
549
|
+
data: c,
|
|
550
|
+
body: [],
|
|
551
|
+
children: c.RoleActions.map((a) => {
|
|
552
|
+
return {
|
|
553
|
+
selected: false,
|
|
554
|
+
title: this.getFormattedName(a.Name),
|
|
555
|
+
data: a,
|
|
556
|
+
body: [],
|
|
557
|
+
children: [],
|
|
558
|
+
};
|
|
559
|
+
}),
|
|
560
|
+
};
|
|
561
|
+
}),
|
|
562
|
+
};
|
|
563
|
+
});
|
|
564
|
+
this.cardData = this.cardData.concat(cardData);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
getFormattedName(name: string): string {
|
|
568
|
+
// Split the key on capital letters, handling "And" as lowercase
|
|
569
|
+
const words = name
|
|
570
|
+
.split(/(?=[A-Z])/)
|
|
571
|
+
.map((word) => (word === 'And' ? 'and' : word));
|
|
572
|
+
// Join the words with spaces
|
|
573
|
+
return words.join(' ');
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
viewDetailsFromTable(data: MappedRole) {
|
|
577
|
+
const cardData = this.cardData.find((x) => x.data == data);
|
|
578
|
+
console.log({ Data: data });
|
|
579
|
+
console.log({ CardData: this.cardData });
|
|
580
|
+
if (cardData) {
|
|
581
|
+
this.dataView.isTableView = false;
|
|
582
|
+
this.viewDetails(cardData);
|
|
583
|
+
}
|
|
584
|
+
this.closePopUp();
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
viewDetails(context: CardData) {
|
|
588
|
+
this.cardContextHistory.push(context);
|
|
589
|
+
this.cardContextHistoryData.push(this.cardData);
|
|
590
|
+
this.cardData = context.children;
|
|
591
|
+
this.cardDataView.clearData();
|
|
592
|
+
}
|
|
593
|
+
viewDetailsChild(context: CardData) {
|
|
594
|
+
if (this.currentExpandedCard) {
|
|
595
|
+
this.cardContextHistory.push(this.currentExpandedCard);
|
|
596
|
+
this.cardContextHistory.push(context);
|
|
597
|
+
this.cardContextHistoryData.push(this.cardData);
|
|
598
|
+
this.cardContextHistoryData.push(this.currentExpandedCard.children);
|
|
599
|
+
this.cardData = context.children;
|
|
600
|
+
this.cardDataView.clearData();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
roleCardClicked(item: CardData) {
|
|
605
|
+
this.currentData = this.cardDataView.onItemClick(item);
|
|
606
|
+
// if (this.currentData) {
|
|
607
|
+
// this.form.controls['Name'].setValue(this.currentData.data?.Name);
|
|
608
|
+
// }
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
toggleChildren(item: CardData) {
|
|
612
|
+
var currToggleState = item.isChildrenExpanded;
|
|
613
|
+
this.cardData.forEach((_) => {
|
|
614
|
+
_.isChildrenExpanded = false;
|
|
615
|
+
});
|
|
616
|
+
item.isChildrenExpanded = !currToggleState;
|
|
617
|
+
if (item.isChildrenExpanded) {
|
|
618
|
+
this.currentExpandedCard = item;
|
|
619
|
+
} else {
|
|
620
|
+
this.currentExpandedCard = null;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
goToTableView() {
|
|
625
|
+
if (!this.currentData) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
this.dataView.toggleView();
|
|
629
|
+
const id = this.currentData.data ? this.currentData.data.Id : '';
|
|
630
|
+
if (id.trim().length > 0 && !this.tableView.isRowEditing(id)) {
|
|
631
|
+
this.tableView.toggleRowEdit(id);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
closeDetails() {
|
|
635
|
+
this.cardData =
|
|
636
|
+
this.cardContextHistoryData[this.cardContextHistoryData.length - 1];
|
|
637
|
+
this.cardContextHistoryData.pop();
|
|
638
|
+
this.cardContextHistory.pop();
|
|
639
|
+
setTimeout(() => {
|
|
640
|
+
if (this.dataView.isTableView) {
|
|
641
|
+
this.dataView.toggleView();
|
|
642
|
+
}
|
|
643
|
+
}, 200);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
getCardSubCaption(item: CardData) {
|
|
647
|
+
const selected = item.children.filter((x) => x.data.Selected).length;
|
|
648
|
+
const total = item.children.length;
|
|
649
|
+
return `${selected} of ${total} ${
|
|
650
|
+
total > 1 ? item.data.ChildrenType + 's' : item.data.ChildrenType
|
|
651
|
+
}`;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
getUpdatedRole(role: MappedRole): Role {
|
|
655
|
+
const newRole = role;
|
|
656
|
+
newRole.RoleContexts = role.RoleContexts.filter((x) => x.Selected).map(
|
|
657
|
+
(y) => {
|
|
658
|
+
y.RoleActions = y.RoleActions.filter((z) => z.Selected);
|
|
659
|
+
return y;
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
newRole.DataState =
|
|
663
|
+
newRole.DataState == ObjectState.New
|
|
664
|
+
? ObjectState.New
|
|
665
|
+
: ObjectState.Changed;
|
|
666
|
+
newRole.Id = '';
|
|
667
|
+
return newRole as Role;
|
|
668
|
+
}
|
|
669
|
+
async saveRole() {
|
|
670
|
+
if (this.currentData) {
|
|
671
|
+
var role: MappedRole = this.currentData.data as MappedRole;
|
|
672
|
+
// role.Name = this.form.controls['Name'].value;
|
|
673
|
+
if (this.currentData.data.Name.trim().length == 0) {
|
|
674
|
+
this.utilService.showInfo('Role name cannot be empty');
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const mappedRole = this.getUpdatedRole(JSON.parse(JSON.stringify(role)));
|
|
678
|
+
this.utilService.sendBI(true);
|
|
679
|
+
const res = await this.server.post(`Role/SaveRoles`, [mappedRole]);
|
|
680
|
+
this.utilService.sendBI(false);
|
|
681
|
+
if (res instanceof ErrorResponse) {
|
|
682
|
+
} else {
|
|
683
|
+
this.utilService.showSuccess('Role saved successfully');
|
|
684
|
+
const result = res as Role[];
|
|
685
|
+
if (result.length > 0) {
|
|
686
|
+
var roleResult = result[0];
|
|
687
|
+
var mappedRoleSave: MappedRole = {
|
|
688
|
+
...roleResult,
|
|
689
|
+
ChildrenType: ChildrenType.Permission,
|
|
690
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
691
|
+
const existingId = roleResult.RoleContexts.findIndex(
|
|
692
|
+
(y) => y.Name == config.Name
|
|
693
|
+
);
|
|
694
|
+
var context: MappedRoleContext = {
|
|
695
|
+
ChildrenType: ChildrenType.Action,
|
|
696
|
+
Selected: existingId > -1 ? true : false,
|
|
697
|
+
RoleActions: config.Actions.map((action) => {
|
|
698
|
+
const existingAction =
|
|
699
|
+
existingId > -1
|
|
700
|
+
? roleResult.RoleContexts[
|
|
701
|
+
existingId
|
|
702
|
+
].RoleActions.findIndex((c) => c.Name == action)
|
|
703
|
+
: -1;
|
|
704
|
+
|
|
705
|
+
var act: MappedRoleAction = {
|
|
706
|
+
Selected: existingAction > -1 ? true : false,
|
|
707
|
+
Name: action,
|
|
708
|
+
Role: roleResult.Code,
|
|
709
|
+
Context: '',
|
|
710
|
+
id:
|
|
711
|
+
existingAction > -1
|
|
712
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
713
|
+
existingAction
|
|
714
|
+
].Code
|
|
715
|
+
: '',
|
|
716
|
+
Id:
|
|
717
|
+
existingAction > -1
|
|
718
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
719
|
+
existingAction
|
|
720
|
+
].Code
|
|
721
|
+
: '',
|
|
722
|
+
CreatedAt: new Date(),
|
|
723
|
+
UpdatedAt: new Date(),
|
|
724
|
+
DataState: ObjectState.New,
|
|
725
|
+
TenantId: roleResult.TenantId,
|
|
726
|
+
Code:
|
|
727
|
+
existingAction > -1
|
|
728
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
729
|
+
existingAction
|
|
730
|
+
].Code
|
|
731
|
+
: '',
|
|
732
|
+
ServiceName:
|
|
733
|
+
existingAction > -1
|
|
734
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
735
|
+
existingAction
|
|
736
|
+
].ServiceName
|
|
737
|
+
: '',
|
|
738
|
+
APIKey:
|
|
739
|
+
existingAction > -1
|
|
740
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
741
|
+
existingAction
|
|
742
|
+
].APIKey
|
|
743
|
+
: this.envSvc.environment.APIKey,
|
|
744
|
+
ApplicationRoleAction:
|
|
745
|
+
this.getApplicationActionCode(action),
|
|
746
|
+
};
|
|
747
|
+
return act;
|
|
748
|
+
}),
|
|
749
|
+
Name: config.Name,
|
|
750
|
+
Role: roleResult.Code,
|
|
751
|
+
id:
|
|
752
|
+
existingId > -1
|
|
753
|
+
? roleResult.RoleContexts[existingId].Code
|
|
754
|
+
: '',
|
|
755
|
+
Id:
|
|
756
|
+
existingId > -1
|
|
757
|
+
? roleResult.RoleContexts[existingId].Code
|
|
758
|
+
: '',
|
|
759
|
+
CreatedAt: new Date(),
|
|
760
|
+
UpdatedAt: new Date(),
|
|
761
|
+
DataState: ObjectState.New,
|
|
762
|
+
TenantId: roleResult.TenantId,
|
|
763
|
+
Code:
|
|
764
|
+
existingId > -1
|
|
765
|
+
? roleResult.RoleContexts[existingId].Code
|
|
766
|
+
: '',
|
|
767
|
+
ServiceName:
|
|
768
|
+
existingId > -1
|
|
769
|
+
? roleResult.RoleContexts[existingId].ServiceName
|
|
770
|
+
: '',
|
|
771
|
+
APIKey:
|
|
772
|
+
existingId > -1
|
|
773
|
+
? roleResult.RoleContexts[existingId].APIKey
|
|
774
|
+
: this.envSvc.environment.APIKey,
|
|
775
|
+
ApplicationRoleContext: this.getApplicationContextCode(
|
|
776
|
+
config.Name
|
|
777
|
+
),
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
return context;
|
|
781
|
+
}),
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
const itemIndex = this.data.findIndex(
|
|
785
|
+
(x) => x == this.currentData?.data
|
|
786
|
+
);
|
|
787
|
+
if (itemIndex > -1) {
|
|
788
|
+
this.data[itemIndex].Code = mappedRoleSave.Code;
|
|
789
|
+
this.data[itemIndex].Id = mappedRoleSave.Code;
|
|
790
|
+
this.data[itemIndex].DataState = mappedRoleSave.DataState;
|
|
791
|
+
this.data[itemIndex].TenantId = mappedRoleSave.TenantId;
|
|
792
|
+
this.data[itemIndex].ServiceName = mappedRoleSave.ServiceName;
|
|
793
|
+
mappedRoleSave.RoleContexts.forEach((x, i) => {
|
|
794
|
+
this.data[itemIndex].RoleContexts[i].Role = mappedRoleSave.Code;
|
|
795
|
+
this.data[itemIndex].RoleContexts[i].Code = x.Code;
|
|
796
|
+
this.data[itemIndex].RoleContexts[i].ServiceName = x.ServiceName;
|
|
797
|
+
x.RoleActions.forEach((y, j) => {
|
|
798
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Role =
|
|
799
|
+
mappedRoleSave.Code;
|
|
800
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Code =
|
|
801
|
+
y.Code;
|
|
802
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[
|
|
803
|
+
j
|
|
804
|
+
].ServiceName = y.ServiceName;
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
this.data = this.data.map((x) => x);
|
|
808
|
+
this.cacheItem(this.data[itemIndex]);
|
|
809
|
+
// this.currentData = {
|
|
810
|
+
// selected: true,
|
|
811
|
+
// title: mappedRoleSave.Name,
|
|
812
|
+
// data: mappedRoleSave,
|
|
813
|
+
// isChildrenExpanded: this.currentData.isChildrenExpanded,
|
|
814
|
+
// body: [],
|
|
815
|
+
// children: mappedRoleSave.RoleContexts.map((c) => {
|
|
816
|
+
// return {
|
|
817
|
+
// selected: false,
|
|
818
|
+
// title: this.getFormattedName(c.Name),
|
|
819
|
+
// data: c,
|
|
820
|
+
// body: [],
|
|
821
|
+
// children: c.RoleActions.map((a) => {
|
|
822
|
+
// return {
|
|
823
|
+
// selected: false,
|
|
824
|
+
// title: this.getFormattedName(a.Name),
|
|
825
|
+
// data: a,
|
|
826
|
+
// body: [],
|
|
827
|
+
// children: [],
|
|
828
|
+
// };
|
|
829
|
+
// }),
|
|
830
|
+
// };
|
|
831
|
+
// }),
|
|
832
|
+
// };
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
async tableSaveRole(role: MappedRole, callBack: () => any) {
|
|
839
|
+
if (role.Name.trim().length == 0) {
|
|
840
|
+
this.utilService.showInfo('Role name cannot be empty');
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
const mappedRole = this.getUpdatedRole(JSON.parse(JSON.stringify(role)));
|
|
844
|
+
this.utilService.sendBI(true);
|
|
845
|
+
const res = await this.server.post(`Role/SaveRoles`, [mappedRole]);
|
|
846
|
+
this.utilService.sendBI(false);
|
|
847
|
+
if (res instanceof ErrorResponse) {
|
|
848
|
+
} else {
|
|
849
|
+
this.utilService.showSuccess('Role saved successfully');
|
|
850
|
+
const result = res as Role[];
|
|
851
|
+
if (result.length > 0) {
|
|
852
|
+
var roleResult = result[0];
|
|
853
|
+
var mappedRoleSave: MappedRole = {
|
|
854
|
+
...roleResult,
|
|
855
|
+
ChildrenType: ChildrenType.Permission,
|
|
856
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
857
|
+
const existingId = roleResult.RoleContexts.findIndex(
|
|
858
|
+
(y) => y.Name == config.Name
|
|
859
|
+
);
|
|
860
|
+
var context: MappedRoleContext = {
|
|
861
|
+
ChildrenType: ChildrenType.Action,
|
|
862
|
+
Selected: existingId > -1 ? true : false,
|
|
863
|
+
RoleActions: config.Actions.map((action) => {
|
|
864
|
+
const existingAction =
|
|
865
|
+
existingId > -1
|
|
866
|
+
? roleResult.RoleContexts[existingId].RoleActions.findIndex(
|
|
867
|
+
(c) => c.Name == action
|
|
868
|
+
)
|
|
869
|
+
: -1;
|
|
870
|
+
|
|
871
|
+
var act: MappedRoleAction = {
|
|
872
|
+
Selected: existingAction > -1 ? true : false,
|
|
873
|
+
Name: action,
|
|
874
|
+
Role: roleResult.Code,
|
|
875
|
+
Context: '',
|
|
876
|
+
id:
|
|
877
|
+
existingAction > -1
|
|
878
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
879
|
+
existingAction
|
|
880
|
+
].Code
|
|
881
|
+
: '',
|
|
882
|
+
Id:
|
|
883
|
+
existingAction > -1
|
|
884
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
885
|
+
existingAction
|
|
886
|
+
].Code
|
|
887
|
+
: '',
|
|
888
|
+
CreatedAt: new Date(),
|
|
889
|
+
UpdatedAt: new Date(),
|
|
890
|
+
DataState: ObjectState.New,
|
|
891
|
+
TenantId: roleResult.TenantId,
|
|
892
|
+
Code:
|
|
893
|
+
existingAction > -1
|
|
894
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
895
|
+
existingAction
|
|
896
|
+
].Code
|
|
897
|
+
: '',
|
|
898
|
+
ServiceName:
|
|
899
|
+
existingAction > -1
|
|
900
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
901
|
+
existingAction
|
|
902
|
+
].ServiceName
|
|
903
|
+
: '',
|
|
904
|
+
APIKey:
|
|
905
|
+
existingAction > -1
|
|
906
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
907
|
+
existingAction
|
|
908
|
+
].APIKey
|
|
909
|
+
: this.envSvc.environment.APIKey,
|
|
910
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
911
|
+
};
|
|
912
|
+
return act;
|
|
913
|
+
}),
|
|
914
|
+
Name: config.Name,
|
|
915
|
+
Role: roleResult.Code,
|
|
916
|
+
id:
|
|
917
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
918
|
+
Id:
|
|
919
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
920
|
+
CreatedAt: new Date(),
|
|
921
|
+
UpdatedAt: new Date(),
|
|
922
|
+
DataState: ObjectState.New,
|
|
923
|
+
TenantId: roleResult.TenantId,
|
|
924
|
+
Code:
|
|
925
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
926
|
+
ServiceName:
|
|
927
|
+
existingId > -1
|
|
928
|
+
? roleResult.RoleContexts[existingId].ServiceName
|
|
929
|
+
: '',
|
|
930
|
+
APIKey:
|
|
931
|
+
existingId > -1
|
|
932
|
+
? roleResult.RoleContexts[existingId].APIKey
|
|
933
|
+
: this.envSvc.environment.APIKey,
|
|
934
|
+
ApplicationRoleContext: this.getApplicationContextCode(
|
|
935
|
+
config.Name
|
|
936
|
+
),
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
return context;
|
|
940
|
+
}),
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
const itemIndex = this.data.findIndex(
|
|
944
|
+
(x) => x == this.currentData?.data
|
|
945
|
+
);
|
|
946
|
+
if (itemIndex > -1) {
|
|
947
|
+
this.data[itemIndex].Code = mappedRoleSave.Code;
|
|
948
|
+
this.data[itemIndex].Id = mappedRoleSave.Code;
|
|
949
|
+
this.data[itemIndex].DataState = mappedRoleSave.DataState;
|
|
950
|
+
this.data[itemIndex].TenantId = mappedRoleSave.TenantId;
|
|
951
|
+
this.data[itemIndex].ServiceName = mappedRoleSave.ServiceName;
|
|
952
|
+
mappedRoleSave.RoleContexts.forEach((x, i) => {
|
|
953
|
+
this.data[itemIndex].RoleContexts[i].Role = mappedRoleSave.Code;
|
|
954
|
+
this.data[itemIndex].RoleContexts[i].Code = x.Code;
|
|
955
|
+
this.data[itemIndex].RoleContexts[i].ServiceName = x.ServiceName;
|
|
956
|
+
x.RoleActions.forEach((y, j) => {
|
|
957
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Role =
|
|
958
|
+
mappedRoleSave.Code;
|
|
959
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Code = y.Code;
|
|
960
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].ServiceName =
|
|
961
|
+
y.ServiceName;
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
this.data = this.data.map((x) => x);
|
|
965
|
+
this.cacheItem(this.data[itemIndex]);
|
|
966
|
+
}
|
|
967
|
+
callBack();
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
async saveRoleDynamic(item: CardData) {
|
|
973
|
+
if (this.isCheckboxDisabled(item)) {
|
|
974
|
+
this.utilService.showInfo('Parent UI not selected');
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
var role: CardData | null =
|
|
979
|
+
this.cardContextHistory.length > 0
|
|
980
|
+
? this.cardContextHistory[0]
|
|
981
|
+
: this.currentExpandedCard
|
|
982
|
+
? this.currentExpandedCard
|
|
983
|
+
: null;
|
|
984
|
+
var cardDataRef: CardData[] | null =
|
|
985
|
+
this.cardContextHistoryData.length > 0
|
|
986
|
+
? this.cardContextHistoryData[0]
|
|
987
|
+
: this.currentExpandedCard
|
|
988
|
+
? this.cardData
|
|
989
|
+
: null;
|
|
990
|
+
// const isExpandedCard: boolean =
|
|
991
|
+
// this.cardContextHistory.length > 0
|
|
992
|
+
// ? false
|
|
993
|
+
// : this.currentExpandedCard
|
|
994
|
+
// ? true
|
|
995
|
+
// : false;
|
|
996
|
+
if (!role) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
if (role.data.Name.trim().length == 0) {
|
|
1000
|
+
item.data.Selected = false;
|
|
1001
|
+
this.utilService.showInfo('Role name cannot be empty');
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
item.data.Selected = !item.data.Selected;
|
|
1005
|
+
const mappedRole = this.getUpdatedRole(
|
|
1006
|
+
JSON.parse(JSON.stringify(role.data))
|
|
1007
|
+
);
|
|
1008
|
+
this.utilService.sendBI(true);
|
|
1009
|
+
const res = await this.server.post(`Role/SaveRoles`, [mappedRole]);
|
|
1010
|
+
this.utilService.sendBI(false);
|
|
1011
|
+
if (res instanceof ErrorResponse) {
|
|
1012
|
+
item.data.Selected = false;
|
|
1013
|
+
} else {
|
|
1014
|
+
this.utilService.showSuccess('Role saved successfully');
|
|
1015
|
+
const result = res as Role[];
|
|
1016
|
+
if (result.length > 0) {
|
|
1017
|
+
var roleResult = result[0];
|
|
1018
|
+
var mappedRoleSave: MappedRole = {
|
|
1019
|
+
...roleResult,
|
|
1020
|
+
ChildrenType: ChildrenType.Permission,
|
|
1021
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
1022
|
+
const existingId = roleResult.RoleContexts.findIndex(
|
|
1023
|
+
(y) => y.Name == config.Name
|
|
1024
|
+
);
|
|
1025
|
+
var context: MappedRoleContext = {
|
|
1026
|
+
ChildrenType: ChildrenType.Action,
|
|
1027
|
+
Selected: existingId > -1 ? true : false,
|
|
1028
|
+
RoleActions: config.Actions.map((action) => {
|
|
1029
|
+
const existingAction =
|
|
1030
|
+
existingId > -1
|
|
1031
|
+
? roleResult.RoleContexts[existingId].RoleActions.findIndex(
|
|
1032
|
+
(c) => c.Name == action
|
|
1033
|
+
)
|
|
1034
|
+
: -1;
|
|
1035
|
+
var act: MappedRoleAction = {
|
|
1036
|
+
Selected: existingAction > -1 ? true : false,
|
|
1037
|
+
Name: action,
|
|
1038
|
+
Role: roleResult.Code,
|
|
1039
|
+
Context: '',
|
|
1040
|
+
id:
|
|
1041
|
+
existingAction > -1
|
|
1042
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1043
|
+
existingAction
|
|
1044
|
+
].Code
|
|
1045
|
+
: '',
|
|
1046
|
+
Id:
|
|
1047
|
+
existingAction > -1
|
|
1048
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1049
|
+
existingAction
|
|
1050
|
+
].Code
|
|
1051
|
+
: '',
|
|
1052
|
+
CreatedAt: new Date(),
|
|
1053
|
+
UpdatedAt: new Date(),
|
|
1054
|
+
DataState: ObjectState.New,
|
|
1055
|
+
TenantId: roleResult.TenantId,
|
|
1056
|
+
Code:
|
|
1057
|
+
existingAction > -1
|
|
1058
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1059
|
+
existingAction
|
|
1060
|
+
].Code
|
|
1061
|
+
: '',
|
|
1062
|
+
ServiceName:
|
|
1063
|
+
existingAction > -1
|
|
1064
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1065
|
+
existingAction
|
|
1066
|
+
].ServiceName
|
|
1067
|
+
: '',
|
|
1068
|
+
APIKey:
|
|
1069
|
+
existingAction > -1
|
|
1070
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1071
|
+
existingAction
|
|
1072
|
+
].APIKey
|
|
1073
|
+
: this.envSvc.environment.APIKey,
|
|
1074
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
1075
|
+
};
|
|
1076
|
+
return act;
|
|
1077
|
+
}),
|
|
1078
|
+
Name: config.Name,
|
|
1079
|
+
Role: roleResult.Code,
|
|
1080
|
+
id:
|
|
1081
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1082
|
+
Id:
|
|
1083
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1084
|
+
CreatedAt: new Date(),
|
|
1085
|
+
UpdatedAt: new Date(),
|
|
1086
|
+
DataState: ObjectState.New,
|
|
1087
|
+
TenantId: roleResult.TenantId,
|
|
1088
|
+
Code:
|
|
1089
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1090
|
+
ServiceName:
|
|
1091
|
+
existingId > -1
|
|
1092
|
+
? roleResult.RoleContexts[existingId].ServiceName
|
|
1093
|
+
: '',
|
|
1094
|
+
APIKey:
|
|
1095
|
+
existingId > -1
|
|
1096
|
+
? roleResult.RoleContexts[existingId].APIKey
|
|
1097
|
+
: this.envSvc.environment.APIKey,
|
|
1098
|
+
ApplicationRoleContext: this.getApplicationContextCode(
|
|
1099
|
+
config.Name
|
|
1100
|
+
),
|
|
1101
|
+
};
|
|
1102
|
+
return context;
|
|
1103
|
+
}),
|
|
1104
|
+
};
|
|
1105
|
+
const itemIndex = cardDataRef
|
|
1106
|
+
? cardDataRef.findIndex((x) => x.data == role?.data)
|
|
1107
|
+
: -1;
|
|
1108
|
+
if (itemIndex > -1) {
|
|
1109
|
+
this.data[itemIndex].Code = mappedRoleSave.Code;
|
|
1110
|
+
this.data[itemIndex].Id = mappedRoleSave.Code;
|
|
1111
|
+
this.data[itemIndex].DataState = mappedRoleSave.DataState;
|
|
1112
|
+
this.data[itemIndex].TenantId = mappedRoleSave.TenantId;
|
|
1113
|
+
this.data[itemIndex].ServiceName = mappedRoleSave.ServiceName;
|
|
1114
|
+
mappedRoleSave.RoleContexts.forEach((x, i) => {
|
|
1115
|
+
this.data[itemIndex].RoleContexts[i].Role = mappedRoleSave.Code;
|
|
1116
|
+
this.data[itemIndex].RoleContexts[i].Code = x.Code;
|
|
1117
|
+
this.data[itemIndex].RoleContexts[i].ServiceName = x.ServiceName;
|
|
1118
|
+
x.RoleActions.forEach((y, j) => {
|
|
1119
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Role =
|
|
1120
|
+
mappedRoleSave.Code;
|
|
1121
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Code = y.Code;
|
|
1122
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].ServiceName =
|
|
1123
|
+
y.ServiceName;
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
// this.data[itemIndex].RoleContexts = mappedRoleSave.RoleContexts;
|
|
1127
|
+
|
|
1128
|
+
this.data = this.data.map((x) => x);
|
|
1129
|
+
// if (cardDataRef) {
|
|
1130
|
+
// console.log({
|
|
1131
|
+
// XDataIsHere: JSON.parse(JSON.stringify(cardDataRef)),
|
|
1132
|
+
// });
|
|
1133
|
+
// cardDataRef[itemIndex] = {
|
|
1134
|
+
// selected: cardDataRef[itemIndex].selected,
|
|
1135
|
+
// isChildrenExpanded: cardDataRef[itemIndex].isChildrenExpanded,
|
|
1136
|
+
// title: mappedRoleSave.Name,
|
|
1137
|
+
// data: mappedRoleSave,
|
|
1138
|
+
// body: [],
|
|
1139
|
+
// children: mappedRoleSave.RoleContexts.map((c) => {
|
|
1140
|
+
// return {
|
|
1141
|
+
// selected: false,
|
|
1142
|
+
// title: this.getFormattedName(c.Name),
|
|
1143
|
+
// data: c,
|
|
1144
|
+
// body: [],
|
|
1145
|
+
// children: c.RoleActions.map((a) => {
|
|
1146
|
+
// return {
|
|
1147
|
+
// selected: false,
|
|
1148
|
+
// title: this.getFormattedName(a.Name),
|
|
1149
|
+
// data: a,
|
|
1150
|
+
// body: [],
|
|
1151
|
+
// children: [],
|
|
1152
|
+
// };
|
|
1153
|
+
// }),
|
|
1154
|
+
// };
|
|
1155
|
+
// }),
|
|
1156
|
+
// };
|
|
1157
|
+
// }
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
async saveAllRoleDynamic(item: CardData) {
|
|
1164
|
+
if (this.isCheckboxDisabled(item)) {
|
|
1165
|
+
this.utilService.showInfo('Parent UI not selected');
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
var role: CardData | null =
|
|
1170
|
+
this.cardContextHistory.length > 0
|
|
1171
|
+
? this.cardContextHistory[0]
|
|
1172
|
+
: this.currentExpandedCard
|
|
1173
|
+
? this.currentExpandedCard
|
|
1174
|
+
: null;
|
|
1175
|
+
var cardDataRef: CardData[] | null =
|
|
1176
|
+
this.cardContextHistoryData.length > 0
|
|
1177
|
+
? this.cardContextHistoryData[0]
|
|
1178
|
+
: this.currentExpandedCard
|
|
1179
|
+
? this.cardData
|
|
1180
|
+
: null;
|
|
1181
|
+
// const isExpandedCard: boolean =
|
|
1182
|
+
// this.cardContextHistory.length > 0
|
|
1183
|
+
// ? false
|
|
1184
|
+
// : this.currentExpandedCard
|
|
1185
|
+
// ? true
|
|
1186
|
+
// : false;
|
|
1187
|
+
if (!role) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
if (role.data.Name.trim().length == 0) {
|
|
1191
|
+
this.utilService.showInfo('Role name cannot be empty');
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
const isAllSelected = this.isAllSelected(item);
|
|
1196
|
+
|
|
1197
|
+
const parent =
|
|
1198
|
+
this.cardContextHistoryData.length > 0
|
|
1199
|
+
? this.findParent(this.cardContextHistoryData[0], item)
|
|
1200
|
+
: this.findParent(this.cardData, item);
|
|
1201
|
+
if (
|
|
1202
|
+
parent &&
|
|
1203
|
+
parent.data.ChildrenType &&
|
|
1204
|
+
parent.data.ChildrenType == ChildrenType.Action
|
|
1205
|
+
) {
|
|
1206
|
+
(parent.data as MappedRoleContext).RoleActions.forEach((x) => {
|
|
1207
|
+
x.Selected = !isAllSelected;
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
if (
|
|
1212
|
+
parent &&
|
|
1213
|
+
parent.data.ChildrenType &&
|
|
1214
|
+
parent.data.ChildrenType == ChildrenType.Permission
|
|
1215
|
+
) {
|
|
1216
|
+
(parent.data as MappedRole).RoleContexts.forEach((x) => {
|
|
1217
|
+
x.Selected = !isAllSelected;
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
const mappedRole = this.getUpdatedRole(
|
|
1222
|
+
JSON.parse(JSON.stringify(role.data))
|
|
1223
|
+
);
|
|
1224
|
+
this.utilService.sendBI(true);
|
|
1225
|
+
const res = await this.server.post(`Role/SaveRoles`, [mappedRole]);
|
|
1226
|
+
this.utilService.sendBI(false);
|
|
1227
|
+
if (res instanceof ErrorResponse) {
|
|
1228
|
+
item.data.Selected = false;
|
|
1229
|
+
} else {
|
|
1230
|
+
this.utilService.showSuccess('Role saved successfully');
|
|
1231
|
+
const result = res as Role[];
|
|
1232
|
+
if (result.length > 0) {
|
|
1233
|
+
var roleResult = result[0];
|
|
1234
|
+
var mappedRoleSave: MappedRole = {
|
|
1235
|
+
...roleResult,
|
|
1236
|
+
ChildrenType: ChildrenType.Permission,
|
|
1237
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
1238
|
+
const existingId = roleResult.RoleContexts.findIndex(
|
|
1239
|
+
(y) => y.Name == config.Name
|
|
1240
|
+
);
|
|
1241
|
+
var context: MappedRoleContext = {
|
|
1242
|
+
ChildrenType: ChildrenType.Action,
|
|
1243
|
+
Selected: existingId > -1 ? true : false,
|
|
1244
|
+
RoleActions: config.Actions.map((action) => {
|
|
1245
|
+
const existingAction =
|
|
1246
|
+
existingId > -1
|
|
1247
|
+
? roleResult.RoleContexts[existingId].RoleActions.findIndex(
|
|
1248
|
+
(c) => c.Name == action
|
|
1249
|
+
)
|
|
1250
|
+
: -1;
|
|
1251
|
+
var act: MappedRoleAction = {
|
|
1252
|
+
Selected: existingAction > -1 ? true : false,
|
|
1253
|
+
Name: action,
|
|
1254
|
+
Role: roleResult.Code,
|
|
1255
|
+
Context: '',
|
|
1256
|
+
id:
|
|
1257
|
+
existingAction > -1
|
|
1258
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1259
|
+
existingAction
|
|
1260
|
+
].Code
|
|
1261
|
+
: '',
|
|
1262
|
+
Id:
|
|
1263
|
+
existingAction > -1
|
|
1264
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1265
|
+
existingAction
|
|
1266
|
+
].Code
|
|
1267
|
+
: '',
|
|
1268
|
+
CreatedAt: new Date(),
|
|
1269
|
+
UpdatedAt: new Date(),
|
|
1270
|
+
DataState: ObjectState.New,
|
|
1271
|
+
TenantId: roleResult.TenantId,
|
|
1272
|
+
Code:
|
|
1273
|
+
existingAction > -1
|
|
1274
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1275
|
+
existingAction
|
|
1276
|
+
].Code
|
|
1277
|
+
: '',
|
|
1278
|
+
ServiceName:
|
|
1279
|
+
existingAction > -1
|
|
1280
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1281
|
+
existingAction
|
|
1282
|
+
].ServiceName
|
|
1283
|
+
: '',
|
|
1284
|
+
APIKey:
|
|
1285
|
+
existingAction > -1
|
|
1286
|
+
? roleResult.RoleContexts[existingId].RoleActions[
|
|
1287
|
+
existingAction
|
|
1288
|
+
].APIKey
|
|
1289
|
+
: this.envSvc.environment.APIKey,
|
|
1290
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
1291
|
+
};
|
|
1292
|
+
return act;
|
|
1293
|
+
}),
|
|
1294
|
+
Name: config.Name,
|
|
1295
|
+
Role: roleResult.Code,
|
|
1296
|
+
id:
|
|
1297
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1298
|
+
Id:
|
|
1299
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1300
|
+
CreatedAt: new Date(),
|
|
1301
|
+
UpdatedAt: new Date(),
|
|
1302
|
+
DataState: ObjectState.New,
|
|
1303
|
+
TenantId: roleResult.TenantId,
|
|
1304
|
+
Code:
|
|
1305
|
+
existingId > -1 ? roleResult.RoleContexts[existingId].Code : '',
|
|
1306
|
+
ServiceName:
|
|
1307
|
+
existingId > -1
|
|
1308
|
+
? roleResult.RoleContexts[existingId].ServiceName
|
|
1309
|
+
: '',
|
|
1310
|
+
APIKey:
|
|
1311
|
+
existingId > -1
|
|
1312
|
+
? roleResult.RoleContexts[existingId].APIKey
|
|
1313
|
+
: this.envSvc.environment.APIKey,
|
|
1314
|
+
ApplicationRoleContext: this.getApplicationContextCode(
|
|
1315
|
+
config.Name
|
|
1316
|
+
),
|
|
1317
|
+
};
|
|
1318
|
+
return context;
|
|
1319
|
+
}),
|
|
1320
|
+
};
|
|
1321
|
+
const itemIndex = cardDataRef
|
|
1322
|
+
? cardDataRef.findIndex((x) => x.data == role?.data)
|
|
1323
|
+
: -1;
|
|
1324
|
+
if (itemIndex > -1) {
|
|
1325
|
+
this.data[itemIndex].Code = mappedRoleSave.Code;
|
|
1326
|
+
this.data[itemIndex].Id = mappedRoleSave.Code;
|
|
1327
|
+
this.data[itemIndex].DataState = mappedRoleSave.DataState;
|
|
1328
|
+
this.data[itemIndex].TenantId = mappedRoleSave.TenantId;
|
|
1329
|
+
this.data[itemIndex].ServiceName = mappedRoleSave.ServiceName;
|
|
1330
|
+
mappedRoleSave.RoleContexts.forEach((x, i) => {
|
|
1331
|
+
this.data[itemIndex].RoleContexts[i].Role = mappedRoleSave.Code;
|
|
1332
|
+
this.data[itemIndex].RoleContexts[i].Code = x.Code;
|
|
1333
|
+
this.data[itemIndex].RoleContexts[i].ServiceName = x.ServiceName;
|
|
1334
|
+
x.RoleActions.forEach((y, j) => {
|
|
1335
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Role =
|
|
1336
|
+
mappedRoleSave.Code;
|
|
1337
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].Code = y.Code;
|
|
1338
|
+
this.data[itemIndex].RoleContexts[i].RoleActions[j].ServiceName =
|
|
1339
|
+
y.ServiceName;
|
|
1340
|
+
});
|
|
1341
|
+
});
|
|
1342
|
+
// this.data[itemIndex].RoleContexts = mappedRoleSave.RoleContexts;
|
|
1343
|
+
|
|
1344
|
+
this.data = this.data.map((x) => x);
|
|
1345
|
+
// if (cardDataRef) {
|
|
1346
|
+
// console.log({
|
|
1347
|
+
// XDataIsHere: JSON.parse(JSON.stringify(cardDataRef)),
|
|
1348
|
+
// });
|
|
1349
|
+
// cardDataRef[itemIndex] = {
|
|
1350
|
+
// selected: cardDataRef[itemIndex].selected,
|
|
1351
|
+
// isChildrenExpanded: cardDataRef[itemIndex].isChildrenExpanded,
|
|
1352
|
+
// title: mappedRoleSave.Name,
|
|
1353
|
+
// data: mappedRoleSave,
|
|
1354
|
+
// body: [],
|
|
1355
|
+
// children: mappedRoleSave.RoleContexts.map((c) => {
|
|
1356
|
+
// return {
|
|
1357
|
+
// selected: false,
|
|
1358
|
+
// title: this.getFormattedName(c.Name),
|
|
1359
|
+
// data: c,
|
|
1360
|
+
// body: [],
|
|
1361
|
+
// children: c.RoleActions.map((a) => {
|
|
1362
|
+
// return {
|
|
1363
|
+
// selected: false,
|
|
1364
|
+
// title: this.getFormattedName(a.Name),
|
|
1365
|
+
// data: a,
|
|
1366
|
+
// body: [],
|
|
1367
|
+
// children: [],
|
|
1368
|
+
// };
|
|
1369
|
+
// }),
|
|
1370
|
+
// };
|
|
1371
|
+
// }),
|
|
1372
|
+
// };
|
|
1373
|
+
// }
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
saveDataAll() {
|
|
1380
|
+
const roles: Role[] = this.data.map((x) => {
|
|
1381
|
+
return {
|
|
1382
|
+
...x,
|
|
1383
|
+
RoleContexts: x.RoleContexts.filter((y) => y.Selected).map((z) => {
|
|
1384
|
+
return {
|
|
1385
|
+
...z,
|
|
1386
|
+
RoleActions: z.RoleActions.filter(
|
|
1387
|
+
(a) => a.Selected
|
|
1388
|
+
) as RoleAction[],
|
|
1389
|
+
};
|
|
1390
|
+
}) as RoleContext[],
|
|
1391
|
+
};
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
updateTable() {
|
|
1396
|
+
this.data = this.data.map((x) => x);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
onViewChange(isGridView: boolean): void {}
|
|
1400
|
+
onStateChange(event: { key: string; value: boolean }): void {
|
|
1401
|
+
switch (event.key) {
|
|
1402
|
+
case 'create':
|
|
1403
|
+
var newMappedRole: MappedRole = {
|
|
1404
|
+
RoleContexts: this.sourceData.map((config) => {
|
|
1405
|
+
var context: MappedRoleContext = {
|
|
1406
|
+
ChildrenType: ChildrenType.Action,
|
|
1407
|
+
Selected: false,
|
|
1408
|
+
RoleActions: config.Actions.map((action) => {
|
|
1409
|
+
var act: MappedRoleAction = {
|
|
1410
|
+
Selected: false,
|
|
1411
|
+
Name: action,
|
|
1412
|
+
Role: '',
|
|
1413
|
+
Context: '',
|
|
1414
|
+
id: '',
|
|
1415
|
+
Id: '',
|
|
1416
|
+
CreatedAt: new Date(),
|
|
1417
|
+
UpdatedAt: new Date(),
|
|
1418
|
+
DataState: ObjectState.New,
|
|
1419
|
+
TenantId: '',
|
|
1420
|
+
Code: '',
|
|
1421
|
+
ServiceName: '',
|
|
1422
|
+
APIKey: this.envSvc.environment.APIKey,
|
|
1423
|
+
ApplicationRoleAction: this.getApplicationActionCode(action),
|
|
1424
|
+
};
|
|
1425
|
+
return act;
|
|
1426
|
+
}),
|
|
1427
|
+
Name: config.Name,
|
|
1428
|
+
Role: '',
|
|
1429
|
+
id: '',
|
|
1430
|
+
Id: '',
|
|
1431
|
+
CreatedAt: new Date(),
|
|
1432
|
+
UpdatedAt: new Date(),
|
|
1433
|
+
DataState: ObjectState.New,
|
|
1434
|
+
TenantId: '',
|
|
1435
|
+
Code: '',
|
|
1436
|
+
ServiceName: '',
|
|
1437
|
+
APIKey: this.envSvc.environment.APIKey,
|
|
1438
|
+
ApplicationRoleContext: this.getApplicationContextCode(
|
|
1439
|
+
config.Name
|
|
1440
|
+
),
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
return context;
|
|
1444
|
+
}),
|
|
1445
|
+
ChildrenType: ChildrenType.Permission,
|
|
1446
|
+
Name: '',
|
|
1447
|
+
id: (this.cardData.length + 1).toString(),
|
|
1448
|
+
Id: (this.cardData.length + 1).toString(),
|
|
1449
|
+
CreatedAt: new Date(),
|
|
1450
|
+
UpdatedAt: new Date(),
|
|
1451
|
+
DataState: ObjectState.New,
|
|
1452
|
+
TenantId: '',
|
|
1453
|
+
Code: '',
|
|
1454
|
+
ServiceName: '',
|
|
1455
|
+
Application: this.application ? this.application : undefined,
|
|
1456
|
+
APIKey: this.envSvc.environment.APIKey,
|
|
1457
|
+
};
|
|
1458
|
+
const cardData: CardData = {
|
|
1459
|
+
selected: false,
|
|
1460
|
+
title: newMappedRole.Name,
|
|
1461
|
+
data: newMappedRole,
|
|
1462
|
+
body: [],
|
|
1463
|
+
children: newMappedRole.RoleContexts.map((c) => {
|
|
1464
|
+
return {
|
|
1465
|
+
selected: false,
|
|
1466
|
+
title: this.getFormattedName(c.Name),
|
|
1467
|
+
data: c,
|
|
1468
|
+
body: [],
|
|
1469
|
+
children: c.RoleActions.map((a) => {
|
|
1470
|
+
return {
|
|
1471
|
+
selected: false,
|
|
1472
|
+
title: this.getFormattedName(a.Name),
|
|
1473
|
+
data: a,
|
|
1474
|
+
body: [],
|
|
1475
|
+
children: [],
|
|
1476
|
+
};
|
|
1477
|
+
}),
|
|
1478
|
+
};
|
|
1479
|
+
}),
|
|
1480
|
+
};
|
|
1481
|
+
this.data = this.data.concat([newMappedRole]);
|
|
1482
|
+
this.cardData.push(cardData);
|
|
1483
|
+
this.roleCardClicked(cardData);
|
|
1484
|
+
this.dataView.isTableView = false;
|
|
1485
|
+
break;
|
|
1486
|
+
default:
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
showTableView: boolean = false;
|
|
1492
|
+
onSelectionChange(selectedRows: Role[]) {}
|
|
1493
|
+
retryMessage() {}
|
|
1494
|
+
onColumnsUpdated(updatedColumns: IDataFilter[]) {
|
|
1495
|
+
const updatedColumnDef: ColumnDefinition<MappedRole>[] = [];
|
|
1496
|
+
updatedColumns.forEach((col) => {
|
|
1497
|
+
const matchingCol = this.roleControlSvc.roleColumns.find(
|
|
1498
|
+
(column) => column.header === col.name || column.id === col.name
|
|
1499
|
+
);
|
|
1500
|
+
if (matchingCol) {
|
|
1501
|
+
updatedColumnDef.push(matchingCol);
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
this.visibleColumnDef = [...updatedColumnDef];
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
async updateFiltersAndSorts(isSearch: boolean = false) {
|
|
1509
|
+
if (!isSearch) {
|
|
1510
|
+
this.dataView.onClearSearch();
|
|
1511
|
+
this.currentSearchTerm = '';
|
|
1512
|
+
this.cdr.detectChanges();
|
|
1513
|
+
const clickEvent = new MouseEvent('click', {
|
|
1514
|
+
bubbles: true,
|
|
1515
|
+
cancelable: true,
|
|
1516
|
+
view: window,
|
|
1517
|
+
});
|
|
1518
|
+
document.dispatchEvent(clickEvent);
|
|
1519
|
+
}
|
|
1520
|
+
var payload: SearchPropertyValue[] = this.currentFilters.map((x) => {
|
|
1521
|
+
return {
|
|
1522
|
+
PropertyName: x.name,
|
|
1523
|
+
EntityValue: x.value,
|
|
1524
|
+
Operator: SearchOperator.And,
|
|
1525
|
+
Sign:
|
|
1526
|
+
x.condition && Object.keys(DateFilterTypes).includes(x.condition)
|
|
1527
|
+
? (DateFilterTypes[
|
|
1528
|
+
x.condition as keyof typeof DateFilterTypes
|
|
1529
|
+
] as unknown as SearchPropertySign)
|
|
1530
|
+
: SearchPropertySign.EQ,
|
|
1531
|
+
Type: SearchPropertyValueType.Date,
|
|
1532
|
+
};
|
|
1533
|
+
});
|
|
1534
|
+
payload.push({
|
|
1535
|
+
PropertyName: 'APIKey',
|
|
1536
|
+
EntityValue: this.envSvc.environment.APIKey,
|
|
1537
|
+
Operator: SearchOperator.And,
|
|
1538
|
+
Sign: SearchPropertySign.EQ,
|
|
1539
|
+
});
|
|
1540
|
+
for (let sort of this.currentSorts) {
|
|
1541
|
+
payload.push({
|
|
1542
|
+
PropertyName: sort.name,
|
|
1543
|
+
EntityValue: '',
|
|
1544
|
+
Operator: SearchOperator.And,
|
|
1545
|
+
Sign: SearchPropertySign.EQ,
|
|
1546
|
+
Sort:
|
|
1547
|
+
sort.value.toLowerCase() == SortDirection.Asc.toLowerCase()
|
|
1548
|
+
? SortDirection.Asc
|
|
1549
|
+
: sort.value.toLowerCase() == SortDirection.Desc.toLowerCase()
|
|
1550
|
+
? SortDirection.Desc
|
|
1551
|
+
: SortDirection.None,
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
const searchTermExists = this.currentSearchTerm.trim().length > 0;
|
|
1555
|
+
this.utilService.sendBI(true);
|
|
1556
|
+
const res = searchTermExists
|
|
1557
|
+
? await this.server.get(
|
|
1558
|
+
`Role/GetRolesWithParam/${this.currentSearchTerm.trim()}/0/${
|
|
1559
|
+
this.pageSize
|
|
1560
|
+
}`
|
|
1561
|
+
)
|
|
1562
|
+
: await this.server.post(`Role/SearchRoles/0/${this.pageSize}`, payload);
|
|
1563
|
+
this.utilService.sendBI(false);
|
|
1564
|
+
if (res instanceof ErrorResponse) {
|
|
1565
|
+
this.currentFilters = [];
|
|
1566
|
+
this.currentSorts = [];
|
|
1567
|
+
return undefined;
|
|
1568
|
+
} else {
|
|
1569
|
+
this.cardDataView.clearData();
|
|
1570
|
+
this.currentData = null;
|
|
1571
|
+
this.pageState = res as PagedResult<Role>;
|
|
1572
|
+
var result = (res as PagedResult<Role>).Result;
|
|
1573
|
+
this.setUpMappedData(result);
|
|
1574
|
+
this.setUpCardData();
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
async loadMoreFiltersAndSorts(): Promise<PagedResult<Role> | undefined> {
|
|
1578
|
+
if (!this.pageState) {
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
var payload: SearchPropertyValue[] = this.currentFilters.map((x) => {
|
|
1582
|
+
return {
|
|
1583
|
+
PropertyName: x.name,
|
|
1584
|
+
EntityValue: x.value,
|
|
1585
|
+
Operator: SearchOperator.And,
|
|
1586
|
+
Sign:
|
|
1587
|
+
x.condition && Object.keys(DateFilterTypes).includes(x.condition)
|
|
1588
|
+
? (DateFilterTypes[
|
|
1589
|
+
x.condition as keyof typeof DateFilterTypes
|
|
1590
|
+
] as unknown as SearchPropertySign)
|
|
1591
|
+
: SearchPropertySign.EQ,
|
|
1592
|
+
Type: SearchPropertyValueType.Date,
|
|
1593
|
+
};
|
|
1594
|
+
});
|
|
1595
|
+
payload.push({
|
|
1596
|
+
PropertyName: 'APIKey',
|
|
1597
|
+
EntityValue: this.envSvc.environment.APIKey,
|
|
1598
|
+
Operator: SearchOperator.And,
|
|
1599
|
+
Sign: SearchPropertySign.EQ,
|
|
1600
|
+
});
|
|
1601
|
+
for (let sort of this.currentSorts) {
|
|
1602
|
+
payload.push({
|
|
1603
|
+
PropertyName: sort.name,
|
|
1604
|
+
EntityValue: '',
|
|
1605
|
+
Operator: SearchOperator.And,
|
|
1606
|
+
Sign: SearchPropertySign.EQ,
|
|
1607
|
+
Sort:
|
|
1608
|
+
sort.value.toLowerCase() == SortDirection.Asc.toLowerCase()
|
|
1609
|
+
? SortDirection.Asc
|
|
1610
|
+
: sort.value.toLowerCase() == SortDirection.Desc.toLowerCase()
|
|
1611
|
+
? SortDirection.Desc
|
|
1612
|
+
: SortDirection.None,
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
const searchTermExists = this.currentSearchTerm.trim().length > 0;
|
|
1616
|
+
this.utilService.sendBI(true);
|
|
1617
|
+
const res = searchTermExists
|
|
1618
|
+
? await this.server.get(
|
|
1619
|
+
`Role/GetRolesWithParam/${this.currentSearchTerm.trim()}/${
|
|
1620
|
+
this.pageState.Skip
|
|
1621
|
+
}/${this.pageSize}`
|
|
1622
|
+
)
|
|
1623
|
+
: await this.server.post(
|
|
1624
|
+
`Role/SearchRoles/${this.pageState.Skip}/${this.pageSize}`,
|
|
1625
|
+
payload
|
|
1626
|
+
);
|
|
1627
|
+
this.utilService.sendBI(false);
|
|
1628
|
+
if (res instanceof ErrorResponse) {
|
|
1629
|
+
return undefined;
|
|
1630
|
+
} else {
|
|
1631
|
+
var result = res as PagedResult<Role>;
|
|
1632
|
+
return result;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
onFilterUpdated(updatedFilters: IDataFilter[] | string) {
|
|
1636
|
+
// Ensure updatedFilters is an array
|
|
1637
|
+
if (Array.isArray(updatedFilters)) {
|
|
1638
|
+
this.currentFilters = updatedFilters;
|
|
1639
|
+
this.updateFiltersAndSorts();
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
onSortUpdated(updatedSorts: IDataFilter[]) {
|
|
1643
|
+
this.currentSorts = updatedSorts;
|
|
1644
|
+
console.log({ CurrSorts: this.currentSorts });
|
|
1645
|
+
this.updateFiltersAndSorts();
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
handleSearch(event: { key: string; value: string }) {
|
|
1649
|
+
this.searchTerm$.next(event.value);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
handleExport(exportedData: Partial<any>[]) {
|
|
1653
|
+
// console.log('Exported data:', exportedData);
|
|
1654
|
+
this.downloadCSV(exportedData);
|
|
1655
|
+
}
|
|
1656
|
+
private downloadCSV(data: Partial<any>[]) {
|
|
1657
|
+
const headers = Object.keys(data[0]);
|
|
1658
|
+
const csvContent = [
|
|
1659
|
+
headers.join(','),
|
|
1660
|
+
...data.map((row) => headers.map((header) => row[header]).join(',')),
|
|
1661
|
+
].join('\n');
|
|
1662
|
+
|
|
1663
|
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
1664
|
+
const link = document.createElement('a');
|
|
1665
|
+
if (link.download !== undefined) {
|
|
1666
|
+
const url = URL.createObjectURL(blob);
|
|
1667
|
+
link.setAttribute('href', url);
|
|
1668
|
+
link.setAttribute('download', 'export.csv');
|
|
1669
|
+
link.style.visibility = 'hidden';
|
|
1670
|
+
document.body.appendChild(link);
|
|
1671
|
+
link.click();
|
|
1672
|
+
document.body.removeChild(link);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
getMockRoles(): Role[] {
|
|
1677
|
+
return new Array(10).fill(1).map((id, i) => ({
|
|
1678
|
+
Id: id + i,
|
|
1679
|
+
id: (id + i).toString(),
|
|
1680
|
+
Name: this.mockNames[i] || '',
|
|
1681
|
+
RoleContexts: this.randomContexts(),
|
|
1682
|
+
CreatedAt: new Date(),
|
|
1683
|
+
UpdatedAt: new Date(),
|
|
1684
|
+
DataState: ObjectState.New,
|
|
1685
|
+
TenantId: `Tenant${id + i}`,
|
|
1686
|
+
Code: '',
|
|
1687
|
+
ServiceName: '',
|
|
1688
|
+
APIKey: '',
|
|
1689
|
+
}));
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
mockNames: string[] = [
|
|
1693
|
+
'Admin',
|
|
1694
|
+
'Super Admin',
|
|
1695
|
+
'Manager',
|
|
1696
|
+
'Intern',
|
|
1697
|
+
'Production Manager',
|
|
1698
|
+
'CEO',
|
|
1699
|
+
'CTO',
|
|
1700
|
+
'COO',
|
|
1701
|
+
'Developer',
|
|
1702
|
+
'Engineer',
|
|
1703
|
+
];
|
|
1704
|
+
|
|
1705
|
+
randomName(): string {
|
|
1706
|
+
const randomIndex = Math.floor(Math.random() * this.mockNames.length);
|
|
1707
|
+
return this.mockNames[randomIndex];
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
randomContexts(): RoleContext[] {
|
|
1711
|
+
const randomNumber = Math.floor(
|
|
1712
|
+
Math.random() * Object.keys(UIs).length + 1
|
|
1713
|
+
);
|
|
1714
|
+
var returnArray: RoleContext[] = [];
|
|
1715
|
+
const usedList: number[] = [];
|
|
1716
|
+
for (let i = 0; i < randomNumber; i++) {
|
|
1717
|
+
let randomIndex;
|
|
1718
|
+
do {
|
|
1719
|
+
randomIndex = Math.floor(Math.random() * Object.keys(UIs).length);
|
|
1720
|
+
} while (usedList.includes(randomIndex));
|
|
1721
|
+
|
|
1722
|
+
returnArray.push({
|
|
1723
|
+
Id: 'context' + i,
|
|
1724
|
+
id: ('context' + i).toString(),
|
|
1725
|
+
Name: Object.keys(UIs)[randomIndex],
|
|
1726
|
+
Role: '',
|
|
1727
|
+
RoleActions: this.randomActions(),
|
|
1728
|
+
CreatedAt: new Date(),
|
|
1729
|
+
UpdatedAt: new Date(),
|
|
1730
|
+
DataState: ObjectState.New,
|
|
1731
|
+
TenantId: `Tenant${'context' + i}`,
|
|
1732
|
+
Code: '',
|
|
1733
|
+
ServiceName: '',
|
|
1734
|
+
APIKey: '',
|
|
1735
|
+
ApplicationRoleContext: '',
|
|
1736
|
+
});
|
|
1737
|
+
usedList.push(randomIndex);
|
|
1738
|
+
}
|
|
1739
|
+
return returnArray;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
randomActions(): RoleAction[] {
|
|
1743
|
+
const randomNumber = Math.floor(
|
|
1744
|
+
Math.random() * Object.keys(UIActions).length + 1
|
|
1745
|
+
);
|
|
1746
|
+
var returnArray: RoleAction[] = [];
|
|
1747
|
+
const usedList: number[] = [];
|
|
1748
|
+
for (let i = 0; i < randomNumber; i++) {
|
|
1749
|
+
let randomIndex;
|
|
1750
|
+
do {
|
|
1751
|
+
randomIndex = Math.floor(Math.random() * Object.keys(UIActions).length);
|
|
1752
|
+
} while (usedList.includes(randomIndex));
|
|
1753
|
+
|
|
1754
|
+
returnArray.push({
|
|
1755
|
+
Id: 'action' + i,
|
|
1756
|
+
id: ('action' + i).toString(),
|
|
1757
|
+
Name: Object.keys(UIActions)[randomIndex],
|
|
1758
|
+
Role: '',
|
|
1759
|
+
Context: '',
|
|
1760
|
+
CreatedAt: new Date(),
|
|
1761
|
+
UpdatedAt: new Date(),
|
|
1762
|
+
DataState: ObjectState.New,
|
|
1763
|
+
TenantId: `Tenant${'action' + i}`,
|
|
1764
|
+
Code: '',
|
|
1765
|
+
ServiceName: '',
|
|
1766
|
+
APIKey: '',
|
|
1767
|
+
ApplicationRoleAction: '',
|
|
1768
|
+
});
|
|
1769
|
+
usedList.push(randomIndex);
|
|
1770
|
+
}
|
|
1771
|
+
return returnArray;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
closePopUp() {
|
|
1775
|
+
this.openDropdownId = null;
|
|
1776
|
+
this.popUps.forEach((popUp) => {
|
|
1777
|
+
if (popUp.dropdownOpen) {
|
|
1778
|
+
popUp.toggleDropdown();
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
updateItem(value: any, key: string): any {
|
|
1784
|
+
return {
|
|
1785
|
+
[key]: value,
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
editValue(value: MappedRole) {
|
|
1790
|
+
const card = this.cardData.find((x) => x.data.Id == value.Id);
|
|
1791
|
+
if (card && this.cardDataView) {
|
|
1792
|
+
this.dataView.toggleView();
|
|
1793
|
+
card.selected = true;
|
|
1794
|
+
this.currentData = this.cardDataView.onItemClick(card);
|
|
1795
|
+
this.closePopUp();
|
|
1796
|
+
// if (this.currentData) {
|
|
1797
|
+
// this.form.controls['Name'].setValue(this.currentData.data?.Name);
|
|
1798
|
+
// }
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
tableCache = new Map<string, MappedRole>();
|
|
1803
|
+
|
|
1804
|
+
cacheItem(item: MappedRole) {
|
|
1805
|
+
const cacheKey = item.Id;
|
|
1806
|
+
this.tableCache.set(cacheKey, JSON.parse(JSON.stringify(item)));
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
restoreCache(item: Role) {
|
|
1810
|
+
const cacheKey = item.Id;
|
|
1811
|
+
const itemCache = this.tableCache.get(cacheKey);
|
|
1812
|
+
if (itemCache) {
|
|
1813
|
+
item.Name = itemCache.Name;
|
|
1814
|
+
}
|
|
1815
|
+
this.tableCache.delete(cacheKey);
|
|
1816
|
+
}
|
|
1817
|
+
}
|