@unipin/angular-applet 18.9.2 → 18.9.4
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/.editorconfig +16 -0
- package/.eslintrc.json +72 -0
- package/.github/ISSUE_TEMPLATE/bug_fix.yml +60 -0
- package/.github/ISSUE_TEMPLATE/dependency_update.yml +20 -0
- package/.github/ISSUE_TEMPLATE/documentation.yml +13 -0
- package/.github/ISSUE_TEMPLATE/engineering.yml +22 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +38 -0
- package/.github/ISSUE_TEMPLATE/testing.yml +38 -0
- package/.github/dependabot.yml +11 -0
- package/.github/pull_request_template.md +77 -0
- package/.github/workflows/npm_publish.yml +52 -0
- package/.storybook/main.ts +28 -0
- package/.storybook/preview.ts +19 -0
- package/.storybook/test-runner.ts +29 -0
- package/.storybook/tsconfig.json +14 -0
- package/.storybook/typings.d.ts +4 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/settings.json +16 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +11 -8
- package/angular.json +102 -0
- package/codegen.yml +8 -0
- package/package.json +86 -38
- package/projects/unipin-angular/README.md +24 -0
- package/projects/unipin-angular/documentation.json +116258 -0
- package/projects/unipin-angular/ng-package.json +19 -0
- package/projects/unipin-angular/package-lock.json +23 -0
- package/projects/unipin-angular/package.json +32 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_accordion.scss +149 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_alert.scss +71 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_badge.scss +38 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_breadcrumb.scss +40 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_button-group.scss +142 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_buttons.scss +209 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_card.scss +234 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_carousel.scss +226 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_close.scss +40 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_containers.scss +41 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_dropdown.scss +249 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_forms.scss +9 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_functions.scss +302 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_grid.scss +33 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_helpers.scss +10 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_images.scss +42 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_list-group.scss +192 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_maps.scss +54 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_mixins.scss +43 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_modal.scss +237 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_nav.scss +172 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_navbar.scss +278 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_offcanvas.scss +144 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_pagination.scss +109 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_placeholders.scss +51 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_popover.scss +196 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_progress.scss +59 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_reboot.scss +610 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_root.scss +73 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_spinners.scss +85 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_tables.scss +164 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_toasts.scss +73 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_tooltip.scss +120 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_transitions.scss +27 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_type.scss +106 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_utilities.scss +647 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/_variables.scss +1634 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/bootstrap-grid.scss +64 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/bootstrap-reboot.scss +9 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/bootstrap-utilities.scss +18 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/bootstrap.scss +24 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_floating-labels.scss +75 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_form-check.scss +175 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_form-control.scss +195 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_form-range.scss +91 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_form-select.scss +71 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_form-text.scss +11 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_input-group.scss +132 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_labels.scss +36 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/forms/_validation.scss +12 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_clearfix.scss +3 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_color-bg.scss +10 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_colored-links.scss +12 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_position.scss +36 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_ratio.scss +26 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_stacks.scss +15 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_stretched-link.scss +15 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_text-truncation.scss +7 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_visually-hidden.scss +8 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/helpers/_vr.scss +8 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_alert.scss +15 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_backdrop.scss +14 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_banner.scss +9 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_border-radius.scss +78 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_box-shadow.scss +18 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_breakpoints.scss +127 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_buttons.scss +70 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_caret.scss +64 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_clearfix.scss +9 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_color-scheme.scss +7 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_container.scss +11 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_deprecate.scss +10 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_forms.scss +152 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_gradients.scss +47 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_grid.scss +151 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_image.scss +16 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_list-group.scss +24 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_lists.scss +7 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_pagination.scss +10 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_reset-text.scss +17 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_resize.scss +6 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_table-variants.scss +24 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_text-truncate.scss +8 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_transition.scss +26 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_utilities.scss +97 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/mixins/_visually-hidden.scss +29 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/utilities/_api.scss +47 -0
- package/projects/unipin-angular/src/assets/private/scss/bootstrap/vendor/_rfs.scss +354 -0
- package/projects/unipin-angular/src/assets/private/scss/theme/variables.scss +59 -0
- package/projects/unipin-angular/src/graphql/generated.d.ts +715 -0
- package/projects/unipin-angular/src/graphql/generated.mjs +49 -0
- package/projects/unipin-angular/src/graphql/generated.ts +19998 -0
- package/projects/unipin-angular/src/lib/components/approval/detail/approval-detail.component.html +14 -0
- package/projects/unipin-angular/src/lib/components/approval/detail/approval-detail.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/approval/detail/approval-detail.component.ts +90 -0
- package/projects/unipin-angular/src/lib/components/approval/detail/approval-detail.stories.ts +61 -0
- package/projects/unipin-angular/src/lib/components/approval/form/approval-form.component.html +41 -0
- package/projects/unipin-angular/src/lib/components/approval/form/approval-form.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/approval/form/approval-form.component.ts +152 -0
- package/projects/unipin-angular/src/lib/components/approval/form/approval-form.stories.ts +111 -0
- package/{lib/components/approval/index.d.ts → projects/unipin-angular/src/lib/components/approval/index.ts} +1 -0
- package/projects/unipin-angular/src/lib/components/approval/list/approval-list.component.html +15 -0
- package/projects/unipin-angular/src/lib/components/approval/list/approval-list.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/approval/list/approval-list.component.ts +136 -0
- package/projects/unipin-angular/src/lib/components/approval/list/approval-list.stories.ts +141 -0
- package/projects/unipin-angular/src/lib/components/approval/list/provide-approval-entities.util.ts +10 -0
- package/projects/unipin-angular/src/lib/components/approval/services/approval.service.ts +46 -0
- package/projects/unipin-angular/src/lib/components/audit/detail/audit-detail.component.html +50 -0
- package/projects/unipin-angular/src/lib/components/audit/detail/audit-detail.component.scss +4 -0
- package/projects/unipin-angular/src/lib/components/audit/detail/audit-detail.component.spec.ts +51 -0
- package/projects/unipin-angular/src/lib/components/audit/detail/audit-detail.component.ts +141 -0
- package/projects/unipin-angular/src/lib/components/audit/detail/audit-detail.stories.ts +126 -0
- package/projects/unipin-angular/src/lib/components/audit/list/audit-list.component.html +5 -0
- package/projects/unipin-angular/src/lib/components/audit/list/audit-list.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/audit/list/audit-list.component.ts +85 -0
- package/projects/unipin-angular/src/lib/components/audit/list/audit-list.stories.ts +170 -0
- package/projects/unipin-angular/src/lib/components/audit/service/audit.service.ts +48 -0
- package/projects/unipin-angular/src/lib/components/audit/types/audit-detail-form.type.ts +13 -0
- package/projects/unipin-angular/src/lib/components/buttons/group/btn-group.component.html +42 -0
- package/projects/unipin-angular/src/lib/components/buttons/group/btn-group.component.scss +19 -0
- package/projects/unipin-angular/src/lib/components/buttons/group/btn-group.component.ts +72 -0
- package/projects/unipin-angular/src/lib/components/buttons/group/btn-group.stories.ts +132 -0
- package/projects/unipin-angular/src/lib/components/buttons/group/interfaces/btn-group-config.interface.ts +63 -0
- package/projects/unipin-angular/src/lib/components/buttons/loading/btn-loading.component.html +9 -0
- package/projects/unipin-angular/src/lib/components/buttons/loading/btn-loading.component.scss +8 -0
- package/projects/unipin-angular/src/lib/components/buttons/loading/btn-loading.component.ts +87 -0
- package/projects/unipin-angular/src/lib/components/buttons/loading/btn-loading.stories.ts +188 -0
- package/projects/unipin-angular/src/lib/components/containers/applet-container/applet-container.component.html +39 -0
- package/projects/unipin-angular/src/lib/components/containers/applet-container/applet-container.component.scss +68 -0
- package/projects/unipin-angular/src/lib/components/containers/applet-container/applet-container.component.ts +98 -0
- package/projects/unipin-angular/src/lib/components/containers/applet-container/provide-applet-config.util.ts +23 -0
- package/projects/unipin-angular/src/lib/components/containers/colum-header-container/column-header-container.component.html +17 -0
- package/projects/unipin-angular/src/lib/components/containers/colum-header-container/column-header-container.component.scss +4 -0
- package/projects/unipin-angular/src/lib/components/containers/colum-header-container/column-header-container.component.ts +32 -0
- package/projects/unipin-angular/src/lib/components/containers/colum-header-container/column-header.stories.ts +77 -0
- package/projects/unipin-angular/src/lib/components/containers/column-container/column-container.component.html +17 -0
- package/projects/unipin-angular/src/lib/components/containers/column-container/column-container.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/containers/column-container/column-container.component.ts +139 -0
- package/projects/unipin-angular/src/lib/components/containers/column-container/directives/lazy-route.directive.ts +86 -0
- package/{lib/components/containers/index.d.ts → projects/unipin-angular/src/lib/components/containers/index.ts} +1 -0
- package/{lib/components/containers/list-container/interfaces/list-container-config.interface.d.ts → projects/unipin-angular/src/lib/components/containers/list-container/interfaces/list-container-config.interface.ts} +5 -4
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.html +19 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.scss +7 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.ts +113 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-pagination-container/list-pagination-container.stories.ts +207 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.html +19 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.scss +7 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.ts +114 -0
- package/projects/unipin-angular/src/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.stories.ts +212 -0
- package/projects/unipin-angular/src/lib/components/containers/modal-container/modal-container.component.html +15 -0
- package/projects/unipin-angular/src/lib/components/containers/modal-container/modal-container.component.scss +2 -0
- package/projects/unipin-angular/src/lib/components/containers/modal-container/modal-container.component.ts +88 -0
- package/projects/unipin-angular/src/lib/components/containers/modal-container/modal-container.stories.ts +66 -0
- package/projects/unipin-angular/src/lib/components/filter/filter.component.html +112 -0
- package/projects/unipin-angular/src/lib/components/filter/filter.component.scss +28 -0
- package/projects/unipin-angular/src/lib/components/filter/filter.component.ts +329 -0
- package/projects/unipin-angular/src/lib/components/filter/filter.stories.ts +176 -0
- package/{lib/components/filter/index.d.ts → projects/unipin-angular/src/lib/components/filter/index.ts} +1 -1
- package/projects/unipin-angular/src/lib/components/filter/interfaces/filter-config.interface.ts +17 -0
- package/projects/unipin-angular/src/lib/components/filter/interfaces/filter-field.interface.ts +73 -0
- package/projects/unipin-angular/src/lib/components/filter/interfaces/filter-search-event.interface.ts +15 -0
- package/projects/unipin-angular/src/lib/components/forms/country-input/form-country-input.component.html +19 -0
- package/projects/unipin-angular/src/lib/components/forms/country-input/form-country-input.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/country-input/form-country-input.component.ts +210 -0
- package/projects/unipin-angular/src/lib/components/forms/country-input/form-country-input.stories.ts +175 -0
- package/projects/unipin-angular/src/lib/components/forms/currency-input/form-currency-input.component.html +42 -0
- package/projects/unipin-angular/src/lib/components/forms/currency-input/form-currency-input.component.scss +4 -0
- package/projects/unipin-angular/src/lib/components/forms/currency-input/form-currency-input.component.ts +285 -0
- package/projects/unipin-angular/src/lib/components/forms/currency-input/form-currency-input.spec.ts +119 -0
- package/projects/unipin-angular/src/lib/components/forms/currency-input/form-currency-input.stories.ts +243 -0
- package/projects/unipin-angular/src/lib/components/forms/date/form-date.component.html +27 -0
- package/projects/unipin-angular/src/lib/components/forms/date/form-date.component.scss +7 -0
- package/projects/unipin-angular/src/lib/components/forms/date/form-date.component.ts +225 -0
- package/projects/unipin-angular/src/lib/components/forms/date/form-date.stories.ts +201 -0
- package/projects/unipin-angular/src/lib/components/forms/image-picker/directives/drag-n-drop.directive.ts +40 -0
- package/projects/unipin-angular/src/lib/components/forms/image-picker/form-image-picker.component.html +29 -0
- package/projects/unipin-angular/src/lib/components/forms/image-picker/form-image-picker.component.scss +40 -0
- package/projects/unipin-angular/src/lib/components/forms/image-picker/form-image-picker.component.ts +109 -0
- package/projects/unipin-angular/src/lib/components/forms/image-picker/form-image-picker.stories.ts +133 -0
- package/projects/unipin-angular/src/lib/components/forms/input/form-input.component.html +22 -0
- package/projects/unipin-angular/src/lib/components/forms/input/form-input.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/input/form-input.component.ts +177 -0
- package/projects/unipin-angular/src/lib/components/forms/input/form-input.stories.ts +185 -0
- package/projects/unipin-angular/src/lib/components/forms/number/form-number.component.html +6 -0
- package/projects/unipin-angular/src/lib/components/forms/number/form-number.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/number/form-number.component.ts +176 -0
- package/projects/unipin-angular/src/lib/components/forms/number/form-number.spec.ts +62 -0
- package/projects/unipin-angular/src/lib/components/forms/number/form-number.stories.ts +150 -0
- package/projects/unipin-angular/src/lib/components/forms/number/pipes/locale-number.pipe.ts +32 -0
- package/projects/unipin-angular/src/lib/components/forms/password/form-password.component.html +11 -0
- package/projects/unipin-angular/src/lib/components/forms/password/form-password.component.scss +5 -0
- package/projects/unipin-angular/src/lib/components/forms/password/form-password.component.ts +177 -0
- package/projects/unipin-angular/src/lib/components/forms/password/form-password.stories.ts +151 -0
- package/projects/unipin-angular/src/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.html +30 -0
- package/projects/unipin-angular/src/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.ts +271 -0
- package/projects/unipin-angular/src/lib/components/forms/rate-group-code-input/form-rate-group-code-input.stories.ts +248 -0
- package/projects/unipin-angular/src/lib/components/forms/searchable-select/form-searchable-select.component.html +28 -0
- package/projects/unipin-angular/src/lib/components/forms/searchable-select/form-searchable-select.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/searchable-select/form-searchable-select.component.ts +281 -0
- package/projects/unipin-angular/src/lib/components/forms/searchable-select/form-searchable-select.stories.ts +267 -0
- package/projects/unipin-angular/src/lib/components/forms/select/form-select.component.html +24 -0
- package/projects/unipin-angular/src/lib/components/forms/select/form-select.component.scss +1 -0
- package/projects/unipin-angular/src/lib/components/forms/select/form-select.component.ts +216 -0
- package/projects/unipin-angular/src/lib/components/forms/select/form-select.stories.ts +220 -0
- package/projects/unipin-angular/src/lib/components/forms/textarea/form-textarea.component.html +9 -0
- package/projects/unipin-angular/src/lib/components/forms/textarea/form-textarea.component.scss +0 -0
- package/projects/unipin-angular/src/lib/components/forms/textarea/form-textarea.component.ts +146 -0
- package/projects/unipin-angular/src/lib/components/forms/textarea/form-textarea.stories.ts +163 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-pagination/grid-pagination.component.html +17 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-pagination/grid-pagination.component.scss +8 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-pagination/grid-pagination.component.ts +224 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-pagination/grid-pagination.stories.ts +219 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-snapshot/grid-snapshot.component.html +17 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-snapshot/grid-snapshot.component.scss +8 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-snapshot/grid-snapshot.component.ts +229 -0
- package/projects/unipin-angular/src/lib/components/grids/grid-snapshot/grid-snapshot.stories.ts +173 -0
- package/projects/unipin-angular/src/lib/components/grids/interfaces/grid-config.interface.ts +44 -0
- package/projects/unipin-angular/src/lib/components/grids/services/grid.service.ts +23 -0
- package/{lib/components/index.d.ts → projects/unipin-angular/src/lib/components/index.ts} +14 -2
- package/projects/unipin-angular/src/lib/components/infinite-scroll/directive/infinite-scroll.directive.ts +72 -0
- package/projects/unipin-angular/src/lib/components/infinite-scroll/infinite-scroll.component.html +13 -0
- package/projects/unipin-angular/src/lib/components/infinite-scroll/infinite-scroll.component.scss +10 -0
- package/projects/unipin-angular/src/lib/components/infinite-scroll/infinite-scroll.component.ts +61 -0
- package/projects/unipin-angular/src/lib/components/infinite-scroll/infinite-scroll.stories.ts +80 -0
- package/{lib/components/tabs/index.d.ts → projects/unipin-angular/src/lib/components/tabs/index.ts} +3 -2
- package/projects/unipin-angular/src/lib/components/tabs/tab-content/tab-content.component.html +3 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab-content/tab-content.component.scss +6 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab-content/tab-content.component.ts +56 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab-group/tab-group.component.html +24 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab-group/tab-group.component.scss +39 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab-group/tab-group.component.ts +92 -0
- package/projects/unipin-angular/src/lib/components/tabs/tab.stories.ts +117 -0
- package/projects/unipin-angular/src/lib/guards/auth/auth.guard.ts +11 -0
- package/projects/unipin-angular/src/lib/interceptors/header/header.interceptor.ts +36 -0
- package/projects/unipin-angular/src/lib/interceptors/refresh-token/refresh-token.interceptor.ts +123 -0
- package/projects/unipin-angular/src/lib/interfaces/user/user.interface.ts +27 -0
- package/projects/unipin-angular/src/lib/modules/index.ts +11 -0
- package/projects/unipin-angular/src/lib/modules/micro-frontend/utils/mf-bootstrap.util.ts +74 -0
- package/projects/unipin-angular/src/lib/modules/micro-frontend/utils/mf-global-state.util.ts +20 -0
- package/projects/unipin-angular/src/lib/modules/permission/directive/permission.directive.spec.ts +50 -0
- package/projects/unipin-angular/src/lib/modules/permission/directive/permission.directive.ts +68 -0
- package/projects/unipin-angular/src/lib/modules/permission/guards/permission.guard.spec.ts +76 -0
- package/projects/unipin-angular/src/lib/modules/permission/guards/permission.guard.ts +30 -0
- package/{lib/modules/permission/index.d.ts → projects/unipin-angular/src/lib/modules/permission/index.ts} +1 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/401/unauthorized.page.html +3 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/401/unauthorized.page.scss +3 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/401/unauthorized.page.ts +14 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/loading/loading.page.html +2 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/loading/loading.page.scss +4 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/loading/loading.page.ts +76 -0
- package/projects/unipin-angular/src/lib/modules/permission/pages/loading/provide-loading-config.util.ts +18 -0
- package/projects/unipin-angular/src/lib/modules/permission/services/permission.service.spec.ts +62 -0
- package/projects/unipin-angular/src/lib/modules/permission/services/permission.service.ts +78 -0
- package/projects/unipin-angular/src/lib/resolvers/auth/auth.resolver.spec.ts +46 -0
- package/projects/unipin-angular/src/lib/resolvers/auth/auth.resolver.ts +144 -0
- package/projects/unipin-angular/src/lib/services/auth/auth.service.ts +243 -0
- package/projects/unipin-angular/src/lib/services/country/country.service.ts +47 -0
- package/projects/unipin-angular/src/lib/services/currency/currency.service.ts +44 -0
- package/projects/unipin-angular/src/lib/services/profile/profile.service.ts +86 -0
- package/projects/unipin-angular/src/lib/services/rate-group-code/rate-group-code.service.ts +29 -0
- package/projects/unipin-angular/src/lib/utils/contrast-color-generator/contrast-color-generator.util.spec.ts +19 -0
- package/projects/unipin-angular/src/lib/utils/contrast-color-generator/contrast-color-generator.util.ts +28 -0
- package/projects/unipin-angular/src/lib/utils/form-error-message/form-error-message.util.spec.ts +58 -0
- package/projects/unipin-angular/src/lib/utils/form-error-message/form-error-message.util.ts +30 -0
- package/projects/unipin-angular/src/lib/utils/format-capitalize/format-capitalize.util.spec.ts +30 -0
- package/projects/unipin-angular/src/lib/utils/format-capitalize/format-capitalize.util.ts +22 -0
- package/projects/unipin-angular/src/lib/utils/redirect-to-first-menu/redirect-to-first-menu.util.ts +15 -0
- package/projects/unipin-angular/src/public-api.ts +126 -0
- package/projects/unipin-angular/tsconfig.lib.json +14 -0
- package/projects/unipin-angular/tsconfig.lib.prod.json +10 -0
- package/projects/unipin-angular/tsconfig.spec.json +14 -0
- package/snapshot-serializer.js +12 -0
- package/test-runner-jest.config.js +13 -0
- package/tsconfig.json +51 -0
- package/esm2022/graphql/generated.mjs +0 -888
- package/esm2022/lib/components/approval/detail/approval-detail.component.mjs +0 -78
- package/esm2022/lib/components/approval/form/approval-form.component.mjs +0 -128
- package/esm2022/lib/components/approval/index.mjs +0 -5
- package/esm2022/lib/components/approval/list/approval-list.component.mjs +0 -114
- package/esm2022/lib/components/approval/list/provide-approval-entities.util.mjs +0 -9
- package/esm2022/lib/components/approval/services/approval.service.mjs +0 -46
- package/esm2022/lib/components/audit/detail/audit-detail.component.mjs +0 -123
- package/esm2022/lib/components/audit/index.mjs +0 -3
- package/esm2022/lib/components/audit/list/audit-list.component.mjs +0 -81
- package/esm2022/lib/components/audit/service/audit.service.mjs +0 -49
- package/esm2022/lib/components/audit/types/audit-detail-form.type.mjs +0 -2
- package/esm2022/lib/components/buttons/group/btn-group.component.mjs +0 -43
- package/esm2022/lib/components/buttons/group/interfaces/btn-group-config.interface.mjs +0 -2
- package/esm2022/lib/components/buttons/index.mjs +0 -3
- package/esm2022/lib/components/buttons/loading/btn-loading.component.mjs +0 -48
- package/esm2022/lib/components/containers/applet-container/applet-container.component.mjs +0 -55
- package/esm2022/lib/components/containers/applet-container/provide-applet-config.util.mjs +0 -9
- package/esm2022/lib/components/containers/colum-header-container/column-header-container.component.mjs +0 -23
- package/esm2022/lib/components/containers/column-container/column-container.component.mjs +0 -79
- package/esm2022/lib/components/containers/column-container/directives/lazy-route.directive.mjs +0 -57
- package/esm2022/lib/components/containers/index.mjs +0 -7
- package/esm2022/lib/components/containers/list-container/index.mjs +0 -3
- package/esm2022/lib/components/containers/list-container/interfaces/list-container-config.interface.mjs +0 -2
- package/esm2022/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.mjs +0 -58
- package/esm2022/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.mjs +0 -57
- package/esm2022/lib/components/containers/modal-container/modal-container.component.mjs +0 -40
- package/esm2022/lib/components/filter/filter.component.mjs +0 -222
- package/esm2022/lib/components/filter/index.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-config.interface.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-field.interface.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-search-event.interface.mjs +0 -2
- package/esm2022/lib/components/forms/country-input/form-country-input.component.mjs +0 -122
- package/esm2022/lib/components/forms/currency-input/form-currency-input.component.mjs +0 -157
- package/esm2022/lib/components/forms/date/form-date.component.mjs +0 -114
- package/esm2022/lib/components/forms/image-picker/directives/drag-n-drop.directive.mjs +0 -49
- package/esm2022/lib/components/forms/image-picker/form-image-picker.component.mjs +0 -68
- package/esm2022/lib/components/forms/index.mjs +0 -12
- package/esm2022/lib/components/forms/input/form-input.component.mjs +0 -98
- package/esm2022/lib/components/forms/number/form-number.component.mjs +0 -97
- package/esm2022/lib/components/forms/number/pipes/locale-number.pipe.mjs +0 -33
- package/esm2022/lib/components/forms/password/form-password.component.mjs +0 -100
- package/esm2022/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.mjs +0 -135
- package/esm2022/lib/components/forms/searchable-select/form-searchable-select.component.mjs +0 -138
- package/esm2022/lib/components/forms/select/form-select.component.mjs +0 -116
- package/esm2022/lib/components/forms/textarea/form-textarea.component.mjs +0 -88
- package/esm2022/lib/components/grids/grid-pagination/grid-pagination.component.mjs +0 -111
- package/esm2022/lib/components/grids/grid-snapshot/grid-snapshot.component.mjs +0 -109
- package/esm2022/lib/components/grids/index.mjs +0 -4
- package/esm2022/lib/components/grids/interfaces/grid-config.interface.mjs +0 -2
- package/esm2022/lib/components/grids/services/grid.service.mjs +0 -25
- package/esm2022/lib/components/index.mjs +0 -9
- package/esm2022/lib/components/infinite-scroll/directive/infinite-scroll.directive.mjs +0 -43
- package/esm2022/lib/components/infinite-scroll/index.mjs +0 -3
- package/esm2022/lib/components/infinite-scroll/infinite-scroll.component.mjs +0 -36
- package/esm2022/lib/components/tabs/index.mjs +0 -3
- package/esm2022/lib/components/tabs/tab-content/tab-content.component.mjs +0 -37
- package/esm2022/lib/components/tabs/tab-group/tab-group.component.mjs +0 -47
- package/esm2022/lib/guards/auth/auth.guard.mjs +0 -10
- package/esm2022/lib/guards/index.mjs +0 -2
- package/esm2022/lib/interceptors/header/header.interceptor.mjs +0 -29
- package/esm2022/lib/interceptors/index.mjs +0 -3
- package/esm2022/lib/interceptors/refresh-token/refresh-token.interceptor.mjs +0 -83
- package/esm2022/lib/interfaces/index.mjs +0 -2
- package/esm2022/lib/interfaces/user/user.interface.mjs +0 -2
- package/esm2022/lib/modules/index.mjs +0 -3
- package/esm2022/lib/modules/micro-frontend/index.mjs +0 -2
- package/esm2022/lib/modules/micro-frontend/utils/mf-bootstrap.util.mjs +0 -55
- package/esm2022/lib/modules/micro-frontend/utils/mf-global-state.util.mjs +0 -14
- package/esm2022/lib/modules/permission/directive/permission.directive.mjs +0 -41
- package/esm2022/lib/modules/permission/guards/permission.guard.mjs +0 -26
- package/esm2022/lib/modules/permission/index.mjs +0 -7
- package/esm2022/lib/modules/permission/pages/401/unauthorized.page.mjs +0 -15
- package/esm2022/lib/modules/permission/pages/loading/loading.page.mjs +0 -65
- package/esm2022/lib/modules/permission/pages/loading/provide-loading-config.util.mjs +0 -9
- package/esm2022/lib/modules/permission/services/permission.service.mjs +0 -50
- package/esm2022/lib/resolvers/auth/auth.resolver.mjs +0 -87
- package/esm2022/lib/resolvers/index.mjs +0 -2
- package/esm2022/lib/services/auth/auth.service.mjs +0 -171
- package/esm2022/lib/services/country/country.service.mjs +0 -43
- package/esm2022/lib/services/currency/currency.service.mjs +0 -40
- package/esm2022/lib/services/index.mjs +0 -6
- package/esm2022/lib/services/profile/profile.service.mjs +0 -82
- package/esm2022/lib/services/rate-group-code/rate-group-code.service.mjs +0 -31
- package/esm2022/lib/utils/contrast-color-generator/contrast-color-generator.util.mjs +0 -16
- package/esm2022/lib/utils/form-error-message/form-error-message.util.mjs +0 -21
- package/esm2022/lib/utils/format-capitalize/format-capitalize.util.mjs +0 -18
- package/esm2022/lib/utils/index.mjs +0 -5
- package/esm2022/lib/utils/redirect-to-first-menu/redirect-to-first-menu.util.mjs +0 -9
- package/esm2022/public-api.mjs +0 -10
- package/esm2022/unipin-angular-applet.mjs +0 -2
- package/fesm2022/unipin-angular-applet.mjs +0 -4564
- package/fesm2022/unipin-angular-applet.mjs.map +0 -1
- package/graphql/generated.d.ts +0 -15719
- package/index.d.ts +0 -2
- package/lib/components/approval/detail/approval-detail.component.d.ts +0 -26
- package/lib/components/approval/form/approval-form.component.d.ts +0 -33
- package/lib/components/approval/list/approval-list.component.d.ts +0 -33
- package/lib/components/approval/list/provide-approval-entities.util.d.ts +0 -3
- package/lib/components/approval/services/approval.service.d.ts +0 -18
- package/lib/components/audit/detail/audit-detail.component.d.ts +0 -33
- package/lib/components/audit/list/audit-list.component.d.ts +0 -31
- package/lib/components/audit/service/audit.service.d.ts +0 -15
- package/lib/components/audit/types/audit-detail-form.type.d.ts +0 -12
- package/lib/components/buttons/group/btn-group.component.d.ts +0 -18
- package/lib/components/buttons/group/interfaces/btn-group-config.interface.d.ts +0 -11
- package/lib/components/buttons/loading/btn-loading.component.d.ts +0 -19
- package/lib/components/containers/applet-container/applet-container.component.d.ts +0 -22
- package/lib/components/containers/applet-container/provide-applet-config.util.d.ts +0 -15
- package/lib/components/containers/colum-header-container/column-header-container.component.d.ts +0 -7
- package/lib/components/containers/column-container/column-container.component.d.ts +0 -26
- package/lib/components/containers/column-container/directives/lazy-route.directive.d.ts +0 -17
- package/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.d.ts +0 -23
- package/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.d.ts +0 -23
- package/lib/components/containers/modal-container/modal-container.component.d.ts +0 -16
- package/lib/components/filter/filter.component.d.ts +0 -44
- package/lib/components/filter/interfaces/filter-config.interface.d.ts +0 -5
- package/lib/components/filter/interfaces/filter-field.interface.d.ts +0 -23
- package/lib/components/filter/interfaces/filter-search-event.interface.d.ts +0 -4
- package/lib/components/forms/country-input/form-country-input.component.d.ts +0 -41
- package/lib/components/forms/currency-input/form-currency-input.component.d.ts +0 -52
- package/lib/components/forms/date/form-date.component.d.ts +0 -32
- package/lib/components/forms/image-picker/directives/drag-n-drop.directive.d.ts +0 -10
- package/lib/components/forms/image-picker/form-image-picker.component.d.ts +0 -21
- package/lib/components/forms/input/form-input.component.d.ts +0 -31
- package/lib/components/forms/number/form-number.component.d.ts +0 -27
- package/lib/components/forms/number/pipes/locale-number.pipe.d.ts +0 -8
- package/lib/components/forms/password/form-password.component.d.ts +0 -27
- package/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.d.ts +0 -41
- package/lib/components/forms/searchable-select/form-searchable-select.component.d.ts +0 -42
- package/lib/components/forms/select/form-select.component.d.ts +0 -33
- package/lib/components/forms/textarea/form-textarea.component.d.ts +0 -26
- package/lib/components/grids/grid-pagination/grid-pagination.component.d.ts +0 -33
- package/lib/components/grids/grid-snapshot/grid-snapshot.component.d.ts +0 -36
- package/lib/components/grids/interfaces/grid-config.interface.d.ts +0 -16
- package/lib/components/grids/services/grid.service.d.ts +0 -12
- package/lib/components/infinite-scroll/directive/infinite-scroll.directive.d.ts +0 -15
- package/lib/components/infinite-scroll/infinite-scroll.component.d.ts +0 -12
- package/lib/components/tabs/tab-content/tab-content.component.d.ts +0 -14
- package/lib/components/tabs/tab-group/tab-group.component.d.ts +0 -18
- package/lib/guards/auth/auth.guard.d.ts +0 -1
- package/lib/interceptors/header/header.interceptor.d.ts +0 -9
- package/lib/interceptors/refresh-token/refresh-token.interceptor.d.ts +0 -14
- package/lib/interfaces/user/user.interface.d.ts +0 -27
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/micro-frontend/utils/mf-bootstrap.util.d.ts +0 -9
- package/lib/modules/micro-frontend/utils/mf-global-state.util.d.ts +0 -4
- package/lib/modules/permission/directive/permission.directive.d.ts +0 -16
- package/lib/modules/permission/guards/permission.guard.d.ts +0 -2
- package/lib/modules/permission/pages/401/unauthorized.page.d.ts +0 -5
- package/lib/modules/permission/pages/loading/loading.page.d.ts +0 -18
- package/lib/modules/permission/pages/loading/provide-loading-config.util.d.ts +0 -10
- package/lib/modules/permission/services/permission.service.d.ts +0 -21
- package/lib/resolvers/auth/auth.resolver.d.ts +0 -14
- package/lib/services/auth/auth.service.d.ts +0 -39
- package/lib/services/country/country.service.d.ts +0 -16
- package/lib/services/currency/currency.service.d.ts +0 -16
- package/lib/services/profile/profile.service.d.ts +0 -12
- package/lib/services/rate-group-code/rate-group-code.service.d.ts +0 -14
- package/lib/utils/contrast-color-generator/contrast-color-generator.util.d.ts +0 -4
- package/lib/utils/form-error-message/form-error-message.util.d.ts +0 -2
- package/lib/utils/format-capitalize/format-capitalize.util.d.ts +0 -1
- package/lib/utils/redirect-to-first-menu/redirect-to-first-menu.util.d.ts +0 -2
- package/public-api.d.ts +0 -11
- /package/{src → projects/unipin-angular/src}/assets/scss/forms.scss +0 -0
- /package/{src → projects/unipin-angular/src}/assets/scss/grid.scss +0 -0
- /package/{src → projects/unipin-angular/src}/assets/scss/select.scss +0 -0
- /package/{lib/components/audit/index.d.ts → projects/unipin-angular/src/lib/components/audit/index.ts} +0 -0
- /package/{lib/components/buttons/index.d.ts → projects/unipin-angular/src/lib/components/buttons/index.ts} +0 -0
- /package/{lib/components/containers/list-container/index.d.ts → projects/unipin-angular/src/lib/components/containers/list-container/index.ts} +0 -0
- /package/{lib/components/forms/index.d.ts → projects/unipin-angular/src/lib/components/forms/index.ts} +0 -0
- /package/{lib/components/grids/index.d.ts → projects/unipin-angular/src/lib/components/grids/index.ts} +0 -0
- /package/{lib/components/infinite-scroll/index.d.ts → projects/unipin-angular/src/lib/components/infinite-scroll/index.ts} +0 -0
- /package/{lib/guards/index.d.ts → projects/unipin-angular/src/lib/guards/index.ts} +0 -0
- /package/{lib/interceptors/index.d.ts → projects/unipin-angular/src/lib/interceptors/index.ts} +0 -0
- /package/{lib/interfaces/index.d.ts → projects/unipin-angular/src/lib/interfaces/index.ts} +0 -0
- /package/{lib/modules/micro-frontend/index.d.ts → projects/unipin-angular/src/lib/modules/micro-frontend/index.ts} +0 -0
- /package/{lib/resolvers/index.d.ts → projects/unipin-angular/src/lib/resolvers/index.ts} +0 -0
- /package/{lib/services/index.d.ts → projects/unipin-angular/src/lib/services/index.ts} +0 -0
- /package/{lib/utils/index.d.ts → projects/unipin-angular/src/lib/utils/index.ts} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApplicationConfig, enableProdMode, Injector, NgZone, Type } from '@angular/core';
|
|
2
|
+
import { Location } from '@angular/common';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { bootstrapApplication, createApplication } from '@angular/platform-browser';
|
|
5
|
+
import { getGlobalStateSlice, setGlobalStateSlice } from './mf-global-state.util';
|
|
6
|
+
import { createCustomElement } from '@angular/elements';
|
|
7
|
+
|
|
8
|
+
export type AppType = 'shell' | 'microfrontend';
|
|
9
|
+
|
|
10
|
+
export type Options = {
|
|
11
|
+
production: boolean;
|
|
12
|
+
appType: AppType;
|
|
13
|
+
elementName?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function getNgZone(): NgZone{
|
|
17
|
+
return (getGlobalStateSlice((state: { ngZone: NgZone }) => state.ngZone));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function shareNgZone(zone: NgZone): void{
|
|
21
|
+
setGlobalStateSlice({ ngZone: zone });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function bootstrap<M>(component: Type<M>, options: Options, config: ApplicationConfig): void{
|
|
25
|
+
options.production && enableProdMode();
|
|
26
|
+
|
|
27
|
+
if (options.appType === 'shell') {
|
|
28
|
+
bootstrapApplication(component, config).then((ref) => {
|
|
29
|
+
shareShellZone(ref.injector);
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!getNgZone() && isLocalhost()) {
|
|
35
|
+
bootstrapApplication(component, config).then((ref) => {
|
|
36
|
+
connectMicroFrontendRouter(ref.injector);
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
(async () => {
|
|
42
|
+
config.providers.push({ provide: NgZone, useValue: getNgZone() });
|
|
43
|
+
|
|
44
|
+
const app = await createApplication(config);
|
|
45
|
+
customElements.define(<string> options.elementName, createCustomElement(component, { injector: app.injector }));
|
|
46
|
+
|
|
47
|
+
connectMicroFrontendRouter(app.injector);
|
|
48
|
+
})();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function shareShellZone(injector: Injector): void{
|
|
52
|
+
const ngZone = injector.get(NgZone, null);
|
|
53
|
+
if (!ngZone) {
|
|
54
|
+
console.warn('No NgZone to share found');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
shareNgZone(ngZone);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function connectMicroFrontendRouter(injector: Injector): void{
|
|
61
|
+
const router = injector.get(Router);
|
|
62
|
+
const location = injector.get(Location);
|
|
63
|
+
|
|
64
|
+
if (!router) {
|
|
65
|
+
console.warn('No router to connect found');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
router.navigateByUrl(location.path() + window.location.hash);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isLocalhost(): boolean{
|
|
72
|
+
const hostname = window.location.hostname;
|
|
73
|
+
return hostname === 'localhost' || hostname === '127.0.0.1';
|
|
74
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const packageNamespace = '@angular-architects/module-federation-tools';
|
|
2
|
+
|
|
3
|
+
function getGlobalState<T>(): T {
|
|
4
|
+
const globalState = window as unknown as { [packageNamespace]: T };
|
|
5
|
+
globalState[packageNamespace] = globalState[packageNamespace] || ({} as unknown as T);
|
|
6
|
+
|
|
7
|
+
return globalState[packageNamespace];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getGlobalStateSlice<T>(): T;
|
|
11
|
+
export function getGlobalStateSlice<T, R>(selector: (globalState: T) => R): R;
|
|
12
|
+
|
|
13
|
+
export function getGlobalStateSlice<T, R>(selector?: (globalState: T) => R): R | T {
|
|
14
|
+
const globalState = getGlobalState<T>();
|
|
15
|
+
return selector? selector(globalState) : globalState;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function setGlobalStateSlice<T extends object>(slice: T): T {
|
|
19
|
+
return Object.assign(getGlobalState<T>(), slice);
|
|
20
|
+
}
|
package/projects/unipin-angular/src/lib/modules/permission/directive/permission.directive.spec.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { Apollo } from 'apollo-angular';
|
|
5
|
+
import { PermissionDirective } from './permission.directive';
|
|
6
|
+
import { PermissionService } from '../services/permission.service';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
template: `
|
|
10
|
+
<div *hasPermission="'MEMBER'; scope: 'GLOBAL'; type: 'ADMIN'">Content</div>
|
|
11
|
+
<span *hasPermission="'JOB'; scope: 'GLOBAL'; type: 'ADMIN'">Content</span>
|
|
12
|
+
`,
|
|
13
|
+
imports: [PermissionDirective]
|
|
14
|
+
})
|
|
15
|
+
class TestComponent {}
|
|
16
|
+
|
|
17
|
+
describe('PermissionDirective', () => {
|
|
18
|
+
let fixture: ComponentFixture<TestComponent>;
|
|
19
|
+
let component: TestComponent;
|
|
20
|
+
let permissionService: PermissionService;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
TestBed.configureTestingModule({
|
|
24
|
+
declarations: [PermissionDirective, TestComponent],
|
|
25
|
+
providers: [
|
|
26
|
+
PermissionService,
|
|
27
|
+
{ provide: Apollo },
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
permissionService = TestBed.inject(PermissionService);
|
|
32
|
+
fixture = TestBed.createComponent(TestComponent);
|
|
33
|
+
component = fixture.componentInstance;
|
|
34
|
+
|
|
35
|
+
permissionService.setPermission([ 'GLOBAL.MEMBER.ADMIN' ], [ 'MEMBER' ])
|
|
36
|
+
fixture.detectChanges();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should create the component', () => expect(component).toBeTruthy());
|
|
40
|
+
|
|
41
|
+
it('should display content when permission is granted', () => {
|
|
42
|
+
const dynamicViewElement = fixture.debugElement.query(By.css('div'));
|
|
43
|
+
expect(dynamicViewElement).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should not display content when permission is denied', () => {
|
|
47
|
+
const dynamicViewElement = fixture.debugElement.query(By.css('span'));
|
|
48
|
+
expect(dynamicViewElement).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { PermissionService } from '../services/permission.service';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `PermissionDirective` is a directive that conditionally renders content based on user permissions.
|
|
6
|
+
* `Scope` param is default to `GLOBAL`
|
|
7
|
+
* @selector '[hasPermission]'
|
|
8
|
+
* @example
|
|
9
|
+
* ```html
|
|
10
|
+
* <div *hasPermission="'POST_AUDIT'; type: 'READ'; scope: 'MERCHANT'"></div>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
@Directive({
|
|
14
|
+
standalone: true,
|
|
15
|
+
selector: '[hasPermission]'
|
|
16
|
+
})
|
|
17
|
+
export class PermissionDirective {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The module name for which permissions are being checked.
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @default {null}
|
|
23
|
+
*/
|
|
24
|
+
protected module!: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The permission scope.
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @default {'GLOBAL'}
|
|
30
|
+
*/
|
|
31
|
+
protected scope: string = 'GLOBAL';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sets the module name for which permissions are being checked.
|
|
35
|
+
* @example 'POST_AUDIT'.
|
|
36
|
+
* @param {string} m - The module name.
|
|
37
|
+
*/
|
|
38
|
+
@Input() set hasPermission(m: string) {
|
|
39
|
+
this.module = m;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Sets the permission scope. Default is 'GLOBAL'.
|
|
44
|
+
* @param {string} s - The permission scope.
|
|
45
|
+
*/
|
|
46
|
+
@Input() set hasPermissionScope(s: string) {
|
|
47
|
+
this.scope = s;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Sets the permission type and conditionally renders content based on user permissions.
|
|
52
|
+
* @param {string} t - The permission type, e.g., 'READ', 'WRITE'.
|
|
53
|
+
*/
|
|
54
|
+
@Input() set hasPermissionType(t: string) {;
|
|
55
|
+
if (this.permissionService.checkPermission(this.scope, this.module, t)) {
|
|
56
|
+
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.viewContainer.clear();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
constructor(
|
|
64
|
+
protected readonly templateRef: TemplateRef<any>,
|
|
65
|
+
protected readonly viewContainer: ViewContainerRef,
|
|
66
|
+
protected readonly permissionService: PermissionService
|
|
67
|
+
) { }
|
|
68
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
|
2
|
+
// import { Location } from '@angular/common';
|
|
3
|
+
// import { PermissionService } from '../services/permission.service';
|
|
4
|
+
// import { canActivate } from './permission.guard';
|
|
5
|
+
|
|
6
|
+
describe('PermissionGuard', () => {
|
|
7
|
+
// let routerSpy: jasmine.SpyObj<Router>;
|
|
8
|
+
// let locationSpy: jasmine.SpyObj<Location>;
|
|
9
|
+
// let permissionServiceSpy: jasmine.SpyObj<PermissionService>;
|
|
10
|
+
|
|
11
|
+
// beforeEach(() => {
|
|
12
|
+
// routerSpy = jasmine.createSpyObj('Router', ['navigate']);
|
|
13
|
+
// locationSpy = jasmine.createSpyObj('Location', ['path']);
|
|
14
|
+
// permissionServiceSpy = jasmine.createSpyObj('PermissionService', ['isInitiated', 'checkPermission']);
|
|
15
|
+
// });
|
|
16
|
+
|
|
17
|
+
// it('should return true when permission is granted', () => {
|
|
18
|
+
// permissionServiceSpy.isInitiated = true;
|
|
19
|
+
// permissionServiceSpy.checkPermission.and.returnValue(true);
|
|
20
|
+
|
|
21
|
+
// const result = canActivate(createActivatedRouteSnapshot('s', 'm', 't'), routerSpy, locationSpy, permissionServiceSpy);
|
|
22
|
+
|
|
23
|
+
// expect(result).toBe(true);
|
|
24
|
+
// expect(routerSpy.navigate).not.toHaveBeenCalled();
|
|
25
|
+
// });
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// it('should return false and navigate to loading when not initiated', () => {
|
|
29
|
+
// permissionServiceSpy.isInitiated = false;
|
|
30
|
+
|
|
31
|
+
// const result = canActivate(createActivatedRouteSnapshot('s', 'm', 't'), routerSpy, locationSpy, permissionServiceSpy);
|
|
32
|
+
|
|
33
|
+
// expect(result).toBe(false);
|
|
34
|
+
// expect(routerSpy.navigate).toHaveBeenCalledWith(['loading'], { queryParams: { url: jasmine.any(String) } });
|
|
35
|
+
// });
|
|
36
|
+
|
|
37
|
+
// it('should return false and navigate to 401 when permission is not granted', () => {
|
|
38
|
+
// permissionServiceSpy.isInitiated = true;
|
|
39
|
+
// permissionServiceSpy.checkPermission.and.returnValue(false);
|
|
40
|
+
|
|
41
|
+
// const result = canActivate(createActivatedRouteSnapshot('s', 'm', 't'), routerSpy, locationSpy, permissionServiceSpy);
|
|
42
|
+
|
|
43
|
+
// expect(result).toBe(false);
|
|
44
|
+
// expect(routerSpy.navigate).toHaveBeenCalledWith(['401']);
|
|
45
|
+
// });
|
|
46
|
+
|
|
47
|
+
// function createActivatedRouteSnapshot(scope: string, module: string, type: string): ActivatedRouteSnapshot {
|
|
48
|
+
// return {
|
|
49
|
+
// data: { requiredPermission: { scope, module, type } },
|
|
50
|
+
// url: [],
|
|
51
|
+
// params: {},
|
|
52
|
+
// queryParams: {},
|
|
53
|
+
// fragment: null,
|
|
54
|
+
// outlet: '',
|
|
55
|
+
// component: null,
|
|
56
|
+
// routeConfig: null,
|
|
57
|
+
// title: undefined,
|
|
58
|
+
// root: new ActivatedRouteSnapshot,
|
|
59
|
+
// parent: null,
|
|
60
|
+
// firstChild: null,
|
|
61
|
+
// children: [],
|
|
62
|
+
// pathFromRoot: [],
|
|
63
|
+
// paramMap: createParamMap(),
|
|
64
|
+
// queryParamMap: createParamMap()
|
|
65
|
+
// } as ActivatedRouteSnapshot;
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// function createParamMap(): any {
|
|
69
|
+
// return {
|
|
70
|
+
// has: () => false,
|
|
71
|
+
// get: () => null,
|
|
72
|
+
// getAll: () => [],
|
|
73
|
+
// keys: []
|
|
74
|
+
// };
|
|
75
|
+
// }
|
|
76
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { Location } from '@angular/common';
|
|
3
|
+
import { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';
|
|
4
|
+
import { PermissionService } from '../services/permission.service';
|
|
5
|
+
|
|
6
|
+
export const PermissionGuard: CanActivateFn = (route: ActivatedRouteSnapshot): boolean => {
|
|
7
|
+
|
|
8
|
+
const router: Router = inject(Router);
|
|
9
|
+
const location: Location = inject(Location);
|
|
10
|
+
const permissionService: PermissionService = inject(PermissionService);
|
|
11
|
+
|
|
12
|
+
const permissions: { scope: string, module: string, type: string }[] = route.data['requiredPermissions'];
|
|
13
|
+
|
|
14
|
+
if (!permissions || permissions.length === 0) throw new Error('Invalid config: requiredPermissions is a required parameter in route data for PermissionGuard');
|
|
15
|
+
|
|
16
|
+
if (!permissionService.isInitiated) {
|
|
17
|
+
router.navigate([ 'loading' ], { queryParams: { url: `${ location.path() + window.location.hash }` } });
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (permissions) {
|
|
22
|
+
for (let i = 0; i < permissions.length; i++) {
|
|
23
|
+
const { scope, module, type } = permissions[i];
|
|
24
|
+
if (permissionService.checkPermission(scope, module, type)) return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
router.navigate([ '401' ]);
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { provideLoadingConfig, LoadingConfig } from './pages/loading/provide-loading-config.util';
|
|
2
2
|
export { LoadingPage } from './pages/loading/loading.page';
|
|
3
|
+
|
|
3
4
|
export { PermissionDirective } from './directive/permission.directive';
|
|
4
5
|
export { PermissionGuard } from './guards/permission.guard';
|
|
5
6
|
export { PermissionService } from './services/permission.service';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { IonicModule } from '@ionic/angular';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
standalone: true,
|
|
6
|
+
selector: 'up-unauthorized',
|
|
7
|
+
templateUrl: './unauthorized.page.html',
|
|
8
|
+
styleUrls: ['./unauthorized.page.scss'],
|
|
9
|
+
host: {
|
|
10
|
+
class: 'd-flex flex-column align-items-center justify-content-center h-100 w-75 mx-auto'
|
|
11
|
+
},
|
|
12
|
+
imports: [ IonicModule ]
|
|
13
|
+
})
|
|
14
|
+
export class UnauthorizedPage { }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
4
|
+
import { IonicModule } from '@ionic/angular';
|
|
5
|
+
import { PermissionService } from '../../services/permission.service';
|
|
6
|
+
import { LOADING_CONFIG, LoadingConfig } from './provide-loading-config.util';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
standalone: true,
|
|
10
|
+
selector: 'up-loading',
|
|
11
|
+
styleUrl: './loading.page.scss',
|
|
12
|
+
templateUrl: './loading.page.html',
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: {
|
|
15
|
+
class: 'd-flex flex-column align-items-center justify-content-center h-100 w-75 mx-auto'
|
|
16
|
+
},
|
|
17
|
+
imports: [
|
|
18
|
+
IonicModule
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
export class LoadingPage implements OnInit, OnDestroy {
|
|
22
|
+
|
|
23
|
+
protected sub?: Subscription;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
@Inject(LOADING_CONFIG) public readonly config: LoadingConfig,
|
|
27
|
+
protected readonly router: Router,
|
|
28
|
+
protected readonly route: ActivatedRoute,
|
|
29
|
+
protected readonly permissionService: PermissionService
|
|
30
|
+
) { }
|
|
31
|
+
|
|
32
|
+
public ngOnInit(): void{
|
|
33
|
+
const subjectGuid = localStorage.getItem(this.config.subjectGuidStorageKey || 'userGuid');
|
|
34
|
+
if (!subjectGuid) {
|
|
35
|
+
this.router.navigate([ '401' ]);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const permCodeList: string[] = [];
|
|
40
|
+
const permModuleList: Map<string, boolean> = new Map();;
|
|
41
|
+
|
|
42
|
+
this.sub = this.permissionService.getPermissions({
|
|
43
|
+
subjectGuid,
|
|
44
|
+
pageSize: 1000,
|
|
45
|
+
permType: this.config.permTypes,
|
|
46
|
+
permModule: this.config.permModules,
|
|
47
|
+
}, this.config.fetchPolicy).subscribe({
|
|
48
|
+
error: () => {
|
|
49
|
+
this.router.navigate([ '401' ]);
|
|
50
|
+
},
|
|
51
|
+
next: ({ data: { authMsPermission: { data }}}) => {
|
|
52
|
+
data.forEach(({ permCode, permModule }) => {
|
|
53
|
+
if (!permCode || !permModule) return;
|
|
54
|
+
|
|
55
|
+
permCodeList.push(permCode);
|
|
56
|
+
if (!permModuleList.has(permModule)) {
|
|
57
|
+
permModuleList.set(permModule, true);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
this.permissionService.isInitiated = true;
|
|
62
|
+
this.permissionService.setPermission(
|
|
63
|
+
permCodeList,
|
|
64
|
+
Array.from(
|
|
65
|
+
permModuleList.keys()
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
this.router.navigateByUrl(this.route.snapshot.queryParamMap.get('url')?? '');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public ngOnDestroy(): void{
|
|
74
|
+
this.sub?.unsubscribe();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
import { FetchPolicy } from '@apollo/client/core';
|
|
3
|
+
|
|
4
|
+
export const LOADING_CONFIG = new InjectionToken<LoadingConfig>('LOADING_CONFIG');
|
|
5
|
+
|
|
6
|
+
export interface LoadingConfig {
|
|
7
|
+
permTypes: string[];
|
|
8
|
+
permModules: string[];
|
|
9
|
+
fetchPolicy?: FetchPolicy;
|
|
10
|
+
subjectGuidStorageKey?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function provideLoadingConfig(config: LoadingConfig): Provider{
|
|
14
|
+
return {
|
|
15
|
+
provide: LOADING_CONFIG,
|
|
16
|
+
useValue: config
|
|
17
|
+
};
|
|
18
|
+
}
|
package/projects/unipin-angular/src/lib/modules/permission/services/permission.service.spec.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { TestBed, inject } from '@angular/core/testing';
|
|
2
|
+
import { ApolloQueryResult } from '@apollo/client/core';
|
|
3
|
+
import { ApolloTestingModule, ApolloTestingController } from 'apollo-angular/testing';
|
|
4
|
+
import { AppPermDfn } from '../../../../graphql/generated';
|
|
5
|
+
import { PermissionService } from './permission.service';
|
|
6
|
+
|
|
7
|
+
describe('PermissionService', () => {
|
|
8
|
+
let service: PermissionService;
|
|
9
|
+
let apolloController: ApolloTestingController;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
TestBed.configureTestingModule({
|
|
13
|
+
imports: [
|
|
14
|
+
ApolloTestingModule
|
|
15
|
+
],
|
|
16
|
+
providers: [PermissionService],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
service = TestBed.inject(PermissionService);
|
|
20
|
+
apolloController = TestBed.inject(ApolloTestingController);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should be created', () => expect(service).toBeTruthy());
|
|
24
|
+
|
|
25
|
+
it('should set permissions correctly', () => {
|
|
26
|
+
const permCodes = ['SCOPE1.MODULE1.ADMIN', 'SCOPE1.MODULE2.READ'];
|
|
27
|
+
const permModules = ['MODULE1', 'MODULE2'];
|
|
28
|
+
|
|
29
|
+
service.setPermission(permCodes, permModules);
|
|
30
|
+
expect(service.checkPermission('SCOPE1', 'MODULE1', 'ADMIN')).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should check permission correctly', () => {
|
|
34
|
+
const permCodes = ['SCOPE1.MODULE1.ADMIN', 'SCOPE1.MODULE2.READ'];
|
|
35
|
+
service.setPermission(permCodes);
|
|
36
|
+
|
|
37
|
+
expect(service.checkPermission('SCOPE1', 'MODULE1', 'ADMIN')).toBe(true);
|
|
38
|
+
expect(service.checkPermission('SCOPE1', 'MODULE2', 'READ')).toBe(true);
|
|
39
|
+
expect(service.checkPermission('SCOPE1', 'MODULE3', 'WRITE')).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should get permissions from Apollo', inject([PermissionService], (permissionService: PermissionService) => {
|
|
43
|
+
const mockPermissions = {
|
|
44
|
+
data: {
|
|
45
|
+
authMsPermission: {
|
|
46
|
+
data: [{ permCode: 'PERM1' }, { permCode: 'PERM2' }]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
permissionService.getPermissions({ page: 0, pageSize: 2 }).subscribe((result) => {
|
|
52
|
+
expect(result).toEqual(mockPermissions as ApolloQueryResult<{ authMsPermission: { data: AppPermDfn[] } }>);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const op = apolloController.expectOne((operation) => operation.operationName === 'QueryPermission');
|
|
56
|
+
op.flush({ data: mockPermissions });
|
|
57
|
+
|
|
58
|
+
apolloController.verify();
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
afterEach(() => apolloController.verify());
|
|
62
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
import { ApolloQueryResult, FetchPolicy } from '@apollo/client/core';
|
|
4
|
+
import { Apollo, gql } from 'apollo-angular';
|
|
5
|
+
import { AppPermDfn, PermissionFilter } from '../../../../graphql/generated';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class PermissionService {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A readonly variable that used to store permission modules in an applet then check if the user
|
|
14
|
+
* has the permission or not. This variable controls menu's icon visibility on the sidebar. The
|
|
15
|
+
* icon will appear if the user has the permission that menu's needed and it will disappear if
|
|
16
|
+
* the user don't have the permission.
|
|
17
|
+
* @type {BehaviorSubject<string[]>}
|
|
18
|
+
*/
|
|
19
|
+
public readonly permModules: BehaviorSubject<string[]> = new BehaviorSubject<string[]>([]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A flag variable that used to know if the applet already initiated or not. Default value is
|
|
23
|
+
* false.
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
*/
|
|
26
|
+
public isInitiated: boolean = false;
|
|
27
|
+
protected permissions: Map<string, boolean> = new Map();
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
protected readonly apollo: Apollo
|
|
31
|
+
) { }
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A method that set the permissions and permission modules.
|
|
35
|
+
* @param {string[]} permCodes - Contain list of permission codes.
|
|
36
|
+
* @param {string[]} permModules - Contain list of permission modules. Default value [].
|
|
37
|
+
*/
|
|
38
|
+
public setPermission(permCodes: string[], permModules: string[] = []): void{
|
|
39
|
+
for (let i = 0; i < permCodes.length; i++) this.permissions.set(permCodes[i], true);
|
|
40
|
+
this.permModules.next(permModules);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A method that checking if the user has the permission or not based on the params value.
|
|
45
|
+
* @param {string} scope - Contain scope of the user's permission.
|
|
46
|
+
* @param {string} module - Contain module of the user's permission.
|
|
47
|
+
* @param {string} type - Contain type of the user's permission.
|
|
48
|
+
* @returns {boolean} Contain boolean value that tells the user has the permission or not.
|
|
49
|
+
*/
|
|
50
|
+
public checkPermission(scope: string, module: string, type: string): boolean{
|
|
51
|
+
if (this.permissions.has(`${ scope }.${ module }.ADMIN`)) return true;
|
|
52
|
+
if (this.permissions.has(`${ scope }.${ module }.${ type }`)) return true;
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A method that get the query value with authMsPermission as the object.
|
|
59
|
+
* @param {PermissionFilter} filter - Contain filter as a conditions for the query.
|
|
60
|
+
* @returns {Observable<ApolloQueryResult<{ authMsPermission: { data: AppPermDfn[] }}>>} Contain query value.
|
|
61
|
+
*/
|
|
62
|
+
public getPermissions(filter: PermissionFilter, fetchPolicy?: FetchPolicy): Observable<ApolloQueryResult<{ authMsPermission: { data: AppPermDfn[] }}>>{
|
|
63
|
+
return this.apollo.query({
|
|
64
|
+
fetchPolicy,
|
|
65
|
+
variables: { filter },
|
|
66
|
+
query: gql`
|
|
67
|
+
query QueryPermission($filter: PermissionFilter!) {
|
|
68
|
+
authMsPermission(filter: $filter) {
|
|
69
|
+
data {
|
|
70
|
+
permCode
|
|
71
|
+
permModule
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { AuthResolver } from './auth.resolver';
|
|
3
|
+
import { AuthService } from '../../services';
|
|
4
|
+
|
|
5
|
+
describe('AuthResolver', () => {
|
|
6
|
+
let authResolver: AuthResolver;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({
|
|
10
|
+
providers: [AuthResolver]
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
authResolver = TestBed.inject(AuthResolver);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should be created', () => expect(authResolver).toBeTruthy());
|
|
17
|
+
|
|
18
|
+
it('should return false if the user is not logged in', () => {
|
|
19
|
+
AuthService.authToken = '';
|
|
20
|
+
expect(authResolver.isUserLoggedIn()).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should return true if the user is logged in', () => {
|
|
24
|
+
AuthService.authToken = 'fakeAuthToken';
|
|
25
|
+
expect(authResolver.isUserLoggedIn()).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should return null if the user is not have token', () => {
|
|
29
|
+
AuthService.authToken = '';
|
|
30
|
+
expect(authResolver.getAuthToken()).toBeNull();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should return the auth token if the user is logged in and the token is not expired', () => {
|
|
34
|
+
spyOn(authResolver, 'isUserLoggedIn').and.returnValue(true);
|
|
35
|
+
AuthService.authToken = 'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxZmU5NTJkYS1kZjViLTQxZDQtOTgxYy1kNmQ1YzAxZDAxNDIiLCJleHAiOjE3MDgzMDE0MTgsImlhdCI6MTcwODI5NzgxOH0.g_STuNb-GRlawePsUqAKFoJ2yTwqiUGpd_5ldiII0T2OiIuPAHFjIWuIuErD7_pCHK9bwx0ZHGx2QtbFdavP4u2sZcNVItGq6fHaAp5PF1DQX1WkpRl9gihSVFvJfgrnr0AgnJm6DtL3PnDqSAETDQOSq7kPH-ZVuV6hU5otz6IrdLExj5Iv3BqxE8gRxpIGfTc-a58soloDDA_LWf7BfRNELUljpo73dHG2-kGhVs7nYR_8CIIOl0Vs6fqRctYX8ZGkGpL4ZY3oXvJfbFhflcN-0ux-xAhKDjzTHshTS1Tt6ihfJOPfwONBIhpNsvaifAlcacuk5LjlgrQ7S-ePla0tIIasTEJGNXJD48BEfX--_s2t_F4Y9PqAwqSYyoCk8Gy48aKvNZy2QGHRCs_4ftU_3JIU0c3adxNsFGaufJrUXp2Cso5_zaul0UYYyvVgJ4Whu4UFIKKrF_E4ypsDjUBr9QvNLPpjzafyeLrNF9QHWHBMnUCw5EN60MJy04cVpVi36dwjuk5w_uOMu-3-M_SK_nsvJWgNaUHMK9aexrGusdGfDx6w6s0nF3Z8WXAbP7BCqMbXYvzbxYenvTS6BGPzArhYPU-Lc2pJLAIFHuVv84Eaett-ca8O5us4rdYSep5LOogQe3LREwuyKZKE_lQkLHiwgVu3kdv430MSobE';
|
|
36
|
+
|
|
37
|
+
expect(authResolver.getAuthToken()).toBe('eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxZmU5NTJkYS1kZjViLTQxZDQtOTgxYy1kNmQ1YzAxZDAxNDIiLCJleHAiOjE3MDgzMDE0MTgsImlhdCI6MTcwODI5NzgxOH0.g_STuNb-GRlawePsUqAKFoJ2yTwqiUGpd_5ldiII0T2OiIuPAHFjIWuIuErD7_pCHK9bwx0ZHGx2QtbFdavP4u2sZcNVItGq6fHaAp5PF1DQX1WkpRl9gihSVFvJfgrnr0AgnJm6DtL3PnDqSAETDQOSq7kPH-ZVuV6hU5otz6IrdLExj5Iv3BqxE8gRxpIGfTc-a58soloDDA_LWf7BfRNELUljpo73dHG2-kGhVs7nYR_8CIIOl0Vs6fqRctYX8ZGkGpL4ZY3oXvJfbFhflcN-0ux-xAhKDjzTHshTS1Tt6ihfJOPfwONBIhpNsvaifAlcacuk5LjlgrQ7S-ePla0tIIasTEJGNXJD48BEfX--_s2t_F4Y9PqAwqSYyoCk8Gy48aKvNZy2QGHRCs_4ftU_3JIU0c3adxNsFGaufJrUXp2Cso5_zaul0UYYyvVgJ4Whu4UFIKKrF_E4ypsDjUBr9QvNLPpjzafyeLrNF9QHWHBMnUCw5EN60MJy04cVpVi36dwjuk5w_uOMu-3-M_SK_nsvJWgNaUHMK9aexrGusdGfDx6w6s0nF3Z8WXAbP7BCqMbXYvzbxYenvTS6BGPzArhYPU-Lc2pJLAIFHuVv84Eaett-ca8O5us4rdYSep5LOogQe3LREwuyKZKE_lQkLHiwgVu3kdv430MSobE');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should return null if the user is logged in but the token is expired', () => {
|
|
41
|
+
spyOn(authResolver, 'isUserLoggedIn').and.returnValue(false);
|
|
42
|
+
AuthService.authToken = '';
|
|
43
|
+
|
|
44
|
+
expect(authResolver.getAuthToken()).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
});
|