@unipin/angular-applet 18.9.3 → 18.9.5
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 +113 -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 +80 -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 +25 -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 +223 -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 -938
- 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 -4614
- package/fesm2022/unipin-angular-applet.mjs.map +0 -1
- package/graphql/generated.d.ts +0 -16225
- 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,144 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { AuthService } from '../../services';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `AuthResolver` service provides methods for handling authentication-related tasks,
|
|
6
|
+
* such as checking user login status, retrieving authentication tokens, and managing token expiration.
|
|
7
|
+
*/
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root'
|
|
10
|
+
})
|
|
11
|
+
export class AuthResolver {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the user is logged in by verifying the presence of an authentication token.
|
|
15
|
+
* @returns {boolean} - True if the user is logged in; otherwise, false.
|
|
16
|
+
*/
|
|
17
|
+
public isUserLoggedIn(): boolean{
|
|
18
|
+
return AuthService.authToken !== '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the authentication token, resolving it if needed.
|
|
23
|
+
* @returns {string | null} - The authentication token if the user is logged in; otherwise, null.
|
|
24
|
+
*/
|
|
25
|
+
public getAuthToken(): string | null{
|
|
26
|
+
this.resolveUserAuthToken();
|
|
27
|
+
|
|
28
|
+
if (this.isUserLoggedIn()) return AuthService.authToken;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the user's authentication token by checking expiration and whether the user still logged in or not.
|
|
34
|
+
*/
|
|
35
|
+
protected resolveUserAuthToken(): void{
|
|
36
|
+
if (!this.isUserLoggedIn() || !this.isTokenExpired(AuthService.authToken)) return;
|
|
37
|
+
|
|
38
|
+
AuthService.authToken = '';
|
|
39
|
+
AuthService.refreshToken = '';
|
|
40
|
+
localStorage.removeItem('authToken');
|
|
41
|
+
localStorage.removeItem('refreshToken');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a given token is expired or not yet.
|
|
46
|
+
* @param {string | null} token - The token to be checked for expiration.
|
|
47
|
+
* @returns {boolean} - True if the token is expired; otherwise, false.
|
|
48
|
+
*/
|
|
49
|
+
protected isTokenExpired(token: string | null): boolean{
|
|
50
|
+
if (!token || token === '') return true;
|
|
51
|
+
const date = this.getTokenExpirationDate(token);
|
|
52
|
+
|
|
53
|
+
if (date === null) return false;
|
|
54
|
+
return !(<number>date.valueOf() > new Date().valueOf() + 0 * 1000);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the expiration date of a token.
|
|
59
|
+
* @param {string | null} token - The token for which to retrieve the expiration date.
|
|
60
|
+
* @returns {Date | null} - The expiration date of the token if available; otherwise, null.
|
|
61
|
+
*/
|
|
62
|
+
protected getTokenExpirationDate(token: string | null): Date | null{
|
|
63
|
+
const decoded: any = this.decodeToken(token);
|
|
64
|
+
if (!decoded || !decoded.hasOwnProperty('exp')) return null;
|
|
65
|
+
|
|
66
|
+
const date = new Date(0);
|
|
67
|
+
date.setUTCSeconds(decoded.exp);
|
|
68
|
+
|
|
69
|
+
return date;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Decodes a JWT token to extract payload information.
|
|
74
|
+
* @param {string | null} token - The JWT token to be decoded.
|
|
75
|
+
* @returns {string | null} - The decoded payload as a string if successful; otherwise, null.
|
|
76
|
+
*/
|
|
77
|
+
protected decodeToken(token: string | null): string | null{
|
|
78
|
+
if (!token || token === '') return null;
|
|
79
|
+
|
|
80
|
+
const parts = token.split('.');
|
|
81
|
+
if (parts.length !== 3) throw new Error(`The inspected token doesn't appear to be a JWT. Check to make sure it has three parts and see https://jwt.io for more.`);
|
|
82
|
+
|
|
83
|
+
const decoded = this.urlBase64Decode(parts[1]);
|
|
84
|
+
if (!decoded) throw new Error('Cannot decode the token.');
|
|
85
|
+
|
|
86
|
+
return JSON.parse(decoded);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Decodes a base64url-encoded string.
|
|
91
|
+
* @param {string} str - The base64url-encoded string to be decoded.
|
|
92
|
+
* @returns {string} - The decoded string.
|
|
93
|
+
*/
|
|
94
|
+
protected urlBase64Decode(str: string): string{
|
|
95
|
+
let output = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
96
|
+
switch (output.length % 4) {
|
|
97
|
+
case 0:
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case 2:
|
|
101
|
+
output += '==';
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 3:
|
|
105
|
+
output += '=';
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
default:
|
|
109
|
+
throw new Error('Illegal base64url string!');
|
|
110
|
+
}
|
|
111
|
+
return this.b64DecodeUnicode(output);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Decodes a Unicode string from a base64-encoded string.
|
|
116
|
+
* @param {string} str - The base64-encoded string to be decoded.
|
|
117
|
+
* @returns {string} - The decoded Unicode string.
|
|
118
|
+
*/
|
|
119
|
+
protected b64DecodeUnicode(str: string): string{
|
|
120
|
+
return decodeURIComponent(Array.prototype.map.call(this.b64decode(str), (c: any) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Decodes a base64-encoded string.
|
|
125
|
+
* @param {string} str - The base64-encoded string to be decoded.
|
|
126
|
+
* @returns {string} - The decoded string.
|
|
127
|
+
*/
|
|
128
|
+
protected b64decode(str: string): string{
|
|
129
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
130
|
+
let output = '';
|
|
131
|
+
|
|
132
|
+
str = String(str).replace(/=+$/, '');
|
|
133
|
+
if (str.length % 4 === 1) throw new Error(`'atob' failed: The string to be decoded is not correctly encoded.`);
|
|
134
|
+
|
|
135
|
+
for (
|
|
136
|
+
let bc = 0, bs: any, buffer: any, idx = 0;
|
|
137
|
+
(buffer = str.charAt(idx++));
|
|
138
|
+
|
|
139
|
+
~buffer && ((bs = bc % 4? bs * 64 + buffer : buffer), bc++ % 4)? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) : 0
|
|
140
|
+
) buffer = chars.indexOf(buffer);
|
|
141
|
+
|
|
142
|
+
return output;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable, tap } from 'rxjs';
|
|
3
|
+
import { Apollo, MutationResult, gql } from 'apollo-angular';
|
|
4
|
+
import { FetchPolicy } from '@apollo/client/core';
|
|
5
|
+
import { AppLoginSubject, ChangePassRq, LoginResponse, LoginRq, MutationAuthMsRefreshAccessTokenArgs, SourcePlatform, SuggestedAction, Token } from '../../../graphql/generated';
|
|
6
|
+
import { User } from '../../interfaces';
|
|
7
|
+
import { ProfileService } from '../profile/profile.service';
|
|
8
|
+
|
|
9
|
+
@Injectable({
|
|
10
|
+
providedIn: 'root'
|
|
11
|
+
})
|
|
12
|
+
export class AuthService {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Both `authToken` and `refreshToken` are public static variable to store the auth token and refresh token obtained form the login API.
|
|
16
|
+
* They will be set as header param inside API calls.
|
|
17
|
+
* @type {string}
|
|
18
|
+
* @default ''
|
|
19
|
+
*/
|
|
20
|
+
public static authToken: string = '';
|
|
21
|
+
public static refreshToken: string = '';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A public variable to store the logined user information.
|
|
25
|
+
* @type {User} An interface contain user information.
|
|
26
|
+
* @default undefined
|
|
27
|
+
*/
|
|
28
|
+
public user?: User;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
protected readonly apollo: Apollo,
|
|
32
|
+
protected readonly profileService: ProfileService
|
|
33
|
+
) { }
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A method to authenticate the user to get the session for applet or platform.
|
|
37
|
+
* When successful it will set the user information to the `user` variable, `authToken` and `refreshToken`.
|
|
38
|
+
* It will set the `authToken`, `refreshToken`, `userGuid` and `roles` to the localStorage also for API calls.
|
|
39
|
+
* @param {{ email: string, password: string, sourcePlatform: string }} input - Contain `email` which is registered user email, `password` which is registered user password
|
|
40
|
+
* and `sourcePlatform` it's value can be `ADMIN` to get the applet session or `CP_COMMERCE` to get the platform session.
|
|
41
|
+
* @returns {Observable<MutationResult<{ authMsLogin: LoginResponse }>>} Contain logined user information.
|
|
42
|
+
*/
|
|
43
|
+
public login(input: LoginRq): Observable<MutationResult<{ authMsLogin: LoginResponse }>>{
|
|
44
|
+
return this.apollo.mutate<{ authMsLogin: LoginResponse }>({
|
|
45
|
+
variables: { input },
|
|
46
|
+
mutation: gql`
|
|
47
|
+
mutation Login($input: LoginRq!) {
|
|
48
|
+
authMsLogin(input: $input) {
|
|
49
|
+
accessToken
|
|
50
|
+
refreshToken
|
|
51
|
+
suggestedAction
|
|
52
|
+
user {
|
|
53
|
+
birthday
|
|
54
|
+
category
|
|
55
|
+
email
|
|
56
|
+
gender
|
|
57
|
+
guid
|
|
58
|
+
mobileNumber
|
|
59
|
+
name
|
|
60
|
+
status
|
|
61
|
+
departments {
|
|
62
|
+
department {
|
|
63
|
+
hierarchyCode
|
|
64
|
+
hierarchyPath
|
|
65
|
+
name
|
|
66
|
+
guid
|
|
67
|
+
status
|
|
68
|
+
}
|
|
69
|
+
isLead
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
roles {
|
|
73
|
+
guid
|
|
74
|
+
code
|
|
75
|
+
name
|
|
76
|
+
isInternal
|
|
77
|
+
status
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
}).pipe(
|
|
83
|
+
tap(({ data }) => {
|
|
84
|
+
if (data?.authMsLogin) {
|
|
85
|
+
const { accessToken, user, refreshToken, suggestedAction, roles } = data.authMsLogin;
|
|
86
|
+
|
|
87
|
+
this.user = user as User;
|
|
88
|
+
this.user.roles = roles as any;
|
|
89
|
+
this.user!.photo = '/assets/imgs/profile.svg';
|
|
90
|
+
AuthService.authToken = accessToken ?? '';
|
|
91
|
+
AuthService.refreshToken = refreshToken ?? '';
|
|
92
|
+
|
|
93
|
+
if (suggestedAction !== SuggestedAction.ChangePassword ) {
|
|
94
|
+
localStorage.setItem('authToken', AuthService.authToken);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
localStorage.setItem('userGuid', this.user!.guid);
|
|
98
|
+
localStorage.setItem('roles', JSON.stringify(roles));
|
|
99
|
+
localStorage.setItem('refreshToken', AuthService.refreshToken);
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* This method is used by the `refreshTokenInterceptor`, to get the new token shortly before the auth token is expired.
|
|
107
|
+
* @param {MutationAuthMsRefreshAccessTokenArgs} variables - Contain `refreshToken` attribute which is the current refresh token.
|
|
108
|
+
* @returns {Observable<MutationResult<{ authMsRefreshAccessToken: Token }>>} Contain new `authToken` and `refreshToken`.
|
|
109
|
+
*/
|
|
110
|
+
public refreshToken(variables: MutationAuthMsRefreshAccessTokenArgs): Observable<MutationResult<{ authMsRefreshAccessToken: Token }>>{
|
|
111
|
+
return this.apollo.mutate({
|
|
112
|
+
context: {
|
|
113
|
+
headers: {
|
|
114
|
+
'operation-type': 'Mutation',
|
|
115
|
+
'operation-name': 'RefreshToken'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
variables,
|
|
119
|
+
mutation: gql`
|
|
120
|
+
mutation RefreshToken($refreshToken: String!) {
|
|
121
|
+
authMsRefreshAccessToken(refreshToken: $refreshToken) {
|
|
122
|
+
accessToken
|
|
123
|
+
refreshToken
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A method to set the user information to the `user` variable when the user refresh the page.
|
|
132
|
+
* Because of the user information only stored in the variable so it will gone while the page refreshed and need to reset again.
|
|
133
|
+
* @param {FetchPolicy | undefined} fetchPolicy - Specifies how Apollo Client should handle data retrieval,
|
|
134
|
+
* determining whether it should make a network request to fetch fresh data from the server or use data from the local cache.
|
|
135
|
+
* @returns {Observable<AppLoginSubject | null>}
|
|
136
|
+
*/
|
|
137
|
+
public getProfile(fetchPolicy?: FetchPolicy): Observable<AppLoginSubject | null>{
|
|
138
|
+
return this.profileService.getMyProfile(fetchPolicy).pipe(
|
|
139
|
+
tap((user: AppLoginSubject | null) => {
|
|
140
|
+
if (!user) return;
|
|
141
|
+
this.user = { ...user, photo: '/assets/imgs/profile.svg' } as User;
|
|
142
|
+
|
|
143
|
+
user.appLoginExt?.forEach(({ paramCode, file: { publicUrl }}: any) => {
|
|
144
|
+
if (paramCode === 'USER_PROFILE_PHOTO') this.user!.photo = publicUrl;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
user.appLoginPrincipal?.forEach(({ principalId, principalType }: any) => {
|
|
148
|
+
if (principalType === 'EMAIL_USERNAME') this.user!.email = principalId;
|
|
149
|
+
});
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* A method to get the otp / verification code for reset password purpose.
|
|
156
|
+
* No need authorization header to call this API.
|
|
157
|
+
* @param {string} email - Contain registered user email.
|
|
158
|
+
* @returns {Observable<MutationResult<any>>} Contain message stating that verification code has been sent to the email.
|
|
159
|
+
*/
|
|
160
|
+
public initForgotPassword(email: string): Observable<MutationResult<any>>{
|
|
161
|
+
return this.apollo.mutate({
|
|
162
|
+
variables: {
|
|
163
|
+
input: {
|
|
164
|
+
email,
|
|
165
|
+
sourcePlatform: SourcePlatform.Admin
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
mutation: gql`
|
|
169
|
+
mutation InitForgotPassword($input: ForgotPassOtpRq!) {
|
|
170
|
+
authMsForgotPasswordOtp(input: $input)
|
|
171
|
+
}
|
|
172
|
+
`
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A method to get the otp / verification code for 2FA.
|
|
178
|
+
* No need authorization header to call this API.
|
|
179
|
+
* @param {string} email - Contain registered user email.
|
|
180
|
+
* @returns {Observable<MutationResult<any>>} Contain message stating that verification code has been sent to the email.
|
|
181
|
+
*/
|
|
182
|
+
public initOtpCode(email: string): Observable<MutationResult<any>>{
|
|
183
|
+
return this.apollo.mutate({
|
|
184
|
+
variables:{
|
|
185
|
+
input:{
|
|
186
|
+
email,
|
|
187
|
+
sourcePlatform: SourcePlatform.Admin
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
mutation: gql`
|
|
191
|
+
mutation AuthMsLoginOtp($input: LoginOtpRq!) {
|
|
192
|
+
authMsLoginOtp(input: $input)
|
|
193
|
+
}
|
|
194
|
+
`
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* A method to generate new password when the user forgets the password.
|
|
200
|
+
* No need authorization header for this API.
|
|
201
|
+
* @param {{ confirm: string, newPassword: string, principalId: string, verifCode: string, sourcePlatform: string }} - Contain :
|
|
202
|
+
* newPassword - the new password.
|
|
203
|
+
* confirm - the exactly same with the new password.
|
|
204
|
+
* principalId - registered email or phone number attached to user.
|
|
205
|
+
* verifCode - otp / verification code that has been sent to email.
|
|
206
|
+
* sourcePlatform - `ADMIN` for applet or `CP_COMMERCE` for platform.
|
|
207
|
+
* @returns {Observable<MutationResult<any>>} Contain message stating that user successfully / failed to reset the password.
|
|
208
|
+
*/
|
|
209
|
+
public createNewPassword({ newPassword, principalId, sourcePlatform, verifCode }: { confirm: string, newPassword: string, principalId: string, verifCode: string, sourcePlatform: string }): Observable<MutationResult<any>>{
|
|
210
|
+
return this.apollo.mutate({
|
|
211
|
+
mutation : gql`
|
|
212
|
+
mutation SubmitForgotPassword($input: ForgotPassRq!) {
|
|
213
|
+
authMsForgotPassword(input: $input)
|
|
214
|
+
}
|
|
215
|
+
`,
|
|
216
|
+
variables: {
|
|
217
|
+
input: {
|
|
218
|
+
newPassword,
|
|
219
|
+
principalId,
|
|
220
|
+
sourcePlatform,
|
|
221
|
+
verifCode
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* A method to update user's password.
|
|
229
|
+
* Need authorization header for this API.
|
|
230
|
+
* @param {{ oldPassword: string, newPassword: string }} input - Contain oldPassword which is old / current password and newPassword which is the new password.
|
|
231
|
+
* @returns {Observable<MutationResult<{ authMsChangePassword: ChangePassRq }>>} Contain message stating the password updated successfully.
|
|
232
|
+
*/
|
|
233
|
+
public updatePassword(input: { oldPassword: string, newPassword: string }): Observable<MutationResult<{ authMsChangePassword: ChangePassRq }>>{
|
|
234
|
+
return this.apollo.mutate({
|
|
235
|
+
mutation: gql`
|
|
236
|
+
mutation ChangePassword($input: ChangePassRq!) {
|
|
237
|
+
authMsChangePassword(input: $input)
|
|
238
|
+
}
|
|
239
|
+
`,
|
|
240
|
+
variables: { input }
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ApolloQueryResult } from '@apollo/client/core';
|
|
4
|
+
import { Apollo, gql } from 'apollo-angular';
|
|
5
|
+
import { Country, CountryQueryCriteria } from '../../../graphql/generated';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class CountryService {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
protected readonly apollo: Apollo
|
|
14
|
+
) { }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A method to get list of country and it's information.
|
|
18
|
+
* The information such as name, phone code, language code, country code and default language code.
|
|
19
|
+
* @param {CountryQueryCriteria} input - Contain country data pagination criteria, it's optional.
|
|
20
|
+
* @returns {Observable<ApolloQueryResult<{ webConfigMsCountry: { data: Country[] }}>>} Contain list of country and it's information.
|
|
21
|
+
*/
|
|
22
|
+
public query(input: CountryQueryCriteria = { page: 0, pageSize: 300, sortBy: 'name', sortDirection: 'asc' }): Observable<ApolloQueryResult<{ webConfigMsCountry: { data: Country[] }}>>{
|
|
23
|
+
return this.apollo.query({
|
|
24
|
+
errorPolicy: 'all',
|
|
25
|
+
variables: { input },
|
|
26
|
+
query: gql`
|
|
27
|
+
query QueryCountry($input: CountryQueryCriteria!) {
|
|
28
|
+
webConfigMsCountry(input: $input) {
|
|
29
|
+
data {
|
|
30
|
+
code
|
|
31
|
+
defaultLangCode
|
|
32
|
+
guid
|
|
33
|
+
langCodes {
|
|
34
|
+
code
|
|
35
|
+
guid
|
|
36
|
+
}
|
|
37
|
+
name
|
|
38
|
+
phoneCodes {
|
|
39
|
+
code
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ApolloQueryResult } from '@apollo/client/core';
|
|
4
|
+
import { Apollo, gql } from 'apollo-angular';
|
|
5
|
+
import { Currency, CurrencyQueryCriteria } from '../../../graphql/generated';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class CurrencyService {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
protected readonly apollo: Apollo
|
|
14
|
+
) { }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A method to get the list of currency and it's information.
|
|
18
|
+
* The information such as currency code, magnify value, name and status.
|
|
19
|
+
* @param {string} keyword - Contain some letters of currency name, it's optional.
|
|
20
|
+
* @returns {Observable<ApolloQueryResult<{ webConfigMsCurrency: { data: Currency[] }}>>} Contain list of currency and it's information.
|
|
21
|
+
*/
|
|
22
|
+
public query(keyword: string = ''): Observable<ApolloQueryResult<{ webConfigMsCurrency: { data: Currency[] }}>>{
|
|
23
|
+
const input: CurrencyQueryCriteria = { page: 0, pageSize: 300, sortBy: 'name', sortDirection: 'asc' };
|
|
24
|
+
if (keyword !== '') input.name = keyword;
|
|
25
|
+
|
|
26
|
+
return this.apollo.query({
|
|
27
|
+
errorPolicy: 'all',
|
|
28
|
+
variables: { input },
|
|
29
|
+
query: gql`
|
|
30
|
+
query QueryCurrency($input: CurrencyQueryCriteria!) {
|
|
31
|
+
webConfigMsCurrency(input: $input) {
|
|
32
|
+
data {
|
|
33
|
+
code
|
|
34
|
+
guid
|
|
35
|
+
magnifyValue
|
|
36
|
+
name
|
|
37
|
+
status
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable, map } from 'rxjs';
|
|
3
|
+
import { FetchPolicy } from '@apollo/client/core';
|
|
4
|
+
import { Apollo, gql } from 'apollo-angular';
|
|
5
|
+
import { AppLoginSubject } from '../../../graphql/generated';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class ProfileService {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
protected readonly apollo: Apollo
|
|
14
|
+
) { }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A method to get the user profile information.
|
|
18
|
+
* @param {FetchPolicy | undefined} fetchPolicy - Specifies how Apollo Client should handle data retrieval,
|
|
19
|
+
* determining whether it should make a network request to fetch fresh data from the server or use data from the local cache.
|
|
20
|
+
* @returns {Observable<AppLoginSubject | null>} Contain user profile information.
|
|
21
|
+
*/
|
|
22
|
+
public getMyProfile(fetchPolicy?: FetchPolicy): Observable<AppLoginSubject | null>{
|
|
23
|
+
return this.apollo.query<{ authMsMyProfile: AppLoginSubject }>({
|
|
24
|
+
fetchPolicy,
|
|
25
|
+
errorPolicy: 'all',
|
|
26
|
+
query: gql`
|
|
27
|
+
query getMyProfile {
|
|
28
|
+
authMsMyProfile {
|
|
29
|
+
appLoginPrincipal {
|
|
30
|
+
principalId
|
|
31
|
+
principalType
|
|
32
|
+
}
|
|
33
|
+
appLoginExt {
|
|
34
|
+
paramCode
|
|
35
|
+
paramType
|
|
36
|
+
file {
|
|
37
|
+
publicUrl
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
birthday
|
|
41
|
+
category
|
|
42
|
+
company {
|
|
43
|
+
code
|
|
44
|
+
guid
|
|
45
|
+
isInternal
|
|
46
|
+
name
|
|
47
|
+
status
|
|
48
|
+
}
|
|
49
|
+
gender
|
|
50
|
+
guid
|
|
51
|
+
merchants {
|
|
52
|
+
guid
|
|
53
|
+
name
|
|
54
|
+
status
|
|
55
|
+
}
|
|
56
|
+
name
|
|
57
|
+
status
|
|
58
|
+
totpSecretGuid
|
|
59
|
+
roles {
|
|
60
|
+
guid
|
|
61
|
+
code
|
|
62
|
+
name
|
|
63
|
+
isInternal
|
|
64
|
+
status
|
|
65
|
+
}
|
|
66
|
+
departments {
|
|
67
|
+
department {
|
|
68
|
+
hierarchyCode
|
|
69
|
+
hierarchyPath
|
|
70
|
+
name
|
|
71
|
+
guid
|
|
72
|
+
status
|
|
73
|
+
}
|
|
74
|
+
isLead
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`,
|
|
79
|
+
}).pipe(
|
|
80
|
+
map(({ data: { authMsMyProfile }}) => {
|
|
81
|
+
if (!authMsMyProfile) return null;
|
|
82
|
+
return authMsMyProfile;
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ApolloQueryResult, FetchPolicy } from '@apollo/client/core';
|
|
4
|
+
import { Apollo, gql } from 'apollo-angular';
|
|
5
|
+
import { RateGroupCodeCriteria, RateGroupCodeRs } from '../../../graphql/generated';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class RateGroupCodeService {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
protected readonly apollo: Apollo
|
|
14
|
+
) { }
|
|
15
|
+
|
|
16
|
+
public query(input: RateGroupCodeCriteria, fetchPolicy?: FetchPolicy): Observable<ApolloQueryResult<{ productMsSearchRateGroupCodes: RateGroupCodeRs }>>{
|
|
17
|
+
return this.apollo.query({
|
|
18
|
+
fetchPolicy,
|
|
19
|
+
variables: { input },
|
|
20
|
+
query: gql`
|
|
21
|
+
query QueryGroupCode($input: RateGroupCodeCriteria) {
|
|
22
|
+
productMsSearchRateGroupCodes(input: $input) {
|
|
23
|
+
data
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { generateContrastColor } from './contrast-color-generator.util';
|
|
2
|
+
|
|
3
|
+
describe('generateContrastColorUtil', () => {
|
|
4
|
+
describe('generateContrastColor', () => {
|
|
5
|
+
it('should generate a color without opacity value', () => {
|
|
6
|
+
const result = generateContrastColor('VOR');
|
|
7
|
+
|
|
8
|
+
expect(result.background).toBe('#564f52');
|
|
9
|
+
expect(result.color).toBe('#fff');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should generate a color with opacity value', () => {
|
|
13
|
+
const result = generateContrastColor('VORE');
|
|
14
|
+
|
|
15
|
+
expect(result.background).toBe('#564f5245');
|
|
16
|
+
expect(result.color).toBe('#fff');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function that generate random background and text color for badge based on given string. The text color has 2 values, either white [for dark background] or black [for light background].
|
|
3
|
+
* The first char will act as red color.
|
|
4
|
+
* The second char will act as green color.
|
|
5
|
+
* The third char will act as blue color.
|
|
6
|
+
* And the final char will act as opacity value.
|
|
7
|
+
* @param {string} str - A string that acts as the random seeder. String length should not exceeding 8 characters. String length will be truncated to 8 if the given string length is exceeding 8 chars.
|
|
8
|
+
* @returns {Object} generatedColor - Generated random color object
|
|
9
|
+
* @property {string} generatedColor.background - Generated background hex color
|
|
10
|
+
* @property {string} generatedColor.color - Generated text hex color
|
|
11
|
+
*/
|
|
12
|
+
export function generateContrastColor(str: string): { background: `#${ string }`, color: `#${ string }` }{
|
|
13
|
+
if (str.length > 4) str = str.substring(0, 4);
|
|
14
|
+
|
|
15
|
+
let res = '';
|
|
16
|
+
let total = 0;
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < str.length; i++) {
|
|
19
|
+
const c = str.charCodeAt(i).toString(16);
|
|
20
|
+
|
|
21
|
+
res += c;
|
|
22
|
+
total += +c;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
background: `#${ res }`,
|
|
26
|
+
color: total > 187? '#000' : '#fff'
|
|
27
|
+
}
|
|
28
|
+
}
|